diff options
author | Andreas Färber <afaerber@suse.de> | 2013-01-23 23:04:01 +0000 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2013-01-25 22:02:54 +0100 |
commit | 07a7484e5d713f1eb7c1c37b18a8ab0d56d88875 (patch) | |
tree | 2c768cca41786f5fb08683c48e5066635c9cded6 /hw/ppc | |
parent | 95ed3b7cf1677dc9f995a6e1fcc7bf377cf94a0e (diff) |
ide/macio: QOM'ify MacIO IDE
It was not qdev'ified before. Turn it into a SysBusDevice.
Embed them into the MacIO devices.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'hw/ppc')
-rw-r--r-- | hw/ppc/mac.h | 25 | ||||
-rw-r--r-- | hw/ppc/mac_newworld.c | 28 | ||||
-rw-r--r-- | hw/ppc/mac_oldworld.c | 36 |
3 files changed, 59 insertions, 30 deletions
diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h index 581e95cf7c..3e390d3ee9 100644 --- a/hw/ppc/mac.h +++ b/hw/ppc/mac.h @@ -27,6 +27,7 @@ #include "exec/memory.h" #include "hw/sysbus.h" +#include "hw/ide/internal.h" /* SMP is not enabled, for now */ #define MAX_CPUS 1 @@ -48,10 +49,30 @@ void cuda_init (MemoryRegion **cuda_mem, qemu_irq irq); /* MacIO */ #define TYPE_OLDWORLD_MACIO "macio-oldworld" #define TYPE_NEWWORLD_MACIO "macio-newworld" + +#define TYPE_MACIO_IDE "macio-ide" +#define MACIO_IDE(obj) OBJECT_CHECK(MACIOIDEState, (obj), TYPE_MACIO_IDE) + +typedef struct MACIOIDEState { + /*< private >*/ + SysBusDevice parent_obj; + /*< public >*/ + + qemu_irq irq; + qemu_irq dma_irq; + + MemoryRegion mem; + IDEBus bus; + BlockDriverAIOCB *aiocb; +} MACIOIDEState; + +void macio_ide_init_drives(MACIOIDEState *ide, DriveInfo **hd_table); +void macio_ide_register_dma(MACIOIDEState *ide, void *dbdma, int channel); + void macio_init(PCIDevice *dev, - MemoryRegion *pic_mem, MemoryRegion *dbdma_mem, + MemoryRegion *pic_mem, MemoryRegion *cuda_mem, - int nb_ide, MemoryRegion **ide_mem, MemoryRegion *escc_mem); + MemoryRegion *escc_mem); /* Heathrow PIC */ qemu_irq *heathrow_pic_init(MemoryRegion **pmem, diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index a4b38fba1e..4fd86b042a 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -148,15 +148,14 @@ static void ppc_core99_init(QEMUMachineInitArgs *args) long kernel_size, initrd_size; PCIBus *pci_bus; PCIDevice *macio; + MACIOIDEState *macio_ide; MacIONVRAMState *nvr; int bios_size; - MemoryRegion *pic_mem, *dbdma_mem, *cuda_mem, *escc_mem; + MemoryRegion *pic_mem, *cuda_mem, *escc_mem; MemoryRegion *escc_bar = g_new(MemoryRegion, 1); - MemoryRegion *ide_mem[3]; int ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; - void *dbdma; int machine_arch; SysBusDevice *s; DeviceState *dev; @@ -363,12 +362,6 @@ static void ppc_core99_init(QEMUMachineInitArgs *args) pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); ide_drive_get(hd, MAX_IDE_BUS); - dbdma = DBDMA_init(&dbdma_mem); - - /* We only emulate 2 out of 3 IDE controllers for now */ - ide_mem[0] = NULL; - ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]); - ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, pic[0x02]); cuda_init(&cuda_mem, pic[0x19]); @@ -376,8 +369,21 @@ static void ppc_core99_init(QEMUMachineInitArgs *args) adb_mouse_init(&adb_bus); macio = pci_create(pci_bus, -1, TYPE_NEWWORLD_MACIO); - macio_init(macio, pic_mem, - dbdma_mem, cuda_mem, 3, ide_mem, escc_bar); + dev = DEVICE(macio); + qdev_connect_gpio_out(dev, 0, pic[0x0d]); /* IDE */ + qdev_connect_gpio_out(dev, 1, pic[0x02]); /* IDE DMA */ + qdev_connect_gpio_out(dev, 2, pic[0x0e]); /* IDE */ + qdev_connect_gpio_out(dev, 3, pic[0x02]); /* IDE DMA */ + macio_init(macio, pic_mem, cuda_mem, escc_bar); + + /* We only emulate 2 out of 3 IDE controllers for now */ + macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), + "ide[0]")); + macio_ide_init_drives(macio_ide, hd); + + macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), + "ide[1]")); + macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]); if (usb_enabled(machine_arch == ARCH_MAC99_U3)) { pci_create_simple(pci_bus, -1, "pci-ohci"); diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 29b3277df7..6039ea61f4 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -27,7 +27,6 @@ #include "hw/ppc.h" #include "mac.h" #include "hw/adb.h" -#include "hw/mac_dbdma.h" #include "hw/nvram.h" #include "sysemu/sysemu.h" #include "net/net.h" @@ -91,13 +90,14 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args) int32_t kernel_size, initrd_size; PCIBus *pci_bus; PCIDevice *macio; + MACIOIDEState *macio_ide; + DeviceState *dev; int bios_size; - MemoryRegion *pic_mem, *dbdma_mem, *cuda_mem; - MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1), *ide_mem[2]; + MemoryRegion *pic_mem, *cuda_mem; + MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1); uint16_t ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; - void *dbdma; linux_boot = (kernel_filename != NULL); @@ -263,17 +263,6 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args) ide_drive_get(hd, MAX_IDE_BUS); - /* First IDE channel is a MAC IDE on the MacIO bus */ - dbdma = DBDMA_init(&dbdma_mem); - ide_mem[0] = NULL; - ide_mem[1] = pmac_ide_init(hd, pic[0x0D], dbdma, 0x16, pic[0x02]); - - /* Second IDE channel is a CMD646 on the PCI bus */ - hd[0] = hd[MAX_IDE_DEVS]; - hd[1] = hd[MAX_IDE_DEVS + 1]; - hd[3] = hd[2] = NULL; - pci_cmd646_ide_init(pci_bus, hd, 0); - /* cuda also initialize ADB */ cuda_init(&cuda_mem, pic[0x12]); @@ -281,8 +270,21 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args) adb_mouse_init(&adb_bus); macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO); - macio_init(macio, pic_mem, - dbdma_mem, cuda_mem, 2, ide_mem, escc_bar); + dev = DEVICE(macio); + qdev_connect_gpio_out(dev, 0, pic[0x0D]); /* IDE */ + qdev_connect_gpio_out(dev, 1, pic[0x02]); /* IDE DMA */ + macio_init(macio, pic_mem, cuda_mem, escc_bar); + + /* First IDE channel is a MAC IDE on the MacIO bus */ + macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), + "ide")); + macio_ide_init_drives(macio_ide, hd); + + /* Second IDE channel is a CMD646 on the PCI bus */ + hd[0] = hd[MAX_IDE_DEVS]; + hd[1] = hd[MAX_IDE_DEVS + 1]; + hd[3] = hd[2] = NULL; + pci_cmd646_ide_init(pci_bus, hd, 0); if (usb_enabled(false)) { pci_create_simple(pci_bus, -1, "pci-ohci"); |