diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2009-09-22 13:53:18 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-10-05 09:32:49 -0500 |
commit | fd8014e132f7ce794cc7c913b583c7b2d0f747af (patch) | |
tree | 0b8f1e7dd34ddae1dd699c04e85ace7ded1b11a0 /hw/fdc.c | |
parent | ef80b466230021da9fe490175cd542a58dcabe94 (diff) | |
download | qemu-fd8014e132f7ce794cc7c913b583c7b2d0f747af.zip qemu-fd8014e132f7ce794cc7c913b583c7b2d0f747af.tar.gz qemu-fd8014e132f7ce794cc7c913b583c7b2d0f747af.tar.bz2 |
floppy: add drive properties.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/fdc.c')
-rw-r--r-- | hw/fdc.c | 50 |
1 files changed, 37 insertions, 13 deletions
@@ -81,6 +81,7 @@ typedef enum fdisk_flags_t { } fdisk_flags_t; typedef struct fdrive_t { + DriveInfo *dinfo; BlockDriverState *bs; /* Drive status */ fdrive_type_t drive; @@ -97,10 +98,10 @@ typedef struct fdrive_t { uint8_t ro; /* Is read-only */ } fdrive_t; -static void fd_init (fdrive_t *drv, BlockDriverState *bs) +static void fd_init (fdrive_t *drv) { /* Drive */ - drv->bs = bs; + drv->bs = drv->dinfo ? drv->dinfo->bdrv : NULL; drv->drive = FDRIVE_DRV_NONE; drv->perpendicular = 0; /* Disk */ @@ -1829,43 +1830,50 @@ static void fdctrl_result_timer(void *opaque) } /* Init functions */ -static void fdctrl_connect_drives(fdctrl_t *fdctrl, BlockDriverState **fds) +static void fdctrl_connect_drives(fdctrl_t *fdctrl) { unsigned int i; for (i = 0; i < MAX_FD; i++) { - fd_init(&fdctrl->drives[i], fds[i]); + fd_init(&fdctrl->drives[i]); fd_revalidate(&fdctrl->drives[i]); } } -fdctrl_t *fdctrl_init_isa(BlockDriverState **fds) +fdctrl_t *fdctrl_init_isa(DriveInfo **fds) { fdctrl_t *fdctrl; ISADevice *dev; int dma_chann = 2; - dev = isa_create_simple("isa-fdc"); + dev = isa_create("isa-fdc"); + qdev_prop_set_drive(&dev->qdev, "driveA", fds[0]); + qdev_prop_set_drive(&dev->qdev, "driveB", fds[1]); + if (qdev_init(&dev->qdev) != 0) + return NULL; fdctrl = &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state); fdctrl->dma_chann = dma_chann; DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl); - fdctrl_connect_drives(fdctrl, fds); + fdctrl_connect_drives(fdctrl); return fdctrl; } fdctrl_t *fdctrl_init_sysbus(qemu_irq irq, int dma_chann, target_phys_addr_t mmio_base, - BlockDriverState **fds) + DriveInfo **fds) { fdctrl_t *fdctrl; DeviceState *dev; fdctrl_sysbus_t *sys; dev = qdev_create(NULL, "sysbus-fdc"); - qdev_init(dev); + qdev_prop_set_drive(dev, "driveA", fds[0]); + qdev_prop_set_drive(dev, "driveB", fds[1]); + if (qdev_init(dev) != 0) + return NULL; sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev); fdctrl = &sys->state; sysbus_connect_irq(&sys->busdev, 0, irq); @@ -1873,20 +1881,22 @@ fdctrl_t *fdctrl_init_sysbus(qemu_irq irq, int dma_chann, fdctrl->dma_chann = dma_chann; DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl); - fdctrl_connect_drives(fdctrl, fds); + fdctrl_connect_drives(fdctrl); return fdctrl; } fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base, - BlockDriverState **fds, qemu_irq *fdc_tc) + DriveInfo **fds, qemu_irq *fdc_tc) { DeviceState *dev; fdctrl_sysbus_t *sys; fdctrl_t *fdctrl; dev = qdev_create(NULL, "SUNW,fdtwo"); - qdev_init(dev); + qdev_prop_set_drive(dev, "drive", fds[0]); + if (qdev_init(dev) != 0) + return NULL; sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev); fdctrl = &sys->state; sysbus_connect_irq(&sys->busdev, 0, irq); @@ -1895,7 +1905,7 @@ fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base, fdctrl->dma_chann = -1; - fdctrl_connect_drives(fdctrl, fds); + fdctrl_connect_drives(fdctrl); return fdctrl; } @@ -1985,18 +1995,32 @@ static ISADeviceInfo isa_fdc_info = { .init = isabus_fdc_init1, .qdev.name = "isa-fdc", .qdev.size = sizeof(fdctrl_isabus_t), + .qdev.props = (Property[]) { + DEFINE_PROP_DRIVE("driveA", fdctrl_isabus_t, state.drives[0].dinfo), + DEFINE_PROP_DRIVE("driveB", fdctrl_isabus_t, state.drives[1].dinfo), + DEFINE_PROP_END_OF_LIST(), + }, }; static SysBusDeviceInfo sysbus_fdc_info = { .init = sysbus_fdc_init1, .qdev.name = "sysbus-fdc", .qdev.size = sizeof(fdctrl_sysbus_t), + .qdev.props = (Property[]) { + DEFINE_PROP_DRIVE("driveA", fdctrl_sysbus_t, state.drives[0].dinfo), + DEFINE_PROP_DRIVE("driveB", fdctrl_sysbus_t, state.drives[1].dinfo), + DEFINE_PROP_END_OF_LIST(), + }, }; static SysBusDeviceInfo sun4m_fdc_info = { .init = sun4m_fdc_init1, .qdev.name = "SUNW,fdtwo", .qdev.size = sizeof(fdctrl_sysbus_t), + .qdev.props = (Property[]) { + DEFINE_PROP_DRIVE("drive", fdctrl_sysbus_t, state.drives[0].dinfo), + DEFINE_PROP_END_OF_LIST(), + }, }; static void fdc_register_devices(void) |