📄 usb.h
字号:
struct _URB_CONTROL_GET_STATUS_REQUEST {
struct _URB_HEADER Hdr; // function code indicates get or set.
PVOID Reserved;
ULONG Reserved0;
ULONG TransferBufferLength;
PVOID TransferBuffer;
PMDL TransferBufferMDL; // *optional*
struct _URB *UrbLink; // *optional* link to next urb request
// if this is a chain of commands
struct _URB_HCD_AREA hca; // fields for HCD use
UCHAR Reserved1[4];
USHORT Index; // zero, interface or endpoint
USHORT Reserved2;
};
// SET_FEATURE
// CLEAR_FEATURE
struct _URB_CONTROL_FEATURE_REQUEST {
struct _URB_HEADER Hdr; // function code indicates get or set.
PVOID Reserved;
ULONG Reserved2;
ULONG Reserved3;
PVOID Reserved4;
PMDL Reserved5;
struct _URB *UrbLink; // *optional* link to next urb request
// if this is a chain of commands
struct _URB_HCD_AREA hca; // fields for HCD use
USHORT Reserved0;
USHORT FeatureSelector;
USHORT Index; // zero, interface or endpoint
USHORT Reserved1;
};
// VENDOR & CLASS
struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST {
struct _URB_HEADER Hdr; // function code indicates get or set.
PVOID Reserved;
ULONG TransferFlags;
ULONG TransferBufferLength;
PVOID TransferBuffer;
PMDL TransferBufferMDL; // *optional*
struct _URB *UrbLink; // *optional* link to next urb request
// if this is a chain of commands
struct _URB_HCD_AREA hca; // fields for HCD use
UCHAR RequestTypeReservedBits;
UCHAR Request;
USHORT Value;
USHORT Index;
USHORT Reserved1;
};
struct _URB_CONTROL_GET_INTERFACE_REQUEST {
struct _URB_HEADER Hdr; // function code indicates get or set.
PVOID Reserved;
ULONG Reserved0;
ULONG TransferBufferLength;
PVOID TransferBuffer;
PMDL TransferBufferMDL; // *optional*
struct _URB *UrbLink; // *optional* link to next urb request
// if this is a chain of commands
struct _URB_HCD_AREA hca; // fields for HCD use
UCHAR Reserved1[4];
USHORT Interface;
USHORT Reserved2;
};
struct _URB_CONTROL_GET_CONFIGURATION_REQUEST {
struct _URB_HEADER Hdr; // function code indicates get or set.
PVOID Reserved;
ULONG Reserved0;
ULONG TransferBufferLength;
PVOID TransferBuffer;
PMDL TransferBufferMDL; // *optional*
struct _URB *UrbLink; // *optional* link to next urb request
// if this is a chain of commands
struct _URB_HCD_AREA hca; // fields for HCD use
UCHAR Reserved1[8];
};
// Microsoft OS Descriptor APIs
#define OS_STRING_DESCRIPTOR_INDEX 0xEE
#define MS_GENRE_DESCRIPTOR_INDEX 0x0001
#define MS_POWER_DESCRIPTOR_INDEX 0x0002
#define MS_OS_STRING_SIGNATURE L"MSFT100"
typedef struct _OS_STRING {
UCHAR bLength;
UCHAR bDescriptorType;
WCHAR MicrosoftString[7];
UCHAR bVendorCode;
UCHAR bPad;
} OS_STRING, *POS_STRING;
struct _URB_OS_FEATURE_DESCRIPTOR_REQUEST {
struct _URB_HEADER Hdr; // function code indicates get or set.
PVOID Reserved;
ULONG Reserved0;
ULONG TransferBufferLength;
PVOID TransferBuffer;
PMDL TransferBufferMDL; // *optional*
struct _URB *UrbLink; // *optional* link to next urb request
// if this is a chain of commands
struct _URB_HCD_AREA hca; // fields for HCD use
USHORT Reserved1; // bmRequest & bRequest
UCHAR InterfaceNumber; // wValue - high byte
UCHAR MS_PageIndex; // wValue - low byte
USHORT MS_FeatureDescriptorIndex; // wIndex field
USHORT Reserved2;
};
//
// request format for a control transfer on
// the non-default pipe.
//
struct _URB_CONTROL_TRANSFER {
struct _URB_HEADER Hdr; // function code indicates get or set.
USBD_PIPE_HANDLE PipeHandle;
ULONG TransferFlags;
ULONG TransferBufferLength;
PVOID TransferBuffer;
PMDL TransferBufferMDL; // *optional*
struct _URB *UrbLink; // *optional* link to next urb request
// if this is a chain of commands
struct _URB_HCD_AREA hca; // fields for HCD use
UCHAR SetupPacket[8];
};
struct _URB_BULK_OR_INTERRUPT_TRANSFER {
struct _URB_HEADER Hdr; // function code indicates get or set.
USBD_PIPE_HANDLE PipeHandle;
ULONG TransferFlags; // note: the direction bit will be set by USBD
ULONG TransferBufferLength;
PVOID TransferBuffer;
PMDL TransferBufferMDL; // *optional*
struct _URB *UrbLink; // *optional* link to next urb request
// if this is a chain of commands
struct _URB_HCD_AREA hca; // fields for HCD use
};
//
// ISO Transfer request
//
// TransferBufferMDL must point to a single virtually
// contiguous buffer.
//
// StartFrame - the frame to send/receive the first packet of
// the request.
//
// NumberOfPackets - number of packets to send in this request
//
//
// IsoPacket Array
//
// Input: Offset - offset of the packet from the beginig
// of the client buffer.
// Output: Length - is set to the actual length of the packet
// (For IN transfers).
// Status: error that occurred during transmission or
// reception of the packet.
//
typedef struct _USBD_ISO_PACKET_DESCRIPTOR {
ULONG Offset; // INPUT Offset of the packet from the begining of the
// buffer.
ULONG Length; // OUTPUT length of data received (for in).
// OUTPUT 0 for OUT.
USBD_STATUS Status; // status code for this packet.
} USBD_ISO_PACKET_DESCRIPTOR, *PUSBD_ISO_PACKET_DESCRIPTOR;
struct _URB_ISOCH_TRANSFER {
//
// This block is the same as CommonTransfer
//
struct _URB_HEADER Hdr; // function code indicates get or set.
USBD_PIPE_HANDLE PipeHandle;
ULONG TransferFlags;
ULONG TransferBufferLength;
PVOID TransferBuffer;
PMDL TransferBufferMDL; // *optional*
struct _URB *UrbLink; // *optional* link to next urb request
// if this is a chain of commands
struct _URB_HCD_AREA hca; // fields for HCD use
//
// this block contains transfer fields
// specific to isochronous transfers
//
// 32 bit frame number to begin this transfer on, must be within 1000
// frames of the current USB frame or an error is returned.
// START_ISO_TRANSFER_ASAP flag in transferFlags:
// If this flag is set and no transfers have been submitted
// for the pipe then the transfer will begin on the next frame
// and StartFrame will be updated with the frame number the transfer
// was started on.
// If this flag is set and the pipe has active transfers then
// the transfer will be queued to begin on the frame after the
// last transfer queued is completed.
//
ULONG StartFrame;
// number of packets that make up this request
ULONG NumberOfPackets;
// number of packets that completed with errors
ULONG ErrorCount;
USBD_ISO_PACKET_DESCRIPTOR IsoPacket[1];
};
#if 0
//
// new for USB 2.0
// client is responsible for initailizing all fields
// of the setup packet
// option URB timeout, if nonzero the request will be
// timed out after the speified number of ms and completed
// with USBD_STATUS_TIMEOUT.
struct _URB_TIMEOUT {
ULONG TimeoutValue; // timeout in ms, 0 = no timeout
#ifdef WIN64
ULONG Pad1;
#endif
} URB_TIMEOUT, *PURB_TIMEOUT;
struct _URB_RAW_CONTROL_TRANSFER {
struct _URB_HEADER Hdr; // function code indicates get or set.
USBD_PIPE_HANDLE PipeHandle;
ULONG TransferFlags;
ULONG TransferBufferLength;
PVOID TransferBuffer;
PMDL TransferBufferMDL; // *optional*
PVOID Reservedxxx;
PVOID HcdTransferContext; // usbport context
URB_TIMEOUT UrbTimeout;
PVOID Reservedxxx[5];
struct _URB_HCD_AREA hcaXXX;
USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
};
//optption flags
//
// option_1
// 'safe abort' stall abort if data is data is bieing received for
// the endpoint
XXX_OPTION_1
// option_2
// enable 'throttleing' on this endpoint bulk_opt_2
XXX_OPTION_2
// option_3
// enable short packet/small transfer optimization bulk_opt_1
XXX_OPTION_3
// option_4
// enable 'irpless' interface for this endpoint
struct _URB_SET_PIPE_PARAMETERS {
struct _URB_HEADER Hdr;
USBD_PIPE_HANDLE PipeHandle;
// This is the maximum thruput of the device
// under optimal conditions
// ie if a device can ony supply or receive 64 bytes/ms
// then set this value to 64.
// this is value is used by the operating system to
// optimize the scheduling of transfers.
// It will default to the maximum for the endpoint type
ULONG DeviceMaxThruput;
// Max Packet size for the endpoint this value defaults to
// the endpoint supplied value and may be subsequently changed
// by the driver.
// This parameter may be used to dymically adjust the packet
// size of an endpoint without re-configuring the device or
// interface.
USHORT MaximumPacketSize;
};
struct _URB_GET_PIPE_PARAMETERS {
struct _URB_HEADER Hdr; // function code indicates get or set.
USBD_PIPE_HANDLE PipeHandle;
USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
};
#endif
typedef struct _URB {
union {
struct _URB_HEADER
UrbHeader;
struct _URB_SELECT_INTERFACE
UrbSelectInterface;
struct _URB_SELECT_CONFIGURATION
UrbSelectConfiguration;
struct _URB_PIPE_REQUEST
UrbPipeRequest;
struct _URB_FRAME_LENGTH_CONTROL
UrbFrameLengthControl;
struct _URB_GET_FRAME_LENGTH
UrbGetFrameLength;
struct _URB_SET_FRAME_LENGTH
UrbSetFrameLength;
struct _URB_GET_CURRENT_FRAME_NUMBER
UrbGetCurrentFrameNumber;
struct _URB_CONTROL_TRANSFER
UrbControlTransfer;
struct _URB_BULK_OR_INTERRUPT_TRANSFER
UrbBulkOrInterruptTransfer;
struct _URB_ISOCH_TRANSFER
UrbIsochronousTransfer;
// for standard control transfers on the default pipe
struct _URB_CONTROL_DESCRIPTOR_REQUEST
UrbControlDescriptorRequest;
struct _URB_CONTROL_GET_STATUS_REQUEST
UrbControlGetStatusRequest;
struct _URB_CONTROL_FEATURE_REQUEST
UrbControlFeatureRequest;
struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST
UrbControlVendorClassRequest;
struct _URB_CONTROL_GET_INTERFACE_REQUEST
UrbControlGetInterfaceRequest;
struct _URB_CONTROL_GET_CONFIGURATION_REQUEST
UrbControlGetConfigurationRequest;
struct _URB_OS_FEATURE_DESCRIPTOR_REQUEST
UrbOSFeatureDescriptorRequest;
};
} URB, *PURB;
#endif /* __USB_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -