to access older c/h/s hard drives i would of used 0x1f0-0x1f7
1f0=data register
1f1=error register
1f2=sector count
1f3=sector number
1f4=cylinder low
1f5=cylinder high
1f6=drive/head
1f7=status register (read)
1f7=command register (write)
to use lba mode i must first set the LBA bit in the Head/Drive Select
register 0x1f6.
Then lba is ready
this is where i get confused, as now i have to deal with LBA High, LBA
Mid, Device, Sector Count, , Command, Status, Features, Error,
and Data registers.
if i have read things correctly of the web, which i have probably not,
then with lba things are:
0x1f0=data register
0x1f1=error register
0x1f2=sector count
0x1f3=sector low
0x1f4=sector mid
0x1f5=sector high
0x1f6=device
0x1f7=Command(write)/status(read)
what i would like to know is if the above is correct??? and if not,
what have i got wrong??? thanks
The register description and I/O numbers above are almost correct for the
first IDE cable (most systems have 2 IDE cables and thus 2 different I/O
address spaces).
IDE Cable 1:
0x1f0=data register (Read/Write)
0x1f1=error register (Read)
0x1f1=Feature Register (Write)
0x1f2=sector count (Read/Write)
0x1f3=sector low (Read/Write)
0x1f4=sector mid (Read/Write)
0x1f5=sector high (Read/Write)
0x1f6=device (Read/Write)
0x1f7=Command(write)/status(read) <==== CORRECT!
0x3f6=Alternative Status Register (Read)
0x3f6=Digital Output Register (Write)
0x3f7=Drive Address (Read)
IDE Cable 2:
0x170=data register (Read/Write)
0x171=error register (Read)
0x171=Feature Register (Write)
0x172=sector count (Read/Write)
0x173=sector low (Read/Write)
0x174=sector mid (Read/Write)
0x175=sector high (Read/Write)
0x176=device (Read/Write)
0x177=Command(write)/status(read)
0x376=Alternative Status Register (Read)
0x376=Digital Output Register (Write)
0x377=Drive Address (Read)
This I how LBA PIO Read/Write 28-bit (the difference is Read uses command
20h, Write uses 30h and of course your driver needs to read the data
register at the end for reading sector and write to the data register at the
end for writing!) is done:
(btw, I use 20h/30h, this is the READ/WRITE SECTOR(S) command, look it up
(and the other READ/WRITE commands to find out what you want to use!))
1) Send 11100000b+DEVICE_BIT (0h for Master, 10h for Slave), remember that
the lower 4 bits of the device/status register is LBA Addr [27:24] so you'll
need to add these, to 0x1f6/0x176.
2) Wait 400ns (ATA4 drives need it, some drives may need more time if I
remember correctly)
3) Read the status register and wait until BUSY isn't set
4) Send LBA Addr [23:16] to 0x1f5/0x175 ("sector high")
5) Send LBA Addr [15:8] to 0x1f4/0x174 ("sector mid")
6) Send LBA Addr [7:0] to 0x1f3/0x173 ("sector low")
7) Send amount of sector you want to read/write => 0x1f2/0x172 ("sector
count")
8) Send command => 0x1f7/0x177 ("Command(write)/status(read)")
9) Wait until BUSY isn't set! (the drive is now seeking the right
cylinder,head & sector)
10) Read/Write data from drive!
(btw nr. 2, X0X00000b the bits marked X (in the Device register) is obsolete
on many newer drives but Bochs x86 Emulator get's a little cranky if you
don't set them since it only supports ATA 2)
The other registers which I didn't mention you will have to look up for your
self...
Happy Coding and I Hope it helps!
//Spike
go to my site and download the boot168 code.
It is in a zip file on the idework page.
Assembly code to read IDE/ATA ports W/o Irqs.
Should answer most questions.
Hardware access is how it works.
--
Doors - Dont look at the future in a window.
just walk to the door http://walk.to/doors
- Open it and go there.
http://www.humboldt1.com/~doors/doors.htm
OR SEARCH AT
http://www.humboldt1.com/~doors/search.htm