📄 cpipe.hpp
字号:
return m_pCPhysMem->VaToPa( PUCHAR(virtAddr) );
}
// static void InitializeQH( OUT PUHCD_QH const pQH,
// IN const PUHCD_QH vaPrevQH,
// IN const QUEUE_HEAD_LINK_POINTER_PHYSICAL_ADDRESS HW_paHLink,
// IN const PUHCD_QH vaNextQH );
// Return the index of the m_interruptQHTree that this frame should point to
#define UHCD_MAX_INTERRUPT_INTERVAL 32
static inline UCHAR QHTreeEntry( IN const DWORD frame )
{
DEBUGCHK( frame >= 0 );
// return interval + (frame % interval)
DEBUGCHK( frame % UHCD_MAX_INTERRUPT_INTERVAL == (frame & (UHCD_MAX_INTERRUPT_INTERVAL - 1)) );
return UCHAR( UHCD_MAX_INTERRUPT_INTERVAL + (frame & (UHCD_MAX_INTERRUPT_INTERVAL - 1)) );
}
// ****************************************************
// Protected Variables for CPipe
// ****************************************************
static CPhysMem * m_pCPhysMem; // memory object for our TD/QH and Frame list alloc
// schedule related vars
// static CRITICAL_SECTION m_csFrameListLock; // critical section for frame list
// static PULONG m_vaFrameList; // virtual address of Frame List
static CRITICAL_SECTION m_csQHScheduleLock; // crit sec for QH section of schedule
static P_ED m_interruptQHTree[ 2 * UHCD_MAX_INTERRUPT_INTERVAL ];
// array to keep track of the binary tree containing
// the interrupt queue heads.
static P_ED m_pFinalQH; // final QH in the schedule
// static PUHCD_TD m_pFrameSynchTD; // for keeping the software frame counter in sync
static P_TD m_pDoneHead; // virt ptr to head of [cached] done queue
P_ED m_pED; // virt ptr to OHCI ED for this pipe
TDLINK m_pDummyTd; // virt ptr to valid TD (see OHCI spec section 5.2.8)
#ifdef DEBUG
static int m_debug_TDMemoryAllocated;
static int m_debug_QHMemoryAllocated;
static int m_debug_BufferMemoryAllocated;
static int m_debug_ControlExtraMemoryAllocated;
#endif // DEBUG
// pipe specific variables
CRITICAL_SECTION m_csPipeLock; // crit sec for this specific pipe's variables
USB_ENDPOINT_DESCRIPTOR m_usbEndpointDescriptor; // descriptor for this pipe's endpoint
BOOL m_fIsLowSpeed; // indicates speed of this pipe
BOOL m_fIsHalted; // indicates pipe is halted
BOOL m_fTransferInProgress; // indicates if this pipe is currently executing a transfer
// WARNING! These parameters are treated as a unit. They
// can all be wiped out at once, for example when a
// transfer is aborted.
STransfer m_transfer; // Parameters for transfer on pipe
STransfer * m_pLastTransfer; // ptr to last transfer in queue
};
class CQueuedPipe : public CPipe
{
public:
// ****************************************************
// Public Functions for CQueuedPipe
// ****************************************************
CQueuedPipe() { DEBUGCHK( 0 ); } // should never be called
CQueuedPipe( IN const LPCUSB_ENDPOINT_DESCRIPTOR lpEndpointDescriptor,
IN const BOOL fIsLowSpeed,
IN const UCHAR bDeviceAddress );
virtual ~CQueuedPipe();
inline const int GetTdSize( void ) const { return sizeof(TD); };
HCD_REQUEST_STATUS ClosePipe( void );
HCD_REQUEST_STATUS AbortTransfer(
IN const LPTRANSFER_NOTIFY_ROUTINE lpCancelAddress,
IN const LPVOID lpvNotifyParameter,
IN LPCVOID lpvCancelId );
// ****************************************************
// Public Variables for CQueuedPipe
// ****************************************************
private:
// ****************************************************
// Private Functions for CQueuedPipe
// ****************************************************
void AbortQueue( void );
// ****************************************************
// Private Variables for CQueuedPipe
// ****************************************************
protected:
// ****************************************************
// Protected Functions for CQueuedPipe
// ****************************************************
virtual USHORT GetNumTDsNeeded( const STransfer *pTransfer = NULL ) const;
BOOL CheckForDoneTransfers( void );
virtual void UpdateInterruptQHTreeLoad( IN const UCHAR branch,
IN const int deltaLoad );
// ****************************************************
// Protected Variables for CQueuedPipe
// ****************************************************
BOOL m_fIsReclamationPipe; // indicates if this pipe is participating in bandwidth reclamation
// UCHAR m_dataToggle; // Transfer data toggle.
};
class CBulkPipe : public CQueuedPipe
{
public:
// ****************************************************
// Public Functions for CBulkPipe
// ****************************************************
CBulkPipe( IN const LPCUSB_ENDPOINT_DESCRIPTOR lpEndpointDescriptor,
IN const BOOL fIsLowSpeed,
IN const UCHAR bDeviceAddress );
~CBulkPipe();
HCD_REQUEST_STATUS OpenPipe( void );
// ****************************************************
// Public variables for CBulkPipe
// ****************************************************
private:
// ****************************************************
// Private Functions for CBulkPipe
// ****************************************************
CBulkPipe() {} // default constructor is not callable
#ifdef DEBUG
const TCHAR* GetPipeType( void ) const
{
return TEXT("Bulk");
}
#endif // DEBUG
// USHORT GetNumTDsNeeded( const STransfer *pTransfer = NULL ) const;
inline virtual ULONG * GetListHead( IN const BOOL fEnable ) {
CHW::ListControl(CHW::LIST_BULK, fEnable, FALSE);
return CHW::m_pBulkHead;
};
BOOL AreTransferParametersValid( const STransfer *pTransfer = NULL ) const;
HCD_REQUEST_STATUS ScheduleTransfer( void );
HCD_REQUEST_STATUS AddTransfer( STransfer *pTransfer );
// ****************************************************
// Private variables for CBulkPipe
// ****************************************************
};
class CControlPipe : public CQueuedPipe
{
public:
// ****************************************************
// Public Functions for CControlPipe
// ****************************************************
CControlPipe( IN const LPCUSB_ENDPOINT_DESCRIPTOR lpEndpointDescriptor,
IN const BOOL fIsLowSpeed,
IN const UCHAR bDeviceAddress );
~CControlPipe();
HCD_REQUEST_STATUS OpenPipe( void );
void ChangeMaxPacketSize( IN const USHORT wMaxPacketSize );
// ****************************************************
// Public variables for CControlPipe
// ****************************************************
private:
// ****************************************************
// Private Functions for CControlPipe
// ****************************************************
CControlPipe() {} // default constructor is not callable
#ifdef DEBUG
const TCHAR* GetPipeType( void ) const
{
static const TCHAR* cszPipeType = TEXT("Control");
return cszPipeType;
}
#endif // DEBUG
USHORT GetNumTDsNeeded( const STransfer *pTransfer = NULL ) const;
BOOL AreTransferParametersValid( const STransfer *pTransfer = NULL ) const;
HCD_REQUEST_STATUS ScheduleTransfer( void );
HCD_REQUEST_STATUS AddTransfer( STransfer *pTransfer );
inline virtual ULONG * GetListHead( IN const BOOL fEnable ) {
CHW::ListControl(CHW::LIST_CONTROL, fEnable, FALSE);
return CHW::m_pControlHead;
};
// ****************************************************
// Private variables for CControlPipe
// ****************************************************
};
class CInterruptPipe : public CQueuedPipe
{
public:
// ****************************************************
// Public Functions for CInterruptPipe
// ****************************************************
CInterruptPipe( IN const LPCUSB_ENDPOINT_DESCRIPTOR lpEndpointDescriptor,
IN const BOOL fIsLowSpeed,
IN const UCHAR bDeviceAddress );
~CInterruptPipe();
HCD_REQUEST_STATUS OpenPipe( void );
// ****************************************************
// Public variables for CInterruptPipe
// ****************************************************
private:
// ****************************************************
// Private Functions for CInterruptPipe
// ****************************************************
CInterruptPipe() {} // default constructor is not callable
#ifdef DEBUG
const TCHAR* GetPipeType( void ) const
{
static const TCHAR* cszPipeType = TEXT("Interrupt");
return cszPipeType;
}
#endif // DEBUG
// ComputeLoad caller must already hold the QHSchedule critsec!
int ComputeLoad( IN const int branch ) const;
void UpdateInterruptQHTreeLoad( IN const UCHAR branch,
IN const int deltaLoad );
//USHORT GetNumTDsNeeded( const STransfer *pTransfer = NULL ) const;
inline virtual ULONG * GetListHead( IN const BOOL fEnable ) {
CHW::ListControl(CHW::LIST_INTERRUPT, fEnable, FALSE);
// return the address of the QH beginning the list for this pipe
return &m_interruptQHTree[m_iListHead]->paNextEd;
};
BOOL AreTransferParametersValid( const STransfer *pTransfer = NULL ) const;
HCD_REQUEST_STATUS ScheduleTransfer( void );
HCD_REQUEST_STATUS AddTransfer( STransfer *pTransfer );
// ****************************************************
// Private variables for CInterruptPipe
// ****************************************************
int m_iListHead; // index of the list head for the list on which this pipe resides
};
class CIsochronousPipe : public CPipe
{
public:
// ****************************************************
// Public Functions for CIsochronousPipe
// ****************************************************
CIsochronousPipe( IN const LPCUSB_ENDPOINT_DESCRIPTOR lpEndpointDescriptor,
IN const BOOL fIsLowSpeed,
IN const UCHAR bDeviceAddress );
~CIsochronousPipe();
inline const int GetTdSize( void ) const { return sizeof(ITD); };
HCD_REQUEST_STATUS OpenPipe( void );
HCD_REQUEST_STATUS ClosePipe( void );
HCD_REQUEST_STATUS AbortTransfer(
IN const LPTRANSFER_NOTIFY_ROUTINE lpCancelAddress,
IN const LPVOID lpvNotifyParameter,
IN LPCVOID lpvCancelId );
// ****************************************************
// Public variables for CIsochronousPipe
// ****************************************************
private:
// ****************************************************
// Private Functions for CIsochronousPipe
// ****************************************************
CIsochronousPipe() {} // default constructor is not callable
#ifdef DEBUG
const TCHAR* GetPipeType( void ) const
{
static const TCHAR* cszPipeType = TEXT("Isochronous");
return cszPipeType;
}
#endif // DEBUG
USHORT GetNumTDsNeeded( const STransfer *pTransfer = NULL ) const;
inline virtual ULONG * GetListHead( IN const BOOL fEnable ) {
CHW::ListControl(CHW::LIST_ISOCH, fEnable, FALSE);
return &m_interruptQHTree[0]->paNextEd;
};
BOOL AreTransferParametersValid( const STransfer *pTransfer = NULL ) const;
DWORD GetMemoryAllocationFlags( void ) const;
HCD_REQUEST_STATUS ScheduleTransfer( void );
HCD_REQUEST_STATUS AddTransfer( STransfer *pTransfer );
BOOL CheckForDoneTransfers( void );
static void InsertIsochTDIntoFrameList( IN_OUT TD* pTD,
IN const DWORD dwFrameIndex );
static void RemoveIsochTDFromFrameList( IN_OUT TD* pTD,
IN const DWORD dwFrameIndex );
// ****************************************************
// Private variables for CIsochronousPipe
// ****************************************************
TD* m_pWakeupTD; // TD used to schedule transfers far into future
BOOL m_fUsingWakeupTD; // indicates if m_pWakeupTD is being used
#define ISOCH_TD_WAKEUP_INTERVAL DWORD(50) // wakeup TD will be scheduled this many frames
// before the first real TD should be executed
};
// This is the maximum number of frames of isoch data that can be queued
// successfully. These frames can be in one or more distinct transfers.
#define ISOCH_STREAMING_MAX 60000
#endif // __CPIPE_HPP__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -