qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH][Resend] Floppy: Properly handle Sense Interrupt Status after FDC Reset
@ 2009-01-22 19:46 Justin Chevrier
  2009-01-24 12:10 ` Blue Swirl
  2009-01-26 17:05 ` Anthony Liguori
  0 siblings, 2 replies; 4+ messages in thread
From: Justin Chevrier @ 2009-01-22 19:46 UTC (permalink / raw)
  To: qemu-devel

Original text below.

Attached is a patch that changes how the emulated floppy controller replies to Sense Interrupt Status commands immediately after a controller reset. The specs state that after a Reset the 82078 goes into polling mode which needs four Sense Interrupt Status commands to be issued afterwards to clear the status of each drive. Currently we always respond to Sense Interrupt Status with a SEEK END instead of POLLING. This causes a problem with the SCO Openserver installer which is expects a POLLING state after reset. This patch returns a POLLING status for four Sense Interrupt Status requests immediately after a controller reset. This approach mirrors the way Bochs handles this situation. With the attached patch applied Openserver gets further when trying to load storage drivers from the floppy disk (blocked by another issue, patch on its way). I have successfully tested the floppy drive on the following OSs after applying this patch: Windows 98, Windows XP
SP2, Linux x86 (SysRescCD 1.1.3 and Ubuntu 8.10).

Justin

Changelog:

Properly handle Sense Interrupt Status after FDC Reset

Signed-off-by: Justin Chevrier <theburner1@yahoo.com>

Index: hw/fdc.c
===================================================================
--- hw/fdc.c    (revision 6193)
+++ hw/fdc.c    (working copy)
@@ -53,8 +53,9 @@
#define SET_CUR_DRV(fdctrl, drive) ((fdctrl)->cur_drv = (drive))

/* Will always be a fixed parameter for us */
-#define FD_SECTOR_LEN 512
-#define FD_SECTOR_SC  2   /* Sector size code */
+#define FD_SECTOR_LEN          512
+#define FD_SECTOR_SC           2   /* Sector size code */
+#define FD_RESET_SENSEI_COUNT  4   /* Number of sense interrupts on RESET */

/* Floppy disk drive emulation */
typedef enum fdisk_type_t {
@@ -506,6 +507,7 @@
     int sun4m;
     /* Floppy drives */
     fdrive_t drives[MAX_FD];
+    int reset_sensei;
};

static uint32_t fdctrl_read (void *opaque, uint32_t reg)
@@ -763,6 +765,7 @@
         qemu_set_irq(fdctrl->irq, 1);
         fdctrl->sra |= FD_SRA_INTPEND;
     }
+    fdctrl->reset_sensei = 0;
     fdctrl->status0 = status0;
     FLOPPY_DPRINTF("Set interrupt status to 0x%02x\n", fdctrl->status0);
}
@@ -793,6 +796,7 @@
     fdctrl_reset_fifo(fdctrl);
     if (do_irq) {
         fdctrl_raise_irq(fdctrl, FD_SR0_RDYCHG);
+        fdctrl->reset_sensei = FD_RESET_SENSEI_COUNT;
     }
}

@@ -1601,16 +1605,18 @@
{
     fdrive_t *cur_drv = get_cur_drv(fdctrl);

-#if 0
-    fdctrl->fifo[0] =
-        fdctrl->status0 | (cur_drv->head << 2) | GET_CUR_DRV(fdctrl);
-#else
-    /* XXX: status0 handling is broken for read/write
-       commands, so we do this hack. It should be suppressed
-       ASAP */
-    fdctrl->fifo[0] =
-        FD_SR0_SEEK | (cur_drv->head << 2) | GET_CUR_DRV(fdctrl);
-#endif
+    if(fdctrl->reset_sensei > 0) {
+        fdctrl->fifo[0] =
+            FD_SR0_RDYCHG + FD_RESET_SENSEI_COUNT - fdctrl->reset_sensei;
+        fdctrl->reset_sensei--;
+    } else {
+        /* XXX: status0 handling is broken for read/write
+           commands, so we do this hack. It should be suppressed
+           ASAP */
+        fdctrl->fifo[0] =
+            FD_SR0_SEEK | (cur_drv->head << 2) | GET_CUR_DRV(fdctrl);
+    }
+
     fdctrl->fifo[1] = cur_drv->track;
     fdctrl_set_fifo(fdctrl, 2, 0);
     fdctrl_reset_irq(fdctrl);


      

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH][Resend] Floppy: Properly handle Sense Interrupt Status after FDC Reset
  2009-01-22 19:46 [Qemu-devel] [PATCH][Resend] Floppy: Properly handle Sense Interrupt Status after FDC Reset Justin Chevrier
@ 2009-01-24 12:10 ` Blue Swirl
  2009-01-26 17:05 ` Anthony Liguori
  1 sibling, 0 replies; 4+ messages in thread
From: Blue Swirl @ 2009-01-24 12:10 UTC (permalink / raw)
  To: theburner1, qemu-devel

On 1/22/09, Justin Chevrier <theburner1@yahoo.com> wrote:
> Original text below.
>
>  Attached is a patch that changes how the emulated floppy controller replies to Sense Interrupt Status commands immediately after a controller reset. The specs state that after a Reset the 82078 goes into polling mode which needs four Sense Interrupt Status commands to be issued afterwards to clear the status of each drive. Currently we always respond to Sense Interrupt Status with a SEEK END instead of POLLING. This causes a problem with the SCO Openserver installer which is expects a POLLING state after reset. This patch returns a POLLING status for four Sense Interrupt Status requests immediately after a controller reset. This approach mirrors the way Bochs handles this situation. With the attached patch applied Openserver gets further when trying to load storage drivers from the floppy disk (blocked by another issue, patch on its way). I have successfully tested the floppy drive on the following OSs after applying this patch: Windows 98, Windows XP
>  SP2, Linux x86 (SysRescCD 1.1.3 and Ubuntu 8.10).
>
>  Justin
>
>  Changelog:
>
>  Properly handle Sense Interrupt Status after FDC Reset
>
>  Signed-off-by: Justin Chevrier <theburner1@yahoo.com>

