Patchwork fdc: fix media change detection for windows

login
register
mail settings
Submitter Pavel Hrdina
Date June 5, 2012, 1:48 p.m.
Message ID <9349989e1c2f12d5d6bc00089efdb7947fdf8dac.1338903679.git.phrdina@redhat.com>
Download mbox | patch
Permalink /patch/163085/
State New
Headers show

Comments

Pavel Hrdina - June 5, 2012, 1:48 p.m.
The windows uses 'READ' command at the start of instalation. We have to
also check the 'media_change' bit in the 'fd_seek'.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 hw/fdc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Kevin Wolf - June 5, 2012, 2:02 p.m.
Am 05.06.2012 15:48, schrieb Pavel Hrdina:
> The windows uses 'READ' command at the start of instalation. We have to
> also check the 'media_change' bit in the 'fd_seek'.
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

Can you explain the scenario in more detail? What is Windows trying and
why should it fail? What is happening today?

> ---
>  hw/fdc.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/fdc.c b/hw/fdc.c
> index 30d34e3..70b0c00 100644
> --- a/hw/fdc.c
> +++ b/hw/fdc.c
> @@ -128,7 +128,8 @@ static int fd_seek(FDrive *drv, uint8_t head, uint8_t track, uint8_t sect,
>      int ret;
>  
>      if (track > drv->max_track ||
> -        (head != 0 && (drv->flags & FDISK_DBL_SIDES) == 0)) {
> +        (head != 0 && (drv->flags & FDISK_DBL_SIDES) == 0) ||
> +        drv->media_changed) {
>          FLOPPY_DPRINTF("try to read %d %02x %02x (max=%d %d %02x %02x)\n",
>                         head, track, sect, 1,
>                         (drv->flags & FDISK_DBL_SIDES) == 0 ? 0 : 1,


Context: Next thing in the code is an error return.

This looks wrong to me. drv->media_changed is also true when a new
floppy has been inserted, but there was no step pulse yet. Is there any
reason why an fd_seek() should fail when a floppy is present?

Last, but not least: Any floppy fixes should come with qtest cases.

Kevin
Pavel Hrdina - June 5, 2012, 2:30 p.m.
On 06/05/2012 04:02 PM, Kevin Wolf wrote:
> Am 05.06.2012 15:48, schrieb Pavel Hrdina:
>> The windows uses 'READ' command at the start of instalation. We have to
>> also check the 'media_change' bit in the 'fd_seek'.
>>
>> Signed-off-by: Pavel Hrdina<phrdina@redhat.com>
> Can you explain the scenario in more detail? What is Windows trying and
> why should it fail? What is happening today?
>
Windows sends these command at the start of installation in this order: 
RECALIBRATE, SENSE INTERRUPT STATUS, READ. Windows completely ignores 
the 'dir' register and reads data from no media and then stuck.
This happens if you start windows installation with floppy drive without 
media.
>> ---
>>   hw/fdc.c |    3 ++-
>>   1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/hw/fdc.c b/hw/fdc.c
>> index 30d34e3..70b0c00 100644
>> --- a/hw/fdc.c
>> +++ b/hw/fdc.c
>> @@ -128,7 +128,8 @@ static int fd_seek(FDrive *drv, uint8_t head, uint8_t track, uint8_t sect,
>>       int ret;
>>
>>       if (track>  drv->max_track ||
>> -        (head != 0&&  (drv->flags&  FDISK_DBL_SIDES) == 0)) {
>> +        (head != 0&&  (drv->flags&  FDISK_DBL_SIDES) == 0) ||
>> +        drv->media_changed) {
>>           FLOPPY_DPRINTF("try to read %d %02x %02x (max=%d %d %02x %02x)\n",
>>                          head, track, sect, 1,
>>                          (drv->flags&  FDISK_DBL_SIDES) == 0 ? 0 : 1,
>
> Context: Next thing in the code is an error return.
>
> This looks wrong to me. drv->media_changed is also true when a new
> floppy has been inserted, but there was no step pulse yet. Is there any
> reason why an fd_seek() should fail when a floppy is present?
>
> Last, but not least: Any floppy fixes should come with qtest cases.
>
> Kevin
Well, you're right. I should change the code a little bit.

Pavel

Patch

diff --git a/hw/fdc.c b/hw/fdc.c
index 30d34e3..70b0c00 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -128,7 +128,8 @@  static int fd_seek(FDrive *drv, uint8_t head, uint8_t track, uint8_t sect,
     int ret;
 
     if (track > drv->max_track ||
-        (head != 0 && (drv->flags & FDISK_DBL_SIDES) == 0)) {
+        (head != 0 && (drv->flags & FDISK_DBL_SIDES) == 0) ||
+        drv->media_changed) {
         FLOPPY_DPRINTF("try to read %d %02x %02x (max=%d %d %02x %02x)\n",
                        head, track, sect, 1,
                        (drv->flags & FDISK_DBL_SIDES) == 0 ? 0 : 1,