From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxK4S-00005M-9B for qemu-devel@nongnu.org; Tue, 14 Feb 2012 10:13:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RxK4F-0004ZU-JI for qemu-devel@nongnu.org; Tue, 14 Feb 2012 10:13:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:2835) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxK4F-0004ZO-Cg for qemu-devel@nongnu.org; Tue, 14 Feb 2012 10:13:19 -0500 Message-ID: <4F3A7ADC.10209@redhat.com> Date: Tue, 14 Feb 2012 16:16:44 +0100 From: Kevin Wolf MIME-Version: 1.0 References: <1328563752-3976-1-git-send-email-hpoussin@reactos.org> <1328563752-3976-10-git-send-email-hpoussin@reactos.org> In-Reply-To: <1328563752-3976-10-git-send-email-hpoussin@reactos.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 09/11] fdc: check if media rate is correct before doing any transfer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?SGVydsOpIFBvdXNzaW5lYXU=?= Cc: Paolo Bonzini , qemu-devel@nongnu.org, Juan Quintela Am 06.02.2012 22:29, schrieb Herv=C3=A9 Poussineau: > The programmed rate has to be the same as the required rate for the > floppy format ; if that's not the case, the transfer should abort. > This check can be disabled by using the 'check_media_rate' property. >=20 > Save media rate value only if media rate check is enabled. >=20 > Signed-off-by: Herv=C3=A9 Poussineau > --- > hw/fdc.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--- > 1 files changed, 50 insertions(+), 3 deletions(-) >=20 > diff --git a/hw/fdc.c b/hw/fdc.c > index af007ae..d2a22fa 100644 > --- a/hw/fdc.c > +++ b/hw/fdc.c > @@ -62,12 +62,15 @@ > #define FD_SECTOR_SC 2 /* Sector size code */ > #define FD_RESET_SENSEI_COUNT 4 /* Number of sense interrupts on RE= SET */ > =20 > +typedef struct FDCtrl FDCtrl; > + > /* Floppy disk drive emulation */ > typedef enum FDiskFlags { > FDISK_DBL_SIDES =3D 0x01, > } FDiskFlags; > =20 > typedef struct FDrive { > + FDCtrl *fdctrl; > BlockDriverState *bs; > /* Drive status */ > FDriveType drive; > @@ -83,6 +86,7 @@ typedef struct FDrive { > uint16_t bps; /* Bytes per sector */ > uint8_t ro; /* Is read-only */ > uint8_t media_changed; /* Is media changed */ > + uint8_t media_rate; /* Data rate of medium */ > } FDrive; > =20 > static void fd_init(FDrive *drv) > @@ -195,6 +199,7 @@ static void fd_revalidate(FDrive *drv) > drv->last_sect =3D last_sect; > drv->ro =3D ro; > drv->drive =3D drive; > + drv->media_rate =3D rate; > } else { > FLOPPY_DPRINTF("No disk in drive\n"); > drv->last_sect =3D 0; > @@ -206,8 +211,6 @@ static void fd_revalidate(FDrive *drv) > /********************************************************/ > /* Intel 82078 floppy disk controller emulation */ > =20 > -typedef struct FDCtrl FDCtrl; > - > static void fdctrl_reset(FDCtrl *fdctrl, int do_irq); > static void fdctrl_reset_fifo(FDCtrl *fdctrl); > static int fdctrl_transfer_handler (void *opaque, int nchan, > @@ -303,6 +306,7 @@ enum { > }; > =20 > enum { > + FD_SR1_MA =3D 0x01, /* Missing address mark */ > FD_SR1_NW =3D 0x02, /* Not writable */ > FD_SR1_EC =3D 0x80, /* End of cylinder */ > }; > @@ -549,6 +553,24 @@ static const VMStateDescription vmstate_fdrive_med= ia_changed =3D { > } > }; > =20 > +static bool fdrive_media_rate_needed(void *opaque) > +{ > + FDrive *drive =3D opaque; > + > + return drive->fdctrl->check_media_rate; > +} > + > +static const VMStateDescription vmstate_fdrive_media_rate =3D { > + .name =3D "fdrive/media_rate", > + .version_id =3D 1, > + .minimum_version_id =3D 1, > + .minimum_version_id_old =3D 1, > + .fields =3D (VMStateField[]) { > + VMSTATE_UINT8(media_rate, FDrive), > + VMSTATE_END_OF_LIST() > + } > +}; Juan, Paolo, this is a subsection in a struct array. Does this work meanwhile or is it still broken? Kevin