Thanks, applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH][Resend] Floppy: Properly handle Sense Interrupt Status after FDC Reset
  2009-01-22 19:46 [Qemu-devel] [PATCH][Resend] Floppy: Properly handle Sense Interrupt Status after FDC Reset Justin Chevrier
  2009-01-24 12:10 ` Blue Swirl
@ 2009-01-26 17:05 ` Anthony Liguori
  2009-01-26 19:19   ` Justin Chevrier
  1 sibling, 1 reply; 4+ messages in thread
From: Anthony Liguori @ 2009-01-26 17:05 UTC (permalink / raw)
  To: theburner1, qemu-devel

Justin Chevrier wrote:
> Original text below.
>
> Attached is a patch that changes how the emulated floppy controller replies to Sense Interrupt Status commands immediately after a controller reset. The specs state that after a Reset the 82078 goes into polling mode which needs four Sense Interrupt Status commands to be issued afterwards to clear the status of each drive. Currently we always respond to Sense Interrupt Status with a SEEK END instead of POLLING. This causes a problem with the SCO Openserver installer which is expects a POLLING state after reset. This patch returns a POLLING status for four Sense Interrupt Status requests immediately after a controller reset. This approach mirrors the way Bochs handles this situation. With the attached patch applied Openserver gets further when trying to load storage drivers from the floppy disk (blocked by another issue, patch on its way). I have successfully tested the floppy drive on the following OSs after applying this patch: Windows 98, Windows XP
> SP2, Linux x86 (SysRescCD 1.1.3 and Ubuntu 8.10).
>
> Justin
>
> Changelog:
>
> Properly handle Sense Interrupt Status after FDC Reset
>
> Signed-off-by: Justin Chevrier <theburner1@yahoo.com>
>   

The patch is whitespace damaged.

> Index: hw/fdc.c
> ===================================================================
> --- hw/fdc.c    (revision 6193)
> +++ hw/fdc.c    (working copy)
> @@ -53,8 +53,9 @@
> #define SET_CUR_DRV(fdctrl, drive) ((fdctrl)->cur_drv = (drive))
>   

The leading space seems to have gotten stripped.  A tool like git-email 
or attaching if your mailer uses text/plain would ensure this doesn't 
happen.

Regards,

Anthony Liguori

> /* Will always be a fixed parameter for us */
> -#define FD_SECTOR_LEN 512
> -#define FD_SECTOR_SC  2   /* Sector size code */
> +#define FD_SECTOR_LEN          512
> +#define FD_SECTOR_SC           2   /* Sector size code */
> +#define FD_RESET_SENSEI_COUNT  4   /* Number of sense interrupts on RESET */
>
> /* Floppy disk drive emulation */
> typedef enum fdisk_type_t {
> @@ -506,6 +507,7 @@
>      int sun4m;
>      /* Floppy drives */
>      fdrive_t drives[MAX_FD];
> +    int reset_sensei;
> };
>
> static uint32_t fdctrl_read (void *opaque, uint32_t reg)
> @@ -763,6 +765,7 @@
>          qemu_set_irq(fdctrl->irq, 1);
>          fdctrl->sra |= FD_SRA_INTPEND;
>      }
> +    fdctrl->reset_sensei = 0;
>      fdctrl->status0 = status0;
>      FLOPPY_DPRINTF("Set interrupt status to 0x%02x\n", fdctrl->status0);
> }
> @@ -793,6 +796,7 @@
>      fdctrl_reset_fifo(fdctrl);
>      if (do_irq) {
>          fdctrl_raise_irq(fdctrl, FD_SR0_RDYCHG);
> +        fdctrl->reset_sensei = FD_RESET_SENSEI_COUNT;
>      }
> }
>
> @@ -1601,16 +1605,18 @@
> {
>      fdrive_t *cur_drv = get_cur_drv(fdctrl);
>
> -#if 0
> -    fdctrl->fifo[0] =
> -        fdctrl->status0 | (cur_drv->head << 2) | GET_CUR_DRV(fdctrl);
> -#else
> -    /* XXX: status0 handling is broken for read/write
> -       commands, so we do this hack. It should be suppressed
> -       ASAP */
> -    fdctrl->fifo[0] =
> -        FD_SR0_SEEK | (cur_drv->head << 2) | GET_CUR_DRV(fdctrl);
> -#endif
> +    if(fdctrl->reset_sensei > 0) {
> +        fdctrl->fifo[0] =
> +            FD_SR0_RDYCHG + FD_RESET_SENSEI_COUNT - fdctrl->reset_sensei;
> +        fdctrl->reset_sensei--;
> +    } else {
> +        /* XXX: status0 handling is broken for read/write
> +           commands, so we do this hack. It should be suppressed
> +           ASAP */
> +        fdctrl->fifo[0] =
> +            FD_SR0_SEEK | (cur_drv->head << 2) | GET_CUR_DRV(fdctrl);
> +    }
> +
>      fdctrl->fifo[1] = cur_drv->track;
>      fdctrl_set_fifo(fdctrl, 2, 0);
>      fdctrl_reset_irq(fdctrl);
>
>
>       
>
>
>
>   

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH][Resend] Floppy: Properly handle Sense Interrupt Status after FDC Reset
  2009-01-26 17:05 ` Anthony Liguori
