Commit aa9311d8cbd6250b9443b0f12b85d8176ec057ca
1 parent
a63bdb31
PL181 qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Showing
5 changed files
with
21 additions
and
39 deletions
hw/integratorcp.c
... | ... | @@ -458,7 +458,6 @@ static void integratorcp_init(ram_addr_t ram_size, |
458 | 458 | ram_addr_t ram_offset; |
459 | 459 | qemu_irq *pic; |
460 | 460 | qemu_irq *cpu_pic; |
461 | - int sd; | |
462 | 461 | |
463 | 462 | if (!cpu_model) |
464 | 463 | cpu_model = "arm926"; |
... | ... | @@ -487,12 +486,7 @@ static void integratorcp_init(ram_addr_t ram_size, |
487 | 486 | icp_control_init(0xcb000000); |
488 | 487 | sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3]); |
489 | 488 | sysbus_create_simple("pl050_mouse", 0x19000000, pic[4]); |
490 | - sd = drive_get_index(IF_SD, 0, 0); | |
491 | - if (sd == -1) { | |
492 | - fprintf(stderr, "qemu: missing SecureDigital card\n"); | |
493 | - exit(1); | |
494 | - } | |
495 | - pl181_init(0x1c000000, drives_table[sd].bdrv, pic[23], pic[24]); | |
489 | + sysbus_create_varargs("pl181", 0x1c000000, pic[23], pic[24], NULL); | |
496 | 490 | if (nd_table[0].vlan) |
497 | 491 | smc91c111_init(&nd_table[0], 0xc8000000, pic[27]); |
498 | 492 | ... | ... |
hw/pl181.c
... | ... | @@ -7,9 +7,9 @@ |
7 | 7 | * This code is licenced under the GPL. |
8 | 8 | */ |
9 | 9 | |
10 | -#include "hw.h" | |
11 | -#include "primecell.h" | |
10 | +#include "sysbus.h" | |
12 | 11 | #include "sd.h" |
12 | +#include "sysemu.h" | |
13 | 13 | |
14 | 14 | //#define DEBUG_PL181 1 |
15 | 15 | |
... | ... | @@ -23,6 +23,7 @@ do { printf("pl181: " fmt , ## __VA_ARGS__); } while (0) |
23 | 23 | #define PL181_FIFO_LEN 16 |
24 | 24 | |
25 | 25 | typedef struct { |
26 | + SysBusDevice busdev; | |
26 | 27 | SDState *card; |
27 | 28 | uint32_t clock; |
28 | 29 | uint32_t power; |
... | ... | @@ -444,20 +445,27 @@ static void pl181_reset(void *opaque) |
444 | 445 | s->mask[1] = 0; |
445 | 446 | } |
446 | 447 | |
447 | -void pl181_init(uint32_t base, BlockDriverState *bd, | |
448 | - qemu_irq irq0, qemu_irq irq1) | |
448 | +static void pl181_init(SysBusDevice *dev) | |
449 | 449 | { |
450 | 450 | int iomemtype; |
451 | - pl181_state *s; | |
451 | + pl181_state *s = FROM_SYSBUS(pl181_state, dev); | |
452 | + BlockDriverState *bd; | |
452 | 453 | |
453 | - s = (pl181_state *)qemu_mallocz(sizeof(pl181_state)); | |
454 | 454 | iomemtype = cpu_register_io_memory(0, pl181_readfn, |
455 | 455 | pl181_writefn, s); |
456 | - cpu_register_physical_memory(base, 0x00001000, iomemtype); | |
456 | + sysbus_init_mmio(dev, 0x1000, iomemtype); | |
457 | + sysbus_init_irq(dev, &s->irq[0]); | |
458 | + sysbus_init_irq(dev, &s->irq[1]); | |
459 | + bd = qdev_init_bdrv(&dev->qdev, IF_SD); | |
457 | 460 | s->card = sd_init(bd, 0); |
458 | - s->irq[0] = irq0; | |
459 | - s->irq[1] = irq1; | |
460 | 461 | qemu_register_reset(pl181_reset, s); |
461 | 462 | pl181_reset(s); |
462 | 463 | /* ??? Save/restore. */ |
463 | 464 | } |
465 | + | |
466 | +static void pl181_register_devices(void) | |
467 | +{ | |
468 | + sysbus_register_dev("pl181", sizeof(pl181_state), pl181_init); | |
469 | +} | |
470 | + | |
471 | +device_init(pl181_register_devices) | ... | ... |
hw/primecell.h
... | ... | @@ -17,10 +17,6 @@ qemu_irq *pl061_init(uint32_t base, qemu_irq irq, qemu_irq **out); |
17 | 17 | /* pl080.c */ |
18 | 18 | void *pl080_init(uint32_t base, qemu_irq irq, int nchannels); |
19 | 19 | |
20 | -/* pl181.c */ | |
21 | -void pl181_init(uint32_t base, BlockDriverState *bd, | |
22 | - qemu_irq irq0, qemu_irq irq1); | |
23 | - | |
24 | 20 | /* pl190.c */ |
25 | 21 | qemu_irq *pl190_init(uint32_t base, qemu_irq irq, qemu_irq fiq); |
26 | 22 | ... | ... |
hw/realview.c
... | ... | @@ -38,7 +38,6 @@ static void realview_init(ram_addr_t ram_size, |
38 | 38 | int done_smc = 0; |
39 | 39 | qemu_irq cpu_irq[4]; |
40 | 40 | int ncpu; |
41 | - int index; | |
42 | 41 | |
43 | 42 | if (!cpu_model) |
44 | 43 | cpu_model = "arm926"; |
... | ... | @@ -97,12 +96,7 @@ static void realview_init(ram_addr_t ram_size, |
97 | 96 | |
98 | 97 | sysbus_create_simple("pl110_versatile", 0x10020000, pic[23]); |
99 | 98 | |
100 | - index = drive_get_index(IF_SD, 0, 0); | |
101 | - if (index == -1) { | |
102 | - fprintf(stderr, "qemu: missing SecureDigital card\n"); | |
103 | - exit(1); | |
104 | - } | |
105 | - pl181_init(0x10005000, drives_table[index].bdrv, pic[17], pic[18]); | |
99 | + sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL); | |
106 | 100 | |
107 | 101 | sysbus_create_simple("pl031", 0x10017000, pic[10]); |
108 | 102 | ... | ... |
hw/versatilepb.c
... | ... | @@ -167,7 +167,6 @@ static void versatile_init(ram_addr_t ram_size, |
167 | 167 | NICInfo *nd; |
168 | 168 | int n; |
169 | 169 | int done_smc = 0; |
170 | - int index; | |
171 | 170 | |
172 | 171 | if (!cpu_model) |
173 | 172 | cpu_model = "arm926"; |
... | ... | @@ -224,17 +223,8 @@ static void versatile_init(ram_addr_t ram_size, |
224 | 223 | that includes hardware cursor support from the PL111. */ |
225 | 224 | sysbus_create_simple("pl110_versatile", 0x10120000, pic[16]); |
226 | 225 | |
227 | - index = drive_get_index(IF_SD, 0, 0); | |
228 | - if (index == -1) { | |
229 | - fprintf(stderr, "qemu: missing SecureDigital card\n"); | |
230 | - exit(1); | |
231 | - } | |
232 | - | |
233 | - pl181_init(0x10005000, drives_table[index].bdrv, sic[22], sic[1]); | |
234 | -#if 0 | |
235 | - /* Disabled because there's no way of specifying a block device. */ | |
236 | - pl181_init(0x1000b000, NULL, sic, 23, 2); | |
237 | -#endif | |
226 | + sysbus_create_varargs("pl181", 0x10005000, sic[22], sic[1], NULL); | |
227 | + sysbus_create_varargs("pl181", 0x1000b000, sic[23], sic[2], NULL); | |
238 | 228 | |
239 | 229 | /* Add PL031 Real Time Clock. */ |
240 | 230 | sysbus_create_simple("pl031", 0x101e8000, pic[10]); | ... | ... |