Return-Path: donn@BSDI.COM
Received: from BSDI.COM by liberty.BSDI.COM (5.67/1.42)
	id AA04781; Mon, 19 Oct 92 16:50:00 -0500
Received: by BSDI.COM (5.61/BSDI-mail-drop)
	id AA12659; Mon, 19 Oct 92 17:50:10 -0400
Date: Mon, 19 Oct 92 17:50:10 -0400
From: donn@BSDI.COM (Donn Seeley)
Message-Id: <9210192150.AA12659@BSDI.COM>
To: karels@BSDI.COM
Subject: Re: comp.unix.bsd discussion about translated hard drives
Cc: pace@BSDI.COM

Xref: uunet comp.unix.bsd:7642
Newsgroups: comp.unix.bsd
Path: uunet!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ucselx!crash!fpm
From: fpm@crash.cts.com (Frank Maclachlan)
Subject: Finding untranslated params for IDE drives (w/ pgm)
Organization: CTS Network Services (crash, ctsnet), El Cajon, CA
Date: 18 Oct 92 15:30:07 PDT
Message-ID: <1992Oct18.153007.28120@crash>
Lines: 724

Given the numerous inquiries about untranslated geometry on various
IDE hard drives, I wrote a quickie program which can be used under
MSDOS to report the "default" drive geometry.  The command used to
query the drive (identify drive, 0xec) is the same command used by
the 386BSD 0.1 wd.c driver.

The program does the following:

1.  Reports the drive configuration as reported by the system ROM BIOS.
2.  Queries the drive for its configuration and prints the geometry
    given by the configuration.
3.  Resets the drive/controller and delays approximately 1 second.
4.  Again queries the drive for its configuration and prints the
    geometry given by the configuration.
5.  Asks user to reboot system since translation may have changed.

Steps 3 and 4 were added because I wanted to know if the identify
drive command would return the sames values after the controller/drive
was reset.  I tested the program on a Fujitsu M2612ET IDE drive (90 mb,
1334 cyls, 4 hds, 33 sec/trk) and found that the "default" geometry
was 667 cyls, 8 hds, 33 sec/trk.  Note that some (albeit simple) trans-
lation occurs on this drive in the "default" state; this was no doubt
done to avoid exceeding the 1024 cylinder limit imposed by the system
BIOS.  Also, the "default" geometry didn't change after a reset (it
really shouldn't); the drive's translation mode, however, did change
after a reset (see below).

I noticed some other things while playing with the Fujitsu drive.
The drive is installed in a system w/ an old Mylex 386/20 MB.
The AMI BIOS does not support a type 47 user configurable drive
type, so I chose a drive type having 1024 cyls, 9 hds, 17 sec/trk.
I didn't really believe that the translation was performed in
software (most IDE interface boards don't have an on-board ROM),
so I wrote a program which scanned the disk by talking directly
to the controller registers.  The drive looked like it had 9 heads,
17 secs/trk and 1150 cyls.  The drive's notion of its geometry
(translation) is determined by the 'Initialize Drive Parameters'
command (0x91).  This command sets the number of sectors from the
sector count register and the number of heads from the head
address field in the SDH register.  The drive then computes how
many translated cylinders it can support with the specified head
and sector count (that's why I could read 1150 cyls even though the
BIOS configuration indicated 1024 cyls).  The translation was cleared
after a controller/drive reset; the drive then behaved as though it
had 667 cyls, 8 hds, 33 secs/trk.

Also, data transfers from this drive averaged about 300 kb/sec when
the drive was set up in translated mode and about 660 kb/sec when
set up in its "default" mode.  This was probably partially caused
by the use of 17 secs/trk rather than the native 33 secs/trk; the
80C31 microprocessor has to work harder to translate addresses.

For those IDE drive users with a modern BIOS supporting user configurable
drive types (type 47 on an AMI BIOS), I suggest configuring the drive
or drives to the default geometry given by step 4 above.  This results
in the geometry remaining constant throughout the 386BSD's handling of
an IDE drive and possibly better performance.

I am enclosing the program (a .c file and a .h file) and an .exe file
(for those of you who don't have an MSDOS C compiler) in a shell archive.

Hope this helps!

