4 * USB user mode IOCTL interface
6 * This file is part of the w32api package.
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
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.
27 #pragma GCC system_header
40 #define USBUSER_VERSION 0x0004
42 #define IOCTL_USB_USER_REQUEST USB_CTL(HCD_USER_REQUEST)
44 #ifndef IOCTL_USB_DIAGNOSTIC_MODE_ON
45 #define IOCTL_USB_DIAGNOSTIC_MODE_ON USB_CTL(HCD_DIAGNOSTIC_MODE_ON)
47 #ifndef IOCTL_USB_DIAGNOSTIC_MODE_OFF
48 #define IOCTL_USB_DIAGNOSTIC_MODE_OFF USB_CTL(HCD_DIAGNOSTIC_MODE_OFF)
51 #ifndef IOCTL_USB_GET_ROOT_HUB_NAME
52 #define IOCTL_USB_GET_ROOT_HUB_NAME USB_CTL(HCD_GET_ROOT_HUB_NAME)
54 #ifndef IOCTL_GET_HCD_DRIVERKEY_NAME
55 #define IOCTL_GET_HCD_DRIVERKEY_NAME USB_CTL(HCD_GET_DRIVERKEY_NAME)
58 typedef enum _USB_USER_ERROR_CODE
{
61 UsbUserInvalidRequestCode
,
62 UsbUserFeatureDisabled
,
63 UsbUserInvalidHeaderParameter
,
64 UsbUserInvalidParameter
,
66 UsbUserBufferTooSmall
,
67 UsbUserErrorNotMapped
,
68 UsbUserDeviceNotStarted
,
69 UsbUserNoDeviceConnected
70 } USB_USER_ERROR_CODE
;
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
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
101 typedef struct _PACKET_PARAMETERS
{
103 UCHAR EndpointAddress
;
104 USHORT MaximumPacketSize
;
108 USHORT HubDeviceAddress
;
112 USBD_STATUS UsbdStatusCode
;
114 } PACKET_PARAMETERS
, *PPACKET_PARAMETERS
;
116 typedef struct _RAW_RESET_PORT_PARAMETERS
{
119 } RAW_RESET_PORT_PARAMETERS
, *PRAW_RESET_PORT_PARAMETERS
;
121 typedef struct _USB_BANDWIDTH_INFO
{
123 ULONG TotalBusBandwidth
;
124 ULONG Total32secBandwidth
;
125 ULONG AllocedBulkAndControl
;
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
;
135 typedef 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
;
142 typedef struct _USBUSER_BANDWIDTH_INFO_REQUEST
{
143 USBUSER_REQUEST_HEADER Header
;
144 USB_BANDWIDTH_INFO BandwidthInformation
;
145 } USBUSER_BANDWIDTH_INFO_REQUEST
, *PUSBUSER_BANDWIDTH_INFO_REQUEST
;
147 typedef struct _USB_BUS_STATISTICS_0
{
149 LARGE_INTEGER CurrentSystemTime
;
150 ULONG CurrentUsbFrame
;
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
;
164 } USB_BUS_STATISTICS_0
, *PUSB_BUS_STATISTICS_0
;
166 typedef 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
;
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
176 typedef struct _USB_CLOSE_RAW_DEVICE_PARAMETERS
{
178 } USB_CLOSE_RAW_DEVICE_PARAMETERS
, *PUSB_CLOSE_RAW_DEVICE_PARAMETERS
;
180 typedef 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
;
185 typedef struct _USB_CONTROLLER_INFO_0
{
189 ULONG NumberOfRootPorts
;
190 USB_CONTROLLER_FLAVOR ControllerFlavor
;
191 ULONG HcFeatureFlags
;
192 } USB_CONTROLLER_INFO_0
, *PUSB_CONTROLLER_INFO_0
;
194 typedef 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
;
199 typedef struct _USB_DRIVER_VERSION_PARAMETERS
{
200 ULONG DriverTrackingCode
;
202 ULONG USBUSER_Version
;
203 BOOLEAN CheckedPortDriver
;
204 BOOLEAN CheckedMiniportDriver
;
206 } USB_DRIVER_VERSION_PARAMETERS
, *PUSB_DRIVER_VERSION_PARAMETERS
;
208 typedef 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
;
213 typedef struct _USB_OPEN_RAW_DEVICE_PARAMETERS
{
216 } USB_OPEN_RAW_DEVICE_PARAMETERS
, *PUSB_OPEN_RAW_DEVICE_PARAMETERS
;
218 typedef 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
;
223 typedef 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,
237 } WDMUSB_POWER_STATE
;
239 typedef 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
;
250 } USB_POWER_INFO
, *PUSB_POWER_INFO
;
252 typedef struct _USBUSER_POWER_INFO_REQUEST
{
253 USBUSER_REQUEST_HEADER Header
;
254 USB_POWER_INFO PowerInformation
;
255 } USBUSER_POWER_INFO_REQUEST
, *PUSBUSER_POWER_INFO_REQUEST
;
257 typedef struct _USB_UNICODE_NAME
{
260 } USB_UNICODE_NAME
, *PUSB_UNICODE_NAME
;
262 typedef struct _USBUSER_CONTROLLER_UNICODE_NAME
{
263 USBUSER_REQUEST_HEADER Header
;
264 USB_UNICODE_NAME UnicodeName
;
265 } USBUSER_CONTROLLER_UNICODE_NAME
, *PUSBUSER_CONTROLLER_UNICODE_NAME
;
267 typedef struct _USB_PASS_THRU_PARAMETERS
{
269 ULONG ParameterLength
;
271 } USB_PASS_THRU_PARAMETERS
, *PUSB_PASS_THRU_PARAMETERS
;
273 typedef 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
;
278 typedef 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
;
283 typedef struct _USBUSER_SEND_ONE_PACKET
{
284 USBUSER_REQUEST_HEADER Header
;
285 PACKET_PARAMETERS PacketParameters
;
286 } USBUSER_SEND_ONE_PACKET
, *PUSBUSER_SEND_ONE_PACKET
;
288 typedef struct _USB_SEND_RAW_COMMAND_PARAMETERS
{
294 USHORT DeviceAddress
;
295 USHORT MaximumPacketSize
;
298 USBD_STATUS UsbdStatusCode
;
300 } USB_SEND_RAW_COMMAND_PARAMETERS
, *PUSB_SEND_RAW_COMMAND_PARAMETERS
;
302 typedef 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
;
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
313 typedef struct _USB_USB2HW_VERSION_PARAMETERS
{
314 UCHAR Usb2HwRevision
;
315 } USB_USB2HW_VERSION_PARAMETERS
, *PUSB_USB2HW_VERSION_PARAMETERS
;
317 typedef 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
;
328 #endif /* __USBUSER_H */