ATA/IDE Disk Drivers

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Jim

ATA/IDE Disk Drivers

Post by Jim »

Does anyone konw how to control the hard/cd drive?
Ive ben hunting all over and only managed to get some pci ide controller registers to do with the disk drive working in compatability mode or not.
Im still trying to find out how to read/write and wake/sleep. :'(

Jim.
DennisCGc

Re:ATA/IDE Disk Drivers

Post by DennisCGc »

Hey,

The commands are:

Code: Select all

ide_calibrate equ 16      ;calibrate
ide_readsec equ 33      ;read sector without retry
ide_readsecretry equ 32      ;read sector with automatic retry
ide_writesec equ 49
ide_writesecretry equ 48
NOTE: these are only HD commands, with CD commands you have to use packets.
See www.t13.org
as a side note (to be helpfull):
(0x1f0 is offset of IDE0)
offset+2 totalsectors to read/write
offset+3 sector
offset+4 lower 8 bit of cylinder (0 till 7 inclusive)
offset+5 higher 8 bit of cylinder (8 till 15 inclusive)
offset+6 the first 4 bits is head, the other 4 bits has to be (according to my own driver) 1010 (READ)
offset+7 command
HTH
Jim

Re:ATA/IDE Disk Drivers

Post by Jim »

Ive been to t13 a couple of times and not been able to find anything usefull (it may well be there, i just cant find it).
When do you have to use calibrate? only when you are booting/coming out of standby?
What offset gives the drive the memory location to load to? (or is there something special that has to be done?)

Jim.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:ATA/IDE Disk Drivers

Post by Pype.Clicker »

it seems that T13 is unfortunately down atm. Otherwise, looking for "ATA/ATAPI revision 6" on google should give you a direct pointer towards the PDF.

AFaik, calibration is not required in 'normal operations' ... It may be a good thing to use it after errors saying that track cannot be found ...

I don't understand quite well the second question.

If you need a reference driver, i suggest the ATA driver from the Mobius, which i used myself as a base (mine being far to be tutor-ish ;)
Jim

Re:ATA/IDE Disk Drivers

Post by Jim »

Ive got ATA/AtAPI-6 & ATA Host Adpter docs from t13 now. Its helped with the reference a bit, but its brought up more problems, like where are CS0 CS1 DA0,1,2 ?? ???
Ive even seen a tutorial that doesnt give anything of real value. >:(

By the second question, i thought the way it would work was that you would give the drive a 'Read 4 sectors starting at Sector 1234 into Memory at byte 5678' kind of command. But i have learneed that there is a data register (thats 512 bytes big from the sounds of it [and processor registers are only 4 bytes big... ???]).

With Mobius you have to get it running to see any code though, and it doesnt run well for me :( .
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:ATA/IDE Disk Drivers

Post by Pype.Clicker »

CS, DA0, DA1 etc. are the wire names on the physical interface. You basically don't need to worry about these. What matters for you is the *ports* that allow interaction with the controller, which is the Drive/Head/Cylinder/sector (or LBA) ..

There are two "blocks" of ports for each controller: the 'control block' (0x1F0 iirc) with status, device control and drive raddress ports and the "command block" with data, error, LBA and command ports (starting at 0x170 iirc)

What you're talkin' about is a ultraDMA transfer. It is indeed possible, but you have to program the BusMAster (PCI device) for your controller first so that it can get the data from the controller and write them properly to the memory...
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:ATA/IDE Disk Drivers

Post by Pype.Clicker »

I suggest you get a look at the 'disk' page of OSD:

It has plenty of good stuff, including code snippets to detect ATA drives and points towards a very interresting page (http://www.stanford.edu/~csapuntz/ide.html) which has reference documents for busmastering, afaik.
DennisCGc

Re:ATA/IDE Disk Drivers

Post by DennisCGc »

Jim wrote: What offset gives the drive the memory location to load to? (or is there something special that has to be done?)

Jim.
You decide where it goes, in pio mode you can decide in the interrupt handler where the data would go.
After all, the interrupt handler reads the data from disk, and place it in memory.
When using DMA, you have to program it when setting up DMA.
Post Reply