From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAOcv-0005QO-7m for qemu-devel@nongnu.org; Sun, 02 Oct 2011 12:10:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RAOcu-0008AV-0X for qemu-devel@nongnu.org; Sun, 02 Oct 2011 12:10:53 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:46117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAOct-00088o-AA for qemu-devel@nongnu.org; Sun, 02 Oct 2011 12:10:51 -0400 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sun, 2 Oct 2011 18:10:18 +0200 Message-Id: <1317571828-9059-7-git-send-email-hpoussin@reactos.org> In-Reply-To: <1317571828-9059-1-git-send-email-hpoussin@reactos.org> References: <1317571828-9059-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 v3 06/16] fulong2e: improve bus implementation of vt82c bridge 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?= Signed-off-by: Herv=C3=A9 Poussineau --- hw/mips_fulong2e.c | 9 ++------- hw/vt82c686.c | 31 +++++++++++++++++++++++++++++-- hw/vt82c686.h | 2 +- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index 04921c1..3034a9c 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -262,7 +262,6 @@ static void mips_fulong2e_init(ram_addr_t ram_size, c= onst char *boot_device, MemoryRegion *bios =3D g_new(MemoryRegion, 1); long bios_size; int64_t kernel_entry; - qemu_irq *i8259; qemu_irq *cpu_exit_irq; int via_devfn; PCIBus *pci_bus; @@ -337,17 +336,13 @@ static void mips_fulong2e_init(ram_addr_t ram_size,= const char *boot_device, /* South bridge */ ide_drive_get(hd, MAX_IDE_BUS); =20 - via_devfn =3D vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0= )); + via_devfn =3D vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0= ), + env->irq[5]); if (via_devfn < 0) { fprintf(stderr, "vt82c686b_init error\n"); exit(1); } =20 - /* Interrupt controller */ - /* The 8259 -> IP5 */ - i8259 =3D i8259_init(env->irq[5]); - isa_bus_irqs(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)); usb_uhci_vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 3)); diff --git a/hw/vt82c686.c b/hw/vt82c686.c index 46e85dd..05a70da 100644 --- a/hw/vt82c686.c +++ b/hw/vt82c686.c @@ -41,6 +41,8 @@ typedef struct SuperIOConfig =20 typedef struct VT82C686BState { PCIDevice dev; + ISABus bus; + qemu_irq *pic; SuperIOConfig superio_conf; } VT82C686BState; =20 @@ -483,14 +485,35 @@ static const VMStateDescription vmstate_via =3D { } }; =20 +static qemu_irq vt82c_bus_get_irq(ISABus *bus, int isairq) +{ + VT82C686BState *vt82c =3D container_of(bus, VT82C686BState, bus); + if (isairq < 0 || isairq >=3D 16) { + hw_error("isa irq %d invalid", isairq); + } + return vt82c->pic[isairq]; +} + +static MemoryRegion *vt82c_bus_get_io_space(ISABus *bus) +{ + VT82C686BState *vt82c =3D container_of(bus, VT82C686BState, bus); + return pci_address_space_io(&vt82c->dev); +} + +static ISABusOps vt82c_bus_ops =3D { + .get_irq =3D vt82c_bus_get_irq, + .get_io_space =3D vt82c_bus_get_io_space, +}; + /* init the PCI-to-ISA bridge */ static int vt82c686b_initfn(PCIDevice *d) { + VT82C686BState *vt82c =3D DO_UPCAST(VT82C686BState, dev, d); uint8_t *pci_conf; uint8_t *wmask; int i; =20 - isa_bus_bridge_init(&d->qdev, pci_address_space_io(d)); + isa_bus_new(&vt82c->bus, &vt82c_bus_ops, &d->qdev); =20 pci_conf =3D d->config; pci_config_set_prog_interface(pci_conf, 0x0); @@ -507,12 +530,16 @@ static int vt82c686b_initfn(PCIDevice *d) return 0; } =20 -int vt82c686b_init(PCIBus *bus, int devfn) +int vt82c686b_init(PCIBus *bus, int devfn, qemu_irq parent_irq) { PCIDevice *d; + VT82C686BState *vt82c; =20 d =3D pci_create_simple_multifunction(bus, devfn, true, "VT82C686B")= ; =20 + vt82c =3D DO_UPCAST(VT82C686BState, dev, d); + vt82c->pic =3D i8259_init(parent_irq); + return d->devfn; } =20 diff --git a/hw/vt82c686.h b/hw/vt82c686.h index e3270ca..1a026c2 100644 --- a/hw/vt82c686.h +++ b/hw/vt82c686.h @@ -2,7 +2,7 @@ #define HW_VT82C686_H =20 /* vt82c686.c */ -int vt82c686b_init(PCIBus * bus, int devfn); +int vt82c686b_init(PCIBus *bus, int devfn, qemu_irq parent_irq); void vt82c686b_ac97_init(PCIBus *bus, int devfn); void vt82c686b_mc97_init(PCIBus *bus, int devfn); i2c_bus *vt82c686b_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, --=20 1.7.6.3