From c295b1cbbb7047229d67fc4e707f199ce6cd7435 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: <5b3bcf18e866636f24ca1c23eb94d5caf23c6dd6.1343915404.git.minovotn@redhat.com> References: <5b3bcf18e866636f24ca1c23eb94d5caf23c6dd6.1343915404.git.minovotn@redhat.com> From: Pavel Hrdina Date: Mon, 16 Jul 2012 16:14:51 +0200 Subject: [PATCH 2/7] fdc: simplify media change handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Pavel Hrdina Message-id: <0168a8a467bb994244e8f2a8a4743943328024bd.1342446805.git.phrdina@redhat.com> Patchwork-id: 40338 O-Subject: [RHEL-6.4 qemu-kvm PATCH v6 2/6] fdc: simplify media change handling Bugzilla: 729244 RH-Acked-by: Laszlo Ersek RH-Acked-by: Miroslav Rezanina RH-Acked-by: Michal Novotny From: Hervé Poussineau 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é Poussineau Signed-off-by: Kevin Wolf (cherry picked from commit 21fcf36095939a97fc3df578e12821c3e6c3ba78) Signed-off-by: Pavel Hrdina --- hw/fdc.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) Signed-off-by: Michal Novotny --- hw/fdc.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/hw/fdc.c b/hw/fdc.c index c978a19..0858b76 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -783,6 +783,15 @@ static void fdctrl_raise_irq (fdctrl_t *fdctrl, uint8_t status0) qemu_set_irq(fdctrl->irq, 1); fdctrl->sra |= FD_SRA_INTPEND; } + if (status0 & FD_SR0_SEEK) { + fdrive_t *cur_drv; + /* A seek clears the disk change line (if a disk is inserted) */ + cur_drv = get_cur_drv(fdctrl); + if (cur_drv->max_track) { + cur_drv->media_changed = 0; + } + } + fdctrl->reset_sensei = 0; fdctrl->status0 = status0; FLOPPY_DPRINTF("Set interrupt status to 0x%02x\n", fdctrl->status0); @@ -997,23 +1006,7 @@ static void fdctrl_write_rate (fdctrl_t *fdctrl, uint32_t value) static int fdctrl_media_changed(fdrive_t *drv) { - int ret; - - if (!drv->bs) - return 0; - if (drv->media_changed) { - drv->media_changed = 0; - ret = 1; - } else { - ret = bdrv_media_changed(drv->bs); - if (ret < 0) { - ret = 0; /* we don't know, assume no */ - } - } - if (ret) { - fd_revalidate(drv); - } - return ret; + return drv->media_changed; } /* Digital input register : 0x07 (read-only) */ @@ -1881,6 +1874,7 @@ static void fdctrl_change_cb(void *opaque, bool load) fdrive_t *drive = opaque; drive->media_changed = 1; + fd_revalidate(drive); } static const BlockDevOps fdctrl_block_ops = { @@ -1899,7 +1893,6 @@ static void fdctrl_connect_drives(fdctrl_t *fdctrl) fd_init(drive); fd_revalidate(drive); if (drive->bs) { - drive->media_changed = 1; bdrv_set_dev_ops(drive->bs, &fdctrl_block_ops, drive); } } -- 1.7.10.4