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

📄 cdevice.hpp

📁 Intel PXA270 Wince5.0 BSP
💻 HPP
📖 第 1 页 / 共 2 页
字号:
                            IN_OUT LPVOID const lpvBuffer,
                            IN const ULONG paBuffer,
                            IN LPCVOID const lpvCancelId,
                            OUT LPDWORD const adwIsochErrors,
                            OUT LPDWORD const adwIsochLengths,
                            OUT LPBOOL const lpfComplete,
                            OUT LPDWORD const lpdwBytesTransfered,
                            OUT LPDWORD const lpdwError );

    HCD_REQUEST_STATUS AbortTransfer( 
                            IN const UINT address,
                            IN const UINT pipeIndex,
                            IN LPTRANSFER_NOTIFY_ROUTINE const lpCancelAddress,
                            IN LPVOID const lpvNotifyParameter,
                            IN LPCVOID const lpvCancelId );

    HCD_REQUEST_STATUS IsPipeHalted( IN const UINT address,
                                     IN const UINT pipeIndex,
                                     OUT LPBOOL const lpbHalted );

    HCD_REQUEST_STATUS ResetPipe( IN const UINT address,
                                  IN const UINT pipeIndex );

#ifdef DEBUG
    static void DumpHubDescriptor( IN const PUSB_HUB_DESCRIPTOR pDescriptor );
#endif // DEBUG

    // ****************************************************
    // Public Variables for CHub
    // ****************************************************

private:
    // ****************************************************
    // Private Functions for CHub
    // ****************************************************

    DWORD HubStatusChangeThread( void );

protected:
    // ****************************************************
    // Protected Functions for CHub
    // ****************************************************
    static DWORD CALLBACK  HubStatusChangeThreadStub( IN PVOID context );

    void AttachDevice( IN const UCHAR port,
                       IN const BOOL fIsLowSpeed );

    BOOL GetDescriptor( IN CControlPipe* const pControlPipe,
                        IN const UCHAR address,
                        IN const UCHAR descriptorType,
                        IN const UCHAR descriptorIndex,
                        IN const USHORT wDescriptorSize,
                        OUT PVOID pBuffer );

    virtual BOOL PowerAllHubPorts( void ) = 0;

    virtual BOOL WaitForPortStatusChange( OUT UCHAR& rPort,
                                          OUT USB_HUB_AND_PORT_STATUS& rStatus ) = 0;

    virtual BOOL  SetOrClearFeature( IN const UCHAR port,
                                     IN const UCHAR setOrClearFeature,
                                     IN const USHORT feature ) = 0;

    virtual BOOL GetStatus( IN const UCHAR port,
                            OUT USB_HUB_AND_PORT_STATUS& rStatus ) = 0;

    virtual BOOL ResetAndEnablePort( IN const UCHAR port ) = 0;

    virtual void DisablePort( IN const UCHAR port ) = 0;


    static DWORD CALLBACK DetachDownstreamDeviceThread( IN PVOID context );
    void DetachDevice( IN const UCHAR port );

    BOOL AllocateDeviceArray( void );

    // ****************************************************
    // Protected Variables for CHub
    // ****************************************************
    USB_HUB_DESCRIPTOR          m_usbHubDescriptor; // the hub's USB descriptor
    CDevice**                   m_ppCDeviceOnPort;  // array of pointers to the devices on this hub's ports
    BOOL                        m_fHubThreadClosing;     // indicates to threads that this device is being closed

    HANDLE                      m_hHubStatusChangeEvent; // indicates status change on one of the hub's ports
    HANDLE                      m_hHubStatusChangeThread; // thread for checking port status change
};

class CRootHub : public CHub
{
public:
    // ****************************************************
    // Public Functions for CRootHub
    // ****************************************************
    CRootHub( IN const USB_DEVICE_INFO& rDeviceInfo,
              IN const BOOL fIsLowSpeed,
              IN const USB_HUB_DESCRIPTOR& rUsbHubDescriptor );

    ~CRootHub();

    BOOL EnterOperationalState( IN CControlPipe* const pEndpoint0Pipe );

    // ****************************************************
    // Public Variables for CRootHub
    // ****************************************************

private:
    // ****************************************************
    // Private Functions for CRootHub
    // ****************************************************
    CRootHub() {}; // default constructor is not callable

    BOOL  SetOrClearFeature( IN const UCHAR port,
                             IN const UCHAR setOrClearFeature,
                             IN const USHORT feature );

    BOOL  GetStatus( IN const UCHAR port,
                     OUT USB_HUB_AND_PORT_STATUS& rStatus );

//#ifdef DEBUG
#if 1
    const TCHAR* GetDeviceType( void ) const
    {
        static const TCHAR* cszDeviceType = TEXT("Root");
        return cszDeviceType;
    }
#endif // DEBUG

    BOOL PowerAllHubPorts( void );

    BOOL WaitForPortStatusChange( OUT UCHAR& rPort,
                                  OUT USB_HUB_AND_PORT_STATUS& rStatus );

    BOOL ResetAndEnablePort( IN const UCHAR port );
     
    void DisablePort( IN const UCHAR port );
};

class CExternalHub : public CHub
{
public:
    // ****************************************************
    // Public Functions for CExternalHub
    // ****************************************************
    CExternalHub( IN const UCHAR address,
                  IN const USB_DEVICE_INFO& rDeviceInfo,
                  IN const BOOL fIsLowSpeed,
                  IN const UCHAR tierNumber,
                  IN const USB_HUB_DESCRIPTOR& rUsbHubDescriptor );

    ~CExternalHub();

    BOOL EnterOperationalState( IN CControlPipe* const pEndpoint0Pipe );

    // ****************************************************
    // Public Variables for CExternalHub
    // ****************************************************

private:
    // ****************************************************
    // Private Functions for CExternalHub
    // ****************************************************
    CExternalHub() {}; // default constructor is not callable

//#ifdef DEBUG
#if 1
    const TCHAR* GetDeviceType( void ) const
    {
        static const TCHAR* cszDeviceType = TEXT("External");
        return cszDeviceType;
    }
#endif // DEBUG

    BOOL  PowerAllHubPorts( void );

    BOOL  GetStatusChangeBitmap( OUT DWORD& rdwHubBitmap );

    BOOL  WaitForPortStatusChange( OUT UCHAR& rPort,
                                   OUT USB_HUB_AND_PORT_STATUS& rStatus );

    BOOL  ResetAndEnablePort( IN const UCHAR port );
     
    void  DisablePort( IN const UCHAR port );

    BOOL  SetOrClearFeature( IN const UCHAR port,
                             IN const UCHAR setOrClearFeature,
                             IN const USHORT feature );

    BOOL  GetStatus( IN const UCHAR port,
                     OUT USB_HUB_AND_PORT_STATUS& rStatus );

    // ****************************************************
    // Private Variables for CExternalHub
    // ****************************************************

};

// class for USB functions (i.e. mice, keyboards, etc)
class CFunction : public CDevice
{
public:
    // ****************************************************
    // Public Functions for CFunction
    // ****************************************************

    CFunction( IN const UCHAR address,
               IN const USB_DEVICE_INFO& rUhcaddress,
               IN const BOOL fIsLowSpeed,
               IN const UCHAR tierNumber );

    ~CFunction();

    BOOL EnterOperationalState( IN CControlPipe* const pEndpoint0Pipe );

    HCD_REQUEST_STATUS OpenPipe( IN const UINT address,
                                 IN LPCUSB_ENDPOINT_DESCRIPTOR const lpEndpointDescriptor,
                                 OUT LPUINT const lpPipeIndex );

    HCD_REQUEST_STATUS ClosePipe( IN const UINT address,
                                  IN const UINT pipeIndex );


    HCD_REQUEST_STATUS IssueTransfer( 
                                IN const UINT address,
                                IN const UINT pipeIndex,
                                IN LPTRANSFER_NOTIFY_ROUTINE const lpStartAddress,
                                IN LPVOID const lpvNotifyParameter,
                                IN const DWORD dwFlags,
                                IN LPCVOID const lpvControlHeader,
                                IN const DWORD dwStartingFrame,
                                IN const DWORD dwFrames,
                                IN LPCDWORD const aLengths,
                                IN const DWORD dwBufferSize,     
                                IN_OUT LPVOID const lpvBuffer,
                                IN const ULONG paBuffer,
                                IN LPCVOID const lpvCancelId,
                                OUT LPDWORD const adwIsochErrors,
                                OUT LPDWORD const adwIsochLengths,
                                OUT LPBOOL const lpfComplete,
                                OUT LPDWORD const lpdwBytesTransfered,
                                OUT LPDWORD const lpdwError );

    HCD_REQUEST_STATUS AbortTransfer( 
                            IN const UINT address,
                            IN const UINT pipeIndex,
                            IN LPTRANSFER_NOTIFY_ROUTINE const lpCancelAddress,
                            IN LPVOID const lpvNotifyParameter,
                            IN LPCVOID const lpvCancelId );

    HCD_REQUEST_STATUS IsPipeHalted( IN const UINT address,
                                     IN const UINT pipeIndex,
                                     OUT LPBOOL const lpbHalted );

    HCD_REQUEST_STATUS ResetPipe( IN const UINT address,
                                  IN const UINT pipeIndex );

    // ****************************************************
    // Public Variables for CFunction
    // ****************************************************

private:
    // ****************************************************
    // Private Functions for CFunction
    // ****************************************************
    CFunction() {} // default constructor is not callable

    void HandleDetach( void );

    BOOL  SetOrClearFeature( IN const UCHAR recipient,
                             IN const WORD wIndex,
                             IN const UCHAR setOrClearFeature,
                             IN const USHORT feature );

//#ifdef DEBUG
#if 1
    const TCHAR* GetDeviceType( void ) const
    {
        static const TCHAR* cszDeviceType = TEXT("Function");
        return cszDeviceType;
    }
#endif // DEBUG

    // ****************************************************
    // Private Variables for CFunction
    // ****************************************************
    PVOID                       m_lpvDetachId;
    HANDLE                      m_hFunctionFeatureEvent; // for blocking on implicit transfers
};
#endif // __CDEVICE_HPP__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -