Hardware Direct Access to IDE HDD

This site is under construction and is in a very rough form there are probably errors I have not seen yet so please enjoy, If I get a good positive response I may create more pages on varying topics I am interested in.

Contained in these pages you will find enough information to directly access the IDE Hard Disk Drive.


WARNING

I cannot guarantee the accuracy of this information, Nor will I be responsible for any loses you may experience. Usage of this information is strictly at your own risk.


Ports
Port  Direction  Description 
BASE+0  R/W  Data 16 Bit 
BASE+1  R/W  R - Error code 

W - Write precomp cylinder/4

 BASE+2   R/W  Sector count for operation 
BASE+3  R/W Sector number(CHS Mode) 

Logical block address, Bits 0-7 (LBA Mode)

BASE+4  R/W Cylinder low (CHS Mode) 

Logical block address, Bits 8-15 (LBA Mode)

BASE+5  R/W Cylinder high (CHS Mode) 

Logical block address, Bits 16-23 (LBA Mode)

BASE+6  R/W Drive & Head (CHS Mode) 

Logical block address, Bits 24-27 (LBA Mode)

BASE+7  R/W  R - Status code 

W - Command 


  Status and error codes
Bit
Status Codes
0
Last command ended in error 
1
Over index hole/marker 
2
Correctable ECC, (Soft Error) 
3
Data request, Sector buffer requires servicing (busy)
4
Seek complete 
5
Write fault 
6
Drive ready for R/W/S (Unless b4=0)
7
Busy. 1=Executing command, Ignore other bits.
Bit
Error Codes (Operational mode)
0
Data address mark not found
1
Track 0 error
2
Command was aborted
3
Reserved, Unused, (Always 1?)
4
Target sector ID could not be found
5
Reserved, Unused, (Always 1)
6
ECC error, (uncorrectable error)
7
Bad block
Bit
Error Codes (Diagnostic mode)
0
001 No error
010 Formatter device error
011 Sector buffer error
100 ECC Circuitry error
101 Controlling microprocessor error
1
2
3
Reserved
4
5
6
7
Which drive failed, 0=Master, 1=Slave

Command list 
Command  Description 
0x10  Recalibrate 
0x2?  Read sector 
0x3? Write sector 
0x3c  Write verify 
0x4?  Verify read 
0x50  Format track (Don't use, You have been warned) 
0x7x  Seek to cylinder 
0x8x  Vendor unique 
0x90  Diagnostics 
0x91  Set parameters 
0x94  Standby - immediate 
0x95  Idle - immediate 
0x96  Standby 
0x97  Idle 
0x98  Check power mode 
0x99  Set sleep mode 
0x9A  Vendor unique 
0xA0  ATAPI packet 
0xA1  Get ATAPI params 
0xC0-0xC3  Vendor unique 
0xC4  Read multi 
0xC5  Write multi 
0xC6  Set multi mode 
0xC8  Read DMA with retry 
0xC9  Read DMA without retry 
0xCA  Write DMA with retry 
0xCB  Write DMA without retry 
0xE4  Read buffer 
0xE8  Write buffer 
0xE9  Write same 
0xEC  Get ATA params (Drive ID) 
0xEF  Set features 
?0 with retry

?1 without retry

?2 long with retry

?3 long without retry


Drive ID

The command 0xEC deserves special mention, It transfers 512 bytes of information that specify the drive parameters,
Offset
Length 
(8 Bit words)
Type
Description
0 2 Bit map 0 Reserved.
1-5 Vendor specific.
6 Removable controller and/or device.
7 Removable media device.
8-14 Vendor specific.
15 Reserved for non magnetic devices.
2 2 lh Number of cylinders
4 2 - Reserved
6 2 lh Number of heads
8 4 - Vendor specific
12 2 lh Number of sectors per track
14 6 - Vendor specific
20 20 ASCII Serial number of drive
40 4 - Vendor specific
44 2 lh Number of long ECC bytes transferred on long operations.
46 8 ASCII Firmware revision
54 40 ASCII Controller model number
94 2 Bit map 0-7 If 0x00 R/W multiple not implemented, 0x01-0xFF Max sectors that can be transferred per interrupt on R/W multiple commands.
8-15 Vendor specific.
96 2 - Reserved
98 2 Bit map Capabilities
0-7 Vendor specific
8 DMA Supported by drive if 1
9 LBA Supported by drive if 1
10 IORDY can be disabled if 1
11 IORDY supported if 1, IORDY may be supported if 0
12 Reserved
13 If 1 standard standby timer values are supported, if 0 standby timer values are vendor specific.
14,15 Reserved
100 2 - Reserved
102 2 lh PIO Data transfer cycle timing
104 2 lh DMA data transfer cycle timing.
106 406 - Reserved


Hardware

IDE Connector pin outs
RESET GND D7 D8 D6 D9 D5 D10 D4 D11 D3 D12 D2 D13 D1 D14 D0 D15 GND N/C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
DMARQ GND DIOW GND DIOR GND IORDY CSEL DMACK GND INTRQ IOCS16 A1 PDIAG A0 A2 CS0 CS1 DASP GND
8 Bit interface

16 Bit interface


Examples in C


Other sites Other sites
http://irb.cs.uni-magdeburg.de/~zbrog/asm/ports.html
http://www.blkbox.com/~jdb8042/SmallSys/8bitIDE.html
http://www.blkbox.com/~jdb8042/images/CoCoIDE.gif
http://nimitz.mcs.kent.edu/~clisowsk/8bit/ide8bit.html
http://www.hut.fi/Misc/Electronics/pc/storage.html#ide
http://www.wi.leidenuniv.nl/ata/
http://www.blackdown.org/~hwb/hwb.html

HDD Manufacturer sites
http://www.seagate.com
http://www.quantum.com
http://www.maxtor.com
http://www.fujitsu.com
http://www.wdc.com
http://www.nec.com


Send constructive comments, Error reports and updates to fred@houweling.com.au

  Back to Index page.