Das ist für mich kein Problem.Locutus hat geschrieben:Sorry, daß ich diesen alten Thread nochmal rauskrame.
So ein Buch kenne ich leider auch nicht.Kommt das Thema "direkte Programmierung des IDE-Controllers" in der PC Intern-Reihe denn überhaupt vor? Vielleicht bin ich ja komplett auf dem falschen Weg hier...
Kennt jemand ein Buch, was sich generell mit x86-Systemprogrammierung auf diesem Level beschäftigt mit Beispiel-Listings in C?
Gruß,
locutus
Auch kann ich nur mit einem Beispiel-Code in Assembler dienen welches "Annie" schon vor einiger Zeit in die Newsgroup nach "alt.lang.asm" gepostet hat :
http://groups.google.com/group/alt.lang ... 3878c2b45b
(Ich habe den Fehler im Listing (siehe dazu auch die nachfolgende Beiträge) hier bei uns im Code bereits berichtigt.)
Code: Alles auswählen
;
; Read a hard disk sector into our allocated buffer, by
; directly accessing the hard disk at the hardware port level.
;
my_buff db 512 dup 0 ;allocate a storage buffer
;
mov dx,1F6h ;drive and head port
mov al,0A6h ;drive 0, head 6
out dx,al ;send it
mov dx,1F2h ;sector count port
mov al,1 ;read one sector
out dx,al ;send it
mov dx,1F3h ;sector number port
mov al,56 ;read sector 56
out dx,al ;send it
mov dx,1F4h ;cylinder low port
mov al,5 ;cylinder 5
out dx,al ;send it
mov dx,1F5h ;cylinder high port
mov al,0 ;the rest of the cylinder (here, 0)
out dx,al ;send it
mov dx,1F7h ;command port
mov al,20h ;read with retry
out dx,al ;send it
still_going:
in al,dx ;read a byte
test al,8 ;are we ready to proceed yet?
jz still_going ;no, so go again
mov cx,512/2 ;one sector (512 bytes/2 = 256 words)
mov di,offset my_buff ;point DI to our local storage buffer
mov dx,1F0h ;data port - data comes in and out here
more:
in ax,dx ;read a word from the port
mov [di],al ;store first byte in our local buffer
inc di ;bump the buffer pointer
mov [di],ah ;store second byte in our local buffer
inc di ;bump the buffer pointer
loop more ;go again if CX > 0
...
...
[ your code here ]
Edit: Vieleicht ist diese Seite hierbei hilfreich:
http://lateblt.tripod.com/atapi.htm
Dirk