diff options
-rw-r--r-- | arch_init.c | 8 | ||||
-rw-r--r-- | arch_init.h | 2 | ||||
-rw-r--r-- | hw/adlib.c | 2 | ||||
-rw-r--r-- | hw/alpha_dp264.c | 10 | ||||
-rw-r--r-- | hw/alpha_typhoon.c | 7 | ||||
-rw-r--r-- | hw/audiodev.h | 8 | ||||
-rw-r--r-- | hw/cs4231a.c | 4 | ||||
-rw-r--r-- | hw/fdc.h | 4 | ||||
-rw-r--r-- | hw/gus.c | 4 | ||||
-rw-r--r-- | hw/i8254.c | 2 | ||||
-rw-r--r-- | hw/i8259.c | 6 | ||||
-rw-r--r-- | hw/ide.h | 2 | ||||
-rw-r--r-- | hw/ide/isa.c | 4 | ||||
-rw-r--r-- | hw/ide/piix.c | 2 | ||||
-rw-r--r-- | hw/ide/via.c | 2 | ||||
-rw-r--r-- | hw/isa-bus.c | 18 | ||||
-rw-r--r-- | hw/isa.h | 11 | ||||
-rw-r--r-- | hw/m48t59.c | 5 | ||||
-rw-r--r-- | hw/mc146818rtc.c | 4 | ||||
-rw-r--r-- | hw/mc146818rtc.h | 2 | ||||
-rw-r--r-- | hw/mips_fulong2e.c | 16 | ||||
-rw-r--r-- | hw/mips_jazz.c | 13 | ||||
-rw-r--r-- | hw/mips_malta.c | 26 | ||||
-rw-r--r-- | hw/mips_r4k.c | 21 | ||||
-rw-r--r-- | hw/nvram.h | 3 | ||||
-rw-r--r-- | hw/pc.c | 28 | ||||
-rw-r--r-- | hw/pc.h | 35 | ||||
-rw-r--r-- | hw/pc_piix.c | 19 | ||||
-rw-r--r-- | hw/pcspk.c | 2 | ||||
-rw-r--r-- | hw/ppc_prep.c | 20 | ||||
-rw-r--r-- | hw/sb16.c | 4 | ||||
-rw-r--r-- | hw/sun4u.c | 20 | ||||
-rw-r--r-- | qemu-common.h | 1 |
33 files changed, 170 insertions, 145 deletions
diff --git a/arch_init.c b/arch_init.c index a411fdf..3bc2a41 100644 --- a/arch_init.c +++ b/arch_init.c @@ -473,7 +473,7 @@ struct soundhw { int enabled; int isa; union { - int (*init_isa) (qemu_irq *pic); + int (*init_isa) (ISABus *bus, qemu_irq *pic); int (*init_pci) (PCIBus *bus); } init; }; @@ -628,7 +628,7 @@ void select_soundhw(const char *optarg) } } -void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus) +void audio_init(ISABus *isa_bus, qemu_irq *isa_pic, PCIBus *pci_bus) { struct soundhw *c; @@ -636,7 +636,7 @@ void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus) if (c->enabled) { if (c->isa) { if (isa_pic) { - c->init.init_isa(isa_pic); + c->init.init_isa(isa_bus, isa_pic); } } else { if (pci_bus) { @@ -650,7 +650,7 @@ void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus) void select_soundhw(const char *optarg) { } -void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus) +void audio_init(ISABus *isa_bus, qemu_irq *isa_pic, PCIBus *pci_bus) { } #endif diff --git a/arch_init.h b/arch_init.h index a74187a..074f02a 100644 --- a/arch_init.h +++ b/arch_init.h @@ -27,7 +27,7 @@ void do_acpitable_option(const char *optarg); void do_smbios_option(const char *optarg); void cpudef_init(void); int audio_available(void); -void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus); +void audio_init(ISABus *isa_bus, qemu_irq *isa_pic, PCIBus *pci_bus); int tcg_available(void); int kvm_available(void); int xen_available(void); @@ -275,7 +275,7 @@ static void Adlib_fini (AdlibState *s) AUD_remove_card (&s->card); } -int Adlib_init (qemu_irq *pic) +int Adlib_init (ISABus *bus, qemu_irq *pic) { AdlibState *s = &glob_adlib; struct audsettings as; diff --git a/hw/alpha_dp264.c b/hw/alpha_dp264.c index 598b830..a07a2ff 100644 --- a/hw/alpha_dp264.c +++ b/hw/alpha_dp264.c @@ -50,6 +50,7 @@ static void clipper_init(ram_addr_t ram_size, { CPUState *cpus[4]; PCIBus *pci_bus; + ISABus *isa_bus; qemu_irq rtc_irq; long size, i; const char *palcode_filename; @@ -68,10 +69,11 @@ static void clipper_init(ram_addr_t ram_size, /* Init the chipset. */ pci_bus = typhoon_init(ram_size, &rtc_irq, cpus, clipper_pci_map_irq); + isa_bus = NULL; - rtc_init(1980, rtc_irq); - pit_init(0x40, 0); - isa_create_simple("i8042"); + rtc_init(isa_bus, 1980, rtc_irq); + pit_init(isa_bus, 0x40, 0); + isa_create_simple(isa_bus, "i8042"); /* VGA setup. Don't bother loading the bios. */ alpha_pci_vga_setup(pci_bus); @@ -79,7 +81,7 @@ static void clipper_init(ram_addr_t ram_size, /* Serial code setup. */ for (i = 0; i < MAX_SERIAL_PORTS; ++i) { if (serial_hds[i]) { - serial_isa_init(i, serial_hds[i]); + serial_isa_init(isa_bus, i, serial_hds[i]); } } diff --git a/hw/alpha_typhoon.c b/hw/alpha_typhoon.c index c7608bb..113837d 100644 --- a/hw/alpha_typhoon.c +++ b/hw/alpha_typhoon.c @@ -791,11 +791,12 @@ PCIBus *typhoon_init(ram_addr_t ram_size, qemu_irq *p_rtc_irq, /* ??? Technically there should be a cy82c693ub pci-isa bridge. */ { qemu_irq isa_pci_irq, *isa_irqs; + ISABus *isa_bus; - isa_bus_new(NULL, addr_space_io); + isa_bus = isa_bus_new(NULL, addr_space_io); isa_pci_irq = *qemu_allocate_irqs(typhoon_set_isa_irq, s, 1); - isa_irqs = i8259_init(isa_pci_irq); - isa_bus_irqs(isa_irqs); + isa_irqs = i8259_init(isa_bus, isa_pci_irq); + isa_bus_irqs(isa_bus, isa_irqs); } return b; diff --git a/hw/audiodev.h b/hw/audiodev.h index d60c349..bfa324a 100644 --- a/hw/audiodev.h +++ b/hw/audiodev.h @@ -2,19 +2,19 @@ int es1370_init(PCIBus *bus); /* sb16.c */ -int SB16_init(qemu_irq *pic); +int SB16_init(ISABus *bus, qemu_irq *pic); /* adlib.c */ -int Adlib_init(qemu_irq *pic); +int Adlib_init(ISABus *bus, qemu_irq *pic); /* gus.c */ -int GUS_init(qemu_irq *pic); +int GUS_init(ISABus *bus, qemu_irq *pic); /* ac97.c */ int ac97_init(PCIBus *bus); /* cs4231a.c */ -int cs4231a_init(qemu_irq *pic); +int cs4231a_init(ISABus *bus, qemu_irq *pic); /* intel-hda.c + hda-audio.c */ int intel_hda_and_codec_init(PCIBus *bus); diff --git a/hw/cs4231a.c b/hw/cs4231a.c index a7e03a3..0238829 100644 --- a/hw/cs4231a.c +++ b/hw/cs4231a.c @@ -659,9 +659,9 @@ static int cs4231a_initfn (ISADevice *dev) return 0; } -int cs4231a_init (qemu_irq *pic) +int cs4231a_init (ISABus *bus, qemu_irq *pic) { - isa_create_simple ("cs4231a"); + isa_create_simple (bus, "cs4231a"); return 0; } @@ -7,11 +7,11 @@ /* fdc.c */ #define MAX_FD 2 -static inline ISADevice *fdctrl_init_isa(DriveInfo **fds) +static inline ISADevice *fdctrl_init_isa(ISABus *bus, DriveInfo **fds) { ISADevice *dev; - dev = isa_try_create("isa-fdc"); + dev = isa_try_create(bus, "isa-fdc"); if (!dev) { return NULL; } @@ -293,9 +293,9 @@ static int gus_initfn (ISADevice *dev) return 0; } -int GUS_init (qemu_irq *pic) +int GUS_init (ISABus *bus, qemu_irq *pic) { - isa_create_simple ("gus"); + isa_create_simple (bus, "gus"); return 0; } @@ -525,7 +525,7 @@ static int pit_initfn(ISADevice *dev) s = &pit->channels[0]; /* the timer 0 is connected to an IRQ */ s->irq_timer = qemu_new_timer_ns(vm_clock, pit_irq_timer, s); - s->irq = isa_get_irq(pit->irq); + s->irq = isa_get_irq(dev, pit->irq); memory_region_init_io(&pit->ioports, &pit_ioport_ops, pit, "pit", 4); isa_register_ioport(dev, &pit->ioports, pit->iobase); @@ -518,7 +518,7 @@ void irq_info(Monitor *mon) #endif } -qemu_irq *i8259_init(qemu_irq parent_irq) +qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq) { qemu_irq *irq_set; ISADevice *dev; @@ -526,7 +526,7 @@ qemu_irq *i8259_init(qemu_irq parent_irq) irq_set = g_malloc(ISA_NUM_IRQS * sizeof(qemu_irq)); - dev = isa_create("isa-i8259"); + dev = isa_create(bus, "isa-i8259"); qdev_prop_set_uint32(&dev->qdev, "iobase", 0x20); qdev_prop_set_uint32(&dev->qdev, "elcr_addr", 0x4d0); qdev_prop_set_uint8(&dev->qdev, "elcr_mask", 0xf8); @@ -540,7 +540,7 @@ qemu_irq *i8259_init(qemu_irq parent_irq) isa_pic = DO_UPCAST(PicState, dev, dev); - dev = isa_create("isa-i8259"); + dev = isa_create(bus, "isa-i8259"); qdev_prop_set_uint32(&dev->qdev, "iobase", 0xa0); qdev_prop_set_uint32(&dev->qdev, "elcr_addr", 0x4d1); qdev_prop_set_uint8(&dev->qdev, "elcr_mask", 0xde); @@ -8,7 +8,7 @@ #define MAX_IDE_DEVS 2 /* ide-isa.c */ -ISADevice *isa_ide_init(int iobase, int iobase2, int isairq, +ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq, DriveInfo *hd0, DriveInfo *hd1); /* ide-pci.c */ diff --git a/hw/ide/isa.c b/hw/ide/isa.c index 01a9e59..219f3a4 100644 --- a/hw/ide/isa.c +++ b/hw/ide/isa.c @@ -73,13 +73,13 @@ static int isa_ide_initfn(ISADevice *dev) return 0; }; -ISADevice *isa_ide_init(int iobase, int iobase2, int isairq, +ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq, DriveInfo *hd0, DriveInfo *hd1) { ISADevice *dev; ISAIDEState *s; - dev = isa_create("isa-ide"); + dev = isa_create(bus, "isa-ide"); qdev_prop_set_uint32(&dev->qdev, "iobase", iobase); qdev_prop_set_uint32(&dev->qdev, "iobase2", iobase2); qdev_prop_set_uint32(&dev->qdev, "irq", isairq); diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 08cbbe2..3473345 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -136,7 +136,7 @@ static void pci_piix_init_ports(PCIIDEState *d) { ide_bus_new(&d->bus[i], &d->dev.qdev, i); ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, port_info[i].iobase2); - ide_init2(&d->bus[i], isa_get_irq(port_info[i].isairq)); + ide_init2(&d->bus[i], isa_get_irq(NULL, port_info[i].isairq)); bmdma_init(&d->bus[i], &d->bmdma[i], d); d->bmdma[i].bus = &d->bus[i]; diff --git a/hw/ide/via.c b/hw/ide/via.c index a57134c..4ea2064 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -160,7 +160,7 @@ static void vt82c686b_init_ports(PCIIDEState *d) { ide_bus_new(&d->bus[i], &d->dev.qdev, i); ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, port_info[i].iobase2); - ide_init2(&d->bus[i], isa_get_irq(port_info[i].isairq)); + ide_init2(&d->bus[i], isa_get_irq(NULL, port_info[i].isairq)); bmdma_init(&d->bus[i], &d->bmdma[i], d); d->bmdma[i].bus = &d->bus[i]; diff --git a/hw/isa-bus.c b/hw/isa-bus.c index 7c2c261..dcbb134 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -56,8 +56,9 @@ ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io) return isabus; } -void isa_bus_irqs(qemu_irq *irqs) +void isa_bus_irqs(ISABus *bus, qemu_irq *irqs) { + assert(!bus || bus == isabus); isabus->irqs = irqs; } @@ -67,8 +68,9 @@ void isa_bus_irqs(qemu_irq *irqs) * This function is only for special cases such as the 'ferr', and * temporary use for normal devices until they are converted to qdev. */ -qemu_irq isa_get_irq(int isairq) +qemu_irq isa_get_irq(ISADevice *dev, int isairq) { + assert(!dev || DO_UPCAST(ISABus, qbus, dev->qdev.parent_bus) == isabus); if (isairq < 0 || isairq > 15) { hw_error("isa irq %d invalid", isairq); } @@ -79,7 +81,7 @@ void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq) { assert(dev->nirqs < ARRAY_SIZE(dev->isairq)); dev->isairq[dev->nirqs] = isairq; - *p = isa_get_irq(isairq); + *p = isa_get_irq(dev, isairq); dev->nirqs++; } @@ -129,10 +131,11 @@ void isa_qdev_register(ISADeviceInfo *info) qdev_register(&info->qdev); } -ISADevice *isa_create(const char *name) +ISADevice *isa_create(ISABus *bus, const char *name) { DeviceState *dev; + assert(!bus || bus == isabus); if (!isabus) { hw_error("Tried to create isa device %s with no isa bus present.", name); @@ -141,10 +144,11 @@ ISADevice *isa_create(const char *name) return DO_UPCAST(ISADevice, qdev, dev); } -ISADevice *isa_try_create(const char *name) +ISADevice *isa_try_create(ISABus *bus, const char *name) { DeviceState *dev; + assert(!bus || bus == isabus); if (!isabus) { hw_error("Tried to create isa device %s with no isa bus present.", name); @@ -153,11 +157,11 @@ ISADevice *isa_try_create(const char *name) return DO_UPCAST(ISADevice, qdev, dev); } -ISADevice *isa_create_simple(const char *name) +ISADevice *isa_create_simple(ISABus *bus, const char *name) { ISADevice *dev; - dev = isa_create(name); + dev = isa_create(bus, name); qdev_init_nofail(&dev->qdev); return dev; } @@ -9,7 +9,6 @@ #define ISA_NUM_IRQS 16 -typedef struct ISABus ISABus; typedef struct ISADevice ISADevice; typedef struct ISADeviceInfo ISADeviceInfo; @@ -27,14 +26,14 @@ struct ISADeviceInfo { }; ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io); -void isa_bus_irqs(qemu_irq *irqs); -qemu_irq isa_get_irq(int isairq); +void isa_bus_irqs(ISABus *bus, qemu_irq *irqs); +qemu_irq isa_get_irq(ISADevice *dev, int isairq); void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq); void isa_qdev_register(ISADeviceInfo *info); MemoryRegion *isa_address_space(ISADevice *dev); -ISADevice *isa_create(const char *name); -ISADevice *isa_try_create(const char *name); -ISADevice *isa_create_simple(const char *name); +ISADevice *isa_create(ISABus *bus, const char *name); +ISADevice *isa_try_create(ISABus *bus, const char *name); +ISADevice *isa_create_simple(ISABus *bus, const char *name); /** * isa_register_ioport: Install an I/O port region on the ISA bus. diff --git a/hw/m48t59.c b/hw/m48t59.c index 8d8d495..c043996 100644 --- a/hw/m48t59.c +++ b/hw/m48t59.c @@ -660,13 +660,14 @@ M48t59State *m48t59_init(qemu_irq IRQ, target_phys_addr_t mem_base, return state; } -M48t59State *m48t59_init_isa(uint32_t io_base, uint16_t size, int type) +M48t59State *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size, + int type) { M48t59ISAState *d; ISADevice *dev; M48t59State *s; - dev = isa_create("m48t59_isa"); + dev = isa_create(bus, "m48t59_isa"); qdev_prop_set_uint32(&dev->qdev, "type", type); qdev_prop_set_uint32(&dev->qdev, "size", size); qdev_prop_set_uint32(&dev->qdev, "io_base", io_base); diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index 0c23cb0..9cbd052 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -677,12 +677,12 @@ static int rtc_initfn(ISADevice *dev) return 0; } -ISADevice *rtc_init(int base_year, qemu_irq intercept_irq) +ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq) { ISADevice *dev; RTCState *s; - dev = isa_create("mc146818rtc"); + dev = isa_create(bus, "mc146818rtc"); s = DO_UPCAST(RTCState, dev, dev); qdev_prop_set_int32(&dev->qdev, "base_year", base_year); qdev_init_nofail(&dev->qdev); diff --git a/hw/mc146818rtc.h b/hw/mc146818rtc.h index 575968c..f119930 100644 --- a/hw/mc146818rtc.h +++ b/hw/mc146818rtc.h @@ -5,7 +5,7 @@ #define RTC_ISA_IRQ 8 -ISADevice *rtc_init(int base_year, qemu_irq intercept_irq); +ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq); void rtc_set_memory(ISADevice *dev, int addr, int val); void rtc_set_date(ISADevice *dev, const struct tm *tm); diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index 04921c1..e6e120c 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -266,6 +266,7 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device, qemu_irq *cpu_exit_irq; int via_devfn; PCIBus *pci_bus; + ISABus *isa_bus; i2c_bus *smbus; int i; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; @@ -342,11 +343,12 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device, fprintf(stderr, "vt82c686b_init error\n"); exit(1); } + isa_bus = NULL; /* Interrupt controller */ /* The 8259 -> IP5 */ - i8259 = i8259_init(env->irq[5]); - isa_bus_irqs(i8259); + i8259 = i8259_init(isa_bus, env->irq[5]); + isa_bus_irqs(isa_bus, i8259); vt82c686b_ide_init(pci_bus, hd, PCI_DEVFN(FULONG2E_VIA_SLOT, 1)); usb_uhci_vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 2)); @@ -358,23 +360,23 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device, smbus_eeprom_init(smbus, 1, eeprom_spd, sizeof(eeprom_spd)); /* init other devices */ - pit = pit_init(0x40, 0); + pit = pit_init(isa_bus, 0x40, 0); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); /* Super I/O */ - isa_create_simple("i8042"); + isa_create_simple(isa_bus, "i8042"); - rtc_init(2000, NULL); + rtc_init(isa_bus, 2000, NULL); for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { - serial_isa_init(i, serial_hds[i]); + serial_isa_init(isa_bus, i, serial_hds[i]); } } if (parallel_hds[0]) { - parallel_init(0, parallel_hds[0]); + parallel_init(isa_bus, 0, parallel_hds[0]); } /* Sound card */ diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index 358de59..8ed66ce 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -120,6 +120,7 @@ static void mips_jazz_init(MemoryRegion *address_space, NICInfo *nd; DeviceState *dev; SysBusDevice *sysbus; + ISABus *isa_bus; ISADevice *pit; DriveInfo *fds[MAX_FD]; qemu_irq esp_reset, dma_enable; @@ -183,12 +184,12 @@ static void mips_jazz_init(MemoryRegion *address_space, memory_region_add_subregion(address_space, 0x8000d000, dma_dummy); /* ISA devices */ - isa_bus_new(NULL, address_space_io); - i8259 = i8259_init(env->irq[4]); - isa_bus_irqs(i8259); + isa_bus = isa_bus_new(NULL, address_space_io); + i8259 = i8259_init(isa_bus, env->irq[4]); + isa_bus_irqs(isa_bus, i8259); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); - pit = pit_init(0x40, 0); + pit = pit_init(isa_bus, 0x40, 0); pcspk_init(pit); /* ISA IO space at 0x90000000 */ @@ -255,7 +256,7 @@ static void mips_jazz_init(MemoryRegion *address_space, fdctrl_init_sysbus(rc4030[1], 0, 0x80003000, fds); /* Real time clock */ - rtc_init(1980, NULL); + rtc_init(isa_bus, 1980, NULL); memory_region_init_io(rtc, &rtc_ops, NULL, "rtc", 0x1000); memory_region_add_subregion(address_space, 0x80004000, rtc); @@ -280,7 +281,7 @@ static void mips_jazz_init(MemoryRegion *address_space, /* Sound card */ /* FIXME: missing Jazz sound at 0x8000c000, rc4030[2] */ - audio_init(i8259, NULL); + audio_init(isa_bus, i8259, NULL); /* NVRAM */ dev = qdev_create(NULL, "ds1225y"); diff --git a/hw/mips_malta.c b/hw/mips_malta.c index e7dfbd6..621e661 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -774,6 +774,7 @@ void mips_malta_init (ram_addr_t ram_size, target_long bios_size; int64_t kernel_entry; PCIBus *pci_bus; + ISABus *isa_bus; CPUState *env; qemu_irq *i8259 = NULL, *isa_irq; qemu_irq *cpu_exit_irq; @@ -942,37 +943,38 @@ void mips_malta_init (ram_addr_t ram_size, ide_drive_get(hd, MAX_IDE_BUS); piix4_devfn = piix4_init(pci_bus, 80); + isa_bus = NULL; /* Interrupt controller */ /* The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 */ - i8259 = i8259_init(env->irq[2]); + i8259 = i8259_init(isa_bus, env->irq[2]); - isa_bus_irqs(i8259); + isa_bus_irqs(isa_bus, i8259); pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1); usb_uhci_piix4_init(pci_bus, piix4_devfn + 2); - smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, isa_get_irq(9), - NULL, NULL, 0); + smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, + isa_get_irq(NULL, 9), NULL, NULL, 0); /* TODO: Populate SPD eeprom data. */ smbus_eeprom_init(smbus, 8, NULL, 0); - pit = pit_init(0x40, 0); + pit = pit_init(isa_bus, 0x40, 0); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); /* Super I/O */ - isa_create_simple("i8042"); + isa_create_simple(isa_bus, "i8042"); - rtc_init(2000, NULL); - serial_isa_init(0, serial_hds[0]); - serial_isa_init(1, serial_hds[1]); + rtc_init(isa_bus, 2000, NULL); + serial_isa_init(isa_bus, 0, serial_hds[0]); + serial_isa_init(isa_bus, 1, serial_hds[1]); if (parallel_hds[0]) - parallel_init(0, parallel_hds[0]); + parallel_init(isa_bus, 0, parallel_hds[0]); for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } - fdctrl_init_isa(fd); + fdctrl_init_isa(isa_bus, fd); /* Sound card */ - audio_init(NULL, pci_bus); + audio_init(isa_bus, NULL, pci_bus); /* Network card */ network_init(); diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index d0564d4..c078078 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -165,6 +165,7 @@ void mips_r4k_init (ram_addr_t ram_size, ResetData *reset_info; int i; qemu_irq *i8259; + ISABus *isa_bus; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DriveInfo *dinfo; int be; @@ -256,36 +257,36 @@ void mips_r4k_init (ram_addr_t ram_size, cpu_mips_clock_init(env); /* The PIC is attached to the MIPS CPU INT0 pin */ - isa_bus_new(NULL, get_system_io()); - i8259 = i8259_init(env->irq[2]); - isa_bus_irqs(i8259); + isa_bus = isa_bus_new(NULL, get_system_io()); + i8259 = i8259_init(isa_bus, env->irq[2]); + isa_bus_irqs(isa_bus, i8259); - rtc_init(2000, NULL); + rtc_init(isa_bus, 2000, NULL); /* Register 64 KB of ISA IO space at 0x14000000 */ isa_mmio_init(0x14000000, 0x00010000); isa_mem_base = 0x10000000; - pit = pit_init(0x40, 0); + pit = pit_init(isa_bus, 0x40, 0); for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { - serial_isa_init(i, serial_hds[i]); + serial_isa_init(isa_bus, i, serial_hds[i]); } } - isa_vga_init(); + isa_vga_init(isa_bus); if (nd_table[0].vlan) - isa_ne2000_init(0x300, 9, &nd_table[0]); + isa_ne2000_init(isa_bus, 0x300, 9, &nd_table[0]); ide_drive_get(hd, MAX_IDE_BUS); for(i = 0; i < MAX_IDE_BUS; i++) - isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i], + isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i], hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); - isa_create_simple("i8042"); + isa_create_simple(isa_bus, "i8042"); } static QEMUMachine mips_machine = { @@ -34,7 +34,8 @@ typedef struct M48t59State M48t59State; void m48t59_write (void *private, uint32_t addr, uint32_t val); uint32_t m48t59_read (void *private, uint32_t addr); void m48t59_toggle_lock (void *private, int lock); -M48t59State *m48t59_init_isa(uint32_t io_base, uint16_t size, int type); +M48t59State *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size, + int type); M48t59State *m48t59_init(qemu_irq IRQ, target_phys_addr_t mem_base, uint32_t io_base, uint16_t size, int type); void m48t59_set_addr (void *opaque, uint32_t addr); @@ -849,13 +849,13 @@ static const int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 }; static const int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc }; static const int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 }; -void pc_init_ne2k_isa(NICInfo *nd) +void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd) { static int nb_ne2k = 0; if (nb_ne2k == NE2000_NB_MAX) return; - isa_ne2000_init(ne2000_io[nb_ne2k], + isa_ne2000_init(bus, ne2000_io[nb_ne2k], ne2000_irq[nb_ne2k], nd); nb_ne2k++; } @@ -1069,7 +1069,7 @@ qemu_irq *pc_allocate_cpu_irq(void) return qemu_allocate_irqs(pic_irq_request, NULL, 1); } -DeviceState *pc_vga_init(PCIBus *pci_bus) +DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus) { DeviceState *dev = NULL; @@ -1102,7 +1102,7 @@ DeviceState *pc_vga_init(PCIBus *pci_bus) if (pci_bus) { dev = pci_vga_init(pci_bus); } else { - dev = isa_vga_init(); + dev = isa_vga_init(isa_bus); } } @@ -1118,7 +1118,7 @@ static void cpu_request_exit(void *opaque, int irq, int level) } } -void pc_basic_device_init(qemu_irq *gsi, +void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, ISADevice **rtc_state, ISADevice **floppy, bool no_vmport) @@ -1144,31 +1144,31 @@ void pc_basic_device_init(qemu_irq *gsi, rtc_irq = qdev_get_gpio_in(hpet, 0); } } - *rtc_state = rtc_init(2000, rtc_irq); + *rtc_state = rtc_init(isa_bus, 2000, rtc_irq); qemu_register_boot_set(pc_boot_set, *rtc_state); - pit = pit_init(0x40, 0); + pit = pit_init(isa_bus, 0x40, 0); pcspk_init(pit); for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { - serial_isa_init(i, serial_hds[i]); + serial_isa_init(isa_bus, i, serial_hds[i]); } } for(i = 0; i < MAX_PARALLEL_PORTS; i++) { if (parallel_hds[i]) { - parallel_init(i, parallel_hds[i]); + parallel_init(isa_bus, i, parallel_hds[i]); } } a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2); - i8042 = isa_create_simple("i8042"); + i8042 = isa_create_simple(isa_bus, "i8042"); i8042_setup_a20_line(i8042, &a20_line[0]); if (!no_vmport) { - vmport_init(); - vmmouse = isa_try_create("vmmouse"); + vmport_init(isa_bus); + vmmouse = isa_try_create(isa_bus, "vmmouse"); } else { vmmouse = NULL; } @@ -1176,7 +1176,7 @@ void pc_basic_device_init(qemu_irq *gsi, qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042); qdev_init_nofail(&vmmouse->qdev); } - port92 = isa_create_simple("port92"); + port92 = isa_create_simple(isa_bus, "port92"); port92_init(port92, &a20_line[1]); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); @@ -1185,7 +1185,7 @@ void pc_basic_device_init(qemu_irq *gsi, for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } - *floppy = fdctrl_init_isa(fd); + *floppy = fdctrl_init_isa(isa_bus, fd); } void pc_pci_device_init(PCIBus *pci_bus) @@ -20,11 +20,12 @@ SerialState *serial_mm_init(MemoryRegion *address_space, target_phys_addr_t base, int it_shift, qemu_irq irq, int baudbase, CharDriverState *chr, enum device_endian); -static inline bool serial_isa_init(int index, CharDriverState *chr) +static inline bool serial_isa_init(ISABus *bus, int index, + CharDriverState *chr) { ISADevice *dev; - dev = isa_try_create("isa-serial"); + dev = isa_try_create(bus, "isa-serial"); if (!dev) { return false; } @@ -39,11 +40,11 @@ static inline bool serial_isa_init(int index, CharDriverState *chr) void serial_set_frequency(SerialState *s, uint32_t frequency); /* parallel.c */ -static inline bool parallel_init(int index, CharDriverState *chr) +static inline bool parallel_init(ISABus *bus, int index, CharDriverState *chr) { ISADevice *dev; - dev = isa_try_create("isa-parallel"); + dev = isa_try_create(bus, "isa-parallel"); if (!dev) { return false; } @@ -63,7 +64,7 @@ bool parallel_mm_init(MemoryRegion *address_space, typedef struct PicState PicState; extern PicState *isa_pic; -qemu_irq *i8259_init(qemu_irq parent_irq); +qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq); int pic_read_irq(PicState *s); int pic_get_output(PicState *s); void pic_info(Monitor *mon); @@ -84,11 +85,11 @@ void gsi_handler(void *opaque, int n, int level); #define PIT_FREQ 1193182 -static inline ISADevice *pit_init(int base, int irq) +static inline ISADevice *pit_init(ISABus *bus, int base, int irq) { ISADevice *dev; - dev = isa_create("isa-pit"); + dev = isa_create(bus, "isa-pit"); qdev_prop_set_uint32(&dev->qdev, "iobase", base); qdev_prop_set_uint32(&dev->qdev, "irq", irq); qdev_init_nofail(&dev->qdev); @@ -106,9 +107,9 @@ void hpet_pit_disable(void); void hpet_pit_enable(void); /* vmport.c */ -static inline void vmport_init(void) +static inline void vmport_init(ISABus *bus) { - isa_create_simple("vmport"); + isa_create_simple(bus, "vmport"); } void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque); void vmmouse_get_data(uint32_t *data); @@ -140,12 +141,12 @@ void pc_memory_init(MemoryRegion *system_memory, MemoryRegion *rom_memory, MemoryRegion **ram_memory); qemu_irq *pc_allocate_cpu_irq(void); -DeviceState *pc_vga_init(PCIBus *pci_bus); -void pc_basic_device_init(qemu_irq *gsi, +DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus); +void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, ISADevice **rtc_state, ISADevice **floppy, bool no_vmport); -void pc_init_ne2k_isa(NICInfo *nd); +void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd); void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, const char *boot_device, ISADevice *floppy, BusState *ide0, BusState *ide1, @@ -175,7 +176,7 @@ extern int no_hpet; /* pcspk.c */ void pcspk_init(ISADevice *pit); -int pcspk_audio_init(qemu_irq *pic); +int pcspk_audio_init(ISABus *bus, qemu_irq *pic); /* piix_pci.c */ struct PCII440FXState; @@ -205,11 +206,11 @@ enum vga_retrace_method { extern enum vga_retrace_method vga_retrace_method; -static inline DeviceState *isa_vga_init(void) +static inline DeviceState *isa_vga_init(ISABus *bus) { ISADevice *dev; - dev = isa_try_create("isa-vga"); + dev = isa_try_create(bus, "isa-vga"); if (!dev) { fprintf(stderr, "Warning: isa-vga not available\n"); return NULL; @@ -228,13 +229,13 @@ DeviceState *pci_cirrus_vga_init(PCIBus *bus); DeviceState *isa_cirrus_vga_init(MemoryRegion *address_space); /* ne2000.c */ -static inline bool isa_ne2000_init(int base, int irq, NICInfo *nd) +static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd) { ISADevice *dev; qemu_check_nic_model(nd, "ne2k_isa"); - dev = isa_try_create("ne2k_isa"); + dev = isa_try_create(bus, "ne2k_isa"); if (!dev) { return false; } diff --git a/hw/pc_piix.c b/hw/pc_piix.c index b9bb09d..b4126b5 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -84,6 +84,7 @@ static void pc_init1(MemoryRegion *system_memory, int i; ram_addr_t below_4g_mem_size, above_4g_mem_size; PCIBus *pci_bus; + ISABus *isa_bus; PCII440FXState *i440fx_state; int piix3_devfn = -1; qemu_irq *cpu_irq; @@ -145,17 +146,18 @@ static void pc_init1(MemoryRegion *system_memory, ? 0 : ((uint64_t)1 << 62)), pci_memory, ram_memory); + isa_bus = NULL; } else { pci_bus = NULL; i440fx_state = NULL; - isa_bus_new(NULL, system_io); + isa_bus = isa_bus_new(NULL, system_io); no_hpet = 1; } - isa_bus_irqs(gsi); + isa_bus_irqs(isa_bus, gsi); if (!xen_enabled()) { cpu_irq = pc_allocate_cpu_irq(); - i8259 = i8259_init(cpu_irq[0]); + i8259 = i8259_init(isa_bus, cpu_irq[0]); } else { i8259 = xen_interrupt_controller_init(); } @@ -169,7 +171,7 @@ static void pc_init1(MemoryRegion *system_memory, pc_register_ferr_irq(gsi[13]); - dev = pc_vga_init(pci_enabled? pci_bus: NULL); + dev = pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL); if (dev) { qdev_property_add_child(qdev_get_root(), "vga", dev, NULL); } @@ -179,13 +181,13 @@ static void pc_init1(MemoryRegion *system_memory, } /* init basic PC hardware */ - pc_basic_device_init(gsi, &rtc_state, &floppy, xen_enabled()); + pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, xen_enabled()); for(i = 0; i < nb_nics; i++) { NICInfo *nd = &nd_table[i]; if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0)) - pc_init_ne2k_isa(nd); + pc_init_ne2k_isa(isa_bus, nd); else pci_nic_init_nofail(nd, "e1000", NULL); } @@ -203,7 +205,8 @@ static void pc_init1(MemoryRegion *system_memory, } else { for(i = 0; i < MAX_IDE_BUS; i++) { ISADevice *dev; - dev = isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i], + dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], + ide_irq[i], hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); idebus[i] = qdev_get_child_bus(&dev->qdev, "ide.0"); } @@ -220,7 +223,7 @@ static void pc_init1(MemoryRegion *system_memory, qdev_property_add_child(qdev_resolve_path("/i440fx/piix3", NULL), "rtc", (DeviceState *)rtc_state, NULL); - audio_init(gsi, pci_enabled ? pci_bus : NULL); + audio_init(isa_bus, gsi, pci_enabled ? pci_bus : NULL); pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, floppy, idebus[0], idebus[1], rtc_state); @@ -96,7 +96,7 @@ static void pcspk_callback(void *opaque, int free) } } -int pcspk_audio_init(qemu_irq *pic) +int pcspk_audio_init(ISABus *bus, qemu_irq *pic) { PCSpkState *s = &pcspk_state; struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0}; diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index f22d5b9..a7d73bf 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -523,6 +523,7 @@ static void ppc_prep_init (ram_addr_t ram_size, uint32_t kernel_base, initrd_base; long kernel_size, initrd_size; PCIBus *pci_bus; + ISABus *isa_bus; qemu_irq *i8259; qemu_irq *cpu_exit_irq; int ppc_boot_device; @@ -628,10 +629,10 @@ static void ppc_prep_init (ram_addr_t ram_size, hw_error("Only 6xx bus is supported on PREP machine\n"); } /* Hmm, prep has no pci-isa bridge ??? */ - isa_bus_new(NULL, get_system_io()); - i8259 = i8259_init(first_cpu->irq_inputs[PPC6xx_INPUT_INT]); + isa_bus = isa_bus_new(NULL, get_system_io()); + i8259 = i8259_init(isa_bus, first_cpu->irq_inputs[PPC6xx_INPUT_INT]); pci_bus = pci_prep_init(i8259, get_system_memory(), get_system_io()); - isa_bus_irqs(i8259); + isa_bus_irqs(isa_bus, i8259); // pci_bus = i440fx_init(); /* Register 8 MB of ISA IO space (needed for non-contiguous map) */ memory_region_init_io(PPC_io_memory, &PPC_prep_io_ops, sysctrl, @@ -642,10 +643,10 @@ static void ppc_prep_init (ram_addr_t ram_size, pci_vga_init(pci_bus); // openpic = openpic_init(0x00000000, 0xF0000000, 1); // pit = pit_init(0x40, 0); - rtc_init(2000, NULL); + rtc_init(isa_bus, 2000, NULL); if (serial_hds[0]) - serial_isa_init(0, serial_hds[0]); + serial_isa_init(isa_bus, 0, serial_hds[0]); nb_nics1 = nb_nics; if (nb_nics1 > NE2000_NB_MAX) nb_nics1 = NE2000_NB_MAX; @@ -654,7 +655,8 @@ static void ppc_prep_init (ram_addr_t ram_size, nd_table[i].model = g_strdup("ne2k_isa"); } if (strcmp(nd_table[i].model, "ne2k_isa") == 0) { - isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]); + isa_ne2000_init(isa_bus, ne2000_io[i], ne2000_irq[i], + &nd_table[i]); } else { pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); } @@ -662,11 +664,11 @@ static void ppc_prep_init (ram_addr_t ram_size, ide_drive_get(hd, MAX_IDE_BUS); for(i = 0; i < MAX_IDE_BUS; i++) { - isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i], + isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i], hd[2 * i], hd[2 * i + 1]); } - isa_create_simple("i8042"); + isa_create_simple(isa_bus, "i8042"); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(1, cpu_exit_irq); @@ -676,7 +678,7 @@ static void ppc_prep_init (ram_addr_t ram_size, for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } - fdctrl_init_isa(fd); + fdctrl_init_isa(isa_bus, fd); /* Register speaker port */ register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL); @@ -1385,9 +1385,9 @@ static int sb16_initfn (ISADevice *dev) return 0; } -int SB16_init (qemu_irq *pic) +int SB16_init (ISABus *bus, qemu_irq *pic) { - isa_create_simple ("sb16"); + isa_create_simple (bus, "sb16"); return 0; } @@ -526,14 +526,17 @@ static void dummy_isa_irq_handler(void *opaque, int n, int level) } /* EBUS (Eight bit bus) bridge */ -static void +static ISABus * pci_ebus_init(PCIBus *bus, int devfn) { qemu_irq *isa_irq; + ISABus *isa_bus; pci_create_simple(bus, devfn, "ebus"); + isa_bus = NULL; isa_irq = qemu_allocate_irqs(dummy_isa_irq_handler, NULL, 16); - isa_bus_irqs(isa_irq); + isa_bus_irqs(isa_bus, isa_irq); + return isa_bus; } static int @@ -744,6 +747,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, unsigned int i; long initrd_size, kernel_size; PCIBus *pci_bus, *pci_bus2, *pci_bus3; + ISABus *isa_bus; qemu_irq *irq; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; DriveInfo *fd[MAX_FD]; @@ -764,7 +768,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, pci_vga_init(pci_bus); // XXX Should be pci_bus3 - pci_ebus_init(pci_bus, -1); + isa_bus = pci_ebus_init(pci_bus, -1); i = 0; if (hwdef->console_serial_base) { @@ -774,13 +778,13 @@ static void sun4uv_init(MemoryRegion *address_space_mem, } for(; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { - serial_isa_init(i, serial_hds[i]); + serial_isa_init(isa_bus, i, serial_hds[i]); } } for(i = 0; i < MAX_PARALLEL_PORTS; i++) { if (parallel_hds[i]) { - parallel_init(i, parallel_hds[i]); + parallel_init(isa_bus, i, parallel_hds[i]); } } @@ -791,12 +795,12 @@ static void sun4uv_init(MemoryRegion *address_space_mem, pci_cmd646_ide_init(pci_bus, hd, 1); - isa_create_simple("i8042"); + isa_create_simple(isa_bus, "i8042"); for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } - fdctrl_init_isa(fd); - nvram = m48t59_init_isa(0x0074, NVRAM_SIZE, 59); + fdctrl_init_isa(isa_bus, fd); + nvram = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59); initrd_size = 0; kernel_size = sun4u_load_kernel(kernel_filename, initrd_filename, diff --git a/qemu-common.h b/qemu-common.h index 44870fe52..b2de015 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -217,6 +217,7 @@ typedef struct VLANState VLANState; typedef struct VLANClientState VLANClientState; typedef struct i2c_bus i2c_bus; typedef struct i2c_slave i2c_slave; +typedef struct ISABus ISABus; typedef struct SMBusDevice SMBusDevice; typedef struct PCIHostState PCIHostState; typedef struct PCIExpressHost PCIExpressHost; |