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

📄 windrvr.h

📁 一个基于windriver开发的
💻 H
📖 第 1 页 / 共 4 页
字号:
    DWORD dwNumEndpoints;
    DWORD dwClass;
    DWORD dwSubClass;
    DWORD dwProtocol;
    DWORD dwIndex;
} WD_USB_INTERFACE_DESC, WD_USB_INTERFACE_DESC_V43;

typedef struct
{
    DWORD dwEndpointAddress;
    DWORD dwAttributes;
    DWORD dwMaxPacketSize;
    DWORD dwInterval;
} WD_USB_ENDPOINT_DESC, WD_USB_ENDPOINT_DESC_V43;

typedef struct
{
    WD_USB_INTERFACE_DESC Interface;
    WD_USB_ENDPOINT_DESC Endpoints[WD_USB_MAX_ENDPOINTS];
} WD_USB_INTERFACE;

typedef struct
{
    DWORD uniqueId;
    DWORD dwConfigurationIndex;
    WD_USB_CONFIG_DESC configuration;
    DWORD dwInterfaceAlternatives;
    WD_USB_INTERFACE Interface[WD_USB_MAX_INTERFACES];
    DWORD dwStatus;  // Configuration status code - see WD_ERROR_CODES enum definition.
                     // WD_USBD_STATUS_SUCCESS for a successful configuration.
} WD_USB_CONFIGURATION, WD_USB_CONFIGURATION_V52;

typedef struct
{
    DWORD   fBusPowered;
    DWORD   dwPorts;              // Number of ports on this hub.
    DWORD   dwCharacteristics;    // Hub Characteristics.
    DWORD   dwPowerOnToPowerGood; // Port power on till power good in 2ms.
    DWORD   dwHubControlCurrent;  // Max current in mA.
} WD_USB_HUB_GENERAL_INFO, WD_USB_HUB_GENERAL_INFO_V43;

#define WD_SINGLE_INTERFACE 0xFFFFFFFF

typedef struct
{
    WD_USB_ID deviceId;
    DWORD dwHubNum; // Unused
    DWORD dwPortNum; // Unused
    DWORD fHub; // Unused
    DWORD fFullSpeed; // Unused
    DWORD dwConfigurationsNum; 
    DWORD deviceAddress; // Unused
    WD_USB_HUB_GENERAL_INFO hubInfo; // Unused
    DWORD deviceClass;  
    DWORD deviceSubClass;      
    DWORD dwInterfaceNum; // For a single device WinDriver sets this
                          // value to WD_SINGLE_INTERFACE
} WD_USB_DEVICE_GENERAL_INFO;

typedef struct
{
    DWORD dwPipes;
    WD_USB_PIPE_INFO Pipe[WD_USB_MAX_PIPE_NUMBER];
} WD_USB_DEVICE_INFO, WD_USB_DEVICE_INFO_V43;

// IOCTL Structures
typedef struct
{
    WD_USB_ID searchId; // If dwVendorId==0 - scan all vendor IDs.
                        // If dwProductId==0 - scan all product IDs.
    DWORD dwDevices;
    DWORD uniqueId[WD_USB_MAX_DEVICE_NUMBER]; // a unique id to identify the device
    WD_USB_DEVICE_GENERAL_INFO deviceGeneralInfo[WD_USB_MAX_DEVICE_NUMBER];
    DWORD dwStatus;     // Scan status code - see WD_ERROR_CODES enum definition.
                        // WD_USBD_STATUS_SUCCESS for a successful scan.
} WD_USB_SCAN_DEVICES, WD_USB_SCAN_DEVICES_V52;

// USB TRANSFER options
enum {
    USB_ISOCH_FULL_PACKETS_ONLY = 0x20,
    
    // The following flags are no longer used beginning with v6.0:
    USB_TRANSFER_HALT = 0x1,
    USB_SHORT_TRANSFER = 0x2,
    USB_FULL_TRANSFER = 0x4,
    USB_ISOCH_ASAP = 0x8,
    USB_ISOCH_RESET = 0x10,
};

// new USB API definitions

typedef PVOID WDU_REGISTER_DEVICES_HANDLE;

#define WDU_ENDPOINT_TYPE_MASK                    0x03

#define WDU_ENDPOINT_DIRECTION_MASK               0x80
// test direction bit in the bEndpointAddress field of
// an endpoint descriptor.
#define WDU_ENDPOINT_DIRECTION_OUT(addr)          (!((addr) & WDU_ENDPOINT_DIRECTION_MASK))
#define WDU_ENDPOINT_DIRECTION_IN(addr)           ((addr) & WDU_ENDPOINT_DIRECTION_MASK)

