Path: blue.weeg.uiowa.edu!news.uiowa.edu!hobbes.physics.uiowa.edu!math.ohio-state.edu!cs.utexas.edu!news.tamu.edu!not-for-mail From: jdb8042@tamsun.tamu.edu (John Donald Baker) Newsgroups: comp.sys.apple2 Subject: IDE Facts and Fallacies Date: 3 Oct 1994 14:23:09 -0500 Organization: Texas A&M University, College Station Lines: 115 Message-ID: <36plmt$bal@tamsun.tamu.edu> References: <780601569.27824@myrias.ab.ca> <5y0DTc2w165w@tlp.apana.org.au> NNTP-Posting-Host: tamsun.tamu.edu I grow tired of reading posts which demostrate a lack of understanding of the nature of the IDE hard disk interface. Thus, to educate to general public, I have the following to say, based on my own research and experi- mentation. The IDE interface is an extension of the old Western Digital WD1002 series of stand-alone disk controllers which were commonly used on machines like the Kaypro 10, TeleVideo 8xxH, and Epson QX-10/QX-16 sytems. IDE, like the WD1002s before them look like a group of 8 registers accessed and interfaced in such a manner as to make the device look like just another peripheral chip. The registers are: addr. offset name operation 0 DATA read/write data 1 ERROR/PRCMP read error / set precomp info. 2 SECTOR COUNT set number of sectors to transfer 3 SECTOR NUMBER set starting sector of transfer 4 CYLINDER LOW low 8 bits of cylinder number 5 CYLINDER HIGH high 8 bits of cylinder number 6 SIZE/DRIVE/HEAD drive select, head select, sector size 7 COMMAND/STATUS send command / read status All registers except the DATA register are 8 bits wide. On the older WD1002, the DATA register is also 8 bits wide. In IDE drives, the data register is 16 bits wide. This is the only relevant hardware difference between the two systems. From the programmer's point of view there is no difference in accessing the WD1002 or IDE. IDE supports all the same basic commands as the older WD1002 systems. Naturally, IDE offers a number of enhanced commands, but those are just icing on the cake. The functional programming differences are in the assignment of bits in the SIZE/DRIVE/HEAD register, the CYLINDER HIGH register, and the starting sector number of a track. The original WD1002 SIZE/DRIVE/HEAD (SDH) register was arranged as: e s s d d h h h where: e = 1 if ECC desired (0 = CRC) s s = 00 for 128-byte sectors 10 for 256-byte sectors 01 for 512-byte sectors d d = 00 -- 11 for selection of any of 4 physical drives h h h = 000 -- 111 for selection of up to 8 heads. The current IDE drives' SDH register is arranged as: e s s d h h h h Note that there is only 1 drive select 'd' bit which is the source of the 2-drive limit on an IDE host adapter. In place of the second 'd' bit there is an extra 'h' bit which allows IDE drives to have up to 16 logical heads. In the IDE drives, the 'e' bit MUST be 1 and 'ss' MUST be '01'. The so-called "Master/Slave" drive setting simply determines whether the drive responds to the 'd' bit being 0 or being 1. In the original WD1002 system, the CYLINDER HIGH register only had it's two least-significant bits available. This is the source of the 1024-cylinder limit that many PClones still have to struggle with and the reason that IDE drives have to remap their physical geometry so that they appear to have 1024 cylinders or less. In some cases, they also have to pretend to have 8 heads or less. I know of no limit on sectors per track. All 8 bits of the CYLINDER HIGH register are available in IDE drives, so it's theoretically possible to have a drive with 65536 cylinders. IDE drives, by default, number their sectors starting at '1' instead of '0' as was more common for the WD1002. I'm told that the IDE's FORMAT command can be used to re-number the sectors in any way that you like (It doesn't actually format the disk), but I've not tried this yet (I have to write a formatter first). Given the above information, the theoretical maximum size of an IDE drive is 65536 cyl. * 16 heads/cyl. * 256 sec/head = 128 gigabytes! Any limitations on disk size are therefore the fault of the programmer who wrote the disk driver routines. Furthermore, they are NOT block- oriented interfaces, as someone else claimed. They are logical cylinder, head, and track devices. Any "block numbers" involved are those passed to the device driver by ProDOS or other block-oriented filesystem. When the IDE is physically accessed, its done on a cylinder/head/sector basis. Now, where do I get off spouting all this stuff? Over the course of this past summer I built and tested an IDE host adapter for an EPSON QX-10 to replace the WD1002-HDO hard disk system that it normally uses. The hardware to map the 16-bit data register to an 8-bit bus is nearly trivial. In the case of the QX-10, only minor changes to the BIOS were required to operate the IDE drive (A Conner CP3022 in this case) as the WD1002 routines were already in place. The only changes made were to add 1 to the sector number and eliminate the explicit seek commands (IDE does full implied seek on all commands). I appologize if this sounded a bit heavy-handed. I guess it's hard for me to accept that many people haven't learned the same things I have. Hopefully this article has remedied some of that. John D. Baker ->A TransWarp'802'd Apple //e CardZ180 Z-System nut// Internet: jdb8042@tamsun.tamu.edu, @blkbox.com, jdbaker@taronga.com BBSs: JOHN BAKER on PIC of the Mid-Town [(713) 961-5817] 1:106/31, The Vector Board [(716) 544-1863], Z-Node #45 [(713) 937-8886]