| HDD GURU FORUMS http://forum.hddguru.com/ |
|
| how to use SATA software reset command? (PIO) http://forum.hddguru.com/viewtopic.php?f=7&t=22533 |
Page 1 of 1 |
| Author: | corner [ March 30th, 2012, 4:47 ] |
| Post subject: | how to use SATA software reset command? (PIO) |
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: 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. |
|
| Author: | guru [ March 30th, 2012, 6:02 ] |
| Post subject: | Re: how to use SATA software reset command? (PIO) |
Hi, Don't have time but take look here http://www.serialata.org/documents/SATA ... rs_000.pdf |
|
| Author: | corner [ March 30th, 2012, 21:37 ] |
| Post subject: | Re: how to use SATA software reset command? (PIO) |
guru wrote: I read this document, just found out the intruduction of SStatus, the SStatus-Register looks like part of SCR-Register(It saids SCR0). However, Which Register I polling is Shadow-Status-Register. Thank you anyway. |
|
| Author: | corner [ March 30th, 2012, 22:53 ] |
| Post subject: | Re: how to use SATA software reset command? (PIO) |
I got it !! Detail here: http://wiki.osdev.org/ATA_PIO_Mode#IDENTIFY_command part of explantion wrote: summary: Resetting a drive / Software Reset For non-ATAPI drives, the only method a driver has of resetting a drive after a major error is to do a "software reset" on the bus. Set bit 2 (SRST, value = 4) in the proper Control Register for the bus. This will reset both ATA devices on the bus. Then, you have to clear that bit again, yourself. The master drive on the bus is automatically selected. ATAPI drives set values on their LBA_LOW and LBA_HIGH IO ports, but are not supposed to reset or even terminate their current command. Hope this could help someone who got the same perplexity like me. |
|
| Author: | corner [ March 30th, 2012, 23:34 ] |
| Post subject: | Re: how to use SATA software reset command? (PIO) |
By the words: 1. The Shadow-Status-Register of SATA-Controller is similar to Status-Register of PATA, just a different name. 2. The Shadow-Status-Register is a 8-bit Register, If you use it with a 16-bit instruction(like "in ax, 0x1F7") the result maybe uncertainty.(If the incorrect instruction executed under VMWare-Guest-OS, the VMWare will stop itself, you can verify this situation.) Share my experience of SATA study. |
|
| Page 1 of 1 | All times are UTC - 5 hours [ DST ] |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|