BOOL CRomiDisk::WaitForInterrupt( DWORD dwTimeOut ) { BYTE bStatus; BOOL fRet = TRUE; DWORD dwRet; // wait for interrupt dwRet = WaitForSingleObject(m_pPort->m_hIRQEvent, dwTimeOut); if (dwRet == WAIT_TIMEOUT) { fRet = FALSE; } else { if (dwRet != WAIT_OBJECT_0) { if (!WaitForDisc(WAIT_TYPE_DRQ, dwTimeOut, 10)) { fRet = FALSE; } } } // read status; acknowledge interrupt bStatus = GetBaseStatus(); if (bStatus & ATA_STATUS_ERROR) { bStatus = GetError(); fRet = FALSE; } // signal interrupt done InterruptDone(m_pPort->m_dwSysIntr); return fRet; }
BOOL CST202T_SATA::SetLookAhead( ) { BYTE bError = 0; BYTE bStatus = 0; // select device SelectDevice(); // wait for device to acknowledge selection WaitForDisc(WAIT_TYPE_NOT_BUSY, 100); WaitForDisc(WAIT_TYPE_READY, 1000); WaitOnBusy(TRUE); // write command WriteFeature(ATA_ENABLE_LOOKAHEAD); WriteCommand(ATAPI_CMD_SET_FEATURES); // wait for device to respond to command WaitOnBusy(TRUE); WaitForDisc(WAIT_TYPE_NOT_BUSY, 200); // check response bStatus = GetBaseStatus(); bError = GetError(); if ((bStatus & ATA_STATUS_ERROR) && (bError & ATA_ERROR_ABORTED)) { DEBUGMSG(ZONE_ERROR, (_T( "Atapi!CDisk::SetLookAhead> Failed to enable read look-ahead; status(%02X), error(%02X)\r\n" ), bStatus, bError)); ResetController(FALSE); return FALSE; } return TRUE; }
BOOL CST202T_SATA::WaitForInterrupt( DWORD dwTimeOut ) { BOOL fRet = TRUE; DWORD dwRet; static CONST HANDLE lpHandles[] = {m_pPort->m_hErrorEvent, m_pPort->m_hSATAEvent}; static DWORD dwCount = 2; // Wait for the ATA interrupt or an error to occur. dwRet = WaitForMultipleObjects(dwCount, lpHandles, FALSE, dwTimeOut); if (dwRet == WAIT_FAILED) { if (!WaitForDisc(WAIT_TYPE_DRQ, dwTimeOut, 10)) { fRet = FALSE; } } else if (dwRet == WAIT_TIMEOUT) { fRet = FALSE; } else if (dwRet == WAIT_OBJECT_0) { // SATA error condition detected DEBUGMSG(ZONE_IO|ZONE_ERROR, (_T( "Atapi!CST202T_SATA::WaitForInterrupt> SError detected.\r\n" ))); fRet = FALSE; } else // ATA interrupt detected { if (m_pPort->m_bStatus & ATA_STATUS_ERROR) { DEBUGMSG(ZONE_IO|ZONE_ERROR, (_T( "Atapi!CST202T_SATA::WaitForInterrupt> Error detected. Error = 0x%x\r\n" ), GetError())); fRet = FALSE; } } return fRet; }