⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpipe.hpp

📁 wince4.2 usb host driver for magic eye mmsp2 platform
💻 HPP
📖 第 1 页 / 共 2 页
字号:

private:
    // ****************************************************
    // Private Functions for CPipe
    // ****************************************************
    // Private instance variables
    UCHAR m_private_address;    // maintains the USB address of this pipe's device
                                //  (default zero; settable once during enumeration)

protected:
    // ****************************************************
    // Protected Functions for CPipe
    // ****************************************************
#ifdef DEBUG
    virtual const TCHAR*  GetPipeType( void ) const = 0;
#endif // DEBUG

    virtual const int     GetTdSize( void ) const = 0;

    virtual USHORT  GetNumTDsNeeded( const STransfer *pTransfer = NULL ) const = 0;

    virtual BOOL    AreTransferParametersValid( const STransfer *pTransfer = NULL ) const = 0;

    virtual DWORD   GetMemoryAllocationFlags( void ) const;

    virtual HCD_REQUEST_STATUS  ScheduleTransfer( void ) = 0;

    virtual HCD_REQUEST_STATUS  AddTransfer( STransfer *pTransfer )
        // The default defn simply disallows the queueing of multiple transfers.
        { /* compiler wants this referenced: */ (void) pTransfer;
          return m_fTransferInProgress ? requestFailed : requestOK; };

    virtual BOOL    CheckForDoneTransfers( void ) = 0;

    void            FreeTransferMemory( STransfer *pTransfer = NULL );

    virtual ULONG * GetListHead( IN const BOOL fEnable ) = 0;

    void     InitializeTD( OUT P_TD const pTD,
                                  IN       STransfer *pTransfer,
                              IN const P_TD vaNextTD,
                              IN const UCHAR InterruptOnComplete,
                              IN const UCHAR Isochronous,
                              IN const BOOL  LowSpeedControl,
                              IN const DWORD PID,
                              IN const UCHAR Address,
                              IN const UCHAR Endpoint,
                              IN const USHORT DataToggle,
                              IN const DWORD paBuffer,
                              IN const DWORD MaxLength,
                              IN const BOOL bShortPacketOk = FALSE);

    CUhcd * const m_pCUhcd;
    
    inline ULONG GetQHPhysAddr( IN P_ED virtAddr );

    inline ULONG GetTDPhysAddr( IN const P_TD virtAddr ) ;

    inline ULONG GetTDPhysAddr( IN const P_ITD 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 );

    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)

    // 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( IN const LPCUSB_ENDPOINT_DESCRIPTOR lpEndpointDescriptor,
                 IN const BOOL fIsLowSpeed,
                 IN const UCHAR bDeviceAddress,
                 IN CUhcd * const pCUhcd);
    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,
               IN CUhcd * const pCUhcd);
    ~CBulkPipe();

    HCD_REQUEST_STATUS    OpenPipe( void );
    // ****************************************************
    // Public variables for CBulkPipe
    // ****************************************************

private:
    // ****************************************************
    // Private Functions for CBulkPipe
    // ****************************************************

#ifdef DEBUG
    const TCHAR*  GetPipeType( void ) const
    {
        return TEXT("Bulk");
    }
#endif // DEBUG
//    USHORT              GetNumTDsNeeded( const STransfer *pTransfer = NULL ) const;

    virtual ULONG * GetListHead( IN const BOOL fEnable );

    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,
                  IN CUhcd * const pCUhcd);
    ~CControlPipe();

    HCD_REQUEST_STATUS  OpenPipe( void );

    void                ChangeMaxPacketSize( IN const USHORT wMaxPacketSize );

    // ****************************************************
    // Public variables for CControlPipe
    // ****************************************************

private:
    // ****************************************************
    // Private Functions for CControlPipe
    // ****************************************************
#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 );

    virtual ULONG * GetListHead( IN const BOOL fEnable );

    // ****************************************************
    // 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,
                    IN CUhcd * const pCUhcd);
    ~CInterruptPipe();

    HCD_REQUEST_STATUS    OpenPipe( void );

    // ****************************************************
    // Public variables for CInterruptPipe
    // ****************************************************

private:
    // ****************************************************
    // Private Functions for CInterruptPipe
    // ****************************************************

#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;

    virtual ULONG * GetListHead( IN const BOOL fEnable );

    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,
                      IN CUhcd * const pCUhcd);
    ~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
    // ****************************************************

#ifdef DEBUG
    const TCHAR*  GetPipeType( void ) const
    {
        static const TCHAR* cszPipeType = TEXT("Isochronous");
        return cszPipeType;
    }
#endif // DEBUG

    USHORT              GetNumTDsNeeded( const STransfer *pTransfer = NULL ) const;

    virtual ULONG * GetListHead( IN const BOOL fEnable );

    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 );

    // ****************************************************
    // 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 + -