ReactOS 0.4.15-dev-5666-gc548b97
fxusbinterfaceapi.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxUsbInterfaceAPI.cpp
8
9Abstract:
10
11
12Author:
13
14Environment:
15
16 Both kernel and user mode
17
18Revision History:
19
20--*/
21#include "fxusbpch.hpp"
22
23extern "C" {
24#include "FxUsbInterfaceAPI.tmh"
25}
26
27//
28// Extern "C" all APIs
29//
30extern "C" {
31
36WDFEXPORT(WdfUsbInterfaceSelectSetting)(
37 __in
39 __in
40 WDFUSBINTERFACE UsbInterface,
43 __in
45 )
46/*++
47
48Routine Description:
49 Selects an alternate setting on a given interface number
50
51Arguments:
52 UsbInterface - the interface whose setting will be selected
53
54 PipesAttributes - Attributes to apply to each of the new pipes on the setting
55
56 Params - Strucutre indicating how to select a new setting
57
58Return Value:
59 NTSTATUS
60
61 --*/
62{
63 DDI_ENTRY();
64
68
74
76
79 return status;
80 }
81
86 "Params size %d, expected %d %!STATUS!", Params->Size,
88 return status;
89 }
90
94 if (!NT_SUCCESS(status)) {
95 return status;
96 }
97
98#if (FX_CORE_MODE == FX_CORE_USER_MODE)
100 FX_VERIFY_WITH_NAME(INTERNAL, TRAPMSG("UMDF may only select settings by index."),
101 DriverGlobals->DriverName);
102 }
103#endif
104
105 switch (Params->Type) {
107 if (Params->Types.Descriptor.InterfaceDescriptor == NULL) {
111 "InterfaceDescriptor passed in is NULL %!STATUS!", status);
112
113 }
114 else {
117 Params->Types.Descriptor.InterfaceDescriptor
118 );
119 }
120 break;
121
125 Params->Types.Interface.SettingIndex
126 );
127 break;
128
130 if (Params->Types.Urb.Urb == NULL ||
131 Params->Types.Urb.Urb->UrbHeader.Function != URB_FUNCTION_SELECT_INTERFACE ||
132 (Params->Types.Urb.Urb->UrbHeader.Length <
133 sizeof(struct _URB_SELECT_INTERFACE) - sizeof(USBD_PIPE_INFORMATION)) ) {
137 "URB or URB fields passed in are invalid Urb 0x%p %!STATUS!",
138 Params->Types.Urb.Urb, status);
139
140 }
141 else {
143 Params->Types.Urb.Urb);
144 }
145 break;
146
147 default:
149 break;
150 }
151
152 return status;
153}
154
155
157BYTE
158WDFAPI
159WDFEXPORT(WdfUsbInterfaceGetInterfaceNumber)(
160 __in
162 __in
163 WDFUSBINTERFACE UsbInterface
164 )
165/*++
166
167Routine Description:
168 Returns the interface number of the given interface. The interface number
169 is not necessarily the same as the index of the interface. Once is specified
170 by the device, the other is where it is located within an internal array.
171
172Arguments:
173 UsbInterface - Interace whose number will be returned
174
175Return Value:
176 interface number
177
178 --*/
179{
180 DDI_ENTRY();
181
183
187 (PVOID*) &pUsbInterface);
188
190}
191
193BYTE
194WDFAPI
195WDFEXPORT(WdfUsbInterfaceGetNumEndpoints)(
196 __in
198 __in
199 WDFUSBINTERFACE UsbInterface,
200 __in
202 )
203/*++
204
205Routine Description:
206 Returns the number of endpoints (not configured) for a given setting on the
207 given interface.
208
209Arguments:
210 UsbInterface - interface whose number of endpoints will be returned
211
212 SettingsIndex - the index into the alternate setting array
213
214Return Value:
215 Number of endpoints
216
217 --*/
218{
219 DDI_ENTRY();
220
222
226 (PVOID*) &pUsbInterface);
227
229}
230
232VOID
233WDFAPI
234WDFEXPORT(WdfUsbInterfaceGetEndpointInformation)(
235 __in
237 __in
238 WDFUSBINTERFACE UsbInterface,
239 __in
241 __in
243 __out
245 )
246/*++
247
248Routine Description:
249 Returns information on a given endpoint (unconfigured) for an interface +
250 alternate setting index.
251
252Arguments:
253 UsbInterface - interface which contains the endpoint
254
255 SettingIndex - alternate setting index
256
257 EndpointIndex - index into the endpoint array contained by interface+setting
258
259 EndpointInfo - structure to be filled in with the info of the endpoint
260
261Return Value:
262 None
263
264 --*/
265{
266 DDI_ENTRY();
267
270
276
278
282 "EndpointInfo Size %d incorrect, expected %d, %!STATUS!",
286 return;
287 }
288
292}
293
295BYTE
296WDFEXPORT(WdfUsbInterfaceGetNumSettings)(
297 __in
299 __in
300 WDFUSBINTERFACE UsbInterface
301 )
302/*++
303
304Routine Description:
305 Returns the number of settings available on an interface.
306
307Arguments:
308 UsbInterface - the usb interface being queried
309
310Return Value:
311 Number of settings as described by the config descriptor
312
313 --*/
314{
315 DDI_ENTRY();
316
318
322 (PVOID*) &pUsbInterface);
323
325}
326
328VOID
329WDFAPI
330WDFEXPORT(WdfUsbInterfaceGetDescriptor)(
331 __in
333 __in
334 WDFUSBINTERFACE UsbInterface,
335 __in
337 __out
339 )
340/*++
341
342Routine Description:
343 Returns the underlying USB interface descriptor for the given WDF handle
344
345Arguments:
346 UsbInterface - interface whose descriptor will be returned
347
348 SettingIndex - alternatve setting whose interface should be returned
349
350 InterfaceDescriptor - Pointer which will receive the descriptor
351
352 --*/
353{
354 DDI_ENTRY();
355
358
364
366
368}
369
371BYTE
372WDFAPI
373WDFEXPORT(WdfUsbInterfaceGetConfiguredSettingIndex)(
374 __in
376 __in
377 WDFUSBINTERFACE UsbInterface
378 )
379/*++
380
381Routine Description:
382 Returns the alternate setting index which is currently configured
383
384Arguments:
385 UsbInterface - interfase whose configured setting is being queried
386
387Return Value:
388 The current setting or 0 on failure
389
390 --*/
391{
392 DDI_ENTRY();
393
395
399 (PVOID*) &pUsbInterface);
400
402}
403
405BYTE
406WDFAPI
407WDFEXPORT(WdfUsbInterfaceGetNumConfiguredPipes)(
408 __in
410 __in
411 WDFUSBINTERFACE UsbInterface
412 )
413/*++
414
415Routine Description:
416 Returns the number of configured pipes on a given interface.
417
418Arguments:
419 UsbInterface - the configured interface
420
421Return Value:
422 Number of configured pipes or 0 on error
423
424 --*/
425{
426 DDI_ENTRY();
427
429
433 (PVOID*) &pUsbInterface);
434
436}
437
439WDFUSBPIPE
440WDFAPI
441WDFEXPORT(WdfUsbInterfaceGetConfiguredPipe)(
442 __in
444 __in
445 WDFUSBINTERFACE UsbInterface,
446 __in
450 )
451/*++
452
453Routine Description:
454 Returns the WDFUSBPIPE handle for the configured interface + pipe index.
455 Optionally, information about the pipe is also returned.
456
457Arguments:
458 UsbInterface - configured interface
459
460 PipeIndex - index into the number of pipes on the interface
461
462 PipeInfo - information to be returned on the pipe
463
464Return Value:
465 valid WDFUSBPIPE or NULL on error
466
467 --*/
468{
469 DDI_ENTRY();
470
474
480
481 if (PipeInfo != NULL && PipeInfo->Size != sizeof(WDF_USB_PIPE_INFORMATION)) {
483
486 "PipeInfo Size %d incorrect, expected %d, %!STATUS!",
488
490
491 return NULL;
492 }
493
495}
496
497} // extern "C"
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ NTSTATUS SelectSettingByIndex(__in PWDF_OBJECT_ATTRIBUTES PipesAttributes, __in UCHAR SettingIndex)
VOID GetEndpointInformation(__in UCHAR SettingIndex, __in UCHAR PipeIndex, __in PWDF_USB_PIPE_INFORMATION PipeInfo)
UCHAR GetNumSettings(VOID)
UCHAR GetInterfaceNumber(VOID)
VOID GetDescriptor(__in PUSB_INTERFACE_DESCRIPTOR UsbInterfaceDescriptor, __in UCHAR SettingIndex)
_Must_inspect_result_ NTSTATUS SelectSettingByDescriptor(__in PWDF_OBJECT_ATTRIBUTES PipesAttributes, __in PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor)
WDFUSBPIPE GetConfiguredPipe(__in UCHAR PipeIndex, __out_opt PWDF_USB_PIPE_INFORMATION PipeInfo)
UCHAR GetConfiguredSettingIndex(VOID)
UCHAR GetNumEndpoints(__in UCHAR SettingIndex)
UCHAR GetNumConfiguredPipes(VOID)
_Must_inspect_result_ NTSTATUS SelectSetting(__in PWDF_OBJECT_ATTRIBUTES PipesAttributes, __in PURB Urb)
#define __out_opt
Definition: dbghelp.h:65
#define __in
Definition: dbghelp.h:35
#define __in_opt
Definition: dbghelp.h:38
#define __out
Definition: dbghelp.h:62
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:290
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FX_VERIFY_WITH_NAME(DRIVER(BadArgument, TODO), CHECK(ERROR_STRING_HW_ACCESS_NOT_ALLOWED,(pDevice->IsDirectHardwareAccessAllowed()==TRUE)), DriverGlobals->DriverName)
FxVerifierDbgBreakPoint(pFxDriverGlobals)
DriverGlobals
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define FxPointerNotNull(FxDriverGlobals, Ptr)
Definition: fxmacros.hpp:253
@ FX_TYPE_USB_INTERFACE
Definition: fxtypes.h:104
_Must_inspect_result_ __in WDFUSBINTERFACE UsbInterface
__in WDFUSBINTERFACE __in UCHAR SettingIndex
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), UsbInterface, FX_TYPE_USB_INTERFACE,(PVOID *) &pUsbInterface)
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), UsbInterface, FX_TYPE_USB_INTERFACE,(PVOID *) &pUsbInterface, &pFxDriverGlobals)
NTSTATUS status
_Must_inspect_result_ __in WDFUSBINTERFACE __in_opt PWDF_OBJECT_ATTRIBUTES PipesAttributes
__in WDFUSBINTERFACE __in UCHAR __out PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
__in WDFUSBINTERFACE __in UCHAR __in UCHAR EndpointIndex
_Must_inspect_result_ __in WDFUSBINTERFACE __in_opt PWDF_OBJECT_ATTRIBUTES __in PWDF_USB_INTERFACE_SELECT_SETTING_PARAMS Params
__in WDFUSBINTERFACE __in UCHAR __out_opt PWDF_USB_PIPE_INFORMATION PipeInfo
__in WDFUSBINTERFACE __in UCHAR __in UCHAR __out PWDF_USB_PIPE_INFORMATION EndpointInfo
FxUsbInterface * pUsbInterface
__in WDFUSBINTERFACE __in UCHAR PipeIndex
PFX_DRIVER_GLOBALS pFxDriverGlobals
@ FX_VALIDATE_OPTION_PARENT_NOT_ALLOWED
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define URB_FUNCTION_SELECT_INTERFACE
Definition: usb.h:87
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308
#define WDFAPI
Definition: wdftypes.h:53
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_opt_ PWDF_USB_PIPE_INFORMATION PipeInfo
Definition: wdfusb.h:2543
_In_ WDFUSBINTERFACE UsbInterface
Definition: wdfusb.h:2276
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: wdfusb.h:2334
_In_ WDFUSBINTERFACE _In_ UCHAR PipeIndex
Definition: wdfusb.h:2540
_In_ WDFUSBINTERFACE _In_ UCHAR _In_ UCHAR _Out_ PWDF_USB_PIPE_INFORMATION EndpointInfo
Definition: wdfusb.h:2429
@ WdfUsbInterfaceSelectSettingTypeUrb
Definition: wdfusb.h:138
@ WdfUsbInterfaceSelectSettingTypeDescriptor
Definition: wdfusb.h:136
@ WdfUsbInterfaceSelectSettingTypeSetting
Definition: wdfusb.h:137
_In_ WDFUSBINTERFACE _In_ UCHAR _In_ UCHAR EndpointIndex
Definition: wdfusb.h:2426
_Must_inspect_result_ _In_ WDFUSBINTERFACE _In_opt_ PWDF_OBJECT_ATTRIBUTES PipesAttributes
Definition: wdfusb.h:2390
_In_ WDFUSBINTERFACE _In_ UCHAR SettingIndex
Definition: wdfusb.h:2303
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned char BYTE
Definition: xxhash.c:193