summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2016-01-22 15:51:00 -0500
committerJohn Snow <jsnow@redhat.com>2016-01-25 14:35:23 -0500
commita73275dd6fc3bfda33165bebc28e0c33c20cb0a0 (patch)
treeb6d6be59b5ac31e96766fab4aaf4faaa597e33a7 /hw
parentd5d47efc856c139ec0cd1887e2d018ff9a93c32d (diff)
downloadqemu-a73275dd6fc3bfda33165bebc28e0c33c20cb0a0.zip
fdc: Add fallback option
Currently, QEMU chooses a drive type automatically based on the inserted media. If there is no disk inserted, it chooses a 1.44MB drive type. Change this behavior to be configurable, but leave it defaulted to 1.44. This is not earnestly intended to be used by a user or a management library, but rather exists so that pre-2.6 board types can configure it to be a legacy value. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1453495865-9649-8-git-send-email-jsnow@redhat.com
Diffstat (limited to 'hw')
-rw-r--r--hw/block/fdc.c25
-rw-r--r--hw/core/qdev-properties.c11
2 files changed, 34 insertions, 2 deletions
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index f8e070e81f..4caed9bcd5 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -154,6 +154,9 @@ typedef struct FDrive {
bool media_validated; /* Have we validated the media? */
} FDrive;
+
+static FloppyDriveType get_fallback_drive_type(FDrive *drv);
+
static void fd_init(FDrive *drv)
{
/* Drive */
@@ -314,8 +317,7 @@ static void pick_drive_type(FDrive *drv)
if (pick_geometry(drv) == 0) {
drv->drive = drv->disk;
} else {
- /* Legacy behavior: default to 1.44MB floppy */
- drv->drive = FLOPPY_DRIVE_TYPE_144;
+ drv->drive = get_fallback_drive_type(drv);
}
}
@@ -598,11 +600,17 @@ struct FDCtrl {
FDrive drives[MAX_FD];
int reset_sensei;
uint32_t check_media_rate;
+ FloppyDriveType fallback; /* type=auto failure fallback */
/* Timers state */
uint8_t timer0;
uint8_t timer1;
};
+static FloppyDriveType get_fallback_drive_type(FDrive *drv)
+{
+ return drv->fdctrl->fallback;
+}
+
#define TYPE_SYSBUS_FDC "base-sysbus-fdc"
#define SYSBUS_FDC(obj) OBJECT_CHECK(FDCtrlSysBus, (obj), TYPE_SYSBUS_FDC)
@@ -2338,6 +2346,10 @@ static void fdctrl_realize_common(FDCtrl *fdctrl, Error **errp)
int i, j;
static int command_tables_inited = 0;
+ if (fdctrl->fallback == FLOPPY_DRIVE_TYPE_AUTO) {
+ error_setg(errp, "Cannot choose a fallback FDrive type of 'auto'");
+ }
+
/* Fill 'command_to_handler' lookup table */
if (!command_tables_inited) {
command_tables_inited = 1;
@@ -2463,6 +2475,9 @@ static Property isa_fdc_properties[] = {
DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.drives[1].blk),
DEFINE_PROP_BIT("check_media_rate", FDCtrlISABus, state.check_media_rate,
0, true),
+ DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback,
+ FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type,
+ FloppyDriveType),
DEFINE_PROP_END_OF_LIST(),
};
@@ -2511,6 +2526,9 @@ static const VMStateDescription vmstate_sysbus_fdc ={
static Property sysbus_fdc_properties[] = {
DEFINE_PROP_DRIVE("driveA", FDCtrlSysBus, state.drives[0].blk),
DEFINE_PROP_DRIVE("driveB", FDCtrlSysBus, state.drives[1].blk),
+ DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback,
+ FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type,
+ FloppyDriveType),
DEFINE_PROP_END_OF_LIST(),
};
@@ -2531,6 +2549,9 @@ static const TypeInfo sysbus_fdc_info = {
static Property sun4m_fdc_properties[] = {
DEFINE_PROP_DRIVE("drive", FDCtrlSysBus, state.drives[0].blk),
+ DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback,
+ FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type,
+ FloppyDriveType),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 3572810b42..aacad669e3 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -541,6 +541,17 @@ PropertyInfo qdev_prop_bios_chs_trans = {
.set = set_enum,
};
+/* --- FDC default drive types */
+
+PropertyInfo qdev_prop_fdc_drive_type = {
+ .name = "FdcDriveType",
+ .description = "FDC drive type, "
+ "144/288/120/none/auto",
+ .enum_table = FloppyDriveType_lookup,
+ .get = get_enum,
+ .set = set_enum
+};
+
/* --- pci address --- */
/*