source: Daodan/MinGW/include/ddk/usbuser.h@ 1130

Last change on this file since 1130 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 9.9 KB
RevLine 
[1046]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#if __GNUC__ >=3
27#pragma GCC system_header
28#endif
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include "ntddk.h"
35#include "usb.h"
36#include "usbiodef.h"
37
38#include <pshpack1.h>
39
40#define USBUSER_VERSION 0x0004
41
42#define IOCTL_USB_USER_REQUEST USB_CTL(HCD_USER_REQUEST)
43
44#ifndef IOCTL_USB_DIAGNOSTIC_MODE_ON
45#define IOCTL_USB_DIAGNOSTIC_MODE_ON USB_CTL(HCD_DIAGNOSTIC_MODE_ON)
46#endif
47#ifndef IOCTL_USB_DIAGNOSTIC_MODE_OFF
48#define IOCTL_USB_DIAGNOSTIC_MODE_OFF USB_CTL(HCD_DIAGNOSTIC_MODE_OFF)
49#endif
50
51#ifndef IOCTL_USB_GET_ROOT_HUB_NAME
52#define IOCTL_USB_GET_ROOT_HUB_NAME USB_CTL(HCD_GET_ROOT_HUB_NAME)
53#endif
54#ifndef IOCTL_GET_HCD_DRIVERKEY_NAME
55#define IOCTL_GET_HCD_DRIVERKEY_NAME USB_CTL(HCD_GET_DRIVERKEY_NAME)
56#endif
57
58typedef enum _USB_USER_ERROR_CODE {
59 UsbUserSuccess = 0,
60 UsbUserNotSupported,
61 UsbUserInvalidRequestCode,
62 UsbUserFeatureDisabled,
63 UsbUserInvalidHeaderParameter,
64 UsbUserInvalidParameter,
65 UsbUserMiniportError,
66 UsbUserBufferTooSmall,
67 UsbUserErrorNotMapped,
68 UsbUserDeviceNotStarted,
69 UsbUserNoDeviceConnected
70} USB_USER_ERROR_CODE;
71
72#define USBUSER_GET_CONTROLLER_INFO_0 0x00000001
73#define USBUSER_GET_CONTROLLER_DRIVER_KEY 0x00000002
74#define USBUSER_PASS_THRU 0x00000003
75#define USBUSER_GET_POWER_STATE_MAP 0x00000004
76#define USBUSER_GET_BANDWIDTH_INFORMATION 0x00000005
77#define USBUSER_GET_BUS_STATISTICS_0 0x00000006
78#define USBUSER_GET_ROOTHUB_SYMBOLIC_NAME 0x00000007
79#define USBUSER_GET_USB_DRIVER_VERSION 0x00000008
80#define USBUSER_GET_USB2_HW_VERSION 0x00000009
81#define USBUSER_OP_SEND_ONE_PACKET 0x10000001
82#define USBUSER_OP_RAW_RESET_PORT 0x20000001
83#define USBUSER_OP_OPEN_RAW_DEVICE 0x20000002
84#define USBUSER_OP_CLOSE_RAW_DEVICE 0x20000003
85#define USBUSER_OP_SEND_RAW_COMMAND 0x20000004
86#define USBUSER_INVALID_REQUEST 0xFFFFFFF0
87#define USBUSER_OP_MASK_DEVONLY_API 0x10000000
88#define USBUSER_OP_MASK_HCTEST_API 0x20000000
89
90#define USB_PACKETFLAG_LOW_SPEED 0x00000001
91#define USB_PACKETFLAG_FULL_SPEED 0x00000002
92#define USB_PACKETFLAG_HIGH_SPEED 0x00000004
93#define USB_PACKETFLAG_ASYNC_IN 0x00000008
94#define USB_PACKETFLAG_ASYNC_OUT 0x00000010
95#define USB_PACKETFLAG_ISO_IN 0x00000020
96#define USB_PACKETFLAG_ISO_OUT 0x00000040
97#define USB_PACKETFLAG_SETUP 0x00000080
98#define USB_PACKETFLAG_TOGGLE0 0x00000100
99#define USB_PACKETFLAG_TOGGLE1 0x00000200
100
101typedef struct _PACKET_PARAMETERS {
102 UCHAR DeviceAddress;
103 UCHAR EndpointAddress;
104 USHORT MaximumPacketSize;
105 ULONG Timeout;
106 ULONG Flags;
107 ULONG DataLength;
108 USHORT HubDeviceAddress;
109 USHORT PortTTNumber;
110 UCHAR ErrorCount;
111 UCHAR Pad[3];
112 USBD_STATUS UsbdStatusCode;
113 UCHAR Data[4];
114} PACKET_PARAMETERS, *PPACKET_PARAMETERS;
115
116typedef struct _RAW_RESET_PORT_PARAMETERS {
117 USHORT PortNumber;
118 USHORT PortStatus;
119} RAW_RESET_PORT_PARAMETERS, *PRAW_RESET_PORT_PARAMETERS;
120
121typedef struct _USB_BANDWIDTH_INFO {
122 ULONG DeviceCount;
123 ULONG TotalBusBandwidth;
124 ULONG Total32secBandwidth;
125 ULONG AllocedBulkAndControl;
126 ULONG AllocedIso;
127 ULONG AllocedInterrupt_1ms;
128 ULONG AllocedInterrupt_2ms;
129 ULONG AllocedInterrupt_4ms;
130 ULONG AllocedInterrupt_8ms;
131 ULONG AllocedInterrupt_16ms;
132 ULONG AllocedInterrupt_32ms;
133} USB_BANDWIDTH_INFO, *PUSB_BANDWIDTH_INFO;
134
135typedef struct _USBUSER_REQUEST_HEADER {
136 ULONG UsbUserRequest;
137 USB_USER_ERROR_CODE UsbUserStatusCode;
138 ULONG RequestBufferLength;
139 ULONG ActualBufferLength;
140} USBUSER_REQUEST_HEADER, *PUSBUSER_REQUEST_HEADER;
141
142typedef struct _USBUSER_BANDWIDTH_INFO_REQUEST {
143 USBUSER_REQUEST_HEADER Header;
144 USB_BANDWIDTH_INFO BandwidthInformation;
145} USBUSER_BANDWIDTH_INFO_REQUEST, *PUSBUSER_BANDWIDTH_INFO_REQUEST;
146
147typedef struct _USB_BUS_STATISTICS_0 {
148 ULONG DeviceCount;
149 LARGE_INTEGER CurrentSystemTime;
150 ULONG CurrentUsbFrame;
151 ULONG BulkBytes;
152 ULONG IsoBytes;
153 ULONG InterruptBytes;
154 ULONG ControlDataBytes;
155 ULONG PciInterruptCount;
156 ULONG HardResetCount;
157 ULONG WorkerSignalCount;
158 ULONG CommonBufferBytes;
159 ULONG WorkerIdleTimeMs;
160 BOOLEAN RootHubEnabled;
161 UCHAR RootHubDevicePowerState;
162 UCHAR Unused;
163 UCHAR NameIndex;
164} USB_BUS_STATISTICS_0, *PUSB_BUS_STATISTICS_0;
165
166typedef struct _USBUSER_BUS_STATISTICS_0_REQUEST {
167 USBUSER_REQUEST_HEADER Header;
168 USB_BUS_STATISTICS_0 BusStatistics0;
169} USBUSER_BUS_STATISTICS_0_REQUEST, *PUSBUSER_BUS_STATISTICS_0_REQUEST;
170
171/* USB_CONTROLLER_INFO_0.HcFeatureFlags constants */
172#define USB_HC_FEATURE_FLAG_PORT_POWER_SWITCHING 0x00000001
173#define USB_HC_FEATURE_FLAG_SEL_SUSPEND 0x00000002
174#define USB_HC_FEATURE_LEGACY_BIOS 0x00000004
175
176typedef struct _USB_CLOSE_RAW_DEVICE_PARAMETERS {
177 ULONG xxx;
178} USB_CLOSE_RAW_DEVICE_PARAMETERS , *PUSB_CLOSE_RAW_DEVICE_PARAMETERS;
179
180typedef struct _USBUSER_CLOSE_RAW_DEVICE {
181 USBUSER_REQUEST_HEADER Header;
182 USB_CLOSE_RAW_DEVICE_PARAMETERS Parameters;
183} USBUSER_CLOSE_RAW_DEVICE, *PUSBUSER_CLOSE_RAW_DEVICE;
184
185typedef struct _USB_CONTROLLER_INFO_0 {
186 ULONG PciVendorId;
187 ULONG PciDeviceId;
188 ULONG PciRevision;
189 ULONG NumberOfRootPorts;
190 USB_CONTROLLER_FLAVOR ControllerFlavor;
191 ULONG HcFeatureFlags;
192} USB_CONTROLLER_INFO_0 , *PUSB_CONTROLLER_INFO_0;
193
194typedef struct _USBUSER_CONTROLLER_INFO_0 {
195 USBUSER_REQUEST_HEADER Header;
196 USB_CONTROLLER_INFO_0 Info0;
197} USBUSER_CONTROLLER_INFO_0, *PUSBUSER_CONTROLLER_INFO_0;
198
199typedef struct _USB_DRIVER_VERSION_PARAMETERS {
200 ULONG DriverTrackingCode;
201 ULONG USBDI_Version;
202 ULONG USBUSER_Version;
203 BOOLEAN CheckedPortDriver;
204 BOOLEAN CheckedMiniportDriver;
205 USHORT USB_Version;
206} USB_DRIVER_VERSION_PARAMETERS , *PUSB_DRIVER_VERSION_PARAMETERS;
207
208typedef struct _USBUSER_GET_DRIVER_VERSION {
209 USBUSER_REQUEST_HEADER Header;
210 USB_DRIVER_VERSION_PARAMETERS Parameters;
211} USBUSER_GET_DRIVER_VERSION, *PUSBUSER_GET_DRIVER_VERSION;
212
213typedef struct _USB_OPEN_RAW_DEVICE_PARAMETERS {
214 USHORT PortStatus;
215 USHORT MaxPacketEp0;
216} USB_OPEN_RAW_DEVICE_PARAMETERS , *PUSB_OPEN_RAW_DEVICE_PARAMETERS;
217
218typedef struct _USBUSER_OPEN_RAW_DEVICE {
219 USBUSER_REQUEST_HEADER Header;
220 USB_OPEN_RAW_DEVICE_PARAMETERS Parameters;
221} USBUSER_OPEN_RAW_DEVICE, *PUSBUSER_OPEN_RAW_DEVICE;
222
223typedef enum _WDMUSB_POWER_STATE {
224 WdmUsbPowerNotMapped = 0,
225 WdmUsbPowerSystemUnspecified = 100,
226 WdmUsbPowerSystemWorking,
227 WdmUsbPowerSystemSleeping1,
228 WdmUsbPowerSystemSleeping2,
229 WdmUsbPowerSystemSleeping3,
230 WdmUsbPowerSystemHibernate,
231 WdmUsbPowerSystemShutdown,
232 WdmUsbPowerDeviceUnspecified = 200,
233 WdmUsbPowerDeviceD0,
234 WdmUsbPowerDeviceD1,
235 WdmUsbPowerDeviceD2,
236 WdmUsbPowerDeviceD3
237} WDMUSB_POWER_STATE;
238
239typedef struct _USB_POWER_INFO {
240 WDMUSB_POWER_STATE SystemState;
241 WDMUSB_POWER_STATE HcDevicePowerState;
242 WDMUSB_POWER_STATE HcDeviceWake;
243 WDMUSB_POWER_STATE HcSystemWake;
244 WDMUSB_POWER_STATE RhDevicePowerState;
245 WDMUSB_POWER_STATE RhDeviceWake;
246 WDMUSB_POWER_STATE RhSystemWake;
247 WDMUSB_POWER_STATE LastSystemSleepState;
248 BOOLEAN CanWakeup;
249 BOOLEAN IsPowered;
250} USB_POWER_INFO, *PUSB_POWER_INFO;
251
252typedef struct _USBUSER_POWER_INFO_REQUEST {
253 USBUSER_REQUEST_HEADER Header;
254 USB_POWER_INFO PowerInformation;
255} USBUSER_POWER_INFO_REQUEST, *PUSBUSER_POWER_INFO_REQUEST;
256
257typedef struct _USB_UNICODE_NAME {
258 ULONG Length;
259 WCHAR String[1];
260} USB_UNICODE_NAME, *PUSB_UNICODE_NAME;
261
262typedef struct _USBUSER_CONTROLLER_UNICODE_NAME {
263 USBUSER_REQUEST_HEADER Header;
264 USB_UNICODE_NAME UnicodeName;
265} USBUSER_CONTROLLER_UNICODE_NAME, *PUSBUSER_CONTROLLER_UNICODE_NAME;
266
267typedef struct _USB_PASS_THRU_PARAMETERS {
268 GUID FunctionGUID;
269 ULONG ParameterLength;
270 UCHAR Parameters[4];
271} USB_PASS_THRU_PARAMETERS, *PUSB_PASS_THRU_PARAMETERS;
272
273typedef struct _USBUSER_PASS_THRU_REQUEST {
274 USBUSER_REQUEST_HEADER Header;
275 USB_PASS_THRU_PARAMETERS PassThru;
276} USBUSER_PASS_THRU_REQUEST, *PUSBUSER_PASS_THRU_REQUEST;
277
278typedef struct _USBUSER_RAW_RESET_ROOT_PORT {
279 USBUSER_REQUEST_HEADER Header;
280 RAW_RESET_PORT_PARAMETERS Parameters;
281} USBUSER_RAW_RESET_ROOT_PORT, *PUSBUSER_RAW_RESET_ROOT_PORT;
282
283typedef struct _USBUSER_SEND_ONE_PACKET {
284 USBUSER_REQUEST_HEADER Header;
285 PACKET_PARAMETERS PacketParameters;
286} USBUSER_SEND_ONE_PACKET, *PUSBUSER_SEND_ONE_PACKET;
287
288typedef struct _USB_SEND_RAW_COMMAND_PARAMETERS {
289 UCHAR Usb_bmRequest;
290 UCHAR Usb_bRequest;
291 USHORT Usb_wVlaue;
292 USHORT Usb_wIndex;
293 USHORT Usb_wLength;
294 USHORT DeviceAddress;
295 USHORT MaximumPacketSize;
296 ULONG Timeout;
297 ULONG DataLength;
298 USBD_STATUS UsbdStatusCode;
299 UCHAR Data[4];
300} USB_SEND_RAW_COMMAND_PARAMETERS, *PUSB_SEND_RAW_COMMAND_PARAMETERS;
301
302typedef struct _USBUSER_SEND_RAW_COMMAND {
303 USBUSER_REQUEST_HEADER Header;
304 USB_SEND_RAW_COMMAND_PARAMETERS Parameters;
305} USBUSER_SEND_RAW_COMMAND, *PUSBUSER_SEND_RAW_COMMAND;
306
307/* USB_USB2HW_VERSION_PARAMETERS.Usb2HwRevision constants */
308#define USB2HW_UNKNOWN 0x00
309#define USB2HW_A0 0xA0
310#define USB2HW_A1 0xA1
311#define USB2HW_B0 0xB0
312
313typedef struct _USB_USB2HW_VERSION_PARAMETERS {
314 UCHAR Usb2HwRevision;
315} USB_USB2HW_VERSION_PARAMETERS, *PUSB_USB2HW_VERSION_PARAMETERS;
316
317typedef struct _USBUSER_GET_USB2HW_VERSION {
318 USBUSER_REQUEST_HEADER Header;
319 USB_USB2HW_VERSION_PARAMETERS Parameters;
320} USBUSER_GET_USB2HW_VERSION, *PUSBUSER_GET_USB2HW_VERSION;
321
322#include <poppack.h>
323
324#ifdef __cplusplus
325}
326#endif
327
328#endif /* __USBUSER_H */
Note: See TracBrowser for help on using the repository browser.