ReactOS  0.4.15-dev-3181-g4acf100
usbutil.hpp
Go to the documentation of this file.
1 //
2 // Copyright (C) Microsoft. All rights reserved.
3 //
4 #ifndef __FX_USB_UTIL_H__
5 #define __FX_USB_UTIL_H__
6 
8 __inline
10  __inout_xcount((BitNumber / sizeof(UCHAR)) + 1) PUCHAR BitArray,
11  __in UCHAR BitNumber
12  )
13 /*++
14 
15 Routine Description:
16  The following function sets a bit in the array and returns a value indicating
17  the bits previous state.
18 
19 Arguments:
20  BitArray - the array to check
21 
22  BitNumber - zero based index into BitArray
23 
24 Return Value:
25  TRUE if the bit was already set
26  FALSE if was previously clear
27 
28  --*/
29 {
30  UCHAR index;
31  UCHAR bit;
32 
33  index = (BitNumber) / sizeof(UCHAR);
34  bit = (UCHAR) (1 << (BitNumber % sizeof(UCHAR)) );
35 
36  if ((BitArray[index] & bit) == 0x0) {
37  //
38  // bit not set
39  //
40  BitArray[index] |= bit;
41  return FALSE;
42  }
43 
44  return TRUE;
45 }
46 
47 VOID
48 __inline
50  __inout_xcount((BitNumber / sizeof(UCHAR)) + 1) PUCHAR BitArray,
51  __in UCHAR BitNumber
52  )
53 /*++
54 
55 Routine Description:
56  Clear the bit in the BitArray
57 
58 Arguments:
59  BitArray - bit array to change
60 
61  BitNumber - zero based bit index into the array to clear
62 
63  --*/
64 {
65  UCHAR index;
66  UCHAR bit;
67 
68  index = BitNumber / sizeof(UCHAR);
69  bit = (UCHAR) (1 << (BitNumber % sizeof(UCHAR)) );
70 
71  BitArray[index] &= ~bit;
72 }
73 
74 VOID
77  __in PURB Urb,
78  __in FX_URB_TYPE FxUrbType,
81  USBD_HANDLE UsbdHandle
82  );
83 
86  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
90  __in FX_URB_TYPE FxUrbType,
93  USBD_HANDLE UsbdHandle
94  );
95 
101  );
102 
103 PURB
105  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
108  __in ULONG DefaultMaxPacketSize
109  );
110 
111 NTSTATUS
113  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
116  );
117 
120  __in PVOID Buffer,
121  __in size_t BufferLength,
122  __in PVOID Start,
124  );
125 
129 };
130 
131 NTSTATUS
133  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
135  __in PVOID Start,
136  __in PVOID End,
138  __in size_t SizeToValidate,
140  __in ULONG MaximumNumDescriptorsToValidate
141  );
142 
143 #if (FX_CORE_MODE == FX_CORE_USER_MODE)
144 VOID
147  __in_xcount(Urb->Length) PUMURB_HEADER Urb,
148  __in IWudfFile* HostFile,
150  );
151 
152 VOID
154  __inout PUMURB UmUrb,
155  __in WINUSB_INTERFACE_HANDLE WinUsbHandle,
159  );
160 
161 VOID
163  __inout PUMURB UmUrb,
164  __in WINUSB_INTERFACE_HANDLE WinUsbHandle,
167  );
168 
169 VOID
171  __inout PUMURB UmUrb,
172  __in WINUSB_INTERFACE_HANDLE WinUsbHandle,
175  );
176 #endif // (FX_CORE_MODE == FX_CORE_USER_MODE)
177 
178 #endif // __FX_USB_UTIL_H__
#define __inout_xcount(size)
Definition: specstrings.h:113
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
PURB FxUsbCreateConfigRequest(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc, __in PUSBD_INTERFACE_LIST_ENTRY InterfaceList, __in ULONG DefaultMaxPacketSize)
Definition: usbutil.cpp:364
NTSTATUS FxFormatUrbRequest(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxIoTarget *Target, __in FxRequestBase *Request, __in FxRequestBuffer *Buffer, __in FX_URB_TYPE FxUrbType, __drv_when(FxUrbType==FxUrbTypeUsbdAllocated, __in) __drv_when(FxUrbType !=FxUrbTypeUsbdAllocated, __in_opt) USBD_HANDLE UsbdHandle)
Definition: usbutil.cpp:62
#define __in_opt
Definition: dbghelp.h:38
_In_ PVOID _In_ LONG _In_ LONG AlternateSetting
Definition: usbdlib.h:168
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:181
NTSTATUS FxUsbValidateConfigDescriptorHeaders(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor, __in size_t ConfigDescriptorLength)
Definition: usbutil.cpp:111
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ WDFUSBDEVICE _Out_writes_bytes_to_opt_ ConfigDescriptorLength PVOID _Inout_ PUSHORT ConfigDescriptorLength
Definition: wdfusb.h:1036
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
BOOLEAN __inline FxBitArraySet(__inout_xcount((BitNumber/sizeof(UCHAR))+1) PUCHAR BitArray, __in UCHAR BitNumber)
Definition: usbutil.hpp:9
enum _FX_URB_TYPE FX_URB_TYPE
#define __in_xcount(size)
Definition: specstrings.h:109
VOID FxUsbUmInitControlTransferUrb(__inout PUMURB UmUrb, __in WINUSB_INTERFACE_HANDLE WinUsbHandle, __in ULONG BufferLength, __in PVOID Buffer)
Definition: usbutil.cpp:578
Definition: usbdlib.h:7
Definition: umusb.h:173
PUSB_COMMON_DESCRIPTOR FxUsbFindDescriptorType(__in PVOID Buffer, __in size_t BufferLength, __in PVOID Start, __in LONG DescriptorType)
Definition: usbutil.cpp:174
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
unsigned char BOOLEAN
VOID __inline FxBitArrayClear(__inout_xcount((BitNumber/sizeof(UCHAR))+1) PUCHAR BitArray, __in UCHAR BitNumber)
Definition: usbutil.hpp:49
_Must_inspect_result_ _In_ WDFUSBDEVICE _Out_writes_bytes_to_opt_ ConfigDescriptorLength PVOID ConfigDescriptor
Definition: wdfusb.h:1036
Definition: bufpool.h:45
GLuint index
Definition: glext.h:6031
_In_ PVOID _In_ LONG InterfaceNumber
Definition: usbdlib.h:168
FxUsbValidateDescriptorOp
Definition: usbutil.hpp:126
#define __drv_when(cond, annotes)
Definition: driverspecs.h:334
PUSB_INTERFACE_DESCRIPTOR FxUsbParseConfigurationDescriptor(__in PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc, __in UCHAR InterfaceNumber=-1, __in UCHAR AlternateSetting=1)
Definition: usbutil.cpp:307
Definition: partlist.h:33
unsigned char UCHAR
Definition: xmlstorage.h:181
#define index(s, c)
Definition: various.h:29
#define __inout
Definition: dbghelp.h:50
NTSTATUS FxUsbValidateDescriptorType(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor, __in PVOID Start, __in PVOID End, __in LONG DescriptorType, __in size_t SizeToValidate, __in FxUsbValidateDescriptorOp Op, __in ULONG MaximumNumDescriptorsToValidate)
Definition: usbutil.cpp:207
VOID FxUsbUmInitDescriptorUrb(__inout PUMURB UmUrb, __in WINUSB_INTERFACE_HANDLE WinUsbHandle, __in UCHAR DescriptorType, __in ULONG BufferLength, __in PVOID Buffer)
Definition: usbutil.cpp:556
return pRequest Reuse(ReuseParams)
Definition: usb.h:529
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
unsigned int ULONG
Definition: retypes.h:1
VOID FxUsbUmFormatRequest(__in FxRequestBase *Request, __in_xcount(Urb->Length) PUMURB_HEADER Urb, __in IWudfFile *HostFile, __in BOOLEAN Reuse=FALSE)
Definition: usbutil.cpp:486
VOID FxFormatUsbRequest(__in FxRequestBase *Request, __in PURB Urb, __in FX_URB_TYPE FxUrbType, __drv_when(FxUrbType==FxUrbTypeUsbdAllocated, __in) __drv_when(FxUrbType !=FxUrbTypeUsbdAllocated, __in_opt) USBD_HANDLE UsbdHandle)
Definition: usbutil.cpp:29
#define __in
Definition: dbghelp.h:35
_In_ ULONG _In_ PVOID _In_ LONG DescriptorType
Definition: usbdlib.h:158
VOID FxUsbUmInitInformationUrb(__inout PUMURB UmUrb, __in WINUSB_INTERFACE_HANDLE WinUsbHandle, __in ULONG BufferLength, __in PVOID Buffer)
Definition: usbutil.cpp:596