I write the following code to read two sectors from the hd:
mov dx, 0x172
mov al, 2
out dx, al
mov dx, 0x173
mov al, 0
out dx, al
mov dx, 0x174
mov al, 0
out dx, al
mov dx, 0x175
mov al, 0
out dx, al
mov dx, 0x176
mov al, 00000000b
out dx, al
mov dx, 0x177
mov al, 0x20
out dx, al
Bochs give me the folowing message:
ata1-0: read sectors issued to non-disk
is this correct, i did read the sectors or not?
ata
Re: ata
IIRC, 0x170-0x177 are for 2nd fixed disk controller, Am I right?
Why don't you use 0x1F0-0x1F7?
Why don't you use 0x1F0-0x1F7?
In CHS, Shouldn't sectors start with sector 1?mobruan wrote: mov dx, 0x173
mov al, 0
out dx, al
I think bits 7 and 5 should be 1mobruan wrote: mov dx, 0x176
mov al, 00000000b
out dx, al
Re: ata
well
have you read the wiki ? (http://wiki.osdev.org/ATA_PIO_Mode)
and by the way, you have to know the "drive" number ( i have done some reserch ( played with a real computer), and if the hdd is primary, it is 0, if there is 2 hdds, then the slave is 1. and if there is only 1, but set as slave, it is 1)
3:
here is a example code for reading the first sector ( to read the secound, just increase the "sector count" to 2, and the "mov cx,.../ 2 " to "mov cx, " as this would duble the data amout.
hope it helps ....
KMT dk
have you read the wiki ? (http://wiki.osdev.org/ATA_PIO_Mode)
and by the way, you have to know the "drive" number ( i have done some reserch ( played with a real computer), and if the hdd is primary, it is 0, if there is 2 hdds, then the slave is 1. and if there is only 1, but set as slave, it is 1)
3:
here is a example code for reading the first sector ( to read the secound, just increase the "sector count" to 2, and the "mov cx,.../ 2 " to "mov cx, " as this would duble the data amout.
Code: Select all
read.harddisk:
xor ax,ax
mov ds,ax
mov dx,0x1f6 ;Drive and head port
mov al,[drive] ;Drive 0, head 0
out dx,al
mov dx,0x1f2 ;Sector count port
mov al,1 ;Read one sector
out dx,al
mov dx,0x1f3 ;Sector number port
mov al,1 ;Read sector one
out dx,al
mov dx,0x1f4 ;Cylinder low port
mov al,0 ;Cylinder 0
out dx,al
mov dx,0x1f5 ;Cylinder high port
mov al,0 ;The rest of the cylinder 0
out dx,al
mov dx,0x1f7 ;Command port
mov al,0x20 ;Read with retry.
out dx,al
still_going:
in al,dx
test al,0x8 ;This means the sector buffer requires
;servicing.
jz still_going ;Don't continue until the sector buffer
;is ready.
mov cx,512/2 ;One sector /2
mov di,0x2000
mov ax,0x0000
mov es,ax
mov dx,0x1f0 ;Data port - data comes in and out of here.
rep insw
hope it helps ....
KMT dk
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.


