[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/5] floppy: add drive properties.
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 1/5] floppy: add drive properties. |
Date: |
Wed, 16 Sep 2009 22:25:40 +0200 |
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/fdc.c | 50 +++++++++++++++++++++++++++++++++++++-------------
hw/fdc.h | 7 ++++---
hw/mips_jazz.c | 5 ++---
hw/mips_malta.c | 5 ++---
hw/pc.c | 6 ++----
hw/ppc_prep.c | 6 ++----
hw/sun4m.c | 16 ++++------------
hw/sun4u.c | 6 ++----
8 files changed, 55 insertions(+), 46 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index 389d9e6..ea3b8ac 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -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)
diff --git a/hw/fdc.h b/hw/fdc.h
index 1b81ec1..c64e8b4 100644
--- a/hw/fdc.h
+++ b/hw/fdc.h
@@ -1,12 +1,13 @@
/* fdc.c */
+#include "sysemu.h"
#define MAX_FD 2
typedef struct fdctrl_t fdctrl_t;
-fdctrl_t *fdctrl_init_isa(BlockDriverState **fds);
+fdctrl_t *fdctrl_init_isa(DriveInfo **fds);
fdctrl_t *fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
target_phys_addr_t mmio_base,
- BlockDriverState **fds);
+ DriveInfo **fds);
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);
int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index d62a584..ace551b 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -127,7 +127,7 @@ void mips_jazz_init (ram_addr_t ram_size,
int s_rtc, s_dma_dummy;
NICInfo *nd;
PITState *pit;
- BlockDriverState *fds[MAX_FD];
+ DriveInfo *fds[MAX_FD];
qemu_irq esp_reset;
ram_addr_t ram_offset;
ram_addr_t bios_offset;
@@ -235,8 +235,7 @@ void mips_jazz_init (ram_addr_t ram_size,
exit(1);
}
for (n = 0; n < MAX_FD; n++) {
- DriveInfo *dinfo = drive_get(IF_FLOPPY, 0, n);
- fds[n] = dinfo ? dinfo->bdrv : NULL;
+ fds[n] = drive_get(IF_FLOPPY, 0, n);
}
fdctrl_init_sysbus(rc4030[1], 0, 0x80003000, fds);
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 0a6eaa4..260f266 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -777,7 +777,7 @@ void mips_malta_init (ram_addr_t ram_size,
int i;
DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
- BlockDriverState *fd[MAX_FD];
+ DriveInfo *fd[MAX_FD];
int fl_idx = 0;
int fl_sectors = 0;
@@ -938,8 +938,7 @@ void mips_malta_init (ram_addr_t ram_size,
if (parallel_hds[0])
parallel_init(0x378, isa_reserve_irq(7), parallel_hds[0]);
for(i = 0; i < MAX_FD; i++) {
- dinfo = drive_get(IF_FLOPPY, 0, i);
- fd[i] = dinfo ? dinfo->bdrv : NULL;
+ fd[i] = drive_get(IF_FLOPPY, 0, i);
}
floppy_controller = fdctrl_init_isa(fd);
diff --git a/hw/pc.c b/hw/pc.c
index 58de372..8865ec0 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1130,9 +1130,8 @@ static void pc_init1(ram_addr_t ram_size,
qemu_irq *isa_irq;
qemu_irq *i8259;
IsaIrqState *isa_irq_state;
- DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
- BlockDriverState *fd[MAX_FD];
+ DriveInfo *fd[MAX_FD];
int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled;
void *fw_cfg;
@@ -1378,8 +1377,7 @@ static void pc_init1(ram_addr_t ram_size,
#endif
for(i = 0; i < MAX_FD; i++) {
- dinfo = drive_get(IF_FLOPPY, 0, i);
- fd[i] = dinfo ? dinfo->bdrv : NULL;
+ fd[i] = drive_get(IF_FLOPPY, 0, i);
}
floppy_controller = fdctrl_init_isa(fd);
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 5392072..32f987c 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -562,9 +562,8 @@ static void ppc_prep_init (ram_addr_t ram_size,
PCIBus *pci_bus;
qemu_irq *i8259;
int ppc_boot_device;
- DriveInfo *dinfo;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
- BlockDriverState *fd[MAX_FD];
+ DriveInfo *fd[MAX_FD];
sysctrl = qemu_mallocz(sizeof(sysctrl_t));
@@ -719,8 +718,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
// SB16_init();
for(i = 0; i < MAX_FD; i++) {
- dinfo = drive_get(IF_FLOPPY, 0, i);
- fd[i] = dinfo ? dinfo->bdrv : NULL;
+ fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(fd);
diff --git a/hw/sun4m.c b/hw/sun4m.c
index d970723..6d5d4e8 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -747,9 +747,8 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
ram_addr_t RAM_size,
qemu_irq fdc_tc;
qemu_irq *cpu_halt;
unsigned long kernel_size;
- BlockDriverState *fd[MAX_FD];
+ DriveInfo *fd[MAX_FD];
void *fw_cfg;
- DriveInfo *dinfo;
/* init CPUs */
if (!cpu_model)
@@ -823,10 +822,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
ram_addr_t RAM_size,
if (hwdef->fd_base) {
/* there is zero or one floppy drive */
memset(fd, 0, sizeof(fd));
- dinfo = drive_get(IF_FLOPPY, 0, 0);
- if (dinfo)
- fd[0] = dinfo->bdrv;
-
+ fd[0] = drive_get(IF_FLOPPY, 0, 0);
sun4m_fdctrl_init(slavio_irq[22], hwdef->fd_base, fd,
&fdc_tc);
}
@@ -1551,11 +1547,10 @@ static void sun4c_hw_init(const struct sun4c_hwdef
*hwdef, ram_addr_t RAM_size,
qemu_irq esp_reset;
qemu_irq fdc_tc;
unsigned long kernel_size;
- BlockDriverState *fd[MAX_FD];
+ DriveInfo *fd[MAX_FD];
void *fw_cfg;
DeviceState *dev;
unsigned int i;
- DriveInfo *dinfo;
/* init CPU */
if (!cpu_model)
@@ -1607,10 +1602,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef
*hwdef, ram_addr_t RAM_size,
if (hwdef->fd_base != (target_phys_addr_t)-1) {
/* there is zero or one floppy drive */
memset(fd, 0, sizeof(fd));
- dinfo = drive_get(IF_FLOPPY, 0, 0);
- if (dinfo)
- fd[0] = dinfo->bdrv;
-
+ fd[0] = drive_get(IF_FLOPPY, 0, 0);
sun4m_fdctrl_init(slavio_irq[1], hwdef->fd_base, fd,
&fdc_tc);
}
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 427ee76..81ddf48 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -561,9 +561,8 @@ static void sun4uv_init(ram_addr_t RAM_size,
PCIBus *pci_bus, *pci_bus2, *pci_bus3;
qemu_irq *irq;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
- BlockDriverState *fd[MAX_FD];
+ DriveInfo *fd[MAX_FD];
void *fw_cfg;
- DriveInfo *dinfo;
/* init CPUs */
env = cpu_devinit(cpu_model, hwdef);
@@ -619,8 +618,7 @@ static void sun4uv_init(ram_addr_t RAM_size,
isa_create_simple("i8042");
for(i = 0; i < MAX_FD; i++) {
- dinfo = drive_get(IF_FLOPPY, 0, i);
- fd[i] = dinfo ? dinfo->bdrv : NULL;
+ fd[i] = drive_get(IF_FLOPPY, 0, i);
}
fdctrl_init_isa(fd);
nvram = m48t59_init_isa(0x0074, NVRAM_SIZE, 59);
--
1.6.2.5
- [Qemu-devel] [PATCH 0/5] isa: more qdev conversions., Gerd Hoffmann, 2009/09/16
- [Qemu-devel] [PATCH 3/5] qdev: don't crash on unset drive properties., Gerd Hoffmann, 2009/09/16
- [Qemu-devel] [PATCH 2/5] floppy: move dma setup + drive connect to fdctrl_init_common(), Gerd Hoffmann, 2009/09/16
- [Qemu-devel] [PATCH 4/5] serial: convert isa to qdev, Gerd Hoffmann, 2009/09/16
- [Qemu-devel] [PATCH 1/5] floppy: add drive properties.,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 5/5] parallel: convert isa to qdev, Gerd Hoffmann, 2009/09/16
- Re: [Qemu-devel] [PATCH 0/5] isa: more qdev conversions., Markus Armbruster, 2009/09/18