📄 cuhcd.cpp
字号:
lpPipeIndex ) );
}
LeaveCriticalSection( &m_csHCLock );
DEBUGMSG(ZONE_UHCD, (TEXT("-CUhcd::OpenPipe for address %d, returning BOOL %d\n"), address, fSuccess ));
return fSuccess;
}
// ******************************************************************
BOOL CUhcd::ClosePipe( IN UINT address,
IN UINT pipeIndex )
//
// Purpose: Close the logical communication pipe to this device's endpoint
//
// Parameters: address - address of device to close pipe for
//
// pipeIndex - indicating index of pipe to close
//
// Returns: TRUE if call to m_pCRootHub succeeds, else FALSE
//
// Notes: This needs to be implemented for HCDI
// ******************************************************************
{
DEBUGMSG( ZONE_UHCD, (TEXT("+CUhcd::ClosePipe - address = %d, pipeIndex = %d\n"), address, pipeIndex) );
BOOL fSuccess = FALSE;
EnterCriticalSection( &m_csHCLock );
CRootHub *pRoot = m_pCRootHub;
if (pRoot != NULL)
fSuccess = (requestOK == pRoot->ClosePipe( address, pipeIndex ) );
LeaveCriticalSection( &m_csHCLock );
DEBUGMSG( ZONE_UHCD, (TEXT("-CUhcd::ClosePipe - address = %d, pipeIndex = %d, returning BOOL %d\n"), address, pipeIndex, fSuccess) );
return fSuccess;
}
// ******************************************************************
BOOL CUhcd::IssueTransfer( IN UINT address,
IN UINT pipeIndex,
IN LPTRANSFER_NOTIFY_ROUTINE lpStartAddress,
IN LPVOID lpvNotifyParameter,
IN DWORD dwFlags,
IN LPCVOID lpvControlHeader,
IN DWORD dwStartingFrame,
IN DWORD dwFrames,
IN LPCDWORD aLengths,
IN DWORD dwBufferSize,
IN_OUT LPVOID lpvBuffer,
IN ULONG paBuffer,
IN LPCVOID lpvCancelId,
OUT LPDWORD adwIsochErrors,
OUT LPDWORD adwIsochLengths,
OUT LPBOOL lpfComplete,
OUT LPDWORD lpdwBytesTransfered,
OUT LPDWORD lpdwError )
// Purpose: Issue a USB transfer
//
// Parameters: address - address of device
//
// pipeIndex - index of pipe to issue transfer on (NOT the endpoint address)
//
// lpStartAddress - ptr to function to callback when transfer completes
// (this can be NULL)
//
// lpvNotifyParameter - parameter to pass to lpStartAddress in callback
//
// dwFlags - combination of
// USB_IN_TRANSFER
// USB_OUT_TRANSFER
// USB_NO_WAIT
// USB_SHORT_TRANSFER_OK
// USB_START_ISOCH_ASAP
// USB_COMPRESS_ISOCH
// USB_SEND_TO_DEVICE
// USB_SEND_TO_INTERFACE
// USB_SEND_TO_ENDPOINT
// USB_DONT_BLOCK_FOR_MEM
// defined in usbtypes.h
//
// lpvControlHeader - for control transfers, a pointer to the
// USB_DEVICE_REQUEST structure
//
//
// dwStartingFrame - for Isoch transfers, this indicates the
// first frame of the transfer. If the
// USB_START_ISOCH_ASAP flag is set in
// dwFlags, the dwStartingFrame is ignored
// and the transfer is scheduled As Soon
// As Possible
//
// dwFrames - indicates over how many frames to conduct this
// Isochronous transfer. Also should be the # of
// entries in aLengths, adwIsochErrors, adwIsochLengths
//
//
// aLengths - array of dwFrames long. aLengths[i] is how much
// isoch data to transfer in the i'th frame. The
// sum of all entries should be dwBufferSize
//
// dwBufferSize - size of data buffer passed in lpvBuffer
//
// lpvBuffer - data buffer (may be NULL)
//
// paBuffer - physical address of data buffer (may be 0)
//
// lpvCancelId - identifier used to refer to this transfer
// in case it needs to be canceled later
//
// adwIsochErrors - array of dwFrames long. adwIsochErrors[ i ]
// is set on transfer complete to be the status
// of the i'th frame of the isoch transfer
//
// adwIsochLengths - array of dwFrames long. adwIsochLengths[ i ]
// is set on transfer complete to be the amount
// of data transferred in the i'th frame of
// the isoch transfer
//
// lpfComplete - pointer to BOOL indicating TRUE/FALSE on
// whether this transfer is complete
//
// lpdwBytesTransfered - pointer to DWORD indicating total # of
// bytes successfully transferred
//
// lpdwError - pointer to DWORD set to error status on
// transfer complete
//
// Returns: TRUE if transfer scheduled ok, otherwise FALSE
//
// Notes: This needs to be implemented for HCDI
// ******************************************************************
{
DEBUGMSG( ZONE_UHCD | ZONE_TRANSFER, (TEXT("+CUhcd::IssueTransfer - address = %d, pipe = %d, dwFlags = 0x%x, lpvControlHeader = 0x%x, lpvBuffer = 0x%x (pa=%08x), dwBufferSize = %d\n"), address, pipeIndex, dwFlags, lpvControlHeader, lpvBuffer, paBuffer, dwBufferSize));
BOOL fSuccess = FALSE;
EnterCriticalSection( &m_csHCLock );
CRootHub *pRoot = m_pCRootHub;
if (pRoot != NULL) {
fSuccess = (requestOK == pRoot->IssueTransfer(
address,
pipeIndex,
lpStartAddress,
lpvNotifyParameter,
dwFlags,
lpvControlHeader,
dwStartingFrame,
dwFrames,
aLengths,
dwBufferSize,
lpvBuffer,
paBuffer,
lpvCancelId,
adwIsochErrors,
adwIsochLengths,
lpfComplete,
lpdwBytesTransfered,
lpdwError ) );
}
LeaveCriticalSection( &m_csHCLock );
DEBUGMSG( ( ZONE_UHCD && ZONE_VERBOSE ) | ZONE_TRANSFER, (TEXT("-CUhcd::IssueTransfer - returing BOOL %d\n"), fSuccess ) );
return fSuccess;
}
// ******************************************************************
BOOL CUhcd::AbortTransfer( IN UINT address,
IN UINT pipeIndex,
IN LPTRANSFER_NOTIFY_ROUTINE lpCancelAddress,
IN LPVOID lpvNotifyParameter,
IN LPCVOID lpvCancelId )
//
// Purpose: Abort a previously issued transfer
//
// Parameters: address - address of device on which transfer was issued
//
// pipeIndex - index of pipe on which transfer was issued
//
// lpCancelAddress - function to callback when this transfer has aborted
//
// lpvNotifyParameter - parameter to callback lpCancelAddress
//
// lpvCancelId - used to identify the transfer to abort. This was passed
// in when IssueTransfer was called
//
// Returns: TRUE if call to m_pCRootHub succeeds, else FALSE
//
// Notes: This needs to be implemented for HCDI
// ******************************************************************
{
DEBUGMSG( ZONE_UHCD | ZONE_TRANSFER, (TEXT("+CUhcd::AbortTransfer - address = %d, pipeIndex = %d, lpvCancelId = 0x%x\n"), address, pipeIndex, lpvCancelId) );
BOOL fSuccess = FALSE;
EnterCriticalSection( &m_csHCLock );
CRootHub *pRoot = m_pCRootHub;
if (pRoot != NULL)
fSuccess = (requestOK == pRoot->AbortTransfer( address,
pipeIndex,
lpCancelAddress,
lpvNotifyParameter,
lpvCancelId ) );
LeaveCriticalSection( &m_csHCLock );
DEBUGMSG( ZONE_UHCD | ZONE_TRANSFER, (TEXT("-CUhcd::AbortTransfer - address = %d, pipeIndex = %d, returning BOOL %d\n"), address, pipeIndex, fSuccess ) );
return fSuccess;
}
// ******************************************************************
BOOL CUhcd::IsPipeHalted( IN UINT address,
IN UINT pipeIndex,
OUT LPBOOL lpbHalted )
//
// Purpose: Check whether the pipe indicated by address/pipeIndex is
// halted (stalled) and return result in *lpbHalted
//
// Parameters: address - address of device to check pipe for
//
// pipeIndex - indicating index of pipe to check
//
// lpbHalted - out param, indicating TRUE if pipe is halted,
// else FALSE
//
// Returns: TRUE if correct status placed in *lpbHalted, else FALSE
//
// Notes: This needs to be implemented for HCDI
// ******************************************************************
{
DEBUGMSG(ZONE_UHCD && ZONE_VERBOSE,(TEXT("+CUhcd::IsPipeHalted - address = %d, pipeIndex = %d\n"), address, pipeIndex ));
BOOL retval = FALSE;
EnterCriticalSection( &m_csHCLock );
CRootHub *pRoot = m_pCRootHub;
if ( pRoot != NULL && lpbHalted != NULL ) {
retval = ( requestOK == pRoot->IsPipeHalted( address,
pipeIndex,
lpbHalted ) );
}
LeaveCriticalSection( &m_csHCLock );
DEBUGMSG(ZONE_UHCD && ZONE_VERBOSE,(TEXT("-CUhcd::IsPipeHalted - address = %d, pipeIndex = %d, *lpbHalted = %d, retval = %d\n"), address, pipeIndex, ((lpbHalted) ? *lpbHalted : -1), retval ));
return retval;
}
// ******************************************************************
BOOL CUhcd::ResetPipe( IN UINT address,
IN UINT pipeIndex )
//
// Purpose: Reset a stalled pipe on device at address "address"
//
// Parameters: address - address of device to reset pipe for
//
// pipeIndex - indicating index of pipe to check
//
// lpbHalted - out param, indicating TRUE if pipe is halted,
// else FALSE
//
// Returns: TRUE if correct status placed in *lpbHalted, else FALSE
//
// Notes: This needs to be implemented for HCDI
// ******************************************************************
{
DEBUGMSG( ZONE_UHCD, (TEXT("+CUhcd::ResetPipe - address = %d, pipeIndex = %d\n"), address, pipeIndex) );
BOOL fSuccess = FALSE;
EnterCriticalSection( &m_csHCLock );
CRootHub *pRoot = m_pCRootHub;
if (pRoot != NULL)
fSuccess = (requestOK == pRoot->ResetPipe( address, pipeIndex ) );
LeaveCriticalSection( &m_csHCLock );
DEBUGMSG( ZONE_UHCD, (TEXT("-CUhcd::ResetPipe - address = %d, pipeIndex = %d, returning BOOL %d\n"), address, pipeIndex, fSuccess) );
return fSuccess;
}
// ******************************************************************
VOID CUhcd::PowerMgmtCallback( IN BOOL fOff )
//
// Purpose: System power handler - called when device goes into/out of
// suspend.
//
// Parameters: fOff - if TRUE indicates that we're entering suspend,
// else signifies resume
//
// Returns: Nothing
//
// Notes: This needs to be implemented for HCDI
// ******************************************************************
{
if ( fOff )
{
CHW::StopHostController();
}
else
{ // resuming...
g_fPowerUpFlag = TRUE;
SetInterruptEvent(m_dwSysIntr);
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -