Introduce a helper function which initialize ahci port with ide device It will be used by q35 support later.
Cc: Alexander Graf <ag...@suse.de> Signed-off-by: Isaku Yamahata <yamah...@valinux.co.jp> --- hw/ide.h | 3 +++ hw/ide/ahci.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/hw/ide.h b/hw/ide.h index 73fb550..e90f557 100644 --- a/hw/ide.h +++ b/hw/ide.h @@ -28,4 +28,7 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2, void ide_get_bs(BlockDriverState *bs[], BusState *qbus); +/* ide/ahci.c */ +void pci_ahci_ide_create_devs(PCIDevice *pci_dev, DriveInfo **hd_table); + #endif /* HW_IDE_H */ diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 98bdf70..5597885 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1150,3 +1150,18 @@ void ahci_reset(void *opaque) ahci_reset_port(&d->ahci, i); } } + +void pci_ahci_ide_create_devs(PCIDevice *pci_dev, DriveInfo **hd_table) +{ + struct AHCIPCIState *dev = DO_UPCAST(struct AHCIPCIState, card, pci_dev); + int i; + + for (i = 0; i < dev->ahci.ports; i++) { + /* master device only, ignore slaves */ + if (hd_table[i * MAX_IDE_DEVS] == NULL) { + continue; + } + ide_create_drive(&dev->ahci.dev[i].port, 0, + hd_table[i * MAX_IDE_DEVS]); + } +} -- 1.7.1.1