[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 08/13] fdc: Add fallback option
From: |
John Snow |
Subject: |
[Qemu-devel] [PULL 08/13] fdc: Add fallback option |
Date: |
Mon, 25 Jan 2016 14:41:20 -0500 |
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 <address@hidden>
Signed-off-by: John Snow <address@hidden>
Message-id: address@hidden
---
hw/block/fdc.c | 25 +++++++++++++++++++++++--
hw/core/qdev-properties.c | 11 +++++++++++
include/hw/qdev-properties.h | 1 +
3 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index f8e070e..4caed9b 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 3572810..aacad66 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 --- */
/*
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 254afd8..03a1b91 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -20,6 +20,7 @@ extern PropertyInfo qdev_prop_ptr;
extern PropertyInfo qdev_prop_macaddr;
extern PropertyInfo qdev_prop_losttickpolicy;
extern PropertyInfo qdev_prop_bios_chs_trans;
+extern PropertyInfo qdev_prop_fdc_drive_type;
extern PropertyInfo qdev_prop_drive;
extern PropertyInfo qdev_prop_netdev;
extern PropertyInfo qdev_prop_vlan;
--
2.4.3
- [Qemu-devel] [PULL 02/13] fdc: move pick_geometry, (continued)
- [Qemu-devel] [PULL 02/13] fdc: move pick_geometry, John Snow, 2016/01/25
- [Qemu-devel] [PULL 03/13] fdc: reduce number of pick_geometry arguments, John Snow, 2016/01/25
- [Qemu-devel] [PULL 12/13] qtest/fdc: Support for 2.88MB drives, John Snow, 2016/01/25
- [Qemu-devel] [PULL 01/13] ide: Correct the CHS 'cyls_max' limit to be 65535, John Snow, 2016/01/25
- [Qemu-devel] [PULL 13/13] fdc: change auto fallback drive for ISA FDC to 288, John Snow, 2016/01/25
- [Qemu-devel] [PULL 06/13] fdc: Throw an assertion on misconfigured fd_formats table, John Snow, 2016/01/25
- [Qemu-devel] [PULL 07/13] fdc: add pick_drive, John Snow, 2016/01/25
- [Qemu-devel] [PULL 10/13] fdc: add physical disk sizes, John Snow, 2016/01/25
- [Qemu-devel] [PULL 11/13] fdc: rework pick_geometry, John Snow, 2016/01/25
- [Qemu-devel] [PULL 08/13] fdc: Add fallback option,
John Snow <=
- [Qemu-devel] [PULL 05/13] fdc: add disk field, John Snow, 2016/01/25
- [Qemu-devel] [PULL 09/13] fdc: add drive type option, John Snow, 2016/01/25
- [Qemu-devel] [PULL 04/13] fdc: add drive type qapi enum, John Snow, 2016/01/25
- Re: [Qemu-devel] [PULL 00/13] IDE & FDC patches, Peter Maydell, 2016/01/26