From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpFbj-0002WR-2w for qemu-devel@nongnu.org; Mon, 23 Jan 2012 03:50:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RpFbd-0006UC-3X for qemu-devel@nongnu.org; Mon, 23 Jan 2012 03:50:30 -0500 Received: from smtp1-g21.free.fr ([212.27.42.1]:44310) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpFbc-0006Tz-A6 for qemu-devel@nongnu.org; Mon, 23 Jan 2012 03:50:25 -0500 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Mon, 23 Jan 2012 09:50:35 +0100 Message-Id: <1327308641-14736-5-git-send-email-hpoussin@reactos.org> In-Reply-To: <1327308641-14736-1-git-send-email-hpoussin@reactos.org> References: <1327308641-14736-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 v3 4/9] fdc: handle read-only floppies (abort early on write commands) 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?= A real floppy doesn't attempt to write to read-only media either. Signed-off-by: Herv=C3=A9 Poussineau --- hw/fdc.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/hw/fdc.c b/hw/fdc.c index bedaeca..4a363bd 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -300,6 +300,7 @@ enum { }; =20 enum { + FD_SR1_NW =3D 0x02, /* Not writable */ FD_SR1_EC =3D 0x80, /* End of cylinder */ }; =20 @@ -1179,6 +1180,16 @@ static int fdctrl_transfer_handler (void *opaque, = int nchan, break; case FD_DIR_WRITE: /* WRITE commands */ + if (cur_drv->ro) { + /* Handle readonly medium early, no need to do DMA, touc= h the + * LED or attempt any writes. A real floppy doesn't atte= mpt + * to write to readonly media either. */ + fdctrl_stop_transfer(fdctrl, + FD_SR0_ABNTERM | FD_SR0_SEEK, FD_SR= 1_NW, + 0x00); + goto transfer_error; + } + DMA_read_memory (nchan, fdctrl->fifo + rel_pos, fdctrl->data_pos, len); if (bdrv_write(cur_drv->bs, fd_sector(cur_drv), --=20 1.7.7.3