More work on USB related definitions
[reactos.git] / include / ddk / usbuser.h
1 /*
2 * usbuser.h
3 *
4 * USB user mode IOCTL interface
5 *
6 * This file is part of the w32api 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 #ifndef __USBUSER_H
24 #define __USBUSER_H
25
26 #include "usb.h"
27 #include "usbiodef.h"
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
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_OP_SEND_ONE_PACKET 0x10000001
77 #define USBUSER_OP_RAW_RESET_PORT 0x20000001
78 #define USBUSER_OP_OPEN_RAW_DEVICE 0x20000002
79 #define USBUSER_OP_CLOSE_RAW_DEVICE 0x20000003
80 #define USBUSER_OP_SEND_RAW_COMMAND 0x20000004
81 #define USBUSER_INVALID_REQUEST 0xFFFFFFF0
82 #define USBUSER_OP_MASK_DEVONLY_API 0x10000000
83 #define USBUSER_OP_MASK_HCTEST_API 0x20000000
84
85 #define USB_PACKETFLAG_LOW_SPEED 0x00000001
86 #define USB_PACKETFLAG_FULL_SPEED 0x00000002
87 #define USB_PACKETFLAG_HIGH_SPEED 0x00000004
88 #define USB_PACKETFLAG_ASYNC_IN 0x00000008
89 #define USB_PACKETFLAG_ASYNC_OUT 0x00000010
90 #define USB_PACKETFLAG_ISO_IN 0x00000020
91 #define USB_PACKETFLAG_ISO_OUT 0x00000040
92 #define USB_PACKETFLAG_SETUP 0x00000080
93 #define USB_PACKETFLAG_TOGGLE0 0x00000100
94 #define USB_PACKETFLAG_TOGGLE1 0x00000200
95
96 typedef struct _PACKET_PARAMETERS {
97 UCHAR DeviceAddress;
98 UCHAR EndpointAddress;
99 USHORT MaximumPacketSize;
100 ULONG Timeout;
101 ULONG Flags;
102 ULONG DataLength;
103 USHORT HubDeviceAddress;
104 USHORT PortTTNumber;
105 UCHAR ErrorCount;
106 UCHAR Pad[3];
107 USBD_STATUS UsbdStatusCode;
108 UCHAR Data[4];
109 } PACKET_PARAMETERS, *PPACKET_PARAMETERS;
110
111 typedef struct _RAW_RESET_PORT_PARAMETERS {
112 USHORT PortNumber;
113 USHORT PortStatus;
114 } RAW_RESET_PORT_PARAMETERS, *PRAW_RESET_PORT_PARAMETERS;
115
116 typedef struct _USB_BANDWIDTH_INFO {
117 ULONG DeviceCount;
118 ULONG TotalBusBandwidth;
119 ULONG Total32secBandwidth;
120 ULONG AllocedBulkAndControl;
121 ULONG AllocedIso;
122 ULONG AllocedInterrupt_1ms;
123 ULONG AllocedInterrupt_2ms;
124 ULONG AllocedInterrupt_4ms;
125 ULONG AllocedInterrupt_8ms;
126 ULONG AllocedInterrupt_16ms;
127 ULONG AllocedInterrupt_32ms;
128 } USB_BANDWIDTH_INFO, *PUSB_BANDWIDTH_INFO;
129
130 typedef struct _USBUSER_REQUEST_HEADER {
131 ULONG UsbUserRequest;
132 USB_USER_ERROR_CODE UsbUserStatusCode;
133 ULONG RequestBufferLength;
134 ULONG ActualBufferLength;
135 } USBUSER_REQUEST_HEADER, *PUSBUSER_REQUEST_HEADER;
136
137 typedef struct _USBUSER_BANDWIDTH_INFO_REQUEST {
138 USBUSER_REQUEST_HEADER Header;
139 USB_BANDWIDTH_INFO BandwidthInformation;
140 } USBUSER_BANDWIDTH_INFO_REQUEST, *PUSBUSER_BANDWIDTH_INFO_REQUEST;
141
142 typedef struct _USB_BUS_STATISTICS_0 {
143 ULONG DeviceCount;
144 LARGE_INTEGER CurrentSystemTime;
145 ULONG CurrentUsbFrame;
146 ULONG BulkBytes;
147 ULONG IsoBytes;
148 ULONG InterruptBytes;
149 ULONG ControlDataBytes;
150 ULONG PciInterruptCount;
151 ULONG HardResetCount;
152 ULONG WorkerSignalCount;
153 ULONG CommonBufferBytes;
154 ULONG WorkerIdleTimeMs;
155 BOOLEAN RootHubEnabled;
156 UCHAR RootHubDevicePowerState;
157 UCHAR Unused;
158 UCHAR NameIndex;
159 } USB_BUS_STATISTICS_0, *PUSB_BUS_STATISTICS_0;
160
161 typedef struct _USBUSER_BUS_STATISTICS_0_REQUEST {
162 USBUSER_REQUEST_HEADER Header;
163 USB_BUS_STATISTICS_0 BusStatistics0;
164 } USBUSER_BUS_STATISTICS_0_REQUEST, *PUSBUSER_BUS_STATISTICS_0_REQUEST;
165
166 /* USB_CONTROLLER_INFO_0.HcFeatureFlags constants */
167 #define USB_HC_FEATURE_FLAG_PORT_POWER_SWITCHING 0x00000001
168 #define USB_HC_FEATURE_FLAG_SEL_SUSPEND 0x00000002
169 #define USB_HC_FEATURE_LEGACY_BIOS 0x00000004
170
171 typedef struct _USB_CLOSE_RAW_DEVICE_PARAMETERS {
172 ULONG xxx;
173 } USB_CLOSE_RAW_DEVICE_PARAMETERS , *PUSB_CLOSE_RAW_DEVICE_PARAMETERS;
174
175 typedef struct _USBUSER_CLOSE_RAW_DEVICE {
176 USBUSER_REQUEST_HEADER Header;
177 USB_CLOSE_RAW_DEVICE_PARAMETERS Parameters;
178 } USBUSER_CLOSE_RAW_DEVICE, *PUSBUSER_CLOSE_RAW_DEVICE;
179
180 typedef struct _USB_CONTROLLER_INFO_0 {
181 ULONG PciVendorId;
182 ULONG PciDeviceId;
183 ULONG PciRevision;
184 ULONG NumberOfRootPorts;
185 USB_CONTROLLER_FLAVOR ControllerFlavor;
186 ULONG HcFeatureFlags;
187 } USB_CONTROLLER_INFO_0 , *PUSB_CONTROLLER_INFO_0;
188
189 typedef struct _USBUSER_CONTROLLER_INFO_0 {
190 USBUSER_REQUEST_HEADER Header;
191 USB_CONTROLLER_INFO_0 Info0;
192 } USBUSER_CONTROLLER_INFO_0, *PUSBUSER_CONTROLLER_INFO_0;
193
194 typedef struct _USB_DRIVER_VERSION_PARAMETERS {
195 ULONG DriverTrackingCode;
196 ULONG USBDI_Version;
197 ULONG USBUSER_Version;
198 BOOLEAN CheckedPortDriver;
199 BOOLEAN CheckedMiniportDriver;
200 USHORT USB_Version;
201 } USB_DRIVER_VERSION_PARAMETERS , *PUSB_DRIVER_VERSION_PARAMETERS;
202
203 typedef struct _USBUSER_GET_DRIVER_VERSION {
204 USBUSER_REQUEST_HEADER Header;
205 USB_DRIVER_VERSION_PARAMETERS Parameters;
206 } USBUSER_GET_DRIVER_VERSION, *PUSBUSER_GET_DRIVER_VERSION;
207
208 typedef struct _USB_OPEN_RAW_DEVICE_PARAMETERS {
209 USHORT PortStatus;
210 USHORT MaxPacketEp0;
211 } USB_OPEN_RAW_DEVICE_PARAMETERS , *PUSB_OPEN_RAW_DEVICE_PARAMETERS;
212
213 typedef struct _USBUSER_OPEN_RAW_DEVICE {
214 USBUSER_REQUEST_HEADER Header;
215 USB_OPEN_RAW_DEVICE_PARAMETERS Parameters;
216 } USBUSER_OPEN_RAW_DEVICE, *PUSBUSER_OPEN_RAW_DEVICE;
217
218 typedef enum _WDMUSB_POWER_STATE {
219 WdmUsbPowerNotMapped = 0,
220 WdmUsbPowerSystemUnspecified = 100,
221 WdmUsbPowerSystemWorking,
222 WdmUsbPowerSystemSleeping1,
223 WdmUsbPowerSystemSleeping2,
224 WdmUsbPowerSystemSleeping3,
225 WdmUsbPowerSystemHibernate,
226 WdmUsbPowerSystemShutdown,
227 WdmUsbPowerDeviceUnspecified = 200,
228 WdmUsbPowerDeviceD0,
229 WdmUsbPowerDeviceD1,
230 WdmUsbPowerDeviceD2,
231 WdmUsbPowerDeviceD3
232 } WDMUSB_POWER_STATE;
233
234 typedef struct _USB_POWER_INFO {
235 WDMUSB_POWER_STATE SystemState;
236 WDMUSB_POWER_STATE HcDevicePowerState;
237 WDMUSB_POWER_STATE HcDeviceWake;
238 WDMUSB_POWER_STATE HcSystemWake;
239 WDMUSB_POWER_STATE RhDevicePowerState;
240 WDMUSB_POWER_STATE RhDeviceWake;
241 WDMUSB_POWER_STATE RhSystemWake;
242 WDMUSB_POWER_STATE LastSystemSleepState;
243 BOOLEAN CanWakeup;
244 BOOLEAN IsPowered;
245 } USB_POWER_INFO, *PUSB_POWER_INFO;
246
247 typedef struct _USBUSER_POWER_INFO_REQUEST {
248 USBUSER_REQUEST_HEADER Header;
249 USB_POWER_INFO PowerInformation;
250 } USBUSER_POWER_INFO_REQUEST, *PUSBUSER_POWER_INFO_REQUEST;
251
252 typedef struct _USB_UNICODE_NAME {
253 ULONG Length;
254 WCHAR String[1];
255 } USB_UNICODE_NAME, *PUSB_UNICODE_NAME;
256
257 typedef struct _USBUSER_CONTROLLER_UNICODE_NAME {
258 USBUSER_REQUEST_HEADER Header;
259 USB_UNICODE_NAME UnicodeName;
260 } USBUSER_CONTROLLER_UNICODE_NAME, *PUSBUSER_CONTROLLER_UNICODE_NAME;
261
262 typedef struct _USB_PASS_THRU_PARAMETERS {
263 GUID FunctionGUID;
264 ULONG ParameterLength;
265 UCHAR Parameters[4];
266 } USB_PASS_THRU_PARAMETERS, *PUSB_PASS_THRU_PARAMETERS;
267
268 typedef struct _USBUSER_PASS_THRU_REQUEST {
269 USBUSER_REQUEST_HEADER Header;
270 USB_PASS_THRU_PARAMETERS PassThru;
271 } USBUSER_PASS_THRU_REQUEST, *PUSBUSER_PASS_THRU_REQUEST;
272
273 typedef struct _USBUSER_RAW_RESET_ROOT_PORT {
274 USBUSER_REQUEST_HEADER Header;
275 RAW_RESET_PORT_PARAMETERS Parameters;
276 } USBUSER_RAW_RESET_ROOT_PORT, *PUSBUSER_RAW_RESET_ROOT_PORT;
277
278 typedef struct _USBUSER_SEND_ONE_PACKET {
279 USBUSER_REQUEST_HEADER Header;
280 PACKET_PARAMETERS PacketParameters;
281 } USBUSER_SEND_ONE_PACKET, *PUSBUSER_SEND_ONE_PACKET;
282
283 typedef struct _USB_SEND_RAW_COMMAND_PARAMETERS {
284 UCHAR Usb_bmRequest;
285 UCHAR Usb_bRequest;
286 USHORT Usb_wVlaue;
287 USHORT Usb_wIndex;
288 USHORT Usb_wLength;
289 USHORT DeviceAddress;
290 USHORT MaximumPacketSize;
291 ULONG Timeout;
292 ULONG DataLength;
293 USBD_STATUS UsbdStatusCode;
294 UCHAR Data[4];
295 } USB_SEND_RAW_COMMAND_PARAMETERS, *PUSB_SEND_RAW_COMMAND_PARAMETERS;
296
297 typedef struct _USBUSER_SEND_RAW_COMMAND {
298 USBUSER_REQUEST_HEADER Header;
299 USB_SEND_RAW_COMMAND_PARAMETERS Parameters;
300 } USBUSER_SEND_RAW_COMMAND, *PUSBUSER_SEND_RAW_COMMAND;
301
302 /* USB_USB2HW_VERSION_PARAMETERS.Usb2HwRevision constants */
303 #define USB2HW_UNKNOWN 0x00
304 #define USB2HW_A0 0xA0
305 #define USB2HW_A1 0xA1
306 #define USB2HW_B0 0xB0
307
308 typedef struct _USB_USB2HW_VERSION_PARAMETERS {
309 UCHAR Usb2HwRevision;
310 } USB_USB2HW_VERSION_PARAMETERS, *PUSB_USB2HW_VERSION_PARAMETERS;
311
312 typedef struct _USBUSER_GET_USB2HW_VERSION {
313 USBUSER_REQUEST_HEADER Header;
314 USB_USB2HW_VERSION_PARAMETERS Parameters;
315 } USBUSER_GET_USB2HW_VERSION, *PUSBUSER_GET_USB2HW_VERSION;
316
317 #include <poppack.h>
318
319 #ifdef __cplusplus
320 }
321 #endif
322
323 #endif /* __USBUSER_H */