Commit 3950f18b9fd4f069f5b77587bda8cacb6dc95583
1 parent
97aff481
Versatile/PB core qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Showing
1 changed file
with
21 additions
and
11 deletions
hw/versatilepb.c
@@ -20,6 +20,7 @@ | @@ -20,6 +20,7 @@ | ||
20 | 20 | ||
21 | typedef struct vpb_sic_state | 21 | typedef struct vpb_sic_state |
22 | { | 22 | { |
23 | + SysBusDevice busdev; | ||
23 | uint32_t level; | 24 | uint32_t level; |
24 | uint32_t mask; | 25 | uint32_t mask; |
25 | uint32_t pic_enable; | 26 | uint32_t pic_enable; |
@@ -128,24 +129,21 @@ static CPUWriteMemoryFunc *vpb_sic_writefn[] = { | @@ -128,24 +129,21 @@ static CPUWriteMemoryFunc *vpb_sic_writefn[] = { | ||
128 | vpb_sic_write | 129 | vpb_sic_write |
129 | }; | 130 | }; |
130 | 131 | ||
131 | -static qemu_irq *vpb_sic_init(uint32_t base, qemu_irq *parent, int irq) | 132 | +static void vpb_sic_init(SysBusDevice *dev) |
132 | { | 133 | { |
133 | - vpb_sic_state *s; | ||
134 | - qemu_irq *qi; | 134 | + vpb_sic_state *s = FROM_SYSBUS(vpb_sic_state, dev); |
135 | int iomemtype; | 135 | int iomemtype; |
136 | int i; | 136 | int i; |
137 | 137 | ||
138 | - s = (vpb_sic_state *)qemu_mallocz(sizeof(vpb_sic_state)); | ||
139 | - qi = qemu_allocate_irqs(vpb_sic_set_irq, s, 32); | 138 | + qdev_init_irq_sink(&dev->qdev, vpb_sic_set_irq, 32); |
140 | for (i = 0; i < 32; i++) { | 139 | for (i = 0; i < 32; i++) { |
141 | - s->parent[i] = parent[i]; | 140 | + sysbus_init_irq(dev, &s->parent[i]); |
142 | } | 141 | } |
143 | - s->irq = irq; | 142 | + s->irq = 31; |
144 | iomemtype = cpu_register_io_memory(0, vpb_sic_readfn, | 143 | iomemtype = cpu_register_io_memory(0, vpb_sic_readfn, |
145 | vpb_sic_writefn, s); | 144 | vpb_sic_writefn, s); |
146 | - cpu_register_physical_memory(base, 0x00001000, iomemtype); | 145 | + sysbus_init_mmio(dev, 0x1000, iomemtype); |
147 | /* ??? Save/restore. */ | 146 | /* ??? Save/restore. */ |
148 | - return qi; | ||
149 | } | 147 | } |
150 | 148 | ||
151 | /* Board init. */ | 149 | /* Board init. */ |
@@ -166,7 +164,7 @@ static void versatile_init(ram_addr_t ram_size, | @@ -166,7 +164,7 @@ static void versatile_init(ram_addr_t ram_size, | ||
166 | ram_addr_t ram_offset; | 164 | ram_addr_t ram_offset; |
167 | qemu_irq *cpu_pic; | 165 | qemu_irq *cpu_pic; |
168 | qemu_irq pic[32]; | 166 | qemu_irq pic[32]; |
169 | - qemu_irq *sic; | 167 | + qemu_irq sic[32]; |
170 | DeviceState *dev; | 168 | DeviceState *dev; |
171 | PCIBus *pci_bus; | 169 | PCIBus *pci_bus; |
172 | NICInfo *nd; | 170 | NICInfo *nd; |
@@ -192,7 +190,11 @@ static void versatile_init(ram_addr_t ram_size, | @@ -192,7 +190,11 @@ static void versatile_init(ram_addr_t ram_size, | ||
192 | for (n = 0; n < 32; n++) { | 190 | for (n = 0; n < 32; n++) { |
193 | pic[n] = qdev_get_irq_sink(dev, n); | 191 | pic[n] = qdev_get_irq_sink(dev, n); |
194 | } | 192 | } |
195 | - sic = vpb_sic_init(0x10003000, pic, 31); | 193 | + dev = sysbus_create_simple("versatilepb_sic", 0x10003000, NULL); |
194 | + for (n = 0; n < 32; n++) { | ||
195 | + sysbus_connect_irq(sysbus_from_qdev(dev), n, pic[n]); | ||
196 | + sic[n] = qdev_get_irq_sink(dev, n); | ||
197 | + } | ||
196 | 198 | ||
197 | sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3]); | 199 | sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3]); |
198 | sysbus_create_simple("pl050_mouse", 0x10007000, sic[4]); | 200 | sysbus_create_simple("pl050_mouse", 0x10007000, sic[4]); |
@@ -317,3 +319,11 @@ QEMUMachine versatileab_machine = { | @@ -317,3 +319,11 @@ QEMUMachine versatileab_machine = { | ||
317 | .init = vab_init, | 319 | .init = vab_init, |
318 | .use_scsi = 1, | 320 | .use_scsi = 1, |
319 | }; | 321 | }; |
322 | + | ||
323 | +static void versatilepb_register_devices(void) | ||
324 | +{ | ||
325 | + sysbus_register_dev("versatilepb_sic", sizeof(vpb_sic_state), | ||
326 | + vpb_sic_init); | ||
327 | +} | ||
328 | + | ||
329 | +device_init(versatilepb_register_devices) |