[comp.os.minix] Minix/ST fix for most Supra drives

dal@syntel.UUCP (Dale Schumacher) (02/02/89)

I've gotten several requests for information about any progress toward
getting the older Supra hard disk drives to work with Minix/ST.  As usual,
Willie Brown, of Supra Corp., has been most helpful in tracking down this
elusive problem.  Below is a message he sent to me containing a new version
of the kernel routine do_xfer() from the source file "stwini.c".

First a little background information and a caveat.  If you have a Supra
drive with a DMA port on the back of it (for connecting additional DMA
devices) then you don't need this fix, though it won't hurt it install it.
If you have a REALLY old Supra drive (like mine :-) that uses the Seagate
225 drive mechanism, then this fix will *NOT* help you.  The 225 has a
further (as yet unidentified) problem that causes it not to even register
a drive access at all on boot-up.  If you have this symptom, then you
probably have a 225 and will have to wait (like ME :-) for a further patch.
If the drive accesses, but panics during boot or randomly during operation,
then you probably have a Seagate 1xx or Miniscribe drive and THIS IS THE
FIX YOU'RE LOOKING FOR!

The code comments explain the technical aspects of the problem and solution.

----------------------------------------------------------------------------
From: Willie Brown <hpda!hp-pcd!orstcs!jacobs.CS.ORST.EDU!willieb>
Message-Id: <8901120631.AA16601@jacobs.CS.ORST.EDU>
To: syntel!dal
Subject: Supra HD fix! (_finally_)

Dale
Here is the fix that I left you a message on your machine about.  I used it
to compile a version (actually a bunch of versions) of MINIX.  It works
great with a version 6 of our interface and a MiniScribe 8425S 20MB hard
disk.  Try it out and let me know if it works for you.  I set the rest of
this up so that it could be put on the network if you dont find any more
problems.  Be talking to you later.
		Willie
/*****************************************************************************
 * The following is a replacement routine in STWINI.C to allow older Supra   *
 *  hard disk systems (those _without_ a DMA pass thru) to work correctly    *
 *  with MINIX.  The problem is that an extra interrupt gets generated at    *
 *  the end of EVERY hard disk transfer.  I corrected this by disabling the  *
 *  interrups _before_ the status byte is read in.  The delay loop set by    *
 *  PNK_DELAY adds a little extra fudge factor to guaranty that the inter-   *
 *  rupt has happened.  The value of 50 should work with all drives, but I   *
 *  was only able to test it with a MiniScribe 8425S.  The value could be    *
 *  as low as 10 with that drive.  I hope that this will allow all Supra     *
 *  hard disk owners to run MINIX.					     *
 *	Willie Brown - Supra Corporation				     *
 *****************************************************************************/
#define	PNK_DELAY 50
/*===========================================================================*
 *				do_xfer					     *
 *===========================================================================*/
PRIVATE int do_xfer(drive, address, sector, count, rw)
int		drive;
phys_bytes 	address;
long		sector;
int		count;
int		rw;
{
  register	r, s, wrbit;
  /*
   * Carry out the transfer. All parameters have been checked and
   * are set up properly.
   *
   * Every single byte written to the hdc will cause an interrupt.
   * Thus disable interrupts while communicating with hdc. Ready test
   * will be done by busy waiting. Only for real hard disk operations
   * interrupts will be enabled.
   */
  TRACE(printf("hd drive:%d address:0x%X sector:%D count=%d cmd:%s\n",
	 drive, address, sector, count, (rw==DISK_READ)?"READ":"WRITE")
  );
  IDISABLE();
  if (rw == DISK_READ) {
	cmdhead(drive, HD_RD);		/* command code */
	dmaaddr(address);		/* DMA address setup */
	wrbit = 0;
  } else {
	dmaaddr(address);		/* DMA address setup */
	cmdhead(drive, HD_WR);		/* command code */
	wrbit = WRBIT;
  }
  r = cmdtail(drive, sector, count);	/* command parameters */
  if (r == OK) {
	IENABLE();
	dmacomm(wrbit | FDC | SCREG, count, HDC_DELAY);
	dmawdat(wrbit | FDC | HDC | A0, 0, HDC_DELAY);
	DMA->dma_mode = wrbit;		/* needed? */
	receive(HARDWARE, &mess);	/* Wait for interrupt. */
	IDISABLE();			/* Cancel interrupt for status bytes */
	s = dmardat(wrbit | FDC | HDC | A0, HDC_DELAY);
	if (s & HDC_CC) {
		printf("hd: %s: drive=%d sector=%D status=0x%x\n",
			wrbit ? "write" : "read", drive, sector, s&0xFF);
		r = ERROR;
	}
  }
  if (dmardat(FDC, HDC_DELAY))		/* finish HDC command */
	;
  for (s = 0; s < PNK_DELAY; s++) {}	/* Guaranty interrupt is gone! */
  IENABLE();				/* Re-enable normal interrupts */
  return(r);
}

----------------------------------------------------------------------------

PS.  As you may have noticed, Supra now has a representative on the net.
This is a new development, and Willie still doesn't get much time to read
news, but at least they are now reachable via E-Mail.

--
      Dale Schumacher                         399 Beacon Ave.
      (alias: Dalnefre')                      St. Paul, MN  55104
      ...pwcs!stag!syntel!dal                 United States of America
    "It's not reality that's important, but how you perceive things."