how to use SATA software reset command? (PIO)
Posted: March 30th, 2012, 4:47
I've tried to reset SATA-Controller with seting SRST-bit to 1 in Shadow Control Register. While waiting for the BSY-bit in Shadow Status Register be cleared to 0. However, I got 0xD8 everytime I read the Shadow Status Register.
My code follow:
Any info should be appreciated.
My code follow:
- Code:
void software_reset(WORD portCtrl)
{
__asm
{
xor eax, eax
xor edx, edx
mov dx, word ptr[portCtrl]
mov al, _CONTROL_SRST_
out dx, al
}
}
void watch_dog(DWORD* pCount)
{
(*pCount)++;
if((*pCount) >= 0x100000)
{
__asm int 3
(*pCount) = 0;
}
}
void wait_until_ready(WORD portBase)
{
DWORD count = 0;
__asm
{
L_READ:
lea eax, dword ptr[count]
push eax
call watch_dog
mov dx, word ptr[portBase]
xor eax, eax
add dx, 0x7 //status
in al, dx
test al, (_STATUS_BSY_ | _STATUS_DRQ_)
jz L_RET
nop
nop
nop
jmp L_READ
}
L_RET:
__asm int 3
return;
}
void DriverEntry()
{
software_reset(0x3F6);
wait_until_ready(0x1F0);
}
Any info should be appreciated.