ReactOS  0.4.15-dev-2704-gd5265b0
usbuser.h
Go to the documentation of this file.
1 /*
2  * usbuser.h
3  *
4  * USB user mode IOCTL interface
5  *
6  * This file is part of the ReactOS PSDK package.
7  *
8  * Contributors:
9  * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10  *
11  * THIS SOFTWARE IS NOT COPYRIGHTED
12  *
13  * This source code is offered for use in the public domain. You may
14  * use, modify or distribute it freely.
15  *
16  * This code is distributed in the hope that it will be useful but
17  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18  * DISCLAIMED. This includes but is not limited to warranties of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  */
22 
23 #pragma once
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #if (_WIN32_WINNT >= 0x0501)
30 
31 #include "usbiodef.h"
32 
33 #include <pshpack1.h>
34 
35 #define USBUSER_VERSION 0x0004
36 
37 #define IOCTL_USB_USER_REQUEST USB_CTL(HCD_USER_REQUEST)
38 
39 #ifndef IOCTL_USB_DIAGNOSTIC_MODE_ON
40 #define IOCTL_USB_DIAGNOSTIC_MODE_ON USB_CTL(HCD_DIAGNOSTIC_MODE_ON)
41 #endif
42 #ifndef IOCTL_USB_DIAGNOSTIC_MODE_OFF
43 #define IOCTL_USB_DIAGNOSTIC_MODE_OFF USB_CTL(HCD_DIAGNOSTIC_MODE_OFF)
44 #endif
45 
46 #ifndef IOCTL_USB_GET_ROOT_HUB_NAME
47 #define IOCTL_USB_GET_ROOT_HUB_NAME USB_CTL(HCD_GET_ROOT_HUB_NAME)
48 #endif
49 #ifndef IOCTL_GET_HCD_DRIVERKEY_NAME
50 #define IOCTL_GET_HCD_DRIVERKEY_NAME USB_CTL(HCD_GET_DRIVERKEY_NAME)
51 #endif
52 
53 typedef enum _USB_USER_ERROR_CODE {
54  UsbUserSuccess = 0,
55  UsbUserNotSupported,
56  UsbUserInvalidRequestCode,
57  UsbUserFeatureDisabled,
58  UsbUserInvalidHeaderParameter,
59  UsbUserInvalidParameter,
60  UsbUserMiniportError,
61  UsbUserBufferTooSmall,
62  UsbUserErrorNotMapped,
63  UsbUserDeviceNotStarted,
64  UsbUserNoDeviceConnected
65 } USB_USER_ERROR_CODE;
66 
67 #define USBUSER_GET_CONTROLLER_INFO_0 0x00000001
68 #define USBUSER_GET_CONTROLLER_DRIVER_KEY 0x00000002
69 #define USBUSER_PASS_THRU 0x00000003
70 #define USBUSER_GET_POWER_STATE_MAP 0x00000004
71 #define USBUSER_GET_BANDWIDTH_INFORMATION 0x00000005
72 #define USBUSER_GET_BUS_STATISTICS_0 0x00000006
73 #define USBUSER_GET_ROOTHUB_SYMBOLIC_NAME 0x00000007
74 #define USBUSER_GET_USB_DRIVER_VERSION 0x00000008
75 #define USBUSER_GET_USB2_HW_VERSION 0x00000009
76 #define USBUSER_USB_REFRESH_HCT_REG 0x0000000a
77 
78 #define USBUSER_OP_SEND_ONE_PACKET 0x10000001
79 #define USBUSER_OP_RAW_RESET_PORT 0x20000001
80 #define USBUSER_OP_OPEN_RAW_DEVICE 0x20000002
81 #define USBUSER_OP_CLOSE_RAW_DEVICE 0x20000003
82 #define USBUSER_OP_SEND_RAW_COMMAND 0x20000004
83 #define USBUSER_SET_ROOTPORT_FEATURE 0x20000005
84 #define USBUSER_CLEAR_ROOTPORT_FEATURE 0x20000006
85 #define USBUSER_GET_ROOTPORT_STATUS 0x20000007
86 
87 #define USBUSER_INVALID_REQUEST 0xFFFFFFF0
88 #define USBUSER_OP_MASK_DEVONLY_API 0x10000000
89 #define USBUSER_OP_MASK_HCTEST_API 0x20000000
90 
91 #define USB_PACKETFLAG_LOW_SPEED 0x00000001
92 #define USB_PACKETFLAG_FULL_SPEED 0x00000002
93 #define USB_PACKETFLAG_HIGH_SPEED 0x00000004
94 #define USB_PACKETFLAG_ASYNC_IN 0x00000008
95 #define USB_PACKETFLAG_ASYNC_OUT 0x00000010
96 #define USB_PACKETFLAG_ISO_IN 0x00000020
97 #define USB_PACKETFLAG_ISO_OUT 0x00000040
98 #define USB_PACKETFLAG_SETUP 0x00000080
99 #define USB_PACKETFLAG_TOGGLE0 0x00000100
100 #define USB_PACKETFLAG_TOGGLE1 0x00000200
101 
102 /* USB_CONTROLLER_INFO_0.HcFeatureFlags constants */
103 #define USB_HC_FEATURE_FLAG_PORT_POWER_SWITCHING 0x00000001
104 #define USB_HC_FEATURE_FLAG_SEL_SUSPEND 0x00000002
105 #define USB_HC_FEATURE_LEGACY_BIOS 0x00000004
106 
107 typedef struct _USBUSER_REQUEST_HEADER {
108  ULONG UsbUserRequest;
109  USB_USER_ERROR_CODE UsbUserStatusCode;
110  ULONG RequestBufferLength;
111  ULONG ActualBufferLength;
112 } USBUSER_REQUEST_HEADER, *PUSBUSER_REQUEST_HEADER;
113 
114 typedef struct _PACKET_PARAMETERS {
116  UCHAR EndpointAddress;
117  USHORT MaximumPacketSize;
118  ULONG Timeout;
119  ULONG Flags;
121  USHORT HubDeviceAddress;
122  USHORT PortTTNumber;
123  UCHAR ErrorCount;
124  UCHAR Pad[3];
125  USBD_STATUS UsbdStatusCode;
126  UCHAR Data[4];
127 } PACKET_PARAMETERS, *PPACKET_PARAMETERS;
128 
129 typedef struct _USBUSER_SEND_ONE_PACKET {
130  USBUSER_REQUEST_HEADER Header;
131  PACKET_PARAMETERS PacketParameters;
132 } USBUSER_SEND_ONE_PACKET, *PUSBUSER_SEND_ONE_PACKET;
133 
134 typedef struct _RAW_RESET_PORT_PARAMETERS {
137 } RAW_RESET_PORT_PARAMETERS, *PRAW_RESET_PORT_PARAMETERS;
138 
139 typedef struct _USBUSER_RAW_RESET_ROOT_PORT {
140  USBUSER_REQUEST_HEADER Header;
141  RAW_RESET_PORT_PARAMETERS Parameters;
142 } USBUSER_RAW_RESET_ROOT_PORT, *PUSBUSER_RAW_RESET_ROOT_PORT;
143 
144 typedef struct _RAW_ROOTPORT_FEATURE {
146  USHORT PortFeature;
148 } RAW_ROOTPORT_FEATURE, *PRAW_ROOTPORT_FEATURE;
149 
150 typedef struct _USBUSER_ROOTPORT_FEATURE_REQUEST {
151  USBUSER_REQUEST_HEADER Header;
152  RAW_ROOTPORT_FEATURE Parameters;
153 } USBUSER_ROOTPORT_FEATURE_REQUEST, *PUSBUSER_ROOTPORT_FEATURE_REQUEST;
154 
155 typedef struct _RAW_ROOTPORT_PARAMETERS {
158 } RAW_ROOTPORT_PARAMETERS, *PRAW_ROOTPORT_PARAMETERS;
159 
160 typedef struct _USBUSER_ROOTPORT_PARAMETERS {
161  USBUSER_REQUEST_HEADER Header;
162  RAW_ROOTPORT_PARAMETERS Parameters;
163 } USBUSER_ROOTPORT_PARAMETERS, *PUSBUSER_ROOTPORT_PARAMETERS;
164 
165 typedef struct _USB_CONTROLLER_INFO_0 {
166  ULONG PciVendorId;
167  ULONG PciDeviceId;
168  ULONG PciRevision;
169  ULONG NumberOfRootPorts;
170  USB_CONTROLLER_FLAVOR ControllerFlavor;
171  ULONG HcFeatureFlags;
172 } USB_CONTROLLER_INFO_0 , *PUSB_CONTROLLER_INFO_0;
173 
174 typedef struct _USBUSER_CONTROLLER_INFO_0 {
175  USBUSER_REQUEST_HEADER Header;
176  USB_CONTROLLER_INFO_0 Info0;
177 } USBUSER_CONTROLLER_INFO_0, *PUSBUSER_CONTROLLER_INFO_0;
178 
179 typedef struct _USB_UNICODE_NAME {
180  ULONG Length;
181  WCHAR String[1];
182 } USB_UNICODE_NAME, *PUSB_UNICODE_NAME;
183 
184 typedef struct _USBUSER_CONTROLLER_UNICODE_NAME {
185  USBUSER_REQUEST_HEADER Header;
186  USB_UNICODE_NAME UnicodeName;
187 } USBUSER_CONTROLLER_UNICODE_NAME, *PUSBUSER_CONTROLLER_UNICODE_NAME;
188 
189 typedef struct _USB_PASS_THRU_PARAMETERS {
190  GUID FunctionGUID;
192  UCHAR Parameters[4];
193 } USB_PASS_THRU_PARAMETERS, *PUSB_PASS_THRU_PARAMETERS;
194 
195 typedef struct _USBUSER_PASS_THRU_REQUEST {
196  USBUSER_REQUEST_HEADER Header;
197  USB_PASS_THRU_PARAMETERS PassThru;
198 } USBUSER_PASS_THRU_REQUEST, *PUSBUSER_PASS_THRU_REQUEST;
199 
200 typedef enum _WDMUSB_POWER_STATE {
201  WdmUsbPowerNotMapped = 0,
202  WdmUsbPowerSystemUnspecified = 100,
203  WdmUsbPowerSystemWorking,
204  WdmUsbPowerSystemSleeping1,
205  WdmUsbPowerSystemSleeping2,
206  WdmUsbPowerSystemSleeping3,
207  WdmUsbPowerSystemHibernate,
208  WdmUsbPowerSystemShutdown,
209  WdmUsbPowerDeviceUnspecified = 200,
210  WdmUsbPowerDeviceD0,
211  WdmUsbPowerDeviceD1,
212  WdmUsbPowerDeviceD2,
213  WdmUsbPowerDeviceD3
214 } WDMUSB_POWER_STATE;
215 
216 typedef struct _USB_POWER_INFO {
217  WDMUSB_POWER_STATE SystemState;
218  WDMUSB_POWER_STATE HcDevicePowerState;
219  WDMUSB_POWER_STATE HcDeviceWake;
220  WDMUSB_POWER_STATE HcSystemWake;
221  WDMUSB_POWER_STATE RhDevicePowerState;
222  WDMUSB_POWER_STATE RhDeviceWake;
223  WDMUSB_POWER_STATE RhSystemWake;
224  WDMUSB_POWER_STATE LastSystemSleepState;
225  BOOLEAN CanWakeup;
226  BOOLEAN IsPowered;
227 } USB_POWER_INFO, *PUSB_POWER_INFO;
228 
229 typedef struct _USBUSER_POWER_INFO_REQUEST {
230  USBUSER_REQUEST_HEADER Header;
231  USB_POWER_INFO PowerInformation;
232 } USBUSER_POWER_INFO_REQUEST, *PUSBUSER_POWER_INFO_REQUEST;
233 
234 typedef struct _USB_OPEN_RAW_DEVICE_PARAMETERS {
236  USHORT MaxPacketEp0;
237 } USB_OPEN_RAW_DEVICE_PARAMETERS , *PUSB_OPEN_RAW_DEVICE_PARAMETERS;
238 
239 typedef struct _USBUSER_OPEN_RAW_DEVICE {
240  USBUSER_REQUEST_HEADER Header;
241  USB_OPEN_RAW_DEVICE_PARAMETERS Parameters;
242 } USBUSER_OPEN_RAW_DEVICE, *PUSBUSER_OPEN_RAW_DEVICE;
243 
244 typedef struct _USB_CLOSE_RAW_DEVICE_PARAMETERS {
245  ULONG xxx;
246 } USB_CLOSE_RAW_DEVICE_PARAMETERS , *PUSB_CLOSE_RAW_DEVICE_PARAMETERS;
247 
248 typedef struct _USBUSER_CLOSE_RAW_DEVICE {
249  USBUSER_REQUEST_HEADER Header;
250  USB_CLOSE_RAW_DEVICE_PARAMETERS Parameters;
251 } USBUSER_CLOSE_RAW_DEVICE, *PUSBUSER_CLOSE_RAW_DEVICE;
252 
253 typedef struct _USB_SEND_RAW_COMMAND_PARAMETERS {
254  UCHAR Usb_bmRequest;
255  UCHAR Usb_bRequest;
256  USHORT Usb_wVlaue;
257  USHORT Usb_wIndex;
258  USHORT Usb_wLength;
260  USHORT MaximumPacketSize;
261  ULONG Timeout;
263  USBD_STATUS UsbdStatusCode;
264  UCHAR Data[4];
265 } USB_SEND_RAW_COMMAND_PARAMETERS, *PUSB_SEND_RAW_COMMAND_PARAMETERS;
266 
267 typedef struct _USBUSER_SEND_RAW_COMMAND {
268  USBUSER_REQUEST_HEADER Header;
269  USB_SEND_RAW_COMMAND_PARAMETERS Parameters;
270 } USBUSER_SEND_RAW_COMMAND, *PUSBUSER_SEND_RAW_COMMAND;
271 
272 typedef struct _USB_BANDWIDTH_INFO {
274  ULONG TotalBusBandwidth;
275  ULONG Total32secBandwidth;
276  ULONG AllocedBulkAndControl;
277  ULONG AllocedIso;
278  ULONG AllocedInterrupt_1ms;
279  ULONG AllocedInterrupt_2ms;
280  ULONG AllocedInterrupt_4ms;
281  ULONG AllocedInterrupt_8ms;
282  ULONG AllocedInterrupt_16ms;
283  ULONG AllocedInterrupt_32ms;
284 } USB_BANDWIDTH_INFO, *PUSB_BANDWIDTH_INFO;
285 
286 typedef struct _USBUSER_BANDWIDTH_INFO_REQUEST {
287  USBUSER_REQUEST_HEADER Header;
288  USB_BANDWIDTH_INFO BandwidthInformation;
289 } USBUSER_BANDWIDTH_INFO_REQUEST, *PUSBUSER_BANDWIDTH_INFO_REQUEST;
290 
291 typedef struct _USB_BUS_STATISTICS_0 {
293  LARGE_INTEGER CurrentSystemTime;
294  ULONG CurrentUsbFrame;
295  ULONG BulkBytes;
296  ULONG IsoBytes;
297  ULONG InterruptBytes;
298  ULONG ControlDataBytes;
299  ULONG PciInterruptCount;
300  ULONG HardResetCount;
301  ULONG WorkerSignalCount;
302  ULONG CommonBufferBytes;
303  ULONG WorkerIdleTimeMs;
304  BOOLEAN RootHubEnabled;
305  UCHAR RootHubDevicePowerState;
306  UCHAR Unused;
307  UCHAR NameIndex;
308 } USB_BUS_STATISTICS_0, *PUSB_BUS_STATISTICS_0;
309 
310 typedef struct _USBUSER_BUS_STATISTICS_0_REQUEST {
311  USBUSER_REQUEST_HEADER Header;
312  USB_BUS_STATISTICS_0 BusStatistics0;
313 } USBUSER_BUS_STATISTICS_0_REQUEST, *PUSBUSER_BUS_STATISTICS_0_REQUEST;
314 
315 typedef struct _USB_DRIVER_VERSION_PARAMETERS {
316  ULONG DriverTrackingCode;
317  ULONG USBDI_Version;
318  ULONG USBUSER_Version;
319  BOOLEAN CheckedPortDriver;
320  BOOLEAN CheckedMiniportDriver;
321  USHORT USB_Version;
322 } USB_DRIVER_VERSION_PARAMETERS , *PUSB_DRIVER_VERSION_PARAMETERS;
323 
324 typedef struct _USBUSER_GET_DRIVER_VERSION {
325  USBUSER_REQUEST_HEADER Header;
326  USB_DRIVER_VERSION_PARAMETERS Parameters;
327 } USBUSER_GET_DRIVER_VERSION, *PUSBUSER_GET_DRIVER_VERSION;
328 
329 typedef struct _USB_USB2HW_VERSION_PARAMETERS {
330  UCHAR Usb2HwRevision;
331 } USB_USB2HW_VERSION_PARAMETERS, *PUSB_USB2HW_VERSION_PARAMETERS;
332 
333 typedef struct _USBUSER_GET_USB2HW_VERSION {
334  USBUSER_REQUEST_HEADER Header;
335  USB_USB2HW_VERSION_PARAMETERS Parameters;
336 } USBUSER_GET_USB2HW_VERSION, *PUSBUSER_GET_USB2HW_VERSION;
337 
338 typedef struct _USBUSER_REFRESH_HCT_REG {
339  USBUSER_REQUEST_HEADER Header;
340  ULONG Flags;
341 } USBUSER_REFRESH_HCT_REG, *PUSBUSER_REFRESH_HCT_REG;
342 
343 #include <poppack.h>
344 
345 #endif /* _WIN32_WINNT >= 0x0501 */
346 
347 #ifdef __cplusplus
348 }
349 #endif
_Must_inspect_result_ typedef _In_ PVOID Unused
Definition: iotypes.h:1166
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:863
IN PDCB IN POEM_STRING IN PUNICODE_STRING UnicodeName
Definition: fatprocs.h:1303
char * Pad(char *Str, char PadChar, ULONG Length)
Definition: cabman.cxx:29
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
_In_ PUSB_DEVICE_HANDLE _Out_ PUSHORT DeviceAddress
Definition: hubbusif.h:359
Definition: Header.h:8
ULONG DeviceCount
Definition: mpu401.c:26
ULONG PortNumber
Definition: storport.c:18
unsigned char BOOLEAN
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180
enum _USB_CONTROLLER_FLAVOR USB_CONTROLLER_FLAVOR
unsigned char UCHAR
Definition: xmlstorage.h:181
LONG USBD_STATUS
Definition: usb.h:165
_In_ ULONG ParameterLength
Definition: usbdlib.h:206
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
Definition: hubbusif.h:40
static ULONG Timeout
Definition: ping.c:61
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1