I try to read a sector from the CD. after sending a packet unit sets BSY bit and does not clear. I suspect has an otherwise malformed packet, but do not know where the error is.
Code: Select all
mov edi, packetCommand
xor eax, eax
mov ecx, 12
rep stosb
mov [packetCommand], byte 0xA8
mov dword [packetCommand+2], 10000000h ;16th sector
mov dword [packetCommand+6], 01000000h ;1 sectors to read
mov [packetSize], 12 ;packet size is 12 bytes
call sendDataPacket
Code: Select all
sendDataPacket:
pusha
mov [ATAFeatures],0
mov [ATASectorsCount],0
mov [ATASectorNumber],
mov AX,[CDBlockSize]
mov [ATACylinder],AX
mov [ATAHead],0
mov [ATACommand],0A0h
call sendCommandToHDD
cmp [devErrorCode],0 ;
jne .error
xor eax, eax
mov al, [channel]
shl eax, 2
mov dx, [basePort+eax]
add dx, 7
mov ecx, 0xFFF
@@:
dec ecx
jz .error
in AL,DX
test AL,80h ;BSY
jnz @b
test AL,1 ;ERR
jnz @b
test AL,08h ; DRQ
jz @b
sub dx, 7
movzx ecx, [packetSize]
shr ecx, 1
mov esi, packetCommand
xchg bx, bx
@@:
rep outsw
add dx, 7
mov ecx, 0xFFF
@@:
dec ecx
jz .error
in AL,DX ;device returns 0xD
test AL,80h ;BSY
jnz @b
test AL,1 ;ERR
jnz @b
test AL,08h ;DRQ
jz @b
mov edi, CDDataBuf
movzx ecx, [CDBlockSize]
shr ecx, 1
rep insw
mov [devErrorCode], 0
popa
ret
.error:
mov [devErrorCode], 1
popa
ret