From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SQj18-0003VR-2V for qemu-devel@nongnu.org; Sat, 05 May 2012 13:43:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SQj15-0003YW-Uh for qemu-devel@nongnu.org; Sat, 05 May 2012 13:43:37 -0400 Received: from smtp1-g21.free.fr ([212.27.42.1]:58375) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SQj15-0003Kp-C4 for qemu-devel@nongnu.org; Sat, 05 May 2012 13:43:35 -0400 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sat, 5 May 2012 19:43:28 +0200 Message-Id: <1336239809-3958-1-git-send-email-hpoussin@reactos.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH] fdc: simplify media change handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , =?UTF-8?q?Herv=C3=A9=20Poussineau?= This also (partly) fixes IBM OS/2 Warp 4.0 floppy installation, where not all floppies have the same format (2x80x18 for the first ones, 2x80x23 for the next ones). Signed-off-by: Herv=C3=A9 Poussineau --- This patch fixes a real use case, and I didn't notice any regression. However, as we are in bugfixes-only period, I let Kevin decide if it is worth to include (or not) this patch in QEMU 1.1. hw/fdc.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/hw/fdc.c b/hw/fdc.c index a0236b7..bc0c3f6 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -702,6 +702,15 @@ static void fdctrl_raise_irq(FDCtrl *fdctrl, uint8_t= status0) qemu_set_irq(fdctrl->irq, 1); fdctrl->sra |=3D FD_SRA_INTPEND; } + if (status0 & FD_SR0_SEEK) { + FDrive *cur_drv; + /* A seek clears the disk change line (if a disk is inserted) */ + cur_drv =3D get_cur_drv(fdctrl); + if (cur_drv->max_track) { + cur_drv->media_changed =3D 0; + } + } + fdctrl->reset_sensei =3D 0; fdctrl->status0 =3D status0; FLOPPY_DPRINTF("Set interrupt status to 0x%02x\n", fdctrl->status0); @@ -933,23 +942,7 @@ static void fdctrl_write_ccr(FDCtrl *fdctrl, uint32_= t value) =20 static int fdctrl_media_changed(FDrive *drv) { - int ret; - - if (!drv->bs) - return 0; - if (drv->media_changed) { - drv->media_changed =3D 0; - ret =3D 1; - } else { - ret =3D bdrv_media_changed(drv->bs); - if (ret < 0) { - ret =3D 0; /* we don't know, assume no */ - } - } - if (ret) { - fd_revalidate(drv); - } - return ret; + return drv->media_changed; } =20 /* Digital input register : 0x07 (read-only) */ @@ -1853,6 +1846,7 @@ static void fdctrl_change_cb(void *opaque, bool loa= d) FDrive *drive =3D opaque; =20 drive->media_changed =3D 1; + fd_revalidate(drive); } =20 static const BlockDevOps fdctrl_block_ops =3D { @@ -1883,7 +1877,6 @@ static int fdctrl_connect_drives(FDCtrl *fdctrl) fd_init(drive); fd_revalidate(drive); if (drive->bs) { - drive->media_changed =3D 1; bdrv_set_dev_ops(drive->bs, &fdctrl_block_ops, drive); } } --=20 1.7.9.5