ReactOS 0.4.15-dev-8428-g6910fa6
usbdlib.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef DECLSPEC_EXPORT
4#define DECLSPEC_EXPORT __declspec(dllexport)
5#endif
6
11
12#define UsbBuildInterruptOrBulkTransferRequest(urb,length, pipeHandle, transferBuffer, transferBufferMDL, transferBufferLength, transferFlags, link) { \
13 (urb)->UrbHeader.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; \
14 (urb)->UrbHeader.Length = (length); \
15 (urb)->UrbBulkOrInterruptTransfer.PipeHandle = (pipeHandle); \
16 (urb)->UrbBulkOrInterruptTransfer.TransferBufferLength = (transferBufferLength); \
17 (urb)->UrbBulkOrInterruptTransfer.TransferBufferMDL = (transferBufferMDL); \
18 (urb)->UrbBulkOrInterruptTransfer.TransferBuffer = (transferBuffer); \
19 (urb)->UrbBulkOrInterruptTransfer.TransferFlags = (transferFlags); \
20 (urb)->UrbBulkOrInterruptTransfer.UrbLink = (link); \
21}
22
23#define UsbBuildGetDescriptorRequest(urb, length, descriptorType, descriptorIndex, languageId, transferBuffer, transferBufferMDL, transferBufferLength, link) { \
24 (urb)->UrbHeader.Function = URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE; \
25 (urb)->UrbHeader.Length = (length); \
26 (urb)->UrbControlDescriptorRequest.TransferBufferLength = (transferBufferLength); \
27 (urb)->UrbControlDescriptorRequest.TransferBufferMDL = (transferBufferMDL); \
28 (urb)->UrbControlDescriptorRequest.TransferBuffer = (transferBuffer); \
29 (urb)->UrbControlDescriptorRequest.DescriptorType = (descriptorType); \
30 (urb)->UrbControlDescriptorRequest.Index = (descriptorIndex); \
31 (urb)->UrbControlDescriptorRequest.LanguageId = (languageId); \
32 (urb)->UrbControlDescriptorRequest.UrbLink = (link); \
33}
34
35#define UsbBuildGetStatusRequest(urb, op, index, transferBuffer, transferBufferMDL, link) { \
36 (urb)->UrbHeader.Function = (op); \
37 (urb)->UrbHeader.Length = sizeof(struct _URB_CONTROL_GET_STATUS_REQUEST); \
38 (urb)->UrbControlGetStatusRequest.TransferBufferLength = sizeof(USHORT); \
39 (urb)->UrbControlGetStatusRequest.TransferBufferMDL = (transferBufferMDL); \
40 (urb)->UrbControlGetStatusRequest.TransferBuffer = (transferBuffer); \
41 (urb)->UrbControlGetStatusRequest.Index = (index); \
42 (urb)->UrbControlGetStatusRequest.UrbLink = (link); \
43}
44
45#define UsbBuildFeatureRequest(urb, op, featureSelector, index, link) { \
46 (urb)->UrbHeader.Function = (op); \
47 (urb)->UrbHeader.Length = sizeof(struct _URB_CONTROL_FEATURE_REQUEST); \
48 (urb)->UrbControlFeatureRequest.FeatureSelector = (featureSelector); \
49 (urb)->UrbControlFeatureRequest.Index = (index); \
50 (urb)->UrbControlFeatureRequest.UrbLink = (link); \
51}
52
53#define UsbBuildSelectConfigurationRequest(urb, length, configurationDescriptor) { \
54 (urb)->UrbHeader.Function = URB_FUNCTION_SELECT_CONFIGURATION; \
55 (urb)->UrbHeader.Length = (length); \
56 (urb)->UrbSelectConfiguration.ConfigurationDescriptor = (configurationDescriptor); \
57}
58
59#define UsbBuildSelectInterfaceRequest(urb, length, configurationHandle, interfaceNumber, alternateSetting) { \
60 (urb)->UrbHeader.Function = URB_FUNCTION_SELECT_INTERFACE; \
61 (urb)->UrbHeader.Length = (length); \
62 (urb)->UrbSelectInterface.Interface.AlternateSetting = (alternateSetting); \
63 (urb)->UrbSelectInterface.Interface.InterfaceNumber = (interfaceNumber); \
64 (urb)->UrbSelectInterface.Interface.Length = (length - sizeof(struct _URB_HEADER) - sizeof(USBD_CONFIGURATION_HANDLE)); \
65 (urb)->UrbSelectInterface.ConfigurationHandle = (configurationHandle); \
66}
67
68#define UsbBuildVendorRequest(urb, cmd, length, transferFlags, reservedbits, request, value, index, transferBuffer, transferBufferMDL, transferBufferLength, link) { \
69 (urb)->UrbHeader.Function = cmd; \
70 (urb)->UrbHeader.Length = (length); \
71 (urb)->UrbControlVendorClassRequest.TransferBufferLength = (transferBufferLength); \
72 (urb)->UrbControlVendorClassRequest.TransferBufferMDL = (transferBufferMDL); \
73 (urb)->UrbControlVendorClassRequest.TransferBuffer = (transferBuffer); \
74 (urb)->UrbControlVendorClassRequest.RequestTypeReservedBits = (reservedbits); \
75 (urb)->UrbControlVendorClassRequest.Request = (request); \
76 (urb)->UrbControlVendorClassRequest.Value = (value); \
77 (urb)->UrbControlVendorClassRequest.Index = (index); \
78 (urb)->UrbControlVendorClassRequest.TransferFlags = (transferFlags); \
79 (urb)->UrbControlVendorClassRequest.UrbLink = (link); \
80}
81
82#if (NTDDI_VERSION >= NTDDI_WINXP)
83
84#define UsbBuildOsFeatureDescriptorRequest(urb, length, interface, index, transferBuffer, transferBufferMDL, transferBufferLength, link) { \
85 (urb)->UrbHeader.Function = URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR; \
86 (urb)->UrbHeader.Length = (length); \
87 (urb)->UrbOSFeatureDescriptorRequest.TransferBufferLength = (transferBufferLength); \
88 (urb)->UrbOSFeatureDescriptorRequest.TransferBufferMDL = (transferBufferMDL); \
89 (urb)->UrbOSFeatureDescriptorRequest.TransferBuffer = (transferBuffer); \
90 (urb)->UrbOSFeatureDescriptorRequest.InterfaceNumber = (interface); \
91 (urb)->UrbOSFeatureDescriptorRequest.MS_FeatureDescriptorIndex = (index); \
92 (urb)->UrbOSFeatureDescriptorRequest.UrbLink = (link); \
93}
94
95#endif /* NTDDI_VERSION >= NTDDI_WINXP */
96
97#if (NTDDI_VERSION >= NTDDI_VISTA)
98
99#define USBD_CLIENT_CONTRACT_VERSION_INVALID 0xFFFFFFFF
100#define USBD_CLIENT_CONTRACT_VERSION_602 0x602
101
102#define USBD_INTERFACE_VERSION_600 0x600
103#define USBD_INTERFACE_VERSION_602 0x602
104#define USBD_INTERFACE_VERSION_603 0x603
105
106DECLARE_HANDLE(USBD_HANDLE);
107
108#endif // NTDDI_VISTA
109
110#define URB_STATUS(urb) ((urb)->UrbHeader.Status)
111
112#define GET_SELECT_CONFIGURATION_REQUEST_SIZE(totalInterfaces, totalPipes) \
113 (sizeof(struct _URB_SELECT_CONFIGURATION) + \
114 ((totalInterfaces-1) * sizeof(USBD_INTERFACE_INFORMATION)) + \
115 ((totalPipes-totalInterfaces)*sizeof(USBD_PIPE_INFORMATION)))
116
117#define GET_SELECT_INTERFACE_REQUEST_SIZE(totalPipes) \
118 (sizeof(struct _URB_SELECT_INTERFACE) + \
119 ((totalPipes-1)*sizeof(USBD_PIPE_INFORMATION)))
120
121#define GET_USBD_INTERFACE_SIZE(numEndpoints) \
122 (sizeof(USBD_INTERFACE_INFORMATION) + \
123 (sizeof(USBD_PIPE_INFORMATION)*(numEndpoints)) - sizeof(USBD_PIPE_INFORMATION))
124
125#define GET_ISO_URB_SIZE(n) (sizeof(struct _URB_ISOCH_TRANSFER)+ \
126 sizeof(USBD_ISO_PACKET_DESCRIPTOR)*n)
127
128#ifndef _USBD_
129
132VOID
133NTAPI
135 _Out_ PUSBD_VERSION_INFORMATION VersionInformation);
136
139NTAPI
141 _In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
144
146PURB
147NTAPI
149 _In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
150 _Out_ PUSHORT Siz);
151
155NTAPI
161
165NTAPI
167 _In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
174
177PURB
178NTAPI
180 _In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
182
185ULONG
186NTAPI
190
193VOID
194NTAPI
198
202NTAPI
209
212NTAPI
214 _In_ PDEVICE_OBJECT RootHubPdo,
215 _Out_ PULONG CurrentFrame);
216
217#if (NTDDI_VERSION >= NTDDI_WINXP)
218
221ULONG
222NTAPI
224 _In_ ULONG MaxPacketSize,
227
228#endif
229
230#if (NTDDI_VERSION >= NTDDI_VISTA)
231
235NTAPI
236USBD_ValidateConfigurationDescriptor(
242
243#endif
244
245#endif /* ! _USBD_ */
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define _IRQL_requires_max_(irql)
Definition: driverspecs.h:230
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define DECLARE_HANDLE(name)
Definition: mimeole.idl:23
#define _In_reads_bytes_(size)
Definition: ms_sal.h:321
#define _Inout_updates_bytes_(size)
Definition: ms_sal.h:399
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
_In_ UCHAR _Outptr_result_bytebuffer_ DescriptorBufferLength PVOID * DescriptorBuffer
Definition: scsi.h:3884
#define DECLSPEC_IMPORT
Definition: rpc.h:78
Definition: usb.h:529
Definition: usbdlib.h:7
PUSBD_INTERFACE_INFORMATION Interface
Definition: usbdlib.h:9
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: usbdlib.h:8
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
uint16_t * PUSHORT
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
LONG USBD_STATUS
Definition: usb.h:165
PUSB_COMMON_DESCRIPTOR NTAPI USBD_ParseDescriptors(PVOID DescriptorBuffer, ULONG TotalLength, PVOID StartPosition, LONG DescriptorType)
Definition: usbd.c:445
PURB NTAPI USBD_CreateConfigurationRequestEx(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PUSBD_INTERFACE_LIST_ENTRY InterfaceList)
Definition: usbd.c:329
PUSB_INTERFACE_DESCRIPTOR NTAPI USBD_ParseConfigurationDescriptorEx(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PVOID StartPosition, LONG InterfaceNumber, LONG AlternateSetting, LONG InterfaceClass, LONG InterfaceSubClass, LONG InterfaceProtocol)
Definition: usbd.c:496
ULONG NTAPI USBD_CalculateUsbBandwidth(ULONG MaxPacketSize, UCHAR EndpointType, BOOLEAN LowSpeed)
Definition: usbd.c:112
ULONG NTAPI USBD_GetPdoRegistryParameter(PDEVICE_OBJECT PhysicalDeviceObject, PVOID Parameter, ULONG ParameterLength, PWCHAR KeyName, ULONG KeyNameLength)
Definition: usbd.c:620
VOID NTAPI USBD_RegisterHcFilter(PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT FilterDeviceObject)
Definition: usbd.c:250
VOID NTAPI USBD_GetUSBDIVersion(PUSBD_VERSION_INFORMATION Version)
Definition: usbd.c:294
ULONG NTAPI USBD_GetInterfaceLength(PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor, PUCHAR BufferEnd)
Definition: usbd.c:414
_In_ UCHAR EndpointType
Definition: usbdlib.h:225
_In_ ULONG _In_ PVOID StartPosition
Definition: usbdlib.h:159
_In_ ULONG _In_ USHORT Level
Definition: usbdlib.h:239
_In_ UCHAR _In_ BOOLEAN LowSpeed
Definition: usbdlib.h:226
DECLSPEC_IMPORT PUSB_INTERFACE_DESCRIPTOR NTAPI USBD_ParseConfigurationDescriptor(_In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, _In_ UCHAR InterfaceNumber, _In_ UCHAR AlternateSetting)
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG _In_ LONG InterfaceSubClass
Definition: usbdlib.h:172
_In_ ULONG TotalLength
Definition: usbdlib.h:158
_In_ ULONG _In_ PVOID _In_ LONG DescriptorType
Definition: usbdlib.h:160
_In_ PDEVICE_OBJECT FilterDeviceObject
Definition: usbdlib.h:197
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:181
_In_ PVOID _In_ LONG _In_ LONG AlternateSetting
Definition: usbdlib.h:170
struct _USBD_INTERFACE_LIST_ENTRY * PUSBD_INTERFACE_LIST_ENTRY
_In_ ULONG ParameterLength
Definition: usbdlib.h:206
#define DECLSPEC_EXPORT
Definition: usbdlib.h:4
_In_ ULONG _In_ ULONG KeyNameLength
Definition: usbdlib.h:208
struct _USBD_INTERFACE_LIST_ENTRY USBD_INTERFACE_LIST_ENTRY
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG _In_ LONG _In_ LONG InterfaceProtocol
Definition: usbdlib.h:173
_In_ PUCHAR BufferEnd
Definition: usbdlib.h:189
DECLSPEC_EXPORT NTSTATUS NTAPI USBD_QueryBusTime(_In_ PDEVICE_OBJECT RootHubPdo, _Out_ PULONG CurrentFrame)
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG InterfaceClass
Definition: usbdlib.h:171
_In_ PVOID _In_ LONG InterfaceNumber
Definition: usbdlib.h:169
DECLSPEC_IMPORT PURB NTAPI USBD_CreateConfigurationRequest(_In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, _Out_ PUSHORT Siz)
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: wdfusb.h:2334
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336
unsigned char UCHAR
Definition: xmlstorage.h:181