diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2009-09-10 11:43:27 +0200 |
---|---|---|
committer | malc <av1474@comtv.ru> | 2009-09-10 19:47:59 +0400 |
commit | 2e15e23b8a3c5da5576b7ea8631c956381eea0d5 (patch) | |
tree | 6b58c916a271c2fa707f39210a71094a4cfafe06 /hw | |
parent | 86c861578453b544fa67ad50d28c4460bee068c5 (diff) |
qdev: simplify isa irq assignments
isa-bus owns the isa irqs now, so it can hand them out directly.
There is no need for the separate isa_connect_irqs step, drop it.
Also hard-code isa interrupts which can't be configured anyway.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/fdc.c | 6 | ||||
-rw-r--r-- | hw/isa-bus.c | 38 | ||||
-rw-r--r-- | hw/isa.h | 6 | ||||
-rw-r--r-- | hw/mips_malta.c | 2 | ||||
-rw-r--r-- | hw/pc.c | 2 | ||||
-rw-r--r-- | hw/pckbd.c | 4 | ||||
-rw-r--r-- | hw/sun4u.c | 2 |
7 files changed, 21 insertions, 39 deletions
@@ -1875,10 +1875,9 @@ fdctrl_t *fdctrl_init_isa(BlockDriverState **fds) { fdctrl_t *fdctrl; ISADevice *dev; - int isairq = 6; int dma_chann = 2; - dev = isa_create_simple("isa-fdc", isairq, -1); + dev = isa_create_simple("isa-fdc"); fdctrl = &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state); fdctrl->dma_chann = dma_chann; @@ -1969,6 +1968,7 @@ static int isabus_fdc_init1(ISADevice *dev) fdctrl_isabus_t *isa = DO_UPCAST(fdctrl_isabus_t, busdev, dev); fdctrl_t *fdctrl = &isa->state; int iobase = 0x3f0; + int isairq = 6; register_ioport_read(iobase + 0x01, 5, 1, &fdctrl_read_port, fdctrl); @@ -1978,7 +1978,7 @@ static int isabus_fdc_init1(ISADevice *dev) &fdctrl_write_port, fdctrl); register_ioport_write(iobase + 0x07, 1, 1, &fdctrl_write_port, fdctrl); - isa_init_irq(&isa->busdev, &fdctrl->irq); + isa_init_irq(&isa->busdev, &fdctrl->irq, isairq); return fdctrl_init_common(fdctrl); } diff --git a/hw/isa-bus.c b/hw/isa-bus.c index fde066acc..bfd0fffce 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -57,20 +57,6 @@ void isa_bus_irqs(qemu_irq *irqs) isabus->irqs = irqs; } -void isa_connect_irq(ISADevice *dev, int devnr, int isairq) -{ - assert(devnr >= 0 && devnr < dev->nirqs); - if (isabus->assigned & (1 << isairq)) { - fprintf(stderr, "isa irq %d already assigned\n", isairq); - exit(1); - } - if (dev->irqs[devnr]) { - isabus->assigned |= (1 << isairq); - dev->isairq[devnr] = isairq; - *dev->irqs[devnr] = isabus->irqs[isairq]; - } -} - /* * isa_reserve_irq() reserves the ISA irq and returns the corresponding * qemu_irq entry for the i8259. @@ -92,10 +78,16 @@ qemu_irq isa_reserve_irq(int isairq) return isabus->irqs[isairq]; } -void isa_init_irq(ISADevice *dev, qemu_irq *p) +void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq) { - assert(dev->nirqs < ARRAY_SIZE(dev->irqs)); - dev->irqs[dev->nirqs] = p; + assert(dev->nirqs < ARRAY_SIZE(dev->isairq)); + if (isabus->assigned & (1 << isairq)) { + fprintf(stderr, "isa irq %d already assigned\n", isairq); + exit(1); + } + isabus->assigned |= (1 << isairq); + dev->isairq[dev->nirqs] = isairq; + *p = isabus->irqs[isairq]; dev->nirqs++; } @@ -117,25 +109,17 @@ void isa_qdev_register(ISADeviceInfo *info) qdev_register(&info->qdev); } -ISADevice *isa_create_simple(const char *name, uint32_t irq, uint32 irq2) +ISADevice *isa_create_simple(const char *name) { DeviceState *dev; - ISADevice *isa; if (!isabus) { fprintf(stderr, "Tried to create isa device %s with no isa bus present.\n", name); return NULL; } dev = qdev_create(&isabus->qbus, name); - isa = DO_UPCAST(ISADevice, qdev, dev); qdev_init(dev); - if (irq != -1) { - isa_connect_irq(isa, 0, irq); - } - if (irq2 != -1) { - isa_connect_irq(isa, 1, irq2); - } - return isa; + return DO_UPCAST(ISADevice, qdev, dev); } static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent) @@ -13,7 +13,6 @@ typedef struct ISADeviceInfo ISADeviceInfo; struct ISADevice { DeviceState qdev; uint32_t isairq[2]; - qemu_irq *irqs[2]; int nirqs; }; @@ -25,11 +24,10 @@ struct ISADeviceInfo { ISABus *isa_bus_new(DeviceState *dev); void isa_bus_irqs(qemu_irq *irqs); -void isa_connect_irq(ISADevice *dev, int devirq, int isairq); qemu_irq isa_reserve_irq(int isairq); -void isa_init_irq(ISADevice *dev, qemu_irq *p); +void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq); void isa_qdev_register(ISADeviceInfo *info); -ISADevice *isa_create_simple(const char *name, uint32_t irq, uint32_t irq2); +ISADevice *isa_create_simple(const char *name); extern target_phys_addr_t isa_mem_base; diff --git a/hw/mips_malta.c b/hw/mips_malta.c index 3222e166e..32c7102f7 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -921,7 +921,7 @@ void mips_malta_init (ram_addr_t ram_size, DMA_init(0); /* Super I/O */ - isa_dev = isa_create_simple("i8042", 1, 12); + isa_dev = isa_create_simple("i8042"); rtc_state = rtc_init(0x70, isa_reserve_irq(8), 2000); serial_init(0x3f8, isa_reserve_irq(4), 115200, serial_hds[0]); @@ -1373,7 +1373,7 @@ static void pc_init1(ram_addr_t ram_size, } } - isa_dev = isa_create_simple("i8042", 1, 12); + isa_dev = isa_create_simple("i8042"); DMA_init(0); #ifdef HAS_AUDIO audio_init(pci_enabled ? pci_bus : NULL, isa_irq); diff --git a/hw/pckbd.c b/hw/pckbd.c index b4b65a660..5acf4a633 100644 --- a/hw/pckbd.c +++ b/hw/pckbd.c @@ -450,8 +450,8 @@ static int i8042_initfn(ISADevice *dev) { KBDState *s = &(DO_UPCAST(ISAKBDState, dev, dev)->kbd); - isa_init_irq(dev, &s->irq_kbd); - isa_init_irq(dev, &s->irq_mouse); + isa_init_irq(dev, &s->irq_kbd, 1); + isa_init_irq(dev, &s->irq_mouse, 12); kbd_reset(s); register_savevm("pckbd", 0, 3, kbd_save, kbd_load, s); diff --git a/hw/sun4u.c b/hw/sun4u.c index b71df1f7e..ffda4cda1 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -617,7 +617,7 @@ static void sun4uv_init(ram_addr_t RAM_size, pci_cmd646_ide_init(pci_bus, hd, 1); - isa_create_simple("i8042", 1, 12); + isa_create_simple("i8042"); for(i = 0; i < MAX_FD; i++) { dinfo = drive_get(IF_FLOPPY, 0, i); fd[i] = dinfo ? dinfo->bdrv : NULL; |