ReactOS 0.4.16-dev-1946-g52006dd
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#if defined(EVENT_TRACING)
25#include "FxUsbInterfaceAPI.tmh"
26#endif
27}
28
29//
30// Extern "C" all APIs
31//
32extern "C" {
33
39WDFEXPORT(WdfUsbInterfaceSelectSetting)(
40 __in
41 PWDF_DRIVER_GLOBALS DriverGlobals,
42 __in
43 WDFUSBINTERFACE UsbInterface,
46 __in
48 )
49/*++
50
51Routine Description:
52 Selects an alternate setting on a given interface number
53
54Arguments:
55 UsbInterface - the interface whose setting will be selected
56
57 PipesAttributes - Attributes to apply to each of the new pipes on the setting
58
59 Params - Strucutre indicating how to select a new setting
60
61Return Value:
62 NTSTATUS
63
64 --*/
65{
66 DDI_ENTRY();
67
71
77
79
82 return status;
83 }
84
89 "Params size %d, expected %d %!STATUS!", Params->Size,
91 return status;
92 }
93
97 if (!NT_SUCCESS(status)) {
98 return status;
99 }
100
101#if (FX_CORE_MODE == FX_CORE_USER_MODE)
103 FX_VERIFY_WITH_NAME(INTERNAL, TRAPMSG("UMDF may only select settings by index."),
104 DriverGlobals->DriverName);
105 }
106#endif
107
108 switch (Params->Type) {
110 if (Params->Types.Descriptor.InterfaceDescriptor == NULL) {
114 "InterfaceDescriptor passed in is NULL %!STATUS!", status);
115
116 }
117 else {
120 Params->Types.Descriptor.InterfaceDescriptor
121 );
122 }
123 break;
124
128 Params->Types.Interface.SettingIndex
129 );
130 break;
131
133 if (Params->Types.Urb.Urb == NULL ||
134 Params->Types.Urb.Urb->UrbHeader.Function != URB_FUNCTION_SELECT_INTERFACE ||
135 (Params->Types.Urb.Urb->UrbHeader.Length <
136 sizeof(struct _URB_SELECT_INTERFACE) - sizeof(USBD_PIPE_INFORMATION)) ) {
140 "URB or URB fields passed in are invalid Urb 0x%p %!STATUS!",
141 Params->Types.Urb.Urb, status);
142
143 }
144 else {
146 Params->Types.Urb.Urb);
147 }
148 break;
149
150 default:
152 break;
153 }
154
155 return status;
156}
157
158
160BYTE
161WDFAPI
162NTAPI
163WDFEXPORT(WdfUsbInterfaceGetInterfaceNumber)(
164 __in
165 PWDF_DRIVER_GLOBALS DriverGlobals,
166 __in
167 WDFUSBINTERFACE UsbInterface
168 )
169/*++
170
171Routine Description:
172 Returns the interface number of the given interface. The interface number
173 is not necessarily the same as the index of the interface. Once is specified
174 by the device, the other is where it is located within an internal array.
175
176Arguments:
177 UsbInterface - Interace whose number will be returned
178
179Return Value:
180 interface number
181
182 --*/
183{
184 DDI_ENTRY();
185
187
191 (PVOID*) &pUsbInterface);
192
194}
195
197BYTE
198WDFAPI
199NTAPI
200WDFEXPORT(WdfUsbInterfaceGetNumEndpoints)(
201 __in
202 PWDF_DRIVER_GLOBALS DriverGlobals,
203 __in
204 WDFUSBINTERFACE UsbInterface,
205 __in
207 )
208/*++
209
210Routine Description:
211 Returns the number of endpoints (not configured) for a given setting on the
212 given interface.
213
214Arguments:
215 UsbInterface - interface whose number of endpoints will be returned
216
217 SettingsIndex - the index into the alternate setting array
218
219Return Value:
220 Number of endpoints
221
222 --*/
223{
224 DDI_ENTRY();
225
227
231 (PVOID*) &pUsbInterface);
232
234}
235
237VOID
238WDFAPI
239NTAPI
240WDFEXPORT(WdfUsbInterfaceGetEndpointInformation)(
241 __in
242 PWDF_DRIVER_GLOBALS DriverGlobals,
243 __in
244 WDFUSBINTERFACE UsbInterface,
245 __in
247 __in
249 __out
251 )
252/*++
253
254Routine Description:
255 Returns information on a given endpoint (unconfigured) for an interface +
256 alternate setting index.
257
258Arguments:
259 UsbInterface - interface which contains the endpoint
260
261 SettingIndex - alternate setting index
262
263 EndpointIndex - index into the endpoint array contained by interface+setting
264
265 EndpointInfo - structure to be filled in with the info of the endpoint
266
267Return Value:
268 None
269
270 --*/
271{
272 DDI_ENTRY();
273
276
282
284
288 "EndpointInfo Size %d incorrect, expected %d, %!STATUS!",
292 return;
293 }
294
298}
299
301BYTE
302NTAPI
303WDFEXPORT(WdfUsbInterfaceGetNumSettings)(
304 __in
305 PWDF_DRIVER_GLOBALS DriverGlobals,
306 __in
307 WDFUSBINTERFACE UsbInterface
308 )
309/*++
310
311Routine Description:
312 Returns the number of settings available on an interface.
313
314Arguments:
315 UsbInterface - the usb interface being queried
316
317Return Value:
318 Number of settings as described by the config descriptor
319
320 --*/
321{
322 DDI_ENTRY();
323
325
329 (PVOID*) &pUsbInterface);
330
332}
333
335VOID
336WDFAPI
337NTAPI
338WDFEXPORT(WdfUsbInterfaceGetDescriptor)(
339 __in
340 PWDF_DRIVER_GLOBALS DriverGlobals,
341 __in
342 WDFUSBINTERFACE UsbInterface,
343 __in
345 __out
347 )
348/*++
349
350Routine Description:
351 Returns the underlying USB interface descriptor for the given WDF handle
352
353Arguments:
354 UsbInterface - interface whose descriptor will be returned
355
356 SettingIndex - alternatve setting whose interface should be returned
357
358 InterfaceDescriptor - Pointer which will receive the descriptor
359
360 --*/
361{
362 DDI_ENTRY();
363
366
372
374
376}
377
379BYTE
380WDFAPI
381NTAPI
382WDFEXPORT(WdfUsbInterfaceGetConfiguredSettingIndex)(
383 __in
384 PWDF_DRIVER_GLOBALS DriverGlobals,
385 __in
386 WDFUSBINTERFACE UsbInterface
387 )
388/*++
389
390Routine Description:
391 Returns the alternate setting index which is currently configured
392
393Arguments:
394 UsbInterface - interfase whose configured setting is being queried
395
396Return Value:
397 The current setting or 0 on failure
398
399 --*/
400{
401 DDI_ENTRY();
402
404
408 (PVOID*) &pUsbInterface);
409
411}
412
414BYTE
415WDFAPI
416NTAPI
417WDFEXPORT(WdfUsbInterfaceGetNumConfiguredPipes)(
418 __in
419 PWDF_DRIVER_GLOBALS DriverGlobals,
420 __in
421 WDFUSBINTERFACE UsbInterface
422 )
423/*++
424
425Routine Description:
426 Returns the number of configured pipes on a given interface.
427
428Arguments:
429 UsbInterface - the configured interface
430
431Return Value:
432 Number of configured pipes or 0 on error
433
434 --*/
435{
436 DDI_ENTRY();
437
439
443 (PVOID*) &pUsbInterface);
444
446}
447
449WDFUSBPIPE
450WDFAPI
451NTAPI
452WDFEXPORT(WdfUsbInterfaceGetConfiguredPipe)(
453 __in
454 PWDF_DRIVER_GLOBALS DriverGlobals,
455 __in
456 WDFUSBINTERFACE UsbInterface,
457 __in
461 )
462/*++
463
464Routine Description:
465 Returns the WDFUSBPIPE handle for the configured interface + pipe index.
466 Optionally, information about the pipe is also returned.
467
468Arguments:
469 UsbInterface - configured interface
470
471 PipeIndex - index into the number of pipes on the interface
472
473 PipeInfo - information to be returned on the pipe
474
475Return Value:
476 valid WDFUSBPIPE or NULL on error
477
478 --*/
479{
480 DDI_ENTRY();
481
485
491
492 if (PipeInfo != NULL && PipeInfo->Size != sizeof(WDF_USB_PIPE_INFORMATION)) {
494
497 "PipeInfo Size %d incorrect, expected %d, %!STATUS!",
499
501
502 return NULL;
503 }
504
506}
507
508} // 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:33
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:291
#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)
__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: no_sal2.h:62
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
#define NTAPI
Definition: typedefs.h:36
#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