This patch should be reverted once i8259 is qdevified
Signed-off-by: Hervé Poussineau <[email protected]>
---
hw/i8259.c | 29 +++++++++++++++++++++++++++--
1 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/hw/i8259.c b/hw/i8259.c
index e5323ff..9af2bbb 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -499,15 +499,40 @@ static const MemoryRegionOps pic_elcr_ioport_ops = {
},
};
+static BusState *qbus_find_recursive(BusState *bus, const char *name)
+{
+ DeviceState *dev;
+ BusState *child, *ret;
+
+ if (strcmp(bus->name, name) == 0) {
+ return bus;
+ }
+
+ QLIST_FOREACH(dev, &bus->children, sibling) {
+ QLIST_FOREACH(child, &dev->child_bus, sibling) {
+ ret = qbus_find_recursive(child, name);
+ if (ret) {
+ return ret;
+ }
+ }
+ }
+ return NULL;
+}
+
/* XXX: add generic master/slave system */
static void pic_init1(int io_addr, int elcr_addr, PicState *s)
{
+ ISADevice dev;
+
+ memset(&dev, 0, sizeof(dev));
+ dev.qdev.parent_bus = qbus_find_recursive(sysbus_get_default(), "isa.0");
+
memory_region_init_io(&s->base_io, &pic_base_ioport_ops, s, "pic", 2);
memory_region_init_io(&s->elcr_io, &pic_elcr_ioport_ops, s, "elcr", 1);
- isa_register_ioport(NULL, &s->base_io, io_addr);
+ isa_register_ioport(&dev, &s->base_io, io_addr);
if (elcr_addr >= 0) {
- isa_register_ioport(NULL, &s->elcr_io, elcr_addr);
+ isa_register_ioport(&dev, &s->elcr_io, elcr_addr);
}
vmstate_register(NULL, io_addr, &vmstate_pic, s);
--
1.7.6.3