typedef struct 
{
    UCHAR bLength;
    UCHAR bDescriptorType;
    UCHAR bInterfaceNumber;
    UCHAR bAlternateSetting;
    UCHAR bNumEndpoints;
    UCHAR bInterfaceClass;
    UCHAR bInterfaceSubClass;
    UCHAR bInterfaceProtocol;
    UCHAR iInterface;
} WDU_INTERFACE_DESCRIPTOR;

typedef struct 
{
    UCHAR bLength;
    UCHAR bDescriptorType;
    UCHAR bEndpointAddress;
    UCHAR bmAttributes;
    USHORT wMaxPacketSize;
    UCHAR bInterval;
} WDU_ENDPOINT_DESCRIPTOR;

typedef struct 
{
    UCHAR bLength;
    UCHAR bDescriptorType;
    USHORT wTotalLength;
    UCHAR bNumInterfaces;
    UCHAR bConfigurationValue;
    UCHAR iConfiguration;
    UCHAR bmAttributes;
    UCHAR MaxPower;
} WDU_CONFIGURATION_DESCRIPTOR;

typedef struct 
{
    UCHAR bLength;
    UCHAR bDescriptorType;
    USHORT bcdUSB;
    UCHAR bDeviceClass;
    UCHAR bDeviceSubClass;
    UCHAR bDeviceProtocol;
    UCHAR bMaxPacketSize0;

    USHORT idVendor;
    USHORT idProduct;
    USHORT bcdDevice;
    UCHAR iManufacturer;
    UCHAR iProduct;
    UCHAR iSerialNumber;
    UCHAR bNumConfigurations;
} WDU_DEVICE_DESCRIPTOR;

typedef struct
{
    WDU_INTERFACE_DESCRIPTOR Descriptor;
    WDU_ENDPOINT_DESCRIPTOR *pEndpointDescriptors;
    WDU_PIPE_INFO *pPipes;
} WDU_ALTERNATE_SETTING;

typedef struct
{
    WDU_ALTERNATE_SETTING *pAlternateSettings;
    DWORD dwNumAltSettings;
    WDU_ALTERNATE_SETTING *pActiveAltSetting;
} WDU_INTERFACE;

typedef struct
{
    WDU_CONFIGURATION_DESCRIPTOR Descriptor; 
    DWORD dwNumInterfaces; 
    WDU_INTERFACE *pInterfaces;
} WDU_CONFIGURATION;

typedef struct {
    WDU_DEVICE_DESCRIPTOR Descriptor;
    WDU_PIPE_INFO Pipe0;
    WDU_CONFIGURATION *pConfigs;
    WDU_CONFIGURATION *pActiveConfig;
    WDU_INTERFACE *pActiveInterface;
} WDU_DEVICE;

// note: any devices found matching this table will be controlled by WD
typedef struct
{
    WORD wVendorId;
    WORD wProductId;
    BYTE bDeviceClass;
    BYTE bDeviceSubClass;
    BYTE bInterfaceClass;
    BYTE bInterfaceSubClass;
    BYTE bInterfaceProtocol;
} WDU_MATCH_TABLE;

// IOCTL's parameters

typedef struct 
{
    DWORD dwUniqueID;
    PVOID pBuf;
    DWORD dwBytes;
    DWORD dwOptions;
} WDU_GET_DEVICE_DATA;

typedef struct 
{
    DWORD dwUniqueID;
    DWORD dwInterfaceNum;
    DWORD dwAlternateSetting;
    DWORD dwOptions;
} WDU_SET_INTERFACE;

typedef struct
{
    DWORD dwUniqueID;
    DWORD dwPipeNum;
    DWORD dwOptions;
} WDU_RESET_PIPE;

typedef struct
{
    DWORD dwUniqueID;
    DWORD dwPipeNum;
    DWORD dwOptions;
} WDU_HALT_TRANSFER;

