source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/ddk/usbdlib.h@ 1181

Last change on this file since 1181 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 8.2 KB
RevLine 
[1166]1#pragma once
2
3#ifndef DECLSPEC_EXPORT
4#define DECLSPEC_EXPORT __declspec(dllexport)
5#endif
6
7typedef struct _USBD_INTERFACE_LIST_ENTRY {
8 PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
9 PUSBD_INTERFACE_INFORMATION Interface;
10} USBD_INTERFACE_LIST_ENTRY, *PUSBD_INTERFACE_LIST_ENTRY;
11
12#define UsbBuildInterruptOrBulkTransferRequest(urb,length, pipeHandle, transferBuffer, transferBufferMDL, transferBufferLength, transferFlags, link) \
13{ \
14 (urb)->UrbHeader.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; \
15 (urb)->UrbHeader.Length = (length); \
16 (urb)->UrbBulkOrInterruptTransfer.PipeHandle = (pipeHandle); \
17 (urb)->UrbBulkOrInterruptTransfer.TransferBufferLength = (transferBufferLength); \
18 (urb)->UrbBulkOrInterruptTransfer.TransferBufferMDL = (transferBufferMDL); \
19 (urb)->UrbBulkOrInterruptTransfer.TransferBuffer = (transferBuffer); \
20 (urb)->UrbBulkOrInterruptTransfer.TransferFlags = (transferFlags); \
21 (urb)->UrbBulkOrInterruptTransfer.UrbLink = (link); \
22}
23
24#define UsbBuildGetDescriptorRequest(urb, length, descriptorType, descriptorIndex, languageId, transferBuffer, transferBufferMDL, transferBufferLength, link) \
25{ \
26 (urb)->UrbHeader.Function = URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE; \
27 (urb)->UrbHeader.Length = (length); \
28 (urb)->UrbControlDescriptorRequest.TransferBufferLength = (transferBufferLength); \
29 (urb)->UrbControlDescriptorRequest.TransferBufferMDL = (transferBufferMDL); \
30 (urb)->UrbControlDescriptorRequest.TransferBuffer = (transferBuffer); \
31 (urb)->UrbControlDescriptorRequest.DescriptorType = (descriptorType); \
32 (urb)->UrbControlDescriptorRequest.Index = (descriptorIndex); \
33 (urb)->UrbControlDescriptorRequest.LanguageId = (languageId); \
34 (urb)->UrbControlDescriptorRequest.UrbLink = (link); \
35}
36
37#define UsbBuildGetStatusRequest(urb, op, index, transferBuffer, transferBufferMDL, link) \
38{ \
39 (urb)->UrbHeader.Function = (op); \
40 (urb)->UrbHeader.Length = sizeof(struct _URB_CONTROL_GET_STATUS_REQUEST); \
41 (urb)->UrbControlGetStatusRequest.TransferBufferLength = sizeof(USHORT); \
42 (urb)->UrbControlGetStatusRequest.TransferBufferMDL = (transferBufferMDL); \
43 (urb)->UrbControlGetStatusRequest.TransferBuffer = (transferBuffer); \
44 (urb)->UrbControlGetStatusRequest.Index = (index); \
45 (urb)->UrbControlGetStatusRequest.UrbLink = (link); \
46}
47
48#define UsbBuildFeatureRequest(urb, op, featureSelector, index, link) \
49{ \
50 (urb)->UrbHeader.Function = (op); \
51 (urb)->UrbHeader.Length = sizeof(struct _URB_CONTROL_FEATURE_REQUEST); \
52 (urb)->UrbControlFeatureRequest.FeatureSelector = (featureSelector); \
53 (urb)->UrbControlFeatureRequest.Index = (index); \
54 (urb)->UrbControlFeatureRequest.UrbLink = (link); \
55}
56
57#define UsbBuildSelectConfigurationRequest(urb, length, configurationDescriptor) \
58{ \
59 (urb)->UrbHeader.Function = URB_FUNCTION_SELECT_CONFIGURATION; \
60 (urb)->UrbHeader.Length = (length); \
61 (urb)->UrbSelectConfiguration.ConfigurationDescriptor = (configurationDescriptor); \
62}
63
64#define UsbBuildSelectInterfaceRequest(urb, length, configurationHandle, interfaceNumber, alternateSetting) \
65{ \
66 (urb)->UrbHeader.Function = URB_FUNCTION_SELECT_INTERFACE; \
67 (urb)->UrbHeader.Length = (length); \
68 (urb)->UrbSelectInterface.Interface.AlternateSetting = (alternateSetting); \
69 (urb)->UrbSelectInterface.Interface.InterfaceNumber = (interfaceNumber); \
70 (urb)->UrbSelectInterface.Interface.Length = \
71 (length - sizeof(struct _URB_HEADER) - sizeof(USBD_CONFIGURATION_HANDLE)); \
72 (urb)->UrbSelectInterface.ConfigurationHandle = (configurationHandle); \
73}
74
75#define UsbBuildVendorRequest(urb, cmd, length, transferFlags, reservedbits, request, value, index, transferBuffer, transferBufferMDL, transferBufferLength, link) \
76{ \
77 (urb)->UrbHeader.Function = cmd; \
78 (urb)->UrbHeader.Length = (length); \
79 (urb)->UrbControlVendorClassRequest.TransferBufferLength = (transferBufferLength); \
80 (urb)->UrbControlVendorClassRequest.TransferBufferMDL = (transferBufferMDL); \
81 (urb)->UrbControlVendorClassRequest.TransferBuffer = (transferBuffer); \
82 (urb)->UrbControlVendorClassRequest.RequestTypeReservedBits = (reservedbits); \
83 (urb)->UrbControlVendorClassRequest.Request = (request); \
84 (urb)->UrbControlVendorClassRequest.Value = (value); \
85 (urb)->UrbControlVendorClassRequest.Index = (index); \
86 (urb)->UrbControlVendorClassRequest.TransferFlags = (transferFlags); \
87 (urb)->UrbControlVendorClassRequest.UrbLink = (link); \
88}
89
90#if (NTDDI_VERSION >= NTDDI_WINXP)
91
92#define UsbBuildOsFeatureDescriptorRequest(urb, length, interface, index, transferBuffer, transferBufferMDL, transferBufferLength, link) \
93{ \
94 (urb)->UrbHeader.Function = URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR; \
95 (urb)->UrbHeader.Length = (length); \
96 (urb)->UrbOSFeatureDescriptorRequest.TransferBufferLength = (transferBufferLength); \
97 (urb)->UrbOSFeatureDescriptorRequest.TransferBufferMDL = (transferBufferMDL); \
98 (urb)->UrbOSFeatureDescriptorRequest.TransferBuffer = (transferBuffer); \
99 (urb)->UrbOSFeatureDescriptorRequest.InterfaceNumber = (interface); \
100 (urb)->UrbOSFeatureDescriptorRequest.MS_FeatureDescriptorIndex = (index); \
101 (urb)->UrbOSFeatureDescriptorRequest.UrbLink = (link); \
102}
103
104#endif /* NTDDI_VERSION >= NTDDI_WINXP */
105
106#define URB_STATUS(urb) ((urb)->UrbHeader.Status)
107
108#define GET_SELECT_CONFIGURATION_REQUEST_SIZE(totalInterfaces, totalPipes) \
109 (sizeof(struct _URB_SELECT_CONFIGURATION) + \
110 ((totalInterfaces-1) * sizeof(USBD_INTERFACE_INFORMATION)) + \
111 ((totalPipes-totalInterfaces)*sizeof(USBD_PIPE_INFORMATION)))
112
113#define GET_SELECT_INTERFACE_REQUEST_SIZE(totalPipes) \
114 (sizeof(struct _URB_SELECT_INTERFACE) + \
115 ((totalPipes-1)*sizeof(USBD_PIPE_INFORMATION)))
116
117#define GET_USBD_INTERFACE_SIZE(numEndpoints) (sizeof(USBD_INTERFACE_INFORMATION) + \
118 (sizeof(USBD_PIPE_INFORMATION)*(numEndpoints)) \
119 - sizeof(USBD_PIPE_INFORMATION))
120
121#define GET_ISO_URB_SIZE(n) (sizeof(struct _URB_ISOCH_TRANSFER)+ \
122 sizeof(USBD_ISO_PACKET_DESCRIPTOR)*n)
123
124#ifndef _USBD_
125
126DECLSPEC_IMPORT
127VOID
128NTAPI
129USBD_GetUSBDIVersion(
130 OUT PUSBD_VERSION_INFORMATION VersionInformation);
131
132DECLSPEC_IMPORT
133PUSB_INTERFACE_DESCRIPTOR
134NTAPI
135USBD_ParseConfigurationDescriptor(
136 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
137 IN UCHAR InterfaceNumber,
138 IN UCHAR AlternateSetting);
139
140DECLSPEC_IMPORT
141PURB
142NTAPI
143USBD_CreateConfigurationRequest(
144 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
145 OUT PUSHORT Siz);
146
147DECLSPEC_IMPORT
148PUSB_COMMON_DESCRIPTOR
149NTAPI
150USBD_ParseDescriptors(
151 IN PVOID DescriptorBuffer,
152 IN ULONG TotalLength,
153 IN PVOID StartPosition,
154 IN LONG DescriptorType);
155
156DECLSPEC_IMPORT
157PUSB_INTERFACE_DESCRIPTOR
158NTAPI
159USBD_ParseConfigurationDescriptorEx(
160 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
161 IN PVOID StartPosition,
162 IN LONG InterfaceNumber,
163 IN LONG AlternateSetting,
164 IN LONG InterfaceClass,
165 IN LONG InterfaceSubClass,
166 IN LONG InterfaceProtocol);
167
168DECLSPEC_IMPORT
169PURB
170NTAPI
171USBD_CreateConfigurationRequestEx(
172 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
173 IN PUSBD_INTERFACE_LIST_ENTRY InterfaceList);
174
175DECLSPEC_EXPORT
176ULONG
177NTAPI
178USBD_GetInterfaceLength(
179 IN PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor,
180 IN PUCHAR BufferEnd);
181
182DECLSPEC_EXPORT
183VOID
184NTAPI
185USBD_RegisterHcFilter(
186 IN PDEVICE_OBJECT DeviceObject,
187 IN PDEVICE_OBJECT FilterDeviceObject);
188
189DECLSPEC_EXPORT
190NTSTATUS
191NTAPI
192USBD_GetPdoRegistryParameter(
193 IN PDEVICE_OBJECT PhysicalDeviceObject,
194 IN OUT PVOID Parameter,
195 IN ULONG ParameterLength,
196 IN PWSTR KeyName,
197 IN ULONG KeyNameLength);
198
199DECLSPEC_EXPORT
200NTSTATUS
201NTAPI
202USBD_QueryBusTime(
203 IN PDEVICE_OBJECT RootHubPdo,
204 OUT PULONG CurrentFrame);
205
206#if (NTDDI_VERSION >= NTDDI_WINXP)
207
208DECLSPEC_IMPORT
209ULONG
210NTAPI
211USBD_CalculateUsbBandwidth(
212 IN ULONG MaxPacketSize,
213 IN UCHAR EndpointType,
214 IN BOOLEAN LowSpeed);
215
216#endif
217
218#if (NTDDI_VERSION >= NTDDI_VISTA)
219
220DECLSPEC_IMPORT
221USBD_STATUS
222NTAPI
223USBD_ValidateConfigurationDescriptor(
224 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc,
225 IN ULONG BufferLength,
226 IN USHORT Level,
227 OUT PUCHAR *Offset,
228 IN ULONG Tag OPTIONAL);
229
230#endif
231
232#endif /* ! _USBD_ */
233
Note: See TracBrowser for help on using the repository browser.