From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R5Inz-0003VR-DX for qemu-devel@nongnu.org; Sun, 18 Sep 2011 10:57:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R5Inx-0007Ui-HT for qemu-devel@nongnu.org; Sun, 18 Sep 2011 10:57:15 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:56813) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R5Inw-0007UV-Nb for qemu-devel@nongnu.org; Sun, 18 Sep 2011 10:57:13 -0400 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sun, 18 Sep 2011 16:56:42 +0200 Message-Id: <1316357803-2366-11-git-send-email-hpoussin@reactos.org> In-Reply-To: <1316357803-2366-1-git-send-email-hpoussin@reactos.org> References: <1316357803-2366-1-git-send-email-hpoussin@reactos.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 10/11] isa: give bus to isa_create() methods List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Herv=C3=A9=20Poussineau?= This allows to create a device on requested ISA bus. If argument is not provided, 'default' ISA bus is used. Signed-off-by: Herv=C3=A9 Poussineau --- hw/cs4231a.c | 2 +- hw/fdc.h | 2 +- hw/gus.c | 2 +- hw/ide/isa.c | 2 +- hw/isa-bus.c | 30 +++++++++++++++++++----------- hw/isa.h | 6 +++--- hw/m48t59.c | 2 +- hw/mc146818rtc.c | 2 +- hw/mips_fulong2e.c | 2 +- hw/mips_malta.c | 2 +- hw/mips_r4k.c | 2 +- hw/pc.c | 8 ++++---- hw/pc.h | 12 ++++++------ hw/ppc_prep.c | 2 +- hw/sb16.c | 2 +- hw/sun4u.c | 2 +- 16 files changed, 44 insertions(+), 36 deletions(-) diff --git a/hw/cs4231a.c b/hw/cs4231a.c index e16f9a3..9e6fbaa 100644 --- a/hw/cs4231a.c +++ b/hw/cs4231a.c @@ -661,7 +661,7 @@ static int cs4231a_initfn (ISADevice *dev) =20 int cs4231a_init(ISABus *bus) { - isa_create_simple ("cs4231a"); + isa_create_simple(bus, "cs4231a"); return 0; } =20 diff --git a/hw/fdc.h b/hw/fdc.h index 09f73c6..65a4a8d 100644 --- a/hw/fdc.h +++ b/hw/fdc.h @@ -11,7 +11,7 @@ static inline void fdctrl_init_isa(DriveInfo **fds) { ISADevice *dev; =20 - dev =3D isa_try_create("isa-fdc"); + dev =3D isa_try_create(NULL, "isa-fdc"); if (!dev) { return; } diff --git a/hw/gus.c b/hw/gus.c index e4dbc8a..fa56f8f 100644 --- a/hw/gus.c +++ b/hw/gus.c @@ -296,7 +296,7 @@ static int gus_initfn (ISADevice *dev) =20 int GUS_init(ISABus *bus) { - isa_create_simple ("gus"); + isa_create_simple(bus, "gus"); return 0; } =20 diff --git a/hw/ide/isa.c b/hw/ide/isa.c index 28b69d2..032f105 100644 --- a/hw/ide/isa.c +++ b/hw/ide/isa.c @@ -81,7 +81,7 @@ ISADevice *isa_ide_init(int iobase, int iobase2, int is= airq, ISADevice *dev; ISAIDEState *s; =20 - dev =3D isa_create("isa-ide"); + dev =3D isa_create(NULL, "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/isa-bus.c b/hw/isa-bus.c index 37642b7..b697f65 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -126,35 +126,41 @@ void isa_qdev_register(ISADeviceInfo *info) qdev_register(&info->qdev); } =20 -ISADevice *isa_create(const char *name) +ISADevice *isa_create(ISABus *bus, const char *name) { DeviceState *dev; =20 - if (!isabus) { + if (!bus) { + bus =3D isabus; + } + if (!bus) { hw_error("Tried to create isa device %s with no isa bus present.= ", name); } - dev =3D qdev_create(&isabus->qbus, name); + dev =3D qdev_create(&bus->qbus, name); return DO_UPCAST(ISADevice, qdev, dev); } =20 -ISADevice *isa_try_create(const char *name) +ISADevice *isa_try_create(ISABus *bus, const char *name) { DeviceState *dev; =20 - if (!isabus) { + if (!bus) { + bus =3D isabus; + } + if (!bus) { hw_error("Tried to create isa device %s with no isa bus present.= ", name); } - dev =3D qdev_try_create(&isabus->qbus, name); + dev =3D qdev_try_create(&bus->qbus, name); return DO_UPCAST(ISADevice, qdev, dev); } =20 -ISADevice *isa_create_simple(const char *name) +ISADevice *isa_create_simple(ISABus *bus, const char *name) { ISADevice *dev; =20 - dev =3D isa_create(name); + dev =3D isa_create(bus, name); qdev_init_nofail(&dev->qdev); return dev; } @@ -188,9 +194,11 @@ static char *isabus_get_fw_dev_path(DeviceState *dev= ) =20 MemoryRegion *isa_address_space(ISADevice *dev) { - if (!isabus || !isabus->ops->get_address_space) { - hw_error("Tried to get isa address space with no isa bus present= ."); + ISABus *bus =3D FROM_QBUS(ISABus, qdev_get_parent_bus(&dev->qdev)); + + if (!bus->ops->get_address_space) { + hw_error("Tried to get isa address space on invalid isa bus."); } - return isabus->ops->get_address_space(isabus); + return bus->ops->get_address_space(bus); } =20 diff --git a/hw/isa.h b/hw/isa.h index 5219b98..03ecd55 100644 --- a/hw/isa.h +++ b/hw/isa.h @@ -48,9 +48,9 @@ void isa_init_ioport(ISADevice *dev, uint16_t ioport); void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t leng= th); 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); =20 extern target_phys_addr_t isa_mem_base; =20 diff --git a/hw/m48t59.c b/hw/m48t59.c index 0cc361e..91b8c47 100644 --- a/hw/m48t59.c +++ b/hw/m48t59.c @@ -661,7 +661,7 @@ M48t59State *m48t59_init_isa(uint32_t io_base, uint16= _t size, int type) ISADevice *dev; M48t59State *s; =20 - dev =3D isa_create("m48t59_isa"); + dev =3D isa_create(NULL, "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 feb3b25..dd07656 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -646,7 +646,7 @@ ISADevice *rtc_init(int base_year, qemu_irq intercept= _irq) ISADevice *dev; RTCState *s; =20 - dev =3D isa_create("mc146818rtc"); + dev =3D isa_create(NULL, "mc146818rtc"); s =3D DO_UPCAST(RTCState, dev, dev); qdev_prop_set_int32(&dev->qdev, "base_year", base_year); qdev_init_nofail(&dev->qdev); diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index 3034a9c..938aeaf 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -358,7 +358,7 @@ static void mips_fulong2e_init(ram_addr_t ram_size, c= onst char *boot_device, DMA_init(0, cpu_exit_irq); =20 /* Super I/O */ - isa_create_simple("i8042"); + isa_create_simple(NULL, "i8042"); =20 rtc_init(2000, NULL); =20 diff --git a/hw/mips_malta.c b/hw/mips_malta.c index 65e5915..fe90db1 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -951,7 +951,7 @@ void mips_malta_init (ram_addr_t ram_size, DMA_init(0, cpu_exit_irq); =20 /* Super I/O */ - isa_create_simple("i8042"); + isa_create_simple(NULL, "i8042"); =20 rtc_init(2000, NULL); serial_isa_init(0, serial_hds[0]); diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index aaa38b0..d09c62d 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -294,7 +294,7 @@ void mips_r4k_init (ram_addr_t ram_size, hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); =20 - isa_create_simple("i8042"); + isa_create_simple(NULL, "i8042"); } =20 static QEMUMachine mips_machine =3D { diff --git a/hw/pc.c b/hw/pc.c index 5bc845a..c33992f 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1103,7 +1103,7 @@ void pc_vga_init(PCIBus *pci_bus) * For nographic case, sga is enabled at all times */ if (display_type =3D=3D DT_NOGRAPHIC) { - isa_create_simple("sga"); + isa_create_simple(NULL, "sga"); } } =20 @@ -1161,11 +1161,11 @@ void pc_basic_device_init(qemu_irq *isa_irq, } =20 a20_line =3D qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2= ); - i8042 =3D isa_create_simple("i8042"); + i8042 =3D isa_create_simple(NULL, "i8042"); i8042_setup_a20_line(i8042, &a20_line[0]); if (!no_vmport) { vmport_init(); - vmmouse =3D isa_try_create("vmmouse"); + vmmouse =3D isa_try_create(NULL, "vmmouse"); } else { vmmouse =3D NULL; } @@ -1173,7 +1173,7 @@ void pc_basic_device_init(qemu_irq *isa_irq, qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042); qdev_init_nofail(&vmmouse->qdev); } - port92 =3D isa_create_simple("port92"); + port92 =3D isa_create_simple(NULL, "port92"); port92_init(port92, &a20_line[1]); =20 cpu_exit_irq =3D qemu_allocate_irqs(cpu_request_exit, NULL, 1); diff --git a/hw/pc.h b/hw/pc.h index 8d1573f..1824787 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -23,7 +23,7 @@ static inline bool serial_isa_init(int index, CharDrive= rState *chr) { ISADevice *dev; =20 - dev =3D isa_try_create("isa-serial"); + dev =3D isa_try_create(NULL, "isa-serial"); if (!dev) { return false; } @@ -42,7 +42,7 @@ static inline bool parallel_init(int index, CharDriverS= tate *chr) { ISADevice *dev; =20 - dev =3D isa_try_create("isa-parallel"); + dev =3D isa_try_create(NULL, "isa-parallel"); if (!dev) { return false; } @@ -88,7 +88,7 @@ static inline ISADevice *pit_init(int base, int irq) { ISADevice *dev; =20 - dev =3D isa_create("isa-pit"); + dev =3D isa_create(NULL, "isa-pit"); qdev_prop_set_uint32(&dev->qdev, "iobase", base); qdev_prop_set_uint32(&dev->qdev, "irq", irq); qdev_init_nofail(&dev->qdev); @@ -108,7 +108,7 @@ void hpet_pit_enable(void); /* vmport.c */ static inline void vmport_init(void) { - isa_create_simple("vmport"); + isa_create_simple(NULL, "vmport"); } void vmport_register(unsigned char command, IOPortReadFunc *func, void *= opaque); void vmmouse_get_data(uint32_t *data); @@ -208,7 +208,7 @@ static inline int isa_vga_init(void) { ISADevice *dev; =20 - dev =3D isa_try_create("isa-vga"); + dev =3D isa_try_create(NULL, "isa-vga"); if (!dev) { fprintf(stderr, "Warning: isa-vga not available\n"); return 0; @@ -233,7 +233,7 @@ static inline bool isa_ne2000_init(int base, int irq,= NICInfo *nd) =20 qemu_check_nic_model(nd, "ne2k_isa"); =20 - dev =3D isa_try_create("ne2k_isa"); + dev =3D isa_try_create(NULL, "ne2k_isa"); if (!dev) { return false; } diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index 5b313c8..b72453c 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -688,7 +688,7 @@ static void ppc_prep_init (ram_addr_t ram_size, hd[2 * i], hd[2 * i + 1]); } - isa_create_simple("i8042"); + isa_create_simple(NULL, "i8042"); =20 cpu_exit_irq =3D qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(1, cpu_exit_irq); diff --git a/hw/sb16.c b/hw/sb16.c index 6af2f59..b851fcb 100644 --- a/hw/sb16.c +++ b/hw/sb16.c @@ -1393,7 +1393,7 @@ static int sb16_initfn (ISADevice *dev) =20 int SB16_init(ISABus *bus) { - isa_create_simple ("sb16"); + isa_create_simple(bus, "sb16"); return 0; } =20 diff --git a/hw/sun4u.c b/hw/sun4u.c index 211a9bd..4981c3a 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -805,7 +805,7 @@ static void sun4uv_init(ram_addr_t RAM_size, =20 pci_cmd646_ide_init(pci_bus, hd, 1); =20 - isa_create_simple("i8042"); + isa_create_simple(NULL, "i8042"); for(i =3D 0; i < MAX_FD; i++) { fd[i] =3D drive_get(IF_FLOPPY, 0, i); } --=20 1.7.5.4