diff options
Diffstat (limited to 'hw/isa-bus.c')
-rw-r--r-- | hw/isa-bus.c | 70 |
1 files changed, 63 insertions, 7 deletions
diff --git a/hw/isa-bus.c b/hw/isa-bus.c index 315efbbeca..90a171d996 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -18,17 +18,24 @@ */ #include "hw.h" #include "sysemu.h" +#include "monitor.h" +#include "sysbus.h" #include "isa.h" struct ISABus { BusState qbus; + qemu_irq *irqs; + uint32_t assigned; }; static ISABus *isabus; +static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent); + static struct BusInfo isa_bus_info = { - .name = "ISA", - .size = sizeof(ISABus), - .props = (Property[]) { + .name = "ISA", + .size = sizeof(ISABus), + .print_dev = isabus_dev_print, + .props = (Property[]) { DEFINE_PROP_HEX32("iobase", ISADevice, iobase[0], -1), DEFINE_PROP_HEX32("iobase2", ISADevice, iobase[1], -1), DEFINE_PROP_END_OF_LIST(), @@ -41,16 +48,32 @@ ISABus *isa_bus_new(DeviceState *dev) fprintf(stderr, "Can't create a second ISA bus\n"); return NULL; } + if (NULL == dev) { + dev = qdev_create(NULL, "isabus-bridge"); + qdev_init(dev); + } isabus = FROM_QBUS(ISABus, qbus_create(&isa_bus_info, dev, NULL)); return isabus; } -void isa_connect_irq(ISADevice *dev, int n, qemu_irq irq) +void isa_bus_irqs(qemu_irq *irqs) { - assert(n >= 0 && n < dev->nirqs); - if (dev->irqs[n]) - *dev->irqs[n] = irq; + 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]; + } } void isa_init_irq(ISADevice *dev, qemu_irq *p) @@ -65,6 +88,8 @@ static void isa_qdev_init(DeviceState *qdev, DeviceInfo *base) ISADevice *dev = DO_UPCAST(ISADevice, qdev, qdev); ISADeviceInfo *info = DO_UPCAST(ISADeviceInfo, qdev, base); + dev->isairq[0] = -1; + dev->isairq[1] = -1; info->init(dev); } @@ -91,3 +116,34 @@ ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2 qdev_init(dev); return isa; } + +static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent) +{ + ISADevice *d = DO_UPCAST(ISADevice, qdev, dev); + + if (d->isairq[1] != -1) { + monitor_printf(mon, "%*sisa irqs %d,%d\n", indent, "", + d->isairq[0], d->isairq[1]); + } else if (d->isairq[0] != -1) { + monitor_printf(mon, "%*sisa irq %d\n", indent, "", + d->isairq[0]); + } +} + +static void isabus_bridge_init(SysBusDevice *dev) +{ + /* nothing */ +} + +static SysBusDeviceInfo isabus_bridge_info = { + .init = isabus_bridge_init, + .qdev.name = "isabus-bridge", + .qdev.size = sizeof(SysBusDevice), +}; + +static void isabus_register_devices(void) +{ + sysbus_register_withprop(&isabus_bridge_info); +} + +device_init(isabus_register_devices) |