From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9KN1-0004Sp-J2 for qemu-devel@nongnu.org; Wed, 16 Dec 2015 17:16:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9KN0-00084X-5i for qemu-devel@nongnu.org; Wed, 16 Dec 2015 17:16:27 -0500 From: John Snow Date: Wed, 16 Dec 2015 17:16:11 -0500 Message-Id: <1450304177-3935-6-git-send-email-jsnow@redhat.com> In-Reply-To: <1450304177-3935-1-git-send-email-jsnow@redhat.com> References: <1450304177-3935-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH v3 05/11] fdc: Add fallback option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, John Snow , armbru@redhat.com, qemu-devel@nongnu.org Add the fallback drive type as an option so we can control the behavior as a function of the QEMU machine version. Signed-off-by: John Snow --- hw/block/fdc.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index ad0e052..b587de8 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -155,6 +155,9 @@ typedef struct FDrive { bool media_inserted; /* Is there a medium in the tray */ } FDrive; + +static FloppyDriveType get_fallback_drive_type(FDrive *drv); + static void fd_init(FDrive *drv) { /* Drive */ @@ -570,8 +573,15 @@ struct FDCtrl { uint8_t timer0; uint8_t timer1; + FloppyDriveType fallback; }; +__attribute__((__unused__)) +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) @@ -2302,6 +2312,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; @@ -2433,6 +2447,9 @@ static Property isa_fdc_properties[] = { DEFINE_PROP_DEFAULT("fdtypeB", FDCtrlISABus, state.drives[1].drive, FDRIVE_DEFAULT, qdev_prop_fdc_drive_type, FloppyDriveType), + DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback, + FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type, + FloppyDriveType), DEFINE_PROP_END_OF_LIST(), }; @@ -2487,6 +2504,9 @@ static Property sysbus_fdc_properties[] = { DEFINE_PROP_DEFAULT("fdtypeB", FDCtrlSysBus, state.drives[1].drive, FDRIVE_DEFAULT, qdev_prop_fdc_drive_type, FloppyDriveType), + DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback, + FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type, + FloppyDriveType), DEFINE_PROP_END_OF_LIST(), }; @@ -2510,6 +2530,9 @@ static Property sun4m_fdc_properties[] = { DEFINE_PROP_DEFAULT("fdtype", FDCtrlSysBus, state.drives[0].drive, FDRIVE_DEFAULT, qdev_prop_fdc_drive_type, FloppyDriveType), + DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback, + FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type, + FloppyDriveType), DEFINE_PROP_END_OF_LIST(), }; -- 2.4.3