ReactOS 0.4.16-dev-1946-g52006dd
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/* UsbdEx lib */
244
249 _In_ USBD_HANDLE USBDHandle,
256 _Out_opt_
259);
260
262VOID
264 _In_ USBD_HANDLE USBDHandle,
267);
268
277 _Out_ USBD_HANDLE *USBDHandle
278);
279
280VOID
282 _In_ USBD_HANDLE USBDHandle
283);
284
289 _In_ USBD_HANDLE USBDHandle,
291);
292
297 _In_ USBD_HANDLE USBDHandle,
302 PURB *Urb
303);
304
306VOID
308 _In_ USBD_HANDLE USBDHandle,
310);
311
312#endif
313
314#endif /* ! _USBD_ */
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define NULL
Definition: types.h:112
#define _IRQL_requires_max_(irql)
Definition: driverspecs.h:230
#define _IRQL_requires_(irql)
Definition: driverspecs.h:229
#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_(s)
Definition: no_sal2.h:170
#define _Outptr_result_bytebuffer_(s)
Definition: no_sal2.h:288
#define _Out_opt_
Definition: no_sal2.h:214
#define _Deref_out_range_(l, h)
Definition: no_sal2.h:376
#define _Pre_null_
Definition: no_sal2.h:512
#define _Must_inspect_result_
Definition: no_sal2.h:62
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define _Out_writes_bytes_to_opt_(s, c)
Definition: no_sal2.h:240
#define _Inout_updates_bytes_(s)
Definition: no_sal2.h:184
#define _Out_writes_bytes_(s)
Definition: no_sal2.h:178
#define _When_(c, a)
Definition: no_sal2.h:38
_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:3930
#define DECLSPEC_IMPORT
Definition: rpc.h:74
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
NTSTATUS USBD_QueryUsbCapability(_In_ USBD_HANDLE USBDHandle, _In_ const GUID *CapabilityType, _In_ ULONG OutputBufferLength, _When_(OutputBufferLength==0, _Pre_null_) _When_(OutputBufferLength !=0 &&ResultLength==NULL, _Out_writes_bytes_(OutputBufferLength)) _When_(OutputBufferLength !=0 &&ResultLength !=NULL, _Out_writes_bytes_to_opt_(OutputBufferLength, *ResultLength)) PUCHAR OutputBuffer, _Out_opt_ _When_(ResultLength !=NULL, _Deref_out_range_(<=, OutputBufferLength)) PULONG ResultLength)
Definition: usbdex.c:10
NTSTATUS USBD_UrbAllocate(_In_ USBD_HANDLE USBDHandle, _Outptr_result_bytebuffer_(sizeof(URB)) PURB *Urb)
Definition: usbdex.c:59
NTSTATUS USBD_IsochUrbAllocate(_In_ USBD_HANDLE USBDHandle, _In_ ULONG NumberOfIsochPacket, _Outptr_result_bytebuffer_(sizeof(struct _URB_ISOCH_TRANSFER)+(NumberOfIsochPackets *sizeof(USBD_ISO_PACKET_DESCRIPTOR)) - sizeof(USBD_ISO_PACKET_DESCRIPTOR)) PURB *Urb)
Definition: usbdex.c:69
NTSTATUS USBD_CreateHandle(_In_ PDEVICE_OBJECT DeviceObject, _In_ PDEVICE_OBJECT TargetDeviceObject, _In_ ULONG USBDClientContractVersion, _In_ ULONG PoolTag, _Out_ USBD_HANDLE *USBDHandle)
Definition: usbdex.c:38
VOID USBD_AssignUrbToIoStackLocation(_In_ USBD_HANDLE USBDHandle, _In_ PIO_STACK_LOCATION IoStackLocation, _In_ PURB Urb)
Definition: usbdex.c:28
VOID USBD_UrbFree(_In_ USBD_HANDLE USBDHandle, _In_ PURB Urb)
Definition: usbdex.c:83
_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
_Must_inspect_result_ _In_ PDEVICE_OBJECT _In_ ULONG _In_ ULONG _Out_ USBD_HANDLE * USBDHandle
Definition: usbdlib.h:278
_In_ ULONG NumberOfIsochPacket
Definition: usbdlib.h:298
_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
VOID USBD_CloseHandle(_In_ USBD_HANDLE USBDHandle)
Definition: usbdex.c:51
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:181
_In_ PVOID _In_ LONG _In_ LONG AlternateSetting
Definition: usbdlib.h:170
_Must_inspect_result_ _In_ PDEVICE_OBJECT _In_ ULONG USBDClientContractVersion
Definition: usbdlib.h:275
struct _USBD_INTERFACE_LIST_ENTRY * PUSBD_INTERFACE_LIST_ENTRY
_In_ ULONG ParameterLength
Definition: usbdlib.h:206
_In_ PIO_STACK_LOCATION _In_ PURB Urb
Definition: usbdlib.h:267
#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
_Must_inspect_result_ _In_ PDEVICE_OBJECT TargetDeviceObject
Definition: usbdlib.h:274
_In_ PIO_STACK_LOCATION IoStackLocation
Definition: usbdlib.h:265
DECLSPEC_IMPORT PURB NTAPI USBD_CreateConfigurationRequest(_In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, _Out_ PUSHORT Siz)
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3782
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4071
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2705
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3777
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG PoolTag
Definition: wdfmemory.h:164
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: wdfusb.h:2334
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ ULONG NumberOfIsochPackets
Definition: wdfusb.h:1703
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ CONST GUID * CapabilityType
Definition: wdfusb.h:1613
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336
unsigned char UCHAR
Definition: xmlstorage.h:181