Commit 3950f18b9fd4f069f5b77587bda8cacb6dc95583

Authored by Paul Brook
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 20  
21 21 typedef struct vpb_sic_state
22 22 {
  23 + SysBusDevice busdev;
23 24 uint32_t level;
24 25 uint32_t mask;
25 26 uint32_t pic_enable;
... ... @@ -128,24 +129,21 @@ static CPUWriteMemoryFunc *vpb_sic_writefn[] = {
128 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 135 int iomemtype;
136 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 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 143 iomemtype = cpu_register_io_memory(0, vpb_sic_readfn,
145 144 vpb_sic_writefn, s);
146   - cpu_register_physical_memory(base, 0x00001000, iomemtype);
  145 + sysbus_init_mmio(dev, 0x1000, iomemtype);
147 146 /* ??? Save/restore. */
148   - return qi;
149 147 }
150 148  
151 149 /* Board init. */
... ... @@ -166,7 +164,7 @@ static void versatile_init(ram_addr_t ram_size,
166 164 ram_addr_t ram_offset;
167 165 qemu_irq *cpu_pic;
168 166 qemu_irq pic[32];
169   - qemu_irq *sic;
  167 + qemu_irq sic[32];
170 168 DeviceState *dev;
171 169 PCIBus *pci_bus;
172 170 NICInfo *nd;
... ... @@ -192,7 +190,11 @@ static void versatile_init(ram_addr_t ram_size,
192 190 for (n = 0; n < 32; n++) {
193 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 199 sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3]);
198 200 sysbus_create_simple("pl050_mouse", 0x10007000, sic[4]);
... ... @@ -317,3 +319,11 @@ QEMUMachine versatileab_machine = {
317 319 .init = vab_init,
318 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)
... ...