I have been trying to find information on communicating with the IDE/ATA controller to access the hard drive. I have googled it to death and have looked on OS sites but still can't find the information. I have found bits and pieces but it is hard to put together. I was wondering if any of you know of a good site that explains it. I have found sites that state the registers and the commands but I don't know how that maps into the I/O memory location. Also, once it is there how do you let the hard drive know you're ready for it to look at the memory and do what was commanded? Obviously I am not talking about BIOS Int 13 and I don't want to use BIOS. I want to directly talk to the hard drive/controller.
Any help is greatly appreciated.
etollerson
Communicating with hard drive
I AM GO TO LET YOU IN TO A BIG SECRET
Hdd is a piece of p**s, but no where will tell you this, as they want you to think they are clever .
Now the harder part is the FAT part, not the hdd part.
Let say we want to load 512 byte from the primary device
We do this
Then the code to read from hdd
Now that is the only bit of code that is needed to read from hdd, all the rest is FAT code. I would let you into more SECRET code, but most people like to do it the hard way .
Hdd is a piece of p**s, but no where will tell you this, as they want you to think they are clever .
Now the harder part is the FAT part, not the hdd part.
Let say we want to load 512 byte from the primary device
We do this
Code: Select all
hdbase1 equ 0x1f0 ; 0x1f0 for primary device
hdid equ 0x00 ; 0x00 for master hd
Code: Select all
;====================================================;
; hd_read. ;
;====================================================;
HddRead: ; eax block to read
pushad
push eax
newhdread:
mov edx,[hdbase1]
inc edx
mov al,0
out dx,al
inc edx
mov al,1
out dx,al
inc edx
pop ax
out dx,al
inc edx
shr ax,8
out dx,al
inc edx
pop ax
out dx,al
inc edx
shr ax,8
and al,1+2+4+8
add al,[hdid1]
add al,128+64+32
out dx,al
inc edx
mov al,20h
out dx,al
hddwait:
in al,dx
test al,128
jnz hddwait
mov edi,HddBuffer
mov ecx,256
mov edx,[hdbase1]
cld
rep insw
popad
ret
best site ive found, is www.ata-atapi.com -- it contains all the information about the ATA specification, and code samples, and links to the actual docs
-
- Posts: 2
- Joined: Sun Oct 29, 2006 1:06 pm
Thanks Dex, I had no idea that it was that easy. Now I will have to look into DMA even though I don't know if it is worth it. I finally put in some good search terms that yielded usable results. Through this forum I have found good links about ATA. It seems that talking to the CD-ROM is a real pain, but I am not concerned about that right now.
Also thanks to JAAman fo posting the web site. I also found that when looking earlier today.
Also thanks to JAAman fo posting the web site. I also found that when looking earlier today.
http://www.t13.org/docs2004/d1532v1r4b-ATA-ATAPI-7.pdf
That is the official ATA-ATAPI 7 specs. Its not too hard to follow.
I was able to code a working ata driver using that primarily, and looking at a few examples from other kernels.
That is the official ATA-ATAPI 7 specs. Its not too hard to follow.
I was able to code a working ata driver using that primarily, and looking at a few examples from other kernels.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
i strongly encourage anyone willing to run tests with HDDs to print and walk through the code offered (yep, that's PD code) on www.ata-atapi.com. It has it all: PIO, DMA and UDMA mode, for both ATA disks and ATAPI cdroms ... not so sure about SATA/SATAPI support, though.