From 3b3837db6156b3b3d355adb052306a051ea503b8 Mon Sep 17 00:00:00 2001 From: "Rodney W. Grimes" Date: Thu, 12 Aug 1993 09:21:20 +0000 Subject: [PATCH] Fixed poor timeout code in out_fdc. The timeout counter was not being reinitialized between while loops. Added comments about what was going on in the out_fdc routine. out_fdc now returns if the direction bit is not set in time instead of trying to wait for MRQ to get cleared. --- sys/dev/fdc/fdc.c | 23 +++++++++++++++++++---- sys/i386/isa/fd.c | 23 +++++++++++++++++++---- sys/isa/fd.c | 23 +++++++++++++++++++---- 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index ca92b165cbf0..d4eda5a971ad 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -46,12 +46,19 @@ * Largely rewritten to handle multiple controllers and drives * By Julian Elischer, Sun Apr 4 16:34:33 WST 1993 */ -char rev[] = "$Revision: 1.1.1.1 $"; +char rev[] = "$Revision: 1.2 $"; /* - * $Header: /a/cvs/386BSD/src/sys.386bsd/i386/isa/fd.c,v 1.1.1.1 1993/06/12 14:58:02 rgrimes Exp $ + * $Header: /freefall/a/cvs/386BSD/src/sys/i386/isa/fd.c,v 1.2 1993/07/15 17:53:04 davidg Exp $ */ /* * $Log: fd.c,v $ + * Revision 1.2 1993/07/15 17:53:04 davidg + * Modified attach printf's so that the output is compatible with the "new" + * way of doing things. There still remain several drivers that need to + * be updated. Also added a compile-time option to pccons to switch the + * control and caps-lock keys (REVERSE_CAPS_CTRL) - added for my personal + * sanity. + * * Revision 1.1.1.1 1993/06/12 14:58:02 rgrimes * Initial import, 0.1 + pk 0.2.4-B1 * @@ -483,11 +490,19 @@ in_fdc(fdcu_t fdcu) out_fdc(fdcu_t fdcu,int x) { int baseport = fdc_data[fdcu].baseport; - int i = 100000; + int i; + /* Check that the direction bit is set */ + i = 100000; while ((inb(baseport+fdsts) & NE7_DIO) && i-- > 0); + if (i <= 0) return (-1); /* Floppy timed out */ + + /* Check that the floppy controller is ready for a command */ + i = 100000; while ((inb(baseport+fdsts) & NE7_RQM) == 0 && i-- > 0); - if (i <= 0) return (-1); + if (i <= 0) return (-1); /* Floppy timed out */ + + /* Send the command and return */ outb(baseport+fddata,x); TRACE1("[0x%x->fddata]",x); return (0); diff --git a/sys/i386/isa/fd.c b/sys/i386/isa/fd.c index ca92b165cbf0..d4eda5a971ad 100644 --- a/sys/i386/isa/fd.c +++ b/sys/i386/isa/fd.c @@ -46,12 +46,19 @@ * Largely rewritten to handle multiple controllers and drives * By Julian Elischer, Sun Apr 4 16:34:33 WST 1993 */ -char rev[] = "$Revision: 1.1.1.1 $"; +char rev[] = "$Revision: 1.2 $"; /* - * $Header: /a/cvs/386BSD/src/sys.386bsd/i386/isa/fd.c,v 1.1.1.1 1993/06/12 14:58:02 rgrimes Exp $ + * $Header: /freefall/a/cvs/386BSD/src/sys/i386/isa/fd.c,v 1.2 1993/07/15 17:53:04 davidg Exp $ */ /* * $Log: fd.c,v $ + * Revision 1.2 1993/07/15 17:53:04 davidg + * Modified attach printf's so that the output is compatible with the "new" + * way of doing things. There still remain several drivers that need to + * be updated. Also added a compile-time option to pccons to switch the + * control and caps-lock keys (REVERSE_CAPS_CTRL) - added for my personal + * sanity. + * * Revision 1.1.1.1 1993/06/12 14:58:02 rgrimes * Initial import, 0.1 + pk 0.2.4-B1 * @@ -483,11 +490,19 @@ in_fdc(fdcu_t fdcu) out_fdc(fdcu_t fdcu,int x) { int baseport = fdc_data[fdcu].baseport; - int i = 100000; + int i; + /* Check that the direction bit is set */ + i = 100000; while ((inb(baseport+fdsts) & NE7_DIO) && i-- > 0); + if (i <= 0) return (-1); /* Floppy timed out */ + + /* Check that the floppy controller is ready for a command */ + i = 100000; while ((inb(baseport+fdsts) & NE7_RQM) == 0 && i-- > 0); - if (i <= 0) return (-1); + if (i <= 0) return (-1); /* Floppy timed out */ + + /* Send the command and return */ outb(baseport+fddata,x); TRACE1("[0x%x->fddata]",x); return (0); diff --git a/sys/isa/fd.c b/sys/isa/fd.c index ca92b165cbf0..d4eda5a971ad 100644 --- a/sys/isa/fd.c +++ b/sys/isa/fd.c @@ -46,12 +46,19 @@ * Largely rewritten to handle multiple controllers and drives * By Julian Elischer, Sun Apr 4 16:34:33 WST 1993 */ -char rev[] = "$Revision: 1.1.1.1 $"; +char rev[] = "$Revision: 1.2 $"; /* - * $Header: /a/cvs/386BSD/src/sys.386bsd/i386/isa/fd.c,v 1.1.1.1 1993/06/12 14:58:02 rgrimes Exp $ + * $Header: /freefall/a/cvs/386BSD/src/sys/i386/isa/fd.c,v 1.2 1993/07/15 17:53:04 davidg Exp $ */ /* * $Log: fd.c,v $ + * Revision 1.2 1993/07/15 17:53:04 davidg + * Modified attach printf's so that the output is compatible with the "new" + * way of doing things. There still remain several drivers that need to + * be updated. Also added a compile-time option to pccons to switch the + * control and caps-lock keys (REVERSE_CAPS_CTRL) - added for my personal + * sanity. + * * Revision 1.1.1.1 1993/06/12 14:58:02 rgrimes * Initial import, 0.1 + pk 0.2.4-B1 * @@ -483,11 +490,19 @@ in_fdc(fdcu_t fdcu) out_fdc(fdcu_t fdcu,int x) { int baseport = fdc_data[fdcu].baseport; - int i = 100000; + int i; + /* Check that the direction bit is set */ + i = 100000; while ((inb(baseport+fdsts) & NE7_DIO) && i-- > 0); + if (i <= 0) return (-1); /* Floppy timed out */ + + /* Check that the floppy controller is ready for a command */ + i = 100000; while ((inb(baseport+fdsts) & NE7_RQM) == 0 && i-- > 0); - if (i <= 0) return (-1); + if (i <= 0) return (-1); /* Floppy timed out */ + + /* Send the command and return */ outb(baseport+fddata,x); TRACE1("[0x%x->fddata]",x); return (0);