mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 13:30:52 +00:00
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
This commit is contained in:
parent
d5d47efc85
commit
a73275dd6f
@ -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(),
|
||||
};
|
||||
|
||||
|
@ -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 --- */
|
||||
|
||||
/*
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user