aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/integratorcp.c8
-rw-r--r--hw/pl181.c26
-rw-r--r--hw/primecell.h4
-rw-r--r--hw/realview.c8
-rw-r--r--hw/versatilepb.c14
5 files changed, 21 insertions, 39 deletions
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index 8966a25b55..b889f6f2cd 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -458,7 +458,6 @@ static void integratorcp_init(ram_addr_t ram_size,
ram_addr_t ram_offset;
qemu_irq *pic;
qemu_irq *cpu_pic;
- int sd;
if (!cpu_model)
cpu_model = "arm926";
@@ -487,12 +486,7 @@ static void integratorcp_init(ram_addr_t ram_size,
icp_control_init(0xcb000000);
sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3]);
sysbus_create_simple("pl050_mouse", 0x19000000, pic[4]);
- sd = drive_get_index(IF_SD, 0, 0);
- if (sd == -1) {
- fprintf(stderr, "qemu: missing SecureDigital card\n");
- exit(1);
- }
- pl181_init(0x1c000000, drives_table[sd].bdrv, pic[23], pic[24]);
+ sysbus_create_varargs("pl181", 0x1c000000, pic[23], pic[24], NULL);
if (nd_table[0].vlan)
smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
diff --git a/hw/pl181.c b/hw/pl181.c
index ab4e978ae3..277607c04c 100644
--- a/hw/pl181.c
+++ b/hw/pl181.c
@@ -7,9 +7,9 @@
* This code is licenced under the GPL.
*/
-#include "hw.h"
-#include "primecell.h"
+#include "sysbus.h"
#include "sd.h"
+#include "sysemu.h"
//#define DEBUG_PL181 1
@@ -23,6 +23,7 @@ do { printf("pl181: " fmt , ## __VA_ARGS__); } while (0)
#define PL181_FIFO_LEN 16
typedef struct {
+ SysBusDevice busdev;
SDState *card;
uint32_t clock;
uint32_t power;
@@ -444,20 +445,27 @@ static void pl181_reset(void *opaque)
s->mask[1] = 0;
}
-void pl181_init(uint32_t base, BlockDriverState *bd,
- qemu_irq irq0, qemu_irq irq1)
+static void pl181_init(SysBusDevice *dev)
{
int iomemtype;
- pl181_state *s;
+ pl181_state *s = FROM_SYSBUS(pl181_state, dev);
+ BlockDriverState *bd;
- s = (pl181_state *)qemu_mallocz(sizeof(pl181_state));
iomemtype = cpu_register_io_memory(0, pl181_readfn,
pl181_writefn, s);
- cpu_register_physical_memory(base, 0x00001000, iomemtype);
+ sysbus_init_mmio(dev, 0x1000, iomemtype);
+ sysbus_init_irq(dev, &s->irq[0]);
+ sysbus_init_irq(dev, &s->irq[1]);
+ bd = qdev_init_bdrv(&dev->qdev, IF_SD);
s->card = sd_init(bd, 0);
- s->irq[0] = irq0;
- s->irq[1] = irq1;
qemu_register_reset(pl181_reset, s);
pl181_reset(s);
/* ??? Save/restore. */
}
+
+static void pl181_register_devices(void)
+{
+ sysbus_register_dev("pl181", sizeof(pl181_state), pl181_init);
+}
+
+device_init(pl181_register_devices)
diff --git a/hw/primecell.h b/hw/primecell.h
index de28916bfa..ae6aa925bf 100644
--- a/hw/primecell.h
+++ b/hw/primecell.h
@@ -17,10 +17,6 @@ qemu_irq *pl061_init(uint32_t base, qemu_irq irq, qemu_irq **out);
/* pl080.c */
void *pl080_init(uint32_t base, qemu_irq irq, int nchannels);
-/* pl181.c */
-void pl181_init(uint32_t base, BlockDriverState *bd,
- qemu_irq irq0, qemu_irq irq1);
-
/* pl190.c */
qemu_irq *pl190_init(uint32_t base, qemu_irq irq, qemu_irq fiq);
diff --git a/hw/realview.c b/hw/realview.c
index 4001a0f28b..e54918b2ab 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -38,7 +38,6 @@ static void realview_init(ram_addr_t ram_size,
int done_smc = 0;
qemu_irq cpu_irq[4];
int ncpu;
- int index;
if (!cpu_model)
cpu_model = "arm926";
@@ -97,12 +96,7 @@ static void realview_init(ram_addr_t ram_size,
sysbus_create_simple("pl110_versatile", 0x10020000, pic[23]);
- index = drive_get_index(IF_SD, 0, 0);
- if (index == -1) {
- fprintf(stderr, "qemu: missing SecureDigital card\n");
- exit(1);
- }
- pl181_init(0x10005000, drives_table[index].bdrv, pic[17], pic[18]);
+ sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL);
sysbus_create_simple("pl031", 0x10017000, pic[10]);
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index ac630e85e3..31fdb81843 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -167,7 +167,6 @@ static void versatile_init(ram_addr_t ram_size,
NICInfo *nd;
int n;
int done_smc = 0;
- int index;
if (!cpu_model)
cpu_model = "arm926";
@@ -224,17 +223,8 @@ static void versatile_init(ram_addr_t ram_size,
that includes hardware cursor support from the PL111. */
sysbus_create_simple("pl110_versatile", 0x10120000, pic[16]);
- index = drive_get_index(IF_SD, 0, 0);
- if (index == -1) {
- fprintf(stderr, "qemu: missing SecureDigital card\n");
- exit(1);
- }
-
- pl181_init(0x10005000, drives_table[index].bdrv, sic[22], sic[1]);
-#if 0
- /* Disabled because there's no way of specifying a block device. */
- pl181_init(0x1000b000, NULL, sic, 23, 2);
-#endif
+ sysbus_create_varargs("pl181", 0x10005000, sic[22], sic[1], NULL);
+ sysbus_create_varargs("pl181", 0x1000b000, sic[23], sic[2], NULL);
/* Add PL031 Real Time Clock. */
sysbus_create_simple("pl031", 0x101e8000, pic[10]);