Data recovery and disk repair questions and discussions related to old-fashioned SATA, SAS, SCSI, IDE, MFM hard drives - any type of storage device that has moving parts
August 9th, 2014, 1:48
The majority of programmers seem to check if data is ready only once per sector, like in the first example. But is it safe? Shouldn't we check for DRDY every time we read a word from the Data Register, like in the second example?
--------------------------------------------------------------------------------------------------------------------------------------------
[READ SECTORS ATA command]
[...]
mov BX, 120d ;Read 120 sectors.
L120:
mov CX, 256d ;1 sector = 256 words.
WaitForNotBusyAndDRDY ;The majority of programmers seem to check if data is ready only once per sector. But is it safe?
L256:
in AX, DX
loop L256
dec BX
cmp BX, 0
jne L120
--------------------------------------------------------------------------------------------------------------------------------------------
[READ SECTORS ATA command]
[...]
mov BX, 120d ;Read 120 sectors.
L120:
mov CX, 256d ;1 sector = 256 words.
L256:
WaitForNotBusyAndDRDY ;Shouldn't programmers check if data is ready once per word?
in AX, DX
loop L256
dec BX
cmp BX, 0
jne L120
--------------------------------------------------------------------------------------------------------------------------------------------
August 9th, 2014, 11:06
I programmed only apps for CD Roms, so I am not sure if i am right and it might be different for current HDDs.
If you use Read Sector, HDD should have buffer where it stores data, after HDD loads data in buffer, it should set DRQ and you should transfer one sector safely without checking DRQ.
I hope i am right, but wait for somebody who is 100 % sure with his answer

EDIT: oh wait you are asking for DRDY not DRQ

I have to do small research i forgot how it works exactly
August 9th, 2014, 12:45
That's correct, my question is not about DRQ, it's about "Device Ready" (DRDY). Let me modify the examples to get DRQ out of the picture:
--------------------------------------------------------------------------------------------------------------------------------------------
[READ SECTORS ATA command]
[...]
mov BX, 120d ;Read 120 sectors.
WaitForNotBusyAndDRDYandDRQ
L120:
mov CX, 256d ;1 sector = 256 words.
WaitForNotBusyAndDRDY ;The majority of programmers seem to check if device is ready (DRDY bit set to 1) only once per sector. But is it safe?
L256:
in AX, DX
loop L256
dec BX
cmp BX, 0
jne L120
--------------------------------------------------------------------------------------------------------------------------------------------
[READ SECTORS ATA command]
[...]
mov BX, 120d ;Read 120 sectors.
WaitForNotBusyAndDRDYandDRQ
L120:
mov CX, 256d ;1 sector = 256 words.
L256:
WaitForNotBusyAndDRDY ;Shouldn't programmers check if device is ready (DRDY bit set to 1) once per word?
in AX, DX
loop L256
dec BX
cmp BX, 0
jne L120
--------------------------------------------------------------------------------------------------------------------------------------------
August 9th, 2014, 14:26
It is safe to check for ready once per sector.
August 13th, 2014, 4:10
> It is safe to check for ready once per sector.
Could you elaborate a little, Doomer? Because the reasoning statement or a prooflink is absent.
TY
August 13th, 2014, 10:28
It's based on my experience with drives.
Powered by phpBB © phpBB Group.