@ 2009-01-26 19:19   ` Justin Chevrier
  0 siblings, 0 replies; 4+ messages in thread
From: Justin Chevrier @ 2009-01-26 19:19 UTC (permalink / raw)
  To: qemu-devel, Anthony Liguori

Thanks for the heads up Anthony.

I will attach future patches.

Justin


--- On Mon, 1/26/09, Anthony Liguori <aliguori@us.ibm.com> wrote:

> From: Anthony Liguori <aliguori@us.ibm.com>
> Subject: Re: [Qemu-devel] [PATCH][Resend] Floppy: Properly handle Sense Interrupt Status after FDC Reset
> To: theburner1@yahoo.com, qemu-devel@nongnu.org
> Date: Monday, January 26, 2009, 12:05 PM
> Justin Chevrier wrote:
> > Original text below.
> >
> > Attached is a patch that changes how the emulated
> floppy controller replies to Sense Interrupt Status commands
> immediately after a controller reset. The specs state that
> after a Reset the 82078 goes into polling mode which needs
> four Sense Interrupt Status commands to be issued afterwards
> to clear the status of each drive. Currently we always
> respond to Sense Interrupt Status with a SEEK END instead of
> POLLING. This causes a problem with the SCO Openserver
> installer which is expects a POLLING state after reset. This
> patch returns a POLLING status for four Sense Interrupt
> Status requests immediately after a controller reset. This
> approach mirrors the way Bochs handles this situation. With
> the attached patch applied Openserver gets further when
> trying to load storage drivers from the floppy disk (blocked
> by another issue, patch on its way). I have successfully
> tested the floppy drive on the following OSs after applying
> this patch: Windows 98, Windows XP
> > SP2, Linux x86 (SysRescCD 1.1.3 and Ubuntu 8.10).
> >
> > Justin
> >
> > Changelog:
> >
> > Properly handle Sense Interrupt Status after FDC Reset
> >
> > Signed-off-by: Justin Chevrier
> <theburner1@yahoo.com>
> >   
> 
> The patch is whitespace damaged.
> 
> > Index: hw/fdc.c
> >
> ===================================================================
> > --- hw/fdc.c    (revision 6193)
> > +++ hw/fdc.c    (working copy)
> > @@ -53,8 +53,9 @@
> > #define SET_CUR_DRV(fdctrl, drive)
> ((fdctrl)->cur_drv = (drive))
> >   
> 
> The leading space seems to have gotten stripped.  A tool
> like git-email 
> or attaching if your mailer uses text/plain would ensure
> this doesn't 
> happen.
> 
> Regards,
> 
> Anthony Liguori
> 
> > /* Will always be a fixed parameter for us */
> > -#define FD_SECTOR_LEN 512
> > -#define FD_SECTOR_SC  2   /* Sector size code */
> > +#define FD_SECTOR_LEN          512
> > +#define FD_SECTOR_SC           2   /* Sector size
> code */
> > +#define FD_RESET_SENSEI_COUNT  4   /* Number of sense
> interrupts on RESET */
> >
> > /* Floppy disk drive emulation */
> > typedef enum fdisk_type_t {
> > @@ -506,6 +507,7 @@
> >      int sun4m;
> >      /* Floppy drives */
> >      fdrive_t drives[MAX_FD];
> > +    int reset_sensei;
> > };
> >
> > static uint32_t fdctrl_read (void *opaque, uint32_t
> reg)
> > @@ -763,6 +765,7 @@
> >          qemu_set_irq(fdctrl->irq, 1);
> >          fdctrl->sra |= FD_SRA_INTPEND;
> >      }
> > +    fdctrl->reset_sensei = 0;
> >      fdctrl->status0 = status0;
> >      FLOPPY_DPRINTF("Set interrupt status to
> 0x%02x\n", fdctrl->status0);
> > }
> > @@ -793,6 +796,7 @@
> >      fdctrl_reset_fifo(fdctrl);
> >      if (do_irq) {
> >          fdctrl_raise_irq(fdctrl, FD_SR0_RDYCHG);
> > +        fdctrl->reset_sensei =
> FD_RESET_SENSEI_COUNT;
> >      }
> > }
> >
> > @@ -1601,16 +1605,18 @@
> > {
> >      fdrive_t *cur_drv = get_cur_drv(fdctrl);
> >
> > -#if 0
> > -    fdctrl->fifo[0] =
> > -        fdctrl->status0 | (cur_drv->head
> << 2) | GET_CUR_DRV(fdctrl);
> > -#else
> > -    /* XXX: status0 handling is broken for read/write
> > -       commands, so we do this hack. It should be
> suppressed
> > -       ASAP */
> > -    fdctrl->fifo[0] =
> > -        FD_SR0_SEEK | (cur_drv->head << 2) |
> GET_CUR_DRV(fdctrl);
> > -#endif
> > +    if(fdctrl->reset_sensei > 0) {
> > +        fdctrl->fifo[0] =
> > +            FD_SR0_RDYCHG + FD_RESET_SENSEI_COUNT -
> fdctrl->reset_sensei;
> > +        fdctrl->reset_sensei--;
> > +    } else {
> > +        /* XXX: status0 handling is broken for
> read/write
> > +           commands, so we do this hack. It should be
> suppressed
> > +           ASAP */
> > +        fdctrl->fifo[0] =
> > +            FD_SR0_SEEK | (cur_drv->head <<
> 2) | GET_CUR_DRV(fdctrl);
> > +    }
> > +
> >      fdctrl->fifo[1] = cur_drv->track;
> >      fdctrl_set_fifo(fdctrl, 2, 0);
> >      fdctrl_reset_irq(fdctrl);
> >
> >
> >       
> >
> >
> >
> >


      

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-26 19:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-22 19:46 [Qemu-devel] [PATCH][Resend] Floppy: Properly handle Sense Interrupt Status after FDC Reset Justin Chevrier
2009-01-24 12:10 ` Blue Swirl
2009-01-26 17:05 ` Anthony Liguori
2009-01-26 19:19   ` Justin Chevrier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).