typedef struct
{
    DWORD dwUniqueID;
    DWORD dwPipeNum;    // Pipe number on device.
    DWORD fRead;        // TRUE for read (IN) transfers; FALSE for write (OUT) transfers.
    DWORD dwOptions;    // USB_TRANSFER options:
                        // USB_ISOCH_FULL_PACKETS_ONLY - For isochronous 
                        // transfers only. If set, only full packets will be 
                        // transmitted and the transfer function will return 
                        // when the amount of bytes left to transfer is less 
                        // than the maximum packet size for the pipe (the 
                        // function will return without transmitting the 
                        // remaining bytes).
    PVOID pBuffer;    // Pointer to buffer to read/write.
    DWORD dwBufferSize; // Amount of bytes to transfer.
    DWORD dwBytesTransferred; // Returns the number of bytes actually read/written
    BYTE SetupPacket[8];          // Setup packet for control pipe transfer.
    DWORD dwTimeout;    // Timeout for the transfer in milliseconds. Set to 0 for infinite wait.
} WDU_TRANSFER;

typedef struct
{
    DWORD dwUniqueID;
    UCHAR bType; 
    UCHAR bIndex;
    WORD wLength;
    PVOID pBuffer;
    WORD wLanguage;
} WDU_GET_DESCRIPTOR;


typedef enum {
    WD_STATUS_SUCCESS = 0x0L,
    WD_STATUS_INVALID_WD_HANDLE = 0xffffffffL,
    
    WD_WINDRIVER_STATUS_ERROR = 0x20000000L,

    WD_INVALID_HANDLE = 0x20000001L,
    WD_INVALID_PIPE_NUMBER = 0x20000002L,
    WD_READ_WRITE_CONFLICT = 0x20000003L,    // request to read from an OUT (write) pipe or
                                             // request to write to an IN (read) pipe
    WD_ZERO_PACKET_SIZE = 0x20000004L,       // maximum packet size is zero
    WD_INSUFFICIENT_RESOURCES = 0x20000005L,
    WD_UNKNOWN_PIPE_TYPE = 0x20000006L,
    WD_SYSTEM_INTERNAL_ERROR = 0x20000007L,
    WD_DATA_MISMATCH = 0x20000008L,
    WD_NO_LICENSE = 0x20000009L,
    WD_NOT_IMPLEMENTED = 0x2000000aL,
    WD_KERPLUG_FAILURE = 0x2000000bL,
    WD_FAILED_ENABLING_INTERRUPT = 0x2000000cL,
    WD_INTERRUPT_NOT_ENABLED = 0x2000000dL,
    WD_RESOURCE_OVERLAP = 0x2000000eL,
    WD_DEVICE_NOT_FOUND = 0x2000000fL,
    WD_WRONG_UNIQUE_ID = 0x20000010L,
    WD_OPERATION_ALREADY_DONE = 0x20000011L,
    WD_USB_DESCRIPTOR_ERROR = 0x20000012L,
    WD_SET_CONFIGURATION_FAILED = 0x20000013L,
    WD_CANT_OBTAIN_PDO = 0x20000014L,
    WD_TIME_OUT_EXPIRED = 0x20000015L,
    WD_IRP_CANCELED = 0x20000016L,
    WD_FAILED_USER_MAPPING = 0x20000017L,
    WD_FAILED_KERNEL_MAPPING = 0x20000018L,
    WD_NO_RESOURCES_ON_DEVICE = 0x20000019L,
    WD_NO_EVENTS = 0x2000001aL,
    WD_INVALID_PARAMETER = 0x2000001bL,
    WD_INCORRECT_VERSION = 0x2000001cL,
    WD_TRY_AGAIN = 0x2000001dL,
    WD_WINDRIVER_NOT_FOUND = 0x2000001eL,
// The following statuses are returned by USBD:
    // USBD status types:
    WD_USBD_STATUS_SUCCESS = 0x00000000L,
    WD_USBD_STATUS_PENDING = 0x40000000L,
    WD_USBD_STATUS_ERROR = 0x80000000L,
    WD_USBD_STATUS_HALTED = 0xC0000000L,

    // USBD status codes:
    // NOTE: The following status codes are comprised of one of the status types above and an
    // error code [i.e. 0xXYYYYYYYL - where: X = status type; YYYYYYY = error code].
    // The same error codes may also appear with one of the other status types as well.

    // HC (Host Controller) status codes.
    // [NOTE: These status codes use the WD_USBD_STATUS_HALTED status type]:
    WD_USBD_STATUS_CRC = 0xC0000001L,
    WD_USBD_STATUS_BTSTUFF = 0xC0000002L,
    WD_USBD_STATUS_DATA_TOGGLE_MISMATCH = 0xC0000003L,
    WD_USBD_STATUS_STALL_PID = 0xC0000004L,
    WD_USBD_STATUS_DEV_NOT_RESPONDING = 0xC0000005L,
    WD_USBD_STATUS_PID_CHECK_FAILURE = 0xC0000006L,
    WD_USBD_STATUS_UNEXPECTED_PID = 0xC0000007L,
    WD_USBD_STATUS_DATA_OVERRUN = 0xC0000008L,
    WD_USBD_STATUS_DATA_UNDERRUN = 0xC0000009L,
    WD_USBD_STATUS_RESERVED1 = 0xC000000AL,
    WD_USBD_STATUS_RESERVED2 = 0xC000000BL,
    WD_USBD_STATUS_BUFFER_OVERRUN = 0xC000000CL,
    WD_USBD_STATUS_BUFFER_UNDERRUN = 0xC000000DL,
#if defined(WINCE)
    WD_USBD_STATUS_NOT_ACCESSED_ALT = 0xC000000FL,  // HCD maps this to E when encountered 
    WD_USBD_STATUS_NOT_ACCESSED = 0xC000000EL,  
#else
    WD_USBD_STATUS_NOT_ACCESSED = 0xC000000FL,    
#endif
    WD_USBD_STATUS_FIFO = 0xC0000010L,

    WD_USBD_STATUS_ISOCH = 0xC0000100L,
    WD_USBD_STATUS_CANCELED = 0xC0000101L,
    WD_USBD_STATUS_NOT_COMPLETE = 0xC0000103L,
    WD_USBD_STATUS_CLIENT_BUFFER = 0xC0000104L,

    // Returned by HCD (Host Controller Driver) if a transfer is submitted to an endpoint that is
    // stalled:
    WD_USBD_STATUS_ENDPOINT_HALTED = 0xC0000030L,

    // Software status codes
    // [NOTE: The following status codes have only the error bit set]:
    WD_USBD_STATUS_NO_MEMORY = 0x80000100L,
    WD_USBD_STATUS_INVALID_URB_FUNCTION = 0x80000200L,
    WD_USBD_STATUS_INVALID_PARAMETER = 0x80000300L,

    // Returned if client driver attempts to close an endpoint/interface
    // or configuration with outstanding transfers:
    WD_USBD_STATUS_ERROR_BUSY = 0x80000400L,

    // Returned by USBD if it cannot complete a URB request. Typically this
    // will be returned in the URB status field when the Irp is completed
    // with a more specific NT error code. [The Irp statuses are indicated in
    // WinDriver's Monitor Debug Messages (wddebug_gui) tool]:
    WD_USBD_STATUS_REQUEST_FAILED = 0x80000500L,

    WD_USBD_STATUS_INVALID_PIPE_HANDLE = 0x80000600L,

    // Returned when there is not enough bandwidth available
    // to open a requested endpoint:
    WD_USBD_STATUS_NO_BANDWIDTH = 0x80000700L,

    // Generic HC (Host Controller) error:
    WD_USBD_STATUS_INTERNAL_HC_ERROR = 0x80000800L,

    // Returned when a short packet terminates the transfer
    // i.e. USBD_SHORT_TRANSFER_OK bit not set:
    WD_USBD_STATUS_ERROR_SHORT_TRANSFER = 0x80000900L,

    // Returned if the requested start frame is not within
    // USBD_ISO_START_FRAME_RANGE of the current USB frame,
    // NOTE: that the stall bit is set:
    WD_USBD_STATUS_BAD_START_FRAME = 0xC0000A00L,

    // Returned by HCD (Host Controller Driver) if all packets in an iso transfer complete with
    // an error:
    WD_USBD_STATUS_ISOCH_REQUEST_FAILED = 0xC0000B00L,

    // Returned by USBD if the frame length control for a given
    // HC (Host Controller) is already taken by another driver:
    WD_USBD_STATUS_FRAME_CONTROL_OWNED = 0xC0000C00L,

    // Returned by USBD if the caller does not own frame length control and
    // attempts to release or modify the HC frame length:
    WD_USBD_STATUS_FRAME_CONTROL_NOT_OWNED = 0xC0000D00L,
} WD_ERROR_CODES;

typedef struct
{
    DWORD hDevice;      // Handle of USB device to read from or write to.
    DWORD dwPipe;       // Pipe number on device.
    DWORD fRead;        // TRUE for read (IN) transfers; FALSE for write (OUT) transfers.
    DWORD dwOptions;    // USB_TRANSFER options:
                        //    USB_TRANSFER_HALT halts the pervious transfer.
                        //    USB_SHORT_TRANSFER - if set, WD_UsbTransfer() will return
                        //    once a data transfer occurs (within the dwTimeout period),

⌨️ 快捷键说明

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