ReactOS  0.4.12-dev-685-gf36cbf7
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 
7 typedef struct _USBD_INTERFACE_LIST_ENTRY {
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 #define URB_STATUS(urb) ((urb)->UrbHeader.Status)
98 
99 #define GET_SELECT_CONFIGURATION_REQUEST_SIZE(totalInterfaces, totalPipes) \
100  (sizeof(struct _URB_SELECT_CONFIGURATION) + \
101  ((totalInterfaces-1) * sizeof(USBD_INTERFACE_INFORMATION)) + \
102  ((totalPipes-totalInterfaces)*sizeof(USBD_PIPE_INFORMATION)))
103 
104 #define GET_SELECT_INTERFACE_REQUEST_SIZE(totalPipes) \
105  (sizeof(struct _URB_SELECT_INTERFACE) + \
106  ((totalPipes-1)*sizeof(USBD_PIPE_INFORMATION)))
107 
108 #define GET_USBD_INTERFACE_SIZE(numEndpoints) \
109  (sizeof(USBD_INTERFACE_INFORMATION) + \
110  (sizeof(USBD_PIPE_INFORMATION)*(numEndpoints)) - sizeof(USBD_PIPE_INFORMATION))
111 
112 #define GET_ISO_URB_SIZE(n) (sizeof(struct _URB_ISOCH_TRANSFER)+ \
113  sizeof(USBD_ISO_PACKET_DESCRIPTOR)*n)
114 
115 #ifndef _USBD_
116 
119 VOID
120 NTAPI
122  _Out_ PUSBD_VERSION_INFORMATION VersionInformation);
123 
126 NTAPI
128  _In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
131 
133 PURB
134 NTAPI
136  _In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
137  _Out_ PUSHORT Siz);
138 
142 NTAPI
144  _In_ PVOID DescriptorBuffer,
148 
152 NTAPI
154  _In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
161 
164 PURB
165 NTAPI
167  _In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
169 
172 ULONG
173 NTAPI
175  _In_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor,
177 
180 VOID
181 NTAPI
185 
188 NTSTATUS
189 NTAPI
196 
198 NTSTATUS
199 NTAPI
201  _In_ PDEVICE_OBJECT RootHubPdo,
202  _Out_ PULONG CurrentFrame);
203 
204 #if (NTDDI_VERSION >= NTDDI_WINXP)
205 
208 ULONG
209 NTAPI
211  _In_ ULONG MaxPacketSize,
214 
215 #endif
216 
217 #if (NTDDI_VERSION >= NTDDI_VISTA)
218 
222 NTAPI
223 USBD_ValidateConfigurationDescriptor(
226  _In_ USHORT Level,
228  _In_opt_ ULONG Tag);
229 
230 #endif
231 
232 #endif /* ! _USBD_ */
233 
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4693
struct _USBD_INTERFACE_LIST_ENTRY USBD_INTERFACE_LIST_ENTRY
_In_ PVOID _In_ LONG _In_ LONG AlternateSetting
Definition: usbdlib.h:155
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG _In_ LONG InterfaceSubClass
Definition: usbdlib.h:155
uint16_t * PWSTR
Definition: typedefs.h:54
struct _USBD_INTERFACE_LIST_ENTRY * PUSBD_INTERFACE_LIST_ENTRY
unsigned char * PUCHAR
Definition: retypes.h:3
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:168
_In_ ULONG _In_reads_bytes_(KeyNameLength) PWSTR KeyName
LONG NTSTATUS
Definition: precomp.h:26
DECLSPEC_IMPORT PUSB_INTERFACE_DESCRIPTOR NTAPI USBD_ParseConfigurationDescriptor(_In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, _In_ UCHAR InterfaceNumber, _In_ UCHAR AlternateSetting)
_In_ UCHAR _In_ BOOLEAN LowSpeed
Definition: usbdlib.h:212
ULONG NTAPI USBD_GetInterfaceLength(PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor, PUCHAR BufferEnd)
Definition: usbd.c:414
VOID NTAPI USBD_GetUSBDIVersion(PUSBD_VERSION_INFORMATION Version)
Definition: usbd.c:294
_In_ ULONG _In_ USHORT Level
Definition: usbdlib.h:225
_In_ PVOID Parameter
Definition: ldrtypes.h:239
_In_ ULONG TotalLength
Definition: usbdlib.h:145
VOID NTAPI USBD_RegisterHcFilter(PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT FilterDeviceObject)
Definition: usbd.c:250
#define _In_opt_
Definition: no_sal2.h:213
ULONG NTAPI USBD_CalculateUsbBandwidth(ULONG MaxPacketSize, UCHAR EndpointType, BOOLEAN LowSpeed)
Definition: usbd.c:112
_IRQL_requires_max_(DISPATCH_LEVEL) DECLSPEC_IMPORT VOID NTAPI USBD_GetUSBDIVersion(_Out_ PUSBD_VERSION_INFORMATION VersionInformation)
Definition: rmap.c:30
Definition: usbdlib.h:7
ULONG NTAPI USBD_GetPdoRegistryParameter(PDEVICE_OBJECT PhysicalDeviceObject, PVOID Parameter, ULONG ParameterLength, PWCHAR KeyName, ULONG KeyNameLength)
Definition: usbd.c:620
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
long LONG
Definition: pedump.c:60
_In_ ULONG BufferLength
Definition: usbdlib.h:225
_In_ UCHAR EndpointType
Definition: usbdlib.h:212
unsigned char BOOLEAN
#define _Out_
Definition: no_sal2.h:323
_In_ PDEVICE_OBJECT FilterDeviceObject
Definition: usbdlib.h:184
_In_ PVOID _In_ LONG InterfaceNumber
Definition: usbdlib.h:155
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
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG _In_ LONG _In_ LONG InterfaceProtocol
Definition: usbdlib.h:155
PUSB_COMMON_DESCRIPTOR NTAPI USBD_ParseDescriptors(PVOID DescriptorBuffer, ULONG TotalLength, PVOID StartPosition, LONG DescriptorType)
Definition: usbd.c:445
#define DECLSPEC_EXPORT
Definition: usbdlib.h:4
unsigned char UCHAR
Definition: xmlstorage.h:181
LONG USBD_STATUS
Definition: usb.h:165
_In_ ULONG ParameterLength
Definition: usbdlib.h:193
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
_In_ ULONG _In_ ULONG KeyNameLength
Definition: usbdlib.h:195
_In_ PUCHAR BufferEnd
Definition: usbdlib.h:176
_In_ ULONG _In_ PVOID StartPosition
Definition: usbdlib.h:145
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define _In_
Definition: no_sal2.h:204
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: usbdlib.h:8
Definition: usb.h:529
unsigned short USHORT
Definition: pedump.c:61
#define DECLSPEC_IMPORT
Definition: hal.h:20
unsigned int * PULONG
Definition: retypes.h:1
_Inout_updates_bytes_(ParameterLength) PVOID Parameter
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG InterfaceClass
Definition: usbdlib.h:155
PUSBD_INTERFACE_INFORMATION Interface
Definition: usbdlib.h:9
DECLSPEC_IMPORT PURB NTAPI USBD_CreateConfigurationRequest(_In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, _Out_ PUSHORT Siz)
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
unsigned int ULONG
Definition: retypes.h:1
DECLSPEC_EXPORT NTSTATUS NTAPI USBD_QueryBusTime(_In_ PDEVICE_OBJECT RootHubPdo, _Out_ PULONG CurrentFrame)
PURB NTAPI USBD_CreateConfigurationRequestEx(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PUSBD_INTERFACE_LIST_ENTRY InterfaceList)
Definition: usbd.c:329
_In_ ULONG _In_ PVOID _In_ LONG DescriptorType
Definition: usbdlib.h:145
#define APC_LEVEL
Definition: env_spec_w32.h:695
unsigned short * PUSHORT
Definition: retypes.h:2