[comp.os.minix] Initialization in floppy.c

jnall%FSU.BITNET@cunyvm.cuny.edu (John Nall 904-644-5241) (12/16/88)

Within the last few weeks (or perhaps months) someone posted a message
which stated, essentially, that the floppy disk driver was not being
initialized properly, and that in making a decision as to whether it
had a 350K drive or a 1.2 meg drive it could hang depending on what sort
of garbage it  had been initialized with.  (I think that was the thrust of
the message).  Fixes were also posted.

I have just put 1.3d up (made from the D1.2-1.3 file on bugs.nosc.mil) and
find that if the floppy driver encounters a disk error, especially during
an initialization phase, it hangs the system.  I suspect that it is the
same problem as previously reported.  Unfortunately I did not keep the
message, since I did not have the problem at that time.  Would someone
e-mail me a copy?  (or perhaps a copy of floppy.c if they have already
inserted the fix).

Thanks

John Nall (BITNET jnall@rai.fsu.edu)
Computer Science Department
Florida State University

(p.s.  Spelling mistake on fourth line -- should read "360K drive").

ast@cs.vu.nl (Andy Tanenbaum) (12/20/88)

In article <5994@louie.udel.EDU> jnall%FSU.BITNET@cunyvm.cuny.edu (John Nall 904-644-5241) writes:
>Within the last few weeks (or perhaps months) someone posted a message
>which stated, essentially, that the floppy disk driver was not being
>initialized properly

I don't quite understand how this could happen.  The boot block uses the
BIOS to read in the operating system.  Having read in 100K + of data, the
BIOS has used the floppy disk controller over and over, and it certainly
is initialized to something.  If you use a 360K diskette for booting and
1.2M after that, it should still work because floppy.c detects the error
and tries other densities.  Could someone please explain the problem more
clearly?

Andy Tanenbaum (ast@cs.vu.nl)

chasm@killer.DALLAS.TX.US (Charles Marslett) (12/22/88)

In article <1831@ast.cs.vu.nl>, ast@cs.vu.nl (Andy Tanenbaum) writes:
> In article <5994@louie.udel.EDU> jnall%FSU.BITNET@cunyvm.cuny.edu (John Nall 904-644-5241) writes:
> >Within the last few weeks (or perhaps months) someone posted a message
> >which stated, essentially, that the floppy disk driver was not being
> >initialized properly

I think that was me -- I was unable to read or write to fd2 or fd3 on my
Heathkit Z150 until I copied a chunk of code from the IBM AT BIOS into
the floppy initialization code.

> I don't quite understand how this could happen.  The boot block uses the
> BIOS to read in the operating system.  Having read in 100K + of data, the
> BIOS has used the floppy disk controller over and over, and it certainly
> is initialized to something.  If you use a 360K diskette for booting and
> 1.2M after that, it should still work because floppy.c detects the error
> and tries other densities.  Could someone please explain the problem more
> clearly?

My comment had nothing to do with the "normal" drives that the BIOS is aware
of -- it had to do with a configuration where a MSDOS driver would have been
required to access the additional drives anyway (I assume an AT would have
not required the additional code, since it came from an AT BIOS in the first
case).

This is what my reset code looks like:
============================ from floppy.c in kernel ===================
PRIVATE reset()
{
/* Issue a reset to the controller.  This is done after any catastrophe,
 * like the controller refusing to respond.
 */

  int i, r, old_state;
  register struct floppy *fp;

  /* Disable interrupts and strobe reset bit low. */
  need_reset = FALSE;
  old_state = lock();
  motor_status = 0;
  motor_goal = 0;
  port_out(DOR, 0);		/* strobe reset bit low */
  port_out(DOR, ENABLE_INT);	/* strobe it high again */
  restore(old_state);		/* interrupts allowed again */
  receive(HARDWARE, &mess);	/* collect the RESET interrupt */

  /* Interrupt from the reset has been received.  Clear each drive. */
  for (i=0; i<NR_DRIVES; i++) {
	fdc_out(FDC_SENSE);	/* did it work? */
	fdc_results(&floppy[i]);/* get results (using each floppy[i]) */
	floppy[i].fl_calibration = UNCALIBRATED;
  }

  /* Tell FDC drive parameters. */
  fdc_out(FDC_SPECIFY);		/* specify some timing parameters */
  fdc_out(SPEC1);		/* step-rate and head-unload-time */
  fdc_out(SPEC2);		/* head-load-time and non-dma */
}
===================================================================

> Andy Tanenbaum (ast@cs.vu.nl)

Charles Marslett (chasm@killer.dallas.tx.us)