HDReadSector32 proc

pop d.[ebp+#16]

pop d.[ebp+#12] ; Sector Count
pop d.[ebp+#8] ; Sector Number
pop d.[ebp+#4] ; Cylinder
pop d.[ebp] ; Head and drive
pop edi ; Buffer address

push d.[ebp+#16]

mov edx,1f2 ; 1f2
mov eax,[ebp+#12]
out ; Sector Count send.

inc dx ; 1f3
mov eax,[ebp+#8] ; Sector number.
out

inc dx ; Cylinder
mov eax,[ebp+#4]
out
inc dx
mov al,ah
out

inc dx ; 1f6
mov eax,[ebp]
out

inc dx ; 1f7
mov al,#20
out
hdrs32 : ; label for jump
in
test al,8
jnz hdrs32 ; Dont continue until buffer ready

mov ecx,512
mov edx,1f0
rep insb

ret
HDReadSector32 endp



It only give me value -1. Can you try it and tell me whats wrong with it? or maybe a working function ?
Posted on 2003-08-11 22:38:17 by realvampire
I am not certain, but I would look here:
http://board.flatassembler.net/viewtopic.php?t=25
Posted on 2003-08-11 22:44:13 by bitRAKE
Hi,

this works fine (atleast for me :-)

the calculation of cylinder head and sector from LBA needs
some drive metric information which needs to be gathered first.

but as long as you ask to read a only sector ..


DEV_IDE0 equ 01F0h
DEV_IDE1 equ 0170h
DEV_IDE2 equ 01E8h
DEV_IDE3 equ 0168h


ioReadHardDrive PROC USES edi esi, lpBuffer:DWORD, dwLba:DWORD
LOCAL dwSect:DWORD, dwCyl:DWORD, dwHead:DWORD

mov esi, DEV_IDE0

mov dwCyl, 0
mov dwSect, 1
mov dwHead, 0

mov dx, DEV_IDE0 + 6
mov al, 0A0h ; Drive 0, head 0
out dx, al

mov dx, DEV_IDE0 + 2
mov al, 1 ; Read one sector
out dx, al

mov dx, DEV_IDE0 + 3
mov eax, dwSect
out dx, al

mov dx, DEV_IDE0 + 4
mov al, 0 ; cylinder 0 low
out dx, al

mov dx, DEV_IDE0 + 5
mov al, 0 ; cylinder 0 high
out dx, al

mov dx, DEV_IDE0 + 7
mov al, 20h ; read with retry
out dx, al

irhdLoop: in al, dx
test al, 8
jz irhdLoop

mov cx, 512 / 2
mov edi, lpBuffer
mov dx, DEV_IDE0
rep insw

ret


Bye Miracle
Posted on 2003-08-19 04:26:10 by miracle
I see there are 4 Port for IDE control. But my HD size is 20GB. 4 port can only read to max 4GB. How to handle the rest?
Posted on 2003-11-17 22:46:47 by realvampire
i think its 4 ports because you can only have 4 ide devices on the standard motherboard (without getting extra ide cards etc that is), so i dont think the
ports limit it to 4gig, rather its the fat system that limits the size
fat32 limit is 4gig, and from the code i see cylinders ,heads, sector format is used and
its a dword, which would imply that 4gig is definately not a limit for it

then again i might be wrong ;)
Posted on 2003-11-17 23:14:37 by evlncrn8
You are right. It worst, 1 port only for 8 MB. 4 Port only for handle 32MB. How we access the rest?
Posted on 2003-11-18 00:36:22 by realvampire
cant be, cos the c/h/s along with the lba should allow for more than that, afterall its what the bios uses isnt it
Posted on 2003-11-18 00:38:34 by evlncrn8

cant be, cos the c/h/s along with the lba should allow for more than that, afterall its what the bios uses isnt it


You're Right.
; Tech Info.
; HDReadSector, Only read a Sector.
; 1 Port Handle : 2 Drive
; 1 Drive Handle : 2097152 sector (8 Head,1024 cylinder,255 Sector)
; 1 Sector Handle : 512-Bytes.
; 1 Port handle : 1,073,741,824 (1-GB) * 2 = 2 GB
:o , Mis Calculate.
Posted on 2003-11-18 08:21:23 by realvampire
Realvampire,

You seem to ignore that modern hardware is able to expose a series of internal registers and/or stack with complex logic just behind a single 8bit port

For example i could send:
1) an command_byte1 THEN
2) addres_byte1 THEN
3)an address byte_2 and THEN
4)address_byte3
...and so on... ALL to the same 8bit port.

And the hardware's internal logic will know what to do with them and how to reassemble them in the needed order.

Of course above is hypotetical but i am pretty sure the "old" 8272 FDC controller works this way; ie. using just a single status 8 bits port to receive up to 8 succesive command bytes/description and a extra data port for sector bytes in/out

HDD controllers also might work this way ... and many other controllers actually ...

So the number of ports and their size is not always relevant, well at least not in such simple ways... instead you must study and understand EACH hardware port description and usage recommended by producer and/or any standards available
Posted on 2003-11-18 18:25:55 by BogdanOntanu