[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/20] qdev: convert piix-ide.
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 08/20] qdev: convert piix-ide. |
Date: |
Mon, 29 Jun 2009 14:46:09 +0200 |
Hook up pci device into qdev.
First step only: no ide bus yet.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/ide.c | 92 +++++++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 61 insertions(+), 31 deletions(-)
diff --git a/hw/ide.c b/hw/ide.c
index f3787f2..3bc75fa 100644
--- a/hw/ide.c
+++ b/hw/ide.c
@@ -3360,20 +3360,11 @@ static void piix3_reset(void *opaque)
pci_conf[0x20] = 0x01; /* BMIBA: 20-23h */
}
-/* hd_table must contain 4 block drivers */
-/* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */
-void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,
- qemu_irq *pic)
+static void pci_piix3_ide_initfn(PCIDevice *dev)
{
- PCIIDEState *d;
+ PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);
uint8_t *pci_conf;
- int i;
- /* register a function 1 of PIIX3 */
- d = (PCIIDEState *)pci_register_device(bus, "PIIX3 IDE",
- sizeof(PCIIDEState),
- devfn,
- NULL, NULL);
d->type = IDE_TYPE_PIIX3;
pci_conf = d->dev.config;
@@ -3389,31 +3380,14 @@ void pci_piix3_ide_init(PCIBus *bus, BlockDriverState
**hd_table, int devfn,
pci_register_bar((PCIDevice *)d, 4, 0x10,
PCI_ADDRESS_SPACE_IO, bmdma_map);
- ide_init2(&d->ide_if[0], hd_table[0], hd_table[1], pic[14]);
- ide_init2(&d->ide_if[2], hd_table[2], hd_table[3], pic[15]);
- ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6);
- ide_init_ioport(&d->ide_if[2], 0x170, 0x376);
-
- for (i = 0; i < 4; i++)
- if (hd_table[i])
- hd_table[i]->private = &d->dev;
-
register_savevm("ide", 0, 2, pci_ide_save, pci_ide_load, d);
}
-/* hd_table must contain 4 block drivers */
-/* NOTE: for the PIIX4, the IRQs and IOports are hardcoded */
-void pci_piix4_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,
- qemu_irq *pic)
+static void pci_piix4_ide_initfn(PCIDevice *dev)
{
- PCIIDEState *d;
+ PCIIDEState *d = DO_UPCAST(PCIIDEState, dev, dev);
uint8_t *pci_conf;
- /* register a function 1 of PIIX4 */
- d = (PCIIDEState *)pci_register_device(bus, "PIIX4 IDE",
- sizeof(PCIIDEState),
- devfn,
- NULL, NULL);
d->type = IDE_TYPE_PIIX4;
pci_conf = d->dev.config;
@@ -3429,13 +3403,69 @@ void pci_piix4_ide_init(PCIBus *bus, BlockDriverState
**hd_table, int devfn,
pci_register_bar((PCIDevice *)d, 4, 0x10,
PCI_ADDRESS_SPACE_IO, bmdma_map);
+ register_savevm("ide", 0, 2, pci_ide_save, pci_ide_load, d);
+}
+
+/* hd_table must contain 4 block drivers */
+/* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */
+void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,
+ qemu_irq *pic)
+{
+ PCIDevice *dev;
+ PCIIDEState *d;
+ int i;
+
+ dev = pci_create_simple(bus, devfn, "PIIX3 IDE");
+ d = DO_UPCAST(PCIIDEState, dev, dev);
+
+ /* TODO: ide bus */
ide_init2(&d->ide_if[0], hd_table[0], hd_table[1], pic[14]);
ide_init2(&d->ide_if[2], hd_table[2], hd_table[3], pic[15]);
ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6);
ide_init_ioport(&d->ide_if[2], 0x170, 0x376);
- register_savevm("ide", 0, 2, pci_ide_save, pci_ide_load, d);
+ for (i = 0; i < 4; i++)
+ if (hd_table[i])
+ hd_table[i]->private = &d->dev;
+}
+
+/* hd_table must contain 4 block drivers */
+/* NOTE: for the PIIX4, the IRQs and IOports are hardcoded */
+void pci_piix4_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,
+ qemu_irq *pic)
+{
+ PCIDevice *dev;
+ PCIIDEState *d;
+
+ dev = pci_create_simple(bus, devfn, "PIIX4 IDE");
+ d = DO_UPCAST(PCIIDEState, dev, dev);
+
+ /* TODO: ide bus */
+ ide_init2(&d->ide_if[0], hd_table[0], hd_table[1], pic[14]);
+ ide_init2(&d->ide_if[2], hd_table[2], hd_table[3], pic[15]);
+ ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6);
+ ide_init_ioport(&d->ide_if[2], 0x170, 0x376);
+}
+
+static PCIDeviceInfo piix_ide_info[] = {
+ {
+ .qdev.name = "PIIX3 IDE",
+ .qdev.size = sizeof(PCIIDEState),
+ .init = pci_piix3_ide_initfn,
+ },{
+ .qdev.name = "PIIX4 IDE",
+ .qdev.size = sizeof(PCIIDEState),
+ .init = pci_piix4_ide_initfn,
+ },{
+ /* end of list */
+ }
+};
+
+static void piix_ide_register(void)
+{
+ pci_qdev_register_many(piix_ide_info);
}
+device_init(piix_ide_register);
#if defined(TARGET_PPC)
/***********************************************************/
--
1.6.2.5
- [Qemu-devel] [PATCH 0/20] qdev patches., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 03/20] qdev: remove DeviceType, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 05/20] qdev/core: add monitor command to list all drivers, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 04/20] qdev/core: bus list, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 01/20] qdev: update pci device registration., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 06/20] qdev/pci: misc fixes., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 02/20] qdev: replace bus_type enum with bus_info struct., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 09/20] qdev: convert piix acpi., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 08/20] qdev: convert piix-ide.,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 07/20] qdev/pci: hook up i440fx., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 11/20] qdev: convert es1370., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 12/20] qdev: convert ac97., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 17/20] qdev: convert ohci., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 16/20] qdev/usb: print usb dev info, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 10/20] qdev: convert all vga, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 13/20] qdev: convert uhci., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 15/20] qdev/usb: make qemu aware of usb busses., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 14/20] qdev/usb: add usb bus support to qdev, convert drivers., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 19/20] debug/test patch: add ohci controller to pc, Gerd Hoffmann, 2009/06/29