1use shared::basetsd::ULONG64;
8use shared::guiddef::GUID;
9use shared::minwindef::{UCHAR, ULONG, USHORT};
10use um::winnt::WCHAR;
11ENUM!{enum USB_DEVICE_SPEED {
12 UsbLowSpeed = 0,
13 UsbFullSpeed,
14 UsbHighSpeed,
15 UsbSuperSpeed,
16}}
17ENUM!{enum USB_DEVICE_TYPE {
18 Usb11Device = 0,
19 Usb20Device,
20}}
21STRUCT!{#[repr(packed)] struct BM_REQUEST_TYPE {
22 B: UCHAR,
23}}
24BITFIELD!{BM_REQUEST_TYPE B: UCHAR [
25 Recipient set_Recipient[0..2],
26 Reserved set_Reserved[2..5],
27 Type set_Type[5..7],
28 Dir set_Dir[7..8],
29]}
30pub type PBM_REQUEST_TYPE = *mut BM_REQUEST_TYPE;
31STRUCT!{#[repr(packed)] struct USB_DEFAULT_PIPE_SETUP_PACKET_wValue_s {
32 LowByte: UCHAR,
33 HiByte: UCHAR,
34}}
35UNION!{#[repr(packed)] union USB_DEFAULT_PIPE_SETUP_PACKET_wValue {
36 [u16; 1],
37 s s_mut: USB_DEFAULT_PIPE_SETUP_PACKET_wValue_s,
38 W W_mut: USHORT,
39}}
40STRUCT!{#[repr(packed)] struct USB_DEFAULT_PIPE_SETUP_PACKET_wIndex_s {
41 LowByte: UCHAR,
42 HiByte: UCHAR,
43}}
44UNION!{#[repr(packed)] union USB_DEFAULT_PIPE_SETUP_PACKET_wIndex {
45 [u16; 1],
46 s s_mut: USB_DEFAULT_PIPE_SETUP_PACKET_wIndex_s,
47 W W_mut: USHORT,
48}}
49STRUCT!{#[repr(packed)] struct USB_DEFAULT_PIPE_SETUP_PACKET {
50 bmRequestType: BM_REQUEST_TYPE,
51 bRequest: UCHAR,
52 wValue: USB_DEFAULT_PIPE_SETUP_PACKET_wValue,
53 wIndex: USB_DEFAULT_PIPE_SETUP_PACKET_wIndex,
54 wLength: USHORT,
55}}
56pub type PUSB_DEFAULT_PIPE_SETUP_PACKET = *mut USB_DEFAULT_PIPE_SETUP_PACKET;
57pub const BMREQUEST_HOST_TO_DEVICE: UCHAR = 0;
58pub const BMREQUEST_DEVICE_TO_HOST: UCHAR = 1;
59pub const BMREQUEST_STANDARD: UCHAR = 0;
60pub const BMREQUEST_CLASS: UCHAR = 1;
61pub const BMREQUEST_VENDOR: UCHAR = 2;
62pub const BMREQUEST_TO_DEVICE: UCHAR = 0;
63pub const BMREQUEST_TO_INTERFACE: UCHAR = 1;
64pub const BMREQUEST_TO_ENDPOINT: UCHAR = 2;
65pub const BMREQUEST_TO_OTHER: UCHAR = 3;
66#[inline]
67pub fn USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d: UCHAR, i: UCHAR) -> USHORT {
68 (d as USHORT) << 8 | (i as USHORT)
69}
70pub const USB_REQUEST_GET_STATUS: UCHAR = 0x00;
71pub const USB_REQUEST_CLEAR_FEATURE: UCHAR = 0x01;
72pub const USB_REQUEST_SET_FEATURE: UCHAR = 0x03;
73pub const USB_REQUEST_SET_ADDRESS: UCHAR = 0x05;
74pub const USB_REQUEST_GET_DESCRIPTOR: UCHAR = 0x06;
75pub const USB_REQUEST_SET_DESCRIPTOR: UCHAR = 0x07;
76pub const USB_REQUEST_GET_CONFIGURATION: UCHAR = 0x08;
77pub const USB_REQUEST_SET_CONFIGURATION: UCHAR = 0x09;
78pub const USB_REQUEST_GET_INTERFACE: UCHAR = 0x0A;
79pub const USB_REQUEST_SET_INTERFACE: UCHAR = 0x0B;
80pub const USB_REQUEST_SYNC_FRAME: UCHAR = 0x0C;
81pub const USB_REQUEST_SET_SEL: UCHAR = 0x30;
82pub const USB_REQUEST_ISOCH_DELAY: UCHAR = 0x31;
83pub const USB_DEVICE_DESCRIPTOR_TYPE: UCHAR = 0x01;
84pub const USB_CONFIGURATION_DESCRIPTOR_TYPE: UCHAR = 0x02;
85pub const USB_STRING_DESCRIPTOR_TYPE: UCHAR = 0x03;
86pub const USB_INTERFACE_DESCRIPTOR_TYPE: UCHAR = 0x04;
87pub const USB_ENDPOINT_DESCRIPTOR_TYPE: UCHAR = 0x05;
88pub const USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE: UCHAR = 0x06;
89pub const USB_OTHER_SPEED_CONFIGURATION_DESCRIPTOR_TYPE: UCHAR = 0x07;
90pub const USB_INTERFACE_POWER_DESCRIPTOR_TYPE: UCHAR = 0x08;
91pub const USB_OTG_DESCRIPTOR_TYPE: UCHAR = 0x09;
92pub const USB_DEBUG_DESCRIPTOR_TYPE: UCHAR = 0x0A;
93pub const USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE: UCHAR = 0x0B;
94pub const USB_BOS_DESCRIPTOR_TYPE: UCHAR = 0x0F;
95pub const USB_DEVICE_CAPABILITY_DESCRIPTOR_TYPE: UCHAR = 0x10;
96pub const USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_TYPE: UCHAR = 0x30;
97pub const USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR_TYPE: UCHAR = 0x31;
98pub const USB_RESERVED_DESCRIPTOR_TYPE: UCHAR = 0x06;
99pub const USB_CONFIG_POWER_DESCRIPTOR_TYPE: UCHAR = 0x07;
100pub const USB_FEATURE_ENDPOINT_STALL: UCHAR = 0x00;
101pub const USB_FEATURE_REMOTE_WAKEUP: UCHAR = 0x01;
102pub const USB_FEATURE_TEST_MODE: UCHAR = 0x02;
103pub const USB_FEATURE_FUNCTION_SUSPEND: UCHAR = 0x00;
104pub const USB_FEATURE_U1_ENABLE: UCHAR = 0x30;
105pub const USB_FEATURE_U2_ENABLE: UCHAR = 0x31;
106pub const USB_FEATURE_LTM_ENABLE: UCHAR = 0x32;
107pub const USB_FEATURE_LDM_ENABLE: UCHAR = 0x35;
108pub const USB_FEATURE_BATTERY_WAKE_MASK: UCHAR = 0x28;
109pub const USB_FEATURE_OS_IS_PD_AWARE: UCHAR = 0x29;
110pub const USB_FEATURE_POLICY_MODE: UCHAR = 0x2A;
111pub const USB_FEATURE_CHARGING_POLICY: UCHAR = 0x36;
112pub const USB_CHARGING_POLICY_DEFAULT: UCHAR = 0x00;
113pub const USB_CHARGING_POLICY_ICCHPF: UCHAR = 0x01;
114pub const USB_CHARGING_POLICY_ICCLPF: UCHAR = 0x02;
115pub const USB_CHARGING_POLICY_NO_POWER: UCHAR = 0x03;
116pub const USB_STATUS_PORT_STATUS: UCHAR = 0x00;
117pub const USB_STATUS_PD_STATUS: UCHAR = 0x01;
118pub const USB_STATUS_EXT_PORT_STATUS: UCHAR = 0x02;
119pub const USB_GETSTATUS_SELF_POWERED: UCHAR = 0x01;
120pub const USB_GETSTATUS_REMOTE_WAKEUP_ENABLED: UCHAR = 0x02;
121pub const USB_GETSTATUS_U1_ENABLE: UCHAR = 0x04;
122pub const USB_GETSTATUS_U2_ENABLE: UCHAR = 0x08;
123pub const USB_GETSTATUS_LTM_ENABLE: UCHAR = 0x10;
124STRUCT!{#[repr(packed)] struct USB_DEVICE_STATUS {
125 AsUshort16: USHORT,
126}}
127BITFIELD!{USB_DEVICE_STATUS AsUshort16: USHORT [
128 SelfPowered set_SelfPowered[0..1],
129 RemoteWakeup set_RemoteWakeup[1..2],
130 U1Enable set_U1Enable[2..3],
131 U2Enable set_U2Enable[3..4],
132 LtmEnable set_LtmEnable[4..5],
133 Reserved set_Reserved[5..16],
134]}
135pub type PUSB_DEVICE_STATUS = *mut USB_DEVICE_STATUS;
136STRUCT!{#[repr(packed)] struct USB_INTERFACE_STATUS {
137 AsUshort16: USHORT,
138}}
139BITFIELD!{USB_INTERFACE_STATUS AsUshort16: USHORT [
140 RemoteWakeupCapable set_RemoteWakeupCapable[0..1],
141 RemoteWakeupEnabled set_RemoteWakeupEnabled[1..2],
142 Reserved set_Reserved[2..16],
143]}
144pub type PUSB_INTERFACE_STATUS = *mut USB_INTERFACE_STATUS;
145STRUCT!{#[repr(packed)] struct USB_ENDPOINT_STATUS {
146 AsUshort16: USHORT,
147}}
148BITFIELD!{USB_ENDPOINT_STATUS AsUshort16: USHORT [
149 Halt set_Halt[0..1],
150 Reserved set_Reserved[1..16],
151]}
152pub type PUSB_ENDPOINT_STATUS = *mut USB_ENDPOINT_STATUS;
153STRUCT!{#[repr(packed)] struct USB_COMMON_DESCRIPTOR {
154 bLength: UCHAR,
155 bDescriptorType: UCHAR,
156}}
157pub type PUSB_COMMON_DESCRIPTOR = *mut USB_COMMON_DESCRIPTOR;
158STRUCT!{#[repr(packed)] struct USB_DEVICE_DESCRIPTOR {
159 bLength: UCHAR,
160 bDescriptorType: UCHAR,
161 bcdUSB: USHORT,
162 bDeviceClass: UCHAR,
163 bDeviceSubClass: UCHAR,
164 bDeviceProtocol: UCHAR,
165 bMaxPacketSize0: UCHAR,
166 idVendor: USHORT,
167 idProduct: USHORT,
168 bcdDevice: USHORT,
169 iManufacturer: UCHAR,
170 iProduct: UCHAR,
171 iSerialNumber: UCHAR,
172 bNumConfigurations: UCHAR,
173}}
174pub type PUSB_DEVICE_DESCRIPTOR = *mut USB_DEVICE_DESCRIPTOR;
175pub const USB_DEVICE_CLASS_RESERVED: UCHAR = 0x00;
176pub const USB_DEVICE_CLASS_AUDIO: UCHAR = 0x01;
177pub const USB_DEVICE_CLASS_COMMUNICATIONS: UCHAR = 0x02;
178pub const USB_DEVICE_CLASS_HUMAN_INTERFACE: UCHAR = 0x03;
179pub const USB_DEVICE_CLASS_MONITOR: UCHAR = 0x04;
180pub const USB_DEVICE_CLASS_PHYSICAL_INTERFACE: UCHAR = 0x05;
181pub const USB_DEVICE_CLASS_POWER: UCHAR = 0x06;
182pub const USB_DEVICE_CLASS_IMAGE: UCHAR = 0x06;
183pub const USB_DEVICE_CLASS_PRINTER: UCHAR = 0x07;
184pub const USB_DEVICE_CLASS_STORAGE: UCHAR = 0x08;
185pub const USB_DEVICE_CLASS_HUB: UCHAR = 0x09;
186pub const USB_DEVICE_CLASS_CDC_DATA: UCHAR = 0x0A;
187pub const USB_DEVICE_CLASS_SMART_CARD: UCHAR = 0x0B;
188pub const USB_DEVICE_CLASS_CONTENT_SECURITY: UCHAR = 0x0D;
189pub const USB_DEVICE_CLASS_VIDEO: UCHAR = 0x0E;
190pub const USB_DEVICE_CLASS_PERSONAL_HEALTHCARE: UCHAR = 0x0F;
191pub const USB_DEVICE_CLASS_AUDIO_VIDEO: UCHAR = 0x10;
192pub const USB_DEVICE_CLASS_BILLBOARD: UCHAR = 0x11;
193pub const USB_DEVICE_CLASS_DIAGNOSTIC_DEVICE: UCHAR = 0xDC;
194pub const USB_DEVICE_CLASS_WIRELESS_CONTROLLER: UCHAR = 0xE0;
195pub const USB_DEVICE_CLASS_MISCELLANEOUS: UCHAR = 0xEF;
196pub const USB_DEVICE_CLASS_APPLICATION_SPECIFIC: UCHAR = 0xFE;
197pub const USB_DEVICE_CLASS_VENDOR_SPECIFIC: UCHAR = 0xFF;
198STRUCT!{#[repr(packed)] struct USB_DEVICE_QUALIFIER_DESCRIPTOR {
199 bLength: UCHAR,
200 bDescriptorType: UCHAR,
201 bcdUSB: USHORT,
202 bDeviceClass: UCHAR,
203 bDeviceSubClass: UCHAR,
204 bDeviceProtocol: UCHAR,
205 bMaxPacketSize0: UCHAR,
206 bNumConfigurations: UCHAR,
207 bReserved: UCHAR,
208}}
209pub type PUSB_DEVICE_QUALIFIER_DESCRIPTOR = *mut USB_DEVICE_QUALIFIER_DESCRIPTOR;
210STRUCT!{#[repr(packed)] struct USB_BOS_DESCRIPTOR {
211 bLength: UCHAR,
212 bDescriptorType: UCHAR,
213 wTotalLength: USHORT,
214 bNumDeviceCaps: UCHAR,
215}}
216pub type PUSB_BOS_DESCRIPTOR = *mut USB_BOS_DESCRIPTOR;
217pub const USB_DEVICE_CAPABILITY_WIRELESS_USB: UCHAR = 0x01;
218pub const USB_DEVICE_CAPABILITY_USB20_EXTENSION: UCHAR = 0x02;
219pub const USB_DEVICE_CAPABILITY_SUPERSPEED_USB: UCHAR = 0x03;
220pub const USB_DEVICE_CAPABILITY_CONTAINER_ID: UCHAR = 0x04;
221pub const USB_DEVICE_CAPABILITY_PLATFORM: UCHAR = 0x05;
222pub const USB_DEVICE_CAPABILITY_POWER_DELIVERY: UCHAR = 0x06;
223pub const USB_DEVICE_CAPABILITY_BATTERY_INFO: UCHAR = 0x07;
224pub const USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT: UCHAR = 0x08;
225pub const USB_DEVICE_CAPABILITY_PD_PROVIDER_PORT: UCHAR = 0x09;
226pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB: UCHAR = 0x0A;
227pub const USB_DEVICE_CAPABILITY_PRECISION_TIME_MEASUREMENT: UCHAR = 0x0B;
228pub const USB_DEVICE_CAPABILITY_BILLBOARD: UCHAR = 0x0D;
229pub const USB_DEVICE_CAPABILITY_CONFIGURATION_SUMMARY: UCHAR = 0x10;
230STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR_bmAttributes {
231 AsUlong: ULONG,
232}}
233BITFIELD!{USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR_bmAttributes AsUlong: ULONG [
234 Reserved set_Reserved[0..1],
235 LPMCapable set_LPMCapable[1..2],
236 BESLAndAlternateHIRDSupported set_BESLAndAlternateHIRDSupported[2..3],
237 BaselineBESLValid set_BaselineBESLValid[3..4],
238 DeepBESLValid set_DeepBESLValid[4..5],
239 Reserved1 set_Reserved1[5..8],
240 BaselineBESL set_BaselineBESL[8..12],
241 DeepBESL set_DeepBESL[12..16],
242 Reserved2 set_Reserved2[16..32],
243]}
244STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR {
245 bLength: UCHAR,
246 bDescriptorType: UCHAR,
247 bDevCapabilityType: UCHAR,
248 bmAttributes: USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR_bmAttributes,
249}}
250pub type PUSB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR
251 = *mut USB_DEVICE_CAPABILITY_USB20_EXTENSION_DESCRIPTOR;
252pub const USB_DEVICE_CAPABILITY_USB20_EXTENSION_BMATTRIBUTES_RESERVED_MASK: ULONG = 0xFFFF00E1;
253STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR_bmAttributes {
254 AsUlong: ULONG,
255}}
256BITFIELD!{USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR_bmAttributes AsUlong: ULONG [
257 Reserved set_Reserved[0..1],
258 BatteryCharging set_BatteryCharging[1..2],
259 USBPowerDelivery set_USBPowerDelivery[2..3],
260 Provider set_Provider[3..4],
261 Consumer set_Consumer[4..5],
262 ChargingPolicy set_ChargingPolicy[5..6],
263 TypeCCurrent set_TypeCCurrent[6..7],
264 Reserved2 set_Reserved2[7..8],
265 ACSupply set_ACSupply[8..9],
266 Battery set_Battery[9..10],
267 Other set_Other[10..11],
268 NumBatteries set_NumBatteries[11..14],
269 UsesVbus set_UsesVbus[14..15],
270 Reserved3 set_Reserved3[15..32],
271]}
272STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR {
273 bLength: UCHAR,
274 bDescriptorType: UCHAR,
275 bDevCapabilityType: UCHAR,
276 bReserved: UCHAR,
277 bmAttributes: USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR_bmAttributes,
278 bmProviderPorts: USHORT,
279 bmConsumerPorts: USHORT,
280 bcdBCVersion: USHORT,
281 bcdPDVersion: USHORT,
282 bcdUSBTypeCVersion: USHORT,
283}}
284pub type PUSB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR
285 = *mut USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR;
286STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR_bmCapabilities {
287 AsUshort: USHORT,
288}}
289BITFIELD!{USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR_bmCapabilities AsUshort: USHORT [
290 BatteryCharging set_BatteryCharging[0..1],
291 USBPowerDelivery set_USBPowerDelivery[1..2],
292 USBTypeCCurrent set_USBTypeCCurrent[2..3],
293 Reserved set_Reserved[3..16],
294]}
295STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR {
296 bLength: UCHAR,
297 bDescriptorType: UCHAR,
298 bDevCapabilityType: UCHAR,
299 bReserved: UCHAR,
300 bmCapabilities: USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR_bmCapabilities,
301 wMinVoltage: USHORT,
302 wMaxVoltage: USHORT,
303 wReserved: USHORT,
304 dwMaxOperatingPower: ULONG,
305 dwMaxPeakPower: ULONG,
306 dwMaxPeakPowerTime: ULONG,
307}}
308pub type PUSB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR
309 = *mut USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR;
310STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR {
311 bLength: UCHAR,
312 bDescriptorType: UCHAR,
313 bDevCapabilityType: UCHAR,
314 bmAttributes: UCHAR,
315 wSpeedsSupported: USHORT,
316 bFunctionalitySupport: UCHAR,
317 bU1DevExitLat: UCHAR,
318 wU2DevExitLat: USHORT,
319}}
320pub type PUSB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR
321 = *mut USB_DEVICE_CAPABILITY_SUPERSPEED_USB_DESCRIPTOR;
322pub const USB_DEVICE_CAPABILITY_SUPERSPEED_BMATTRIBUTES_RESERVED_MASK: UCHAR = 0xFD;
323pub const USB_DEVICE_CAPABILITY_SUPERSPEED_BMATTRIBUTES_LTM_CAPABLE: UCHAR = 0x02;
324pub const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_RESERVED_MASK: USHORT = 0xFFF0;
325pub const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_LOW: USHORT = 0x0001;
326pub const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_FULL: USHORT = 0x0002;
327pub const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_HIGH: USHORT = 0x0004;
328pub const USB_DEVICE_CAPABILITY_SUPERSPEED_SPEEDS_SUPPORTED_SUPER: USHORT = 0x0008;
329pub const USB_DEVICE_CAPABILITY_SUPERSPEED_U1_DEVICE_EXIT_MAX_VALUE: UCHAR = 0x0A;
330pub const USB_DEVICE_CAPABILITY_SUPERSPEED_U2_DEVICE_EXIT_MAX_VALUE: USHORT = 0x07FF;
331pub const USB_DEVICE_CAPABILITY_MAX_U1_LATENCY: UCHAR = 0x0A;
332pub const USB_DEVICE_CAPABILITY_MAX_U2_LATENCY: USHORT = 0x07FF;
333pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_LSE_BPS: ULONG = 0;
334pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_LSE_KBPS: ULONG = 1;
335pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_LSE_MBPS: ULONG = 2;
336pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_LSE_GBPS: ULONG = 3;
337pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_MODE_SYMMETRIC: ULONG = 0;
338pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_MODE_ASYMMETRIC: ULONG = 1;
339pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_DIR_RX: ULONG = 0;
340pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_DIR_TX: ULONG = 1;
341pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_PROTOCOL_SS: ULONG = 0;
342pub const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_PROTOCOL_SSP: ULONG = 1;
343STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED {
344 AsUlong32: ULONG,
345}}
346BITFIELD!{USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED AsUlong32: ULONG [
347 SublinkSpeedAttrID set_SublinkSpeedAttrID[0..4],
348 LaneSpeedExponent set_LaneSpeedExponent[4..6],
349 SublinkTypeMode set_SublinkTypeMode[6..7],
350 SublinkTypeDir set_SublinkTypeDir[7..8],
351 Reserved set_Reserved[8..14],
352 LinkProtocol set_LinkProtocol[14..16],
353 LaneSpeedMantissa set_LaneSpeedMantissa[16..32],
354]}
355STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_bmAttributes {
356 AsUlong32: ULONG,
357}}
358BITFIELD!{USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_bmAttributes AsUlong32: ULONG [
359 SublinkSpeedAttrCount set_SublinkSpeedAttrCount[0..5],
360 SublinkSpeedIDCount set_SublinkSpeedIDCount[5..9],
361 Reserved set_Reserved[9..32],
362]}
363STRUCT!{#[repr(packed)]
364 struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_wFunctionalitySupport {
365 AsUshort: USHORT,
366}}
367BITFIELD!{
368 USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_wFunctionalitySupport AsUshort: USHORT [
369 SublinkSpeedAttrID set_SublinkSpeedAttrID[0..4],
370 Reserved set_Reserved[4..8],
371 MinRxLaneCount set_MinRxLaneCount[8..12],
372 MinTxLaneCount set_MinTxLaneCount[12..16],
373]}
374STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR {
375 bLength: UCHAR,
376 bDescriptorType: UCHAR,
377 bDevCapabilityType: UCHAR,
378 bReserved: UCHAR,
379 bmAttributes: USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_bmAttributes,
380 wFunctionalitySupport:
381 USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR_wFunctionalitySupport,
382 wReserved: USHORT,
383 bmSublinkSpeedAttr: [USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED; 1],
384}}
385pub type PUSB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR
386 = *mut USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_USB_DESCRIPTOR;
387STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR {
388 bLength: UCHAR,
389 bDescriptorType: UCHAR,
390 bDevCapabilityType: UCHAR,
391 bReserved: UCHAR,
392 ContainerID: [UCHAR; 16],
393}}
394pub type PUSB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR
395 = *mut USB_DEVICE_CAPABILITY_CONTAINER_ID_DESCRIPTOR;
396STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_CONFIGURATION_SUMMARY_DESCRIPTOR_Function {
397 bClass: UCHAR,
398 bSubClass: UCHAR,
399 bProtocol: UCHAR,
400}}
401STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_CONFIGURATION_SUMMARY_DESCRIPTOR {
402 bLength: UCHAR,
403 bDescriptorType: UCHAR,
404 bDevCapabilityType: UCHAR,
405 bcdVersion: USHORT,
406 bConfigurationValue: UCHAR,
407 bMaxPower: UCHAR,
408 bNumFunctions: UCHAR,
409 Function: [USB_DEVICE_CAPABILITY_CONFIGURATION_SUMMARY_DESCRIPTOR_Function; 1],
410}}
411pub type PUSB_DEVICE_CAPABILITY_CONFIGURATION_SUMMARY_DESCRIPTOR
412 = *mut USB_DEVICE_CAPABILITY_CONFIGURATION_SUMMARY_DESCRIPTOR;
413STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR {
414 bLength: UCHAR,
415 bDescriptorType: UCHAR,
416 bDevCapabilityType: UCHAR,
417 bReserved: UCHAR,
418 PlatformCapabilityUuid: GUID,
419 CapabililityData: [UCHAR; 1],
420}}
421pub type PUSB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR
422 = *mut USB_DEVICE_CAPABILITY_PLATFORM_DESCRIPTOR;
423STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR_VconnPower {
424 AsUshort: USHORT,
425}}
426BITFIELD!{USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR_VconnPower AsUshort: USHORT [
427 VConnPowerNeededForFullFunctionality set_VConnPowerNeededForFullFunctionality[0..3],
428 Reserved set_Reserved[3..15],
429 NoVconnPowerRequired set_NoVconnPowerRequired[15..16],
430]}
431STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR_AlternateMode {
432 wSVID: USHORT,
433 bAlternateMode: UCHAR,
434 iAlternateModeSetting: UCHAR,
435}}
436STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR {
437 bLength: UCHAR,
438 bDescriptorType: UCHAR,
439 bDevCapabilityType: UCHAR,
440 iAddtionalInfoURL: UCHAR,
441 bNumberOfAlternateModes: UCHAR,
442 bPreferredAlternateMode: UCHAR,
443 VconnPower: USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR_VconnPower,
444 bmConfigured: [UCHAR; 32],
445 bReserved: ULONG,
446 AlternateMode: [USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR_AlternateMode; 1],
447}}
448pub type PUSB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR
449 = *mut USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR;
450DEFINE_GUID!{GUID_USB_MSOS20_PLATFORM_CAPABILITY_ID,
451 0xd8dd60df, 0x4589, 0x4cc7, 0x9c, 0xd2, 0x65, 0x9d, 0x9e, 0x64, 0x8a, 0x9f}
452STRUCT!{#[repr(packed)] struct USB_DEVICE_CAPABILITY_DESCRIPTOR {
453 bLength: UCHAR,
454 bDescriptorType: UCHAR,
455 bDevCapabilityType: UCHAR,
456}}
457pub type PUSB_DEVICE_CAPABILITY_DESCRIPTOR = *mut USB_DEVICE_CAPABILITY_DESCRIPTOR;
458STRUCT!{#[repr(packed)] struct USB_CONFIGURATION_DESCRIPTOR {
459 bLength: UCHAR,
460 bDescriptorType: UCHAR,
461 wTotalLength: USHORT,
462 bNumInterfaces: UCHAR,
463 bConfigurationValue: UCHAR,
464 iConfiguration: UCHAR,
465 bmAttributes: UCHAR,
466 MaxPower: UCHAR,
467}}
468pub type PUSB_CONFIGURATION_DESCRIPTOR = *mut USB_CONFIGURATION_DESCRIPTOR;
469pub const USB_CONFIG_POWERED_MASK: UCHAR = 0xC0;
470pub const USB_CONFIG_BUS_POWERED: UCHAR = 0x80;
471pub const USB_CONFIG_SELF_POWERED: UCHAR = 0x40;
472pub const USB_CONFIG_REMOTE_WAKEUP: UCHAR = 0x20;
473pub const USB_CONFIG_RESERVED: UCHAR = 0x1F;
474STRUCT!{#[repr(packed)] struct USB_INTERFACE_ASSOCIATION_DESCRIPTOR {
475 bLength: UCHAR,
476 bDescriptorType: UCHAR,
477 bFirstInterface: UCHAR,
478 bInterfaceCount: UCHAR,
479 bFunctionClass: UCHAR,
480 bFunctionSubClass: UCHAR,
481 bFunctionProtocol: UCHAR,
482 iFunction: UCHAR,
483}}
484pub type PUSB_INTERFACE_ASSOCIATION_DESCRIPTOR = *mut USB_INTERFACE_ASSOCIATION_DESCRIPTOR;
485STRUCT!{#[repr(packed)] struct USB_INTERFACE_DESCRIPTOR {
486 bLength: UCHAR,
487 bDescriptorType: UCHAR,
488 bInterfaceNumber: UCHAR,
489 bAlternateSetting: UCHAR,
490 bNumEndpoints: UCHAR,
491 bInterfaceClass: UCHAR,
492 bInterfaceSubClass: UCHAR,
493 bInterfaceProtocol: UCHAR,
494 iInterface: UCHAR,
495}}
496pub type PUSB_INTERFACE_DESCRIPTOR = *mut USB_INTERFACE_DESCRIPTOR;
497STRUCT!{#[repr(packed)] struct USB_ENDPOINT_DESCRIPTOR {
498 bLength: UCHAR,
499 bDescriptorType: UCHAR,
500 bEndpointAddress: UCHAR,
501 bmAttributes: UCHAR,
502 wMaxPacketSize: USHORT,
503 bInterval: UCHAR,
504}}
505pub type PUSB_ENDPOINT_DESCRIPTOR = *mut USB_ENDPOINT_DESCRIPTOR;
506pub const USB_ENDPOINT_DIRECTION_MASK: UCHAR = 0x80;
507#[inline]
508pub fn USB_ENDPOINT_DIRECTION_OUT(addr: UCHAR) -> UCHAR {
509 !(addr & USB_ENDPOINT_DIRECTION_MASK)
510}
511#[inline]
512pub fn USB_ENDPOINT_DIRECTION_IN(addr: UCHAR) -> UCHAR {
513 addr & USB_ENDPOINT_DIRECTION_MASK
514}
515pub const USB_ENDPOINT_ADDRESS_MASK: UCHAR = 0x0F;
516pub const USB_ENDPOINT_TYPE_MASK: UCHAR = 0x03;
517pub const USB_ENDPOINT_TYPE_CONTROL: UCHAR = 0x00;
518pub const USB_ENDPOINT_TYPE_ISOCHRONOUS: UCHAR = 0x01;
519pub const USB_ENDPOINT_TYPE_BULK: UCHAR = 0x02;
520pub const USB_ENDPOINT_TYPE_INTERRUPT: UCHAR = 0x03;
521pub const USB_ENDPOINT_TYPE_BULK_RESERVED_MASK: UCHAR = 0xFC;
522pub const USB_ENDPOINT_TYPE_CONTROL_RESERVED_MASK: UCHAR = 0xFC;
523pub const USB_20_ENDPOINT_TYPE_INTERRUPT_RESERVED_MASK: UCHAR = 0xFC;
524pub const USB_30_ENDPOINT_TYPE_INTERRUPT_RESERVED_MASK: UCHAR = 0xCC;
525pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_RESERVED_MASK: UCHAR = 0xC0;
526pub const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_MASK: UCHAR = 0x30;
527pub const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_PERIODIC: UCHAR = 0x00;
528pub const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_NOTIFICATION: UCHAR = 0x10;
529pub const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_RESERVED10: UCHAR = 0x20;
530pub const USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_RESERVED11: UCHAR = 0x30;
531#[inline]
532pub fn USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE(bmAttr: UCHAR) -> UCHAR {
533 bmAttr & USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_MASK
534}
535pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_MASK: UCHAR = 0x0C;
536pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_NO_SYNCHRONIZATION: UCHAR = 0x00;
537pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_ASYNCHRONOUS: UCHAR = 0x04;
538pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_ADAPTIVE: UCHAR = 0x08;
539pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_SYNCHRONOUS: UCHAR = 0x0C;
540#[inline]
541pub fn USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION(bmAttr: UCHAR) -> UCHAR {
542 bmAttr & USB_ENDPOINT_TYPE_ISOCHRONOUS_SYNCHRONIZATION_MASK
543}
544pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_MASK: UCHAR = 0x30;
545pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_DATA_ENDOINT: UCHAR = 0x00;
546pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_FEEDBACK_ENDPOINT: UCHAR = 0x10;
547pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_IMPLICIT_FEEDBACK_DATA_ENDPOINT: UCHAR = 0x20;
548pub const USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_RESERVED: UCHAR = 0x30;
549#[inline]
550pub fn USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE(bmAttr: UCHAR) -> UCHAR {
551 bmAttr & USB_ENDPOINT_TYPE_ISOCHRONOUS_USAGE_MASK
552}
553STRUCT!{#[repr(packed)] struct USB_HIGH_SPEED_MAXPACKET {
554 us: USHORT,
555}}
556BITFIELD!{USB_HIGH_SPEED_MAXPACKET us: USHORT [
557 MaxPacket set_MaxPacket[0..11],
558 HSmux set_HSmux[11..13],
559 Reserved set_Reserved[13..16],
560]}
561pub type PUSB_HIGH_SPEED_MAXPACKET = *mut USB_HIGH_SPEED_MAXPACKET;
562pub const USB_ENDPOINT_SUPERSPEED_BULK_MAX_PACKET_SIZE: USHORT = 1024;
563pub const USB_ENDPOINT_SUPERSPEED_CONTROL_MAX_PACKET_SIZE: USHORT = 512;
564pub const USB_ENDPOINT_SUPERSPEED_ISO_MAX_PACKET_SIZE: USHORT = 1024;
565pub const USB_ENDPOINT_SUPERSPEED_INTERRUPT_MAX_PACKET_SIZE: USHORT = 1024;
566STRUCT!{#[repr(packed)] struct USB_STRING_DESCRIPTOR {
567 bLength: UCHAR,
568 bDescriptorType: UCHAR,
569 bString: [WCHAR; 1],
570}}
571pub type PUSB_STRING_DESCRIPTOR = *mut USB_STRING_DESCRIPTOR;
572pub const MAXIMUM_USB_STRING_LENGTH: UCHAR = 255;
573STRUCT!{#[repr(packed)] struct USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Bulk {
574 BitField: UCHAR,
575}}
576BITFIELD!{USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Bulk BitField: UCHAR [
577 MaxStreams set_MaxStreams[0..5],
578 Reserved1 set_Reserved1[5..8],
579]}
580STRUCT!{#[repr(packed)]
581 struct USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Isochronous {
582 BitField: UCHAR,
583}}
584BITFIELD!{USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Isochronous BitField: UCHAR [
585 Mult set_Mult[0..2],
586 Reserved2 set_Reserved2[2..7],
587 SspCompanion set_SspCompanion[7..8],
588]}
589UNION!{#[repr(packed)] union USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes {
590 [u8; 1],
591 AsUchar AsUchar_mut: UCHAR,
592 Bulk Bulk_mut: USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Bulk,
593 Isochronous Isochronous_mut:
594 USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes_Isochronous,
595}}
596STRUCT!{#[repr(packed)] struct USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR {
597 bLength: UCHAR,
598 bDescriptorType: UCHAR,
599 bMaxBurst: UCHAR,
600 bmAttributes: USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR_bmAttributes,
601 wBytesPerInterval: USHORT,
602}}
603pub type PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR
604 = *mut USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR;
605pub const USB_SUPERSPEED_ISOCHRONOUS_MAX_MULTIPLIER: UCHAR = 2;
606STRUCT!{#[repr(packed)] struct USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR {
607 bLength: UCHAR,
608 bDescriptorType: UCHAR,
609 wReserved: USHORT,
610 dwBytesPerInterval: ULONG,
611}}
612pub type PUSB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR
613 = *mut USB_SUPERSPEEDPLUS_ISOCH_ENDPOINT_COMPANION_DESCRIPTOR;
614pub const USB_SUPERSPEEDPLUS_ISOCHRONOUS_MIN_BYTESPERINTERVAL: ULONG = 0xC001;
615pub const USB_SUPERSPEEDPLUS_ISOCHRONOUS_MAX_BYTESPERINTERVAL: ULONG = 0xFFFFFF;
616STRUCT!{#[repr(packed)] struct USB_HUB_DESCRIPTOR {
617 bDescriptorLength: UCHAR,
618 bDescriptorType: UCHAR,
619 bNumberOfPorts: UCHAR,
620 wHubCharacteristics: USHORT,
621 bPowerOnToPowerGood: UCHAR,
622 bHubControlCurrent: UCHAR,
623 bRemoveAndPowerMask: [UCHAR; 64],
624}}
625pub type PUSB_HUB_DESCRIPTOR = *mut USB_HUB_DESCRIPTOR;
626pub const USB_20_HUB_DESCRIPTOR_TYPE: UCHAR = 0x29;
627STRUCT!{#[repr(packed)] struct USB_30_HUB_DESCRIPTOR {
628 bLength: UCHAR,
629 bDescriptorType: UCHAR,
630 bNumberOfPorts: UCHAR,
631 wHubCharacteristics: USHORT,
632 bPowerOnToPowerGood: UCHAR,
633 bHubControlCurrent: UCHAR,
634 bHubHdrDecLat: UCHAR,
635 wHubDelay: USHORT,
636 DeviceRemovable: USHORT,
637}}
638pub type PUSB_30_HUB_DESCRIPTOR = *mut USB_30_HUB_DESCRIPTOR;
639pub const USB_30_HUB_DESCRIPTOR_TYPE: UCHAR = 0x2A;
640pub const USB_REQUEST_GET_STATE: UCHAR = 0x02;
641pub const USB_REQUEST_CLEAR_TT_BUFFER: UCHAR = 0x08;
642pub const USB_REQUEST_RESET_TT: UCHAR = 0x09;
643pub const USB_REQUEST_GET_TT_STATE: UCHAR = 0x0A;
644pub const USB_REQUEST_STOP_TT: UCHAR = 0x0B;
645pub const USB_REQUEST_SET_HUB_DEPTH: UCHAR = 0x0C;
646pub const USB_REQUEST_GET_PORT_ERR_COUNT: UCHAR = 0x0D;
647STRUCT!{#[repr(packed)] struct USB_HUB_STATUS {
648 AsUshort16: USHORT,
649}}
650BITFIELD!{USB_HUB_STATUS AsUshort16: USHORT [
651 LocalPowerLost set_LocalPowerLost[0..1],
652 OverCurrent set_OverCurrent[1..2],
653 Reserved set_Reserved[2..16],
654]}
655pub type PUSB_HUB_STATUS = *mut USB_HUB_STATUS;
656STRUCT!{#[repr(packed)] struct USB_HUB_CHANGE {
657 AsUshort16: USHORT,
658}}
659BITFIELD!{USB_HUB_CHANGE AsUshort16: USHORT [
660 LocalPowerChange set_LocalPowerChange[0..1],
661 OverCurrentChange set_OverCurrentChange[1..2],
662 Reserved set_Reserved[2..16],
663]}
664pub type PUSB_HUB_CHANGE = *mut USB_HUB_CHANGE;
665STRUCT!{#[repr(packed)] struct USB_HUB_STATUS_AND_CHANGE_s {
666 HubStatus: USB_HUB_STATUS,
667 HubChange: USB_HUB_CHANGE,
668}}
669UNION!{#[repr(packed)] union USB_HUB_STATUS_AND_CHANGE {
670 [u32; 1],
671 AsUlong32 AsUlong32_mut: ULONG,
672 s s_mut: USB_HUB_STATUS_AND_CHANGE_s,
673}}
674pub type PUSB_HUB_STATUS_AND_CHANGE = *mut USB_HUB_STATUS_AND_CHANGE;
675STRUCT!{#[repr(packed)] struct USB_20_PORT_STATUS {
676 AsUshort16: USHORT,
677}}
678BITFIELD!{USB_20_PORT_STATUS AsUshort16: USHORT [
679 CurrentConnectStatus set_CurrentConnectStatus[0..1],
680 PortEnabledDisabled set_PortEnabledDisabled[1..2],
681 Suspend set_Suspend[2..3],
682 OverCurrent set_OverCurrent[3..4],
683 Reset set_Reset[4..5],
684 L1 set_L1[5..6],
685 Reserved0 set_Reserved0[6..8],
686 PortPower set_PortPower[8..9],
687 LowSpeedDeviceAttached set_LowSpeedDeviceAttached[9..10],
688 HighSpeedDeviceAttached set_HighSpeedDeviceAttached[10..11],
689 PortTestMode set_PortTestMode[11..12],
690 PortIndicatorControl set_PortIndicatorControl[12..13],
691 Reserved1 set_Reserved1[13..16],
692]}
693pub type PUSB_20_PORT_STATUS = *mut USB_20_PORT_STATUS;
694pub const USB_PORT_STATUS_CONNECT: USHORT = 0x0001;
695pub const USB_PORT_STATUS_ENABLE: USHORT = 0x0002;
696pub const USB_PORT_STATUS_SUSPEND: USHORT = 0x0004;
697pub const USB_PORT_STATUS_OVER_CURRENT: USHORT = 0x0008;
698pub const USB_PORT_STATUS_RESET: USHORT = 0x0010;
699pub const USB_PORT_STATUS_POWER: USHORT = 0x0100;
700pub const USB_PORT_STATUS_LOW_SPEED: USHORT = 0x0200;
701pub const USB_PORT_STATUS_HIGH_SPEED: USHORT = 0x0400;
702STRUCT!{#[repr(packed)] struct USB_20_PORT_CHANGE {
703 AsUshort16: USHORT,
704}}
705BITFIELD!{USB_20_PORT_CHANGE AsUshort16: USHORT [
706 ConnectStatusChange set_ConnectStatusChange[0..1],
707 PortEnableDisableChange set_PortEnableDisableChange[1..2],
708 SuspendChange set_SuspendChange[2..3],
709 OverCurrentIndicatorChange set_OverCurrentIndicatorChange[3..4],
710 ResetChange set_ResetChange[4..5],
711 Reserved2 set_Reserved2[5..16],
712]}
713pub type PUSB_20_PORT_CHANGE = *mut USB_20_PORT_CHANGE;
714STRUCT!{#[repr(packed)] struct USB_30_PORT_STATUS {
715 AsUshort16: USHORT,
716}}
717BITFIELD!{USB_30_PORT_STATUS AsUshort16: USHORT [
718 CurrentConnectStatus set_CurrentConnectStatus[0..1],
719 PortEnabledDisabled set_PortEnabledDisabled[1..2],
720 Reserved0 set_Reserved0[2..3],
721 OverCurrent set_OverCurrent[3..4],
722 Reset set_Reset[4..5],
723 PortLinkState set_PortLinkState[5..9],
724 PortPower set_PortPower[9..10],
725 NegotiatedDeviceSpeed set_NegotiatedDeviceSpeed[10..13],
726 Reserved1 set_Reserved1[13..16],
727]}
728pub type PUSB_30_PORT_STATUS = *mut USB_30_PORT_STATUS;
729pub const PORT_LINK_STATE_U0: USHORT = 0;
730pub const PORT_LINK_STATE_U1: USHORT = 1;
731pub const PORT_LINK_STATE_U2: USHORT = 2;
732pub const PORT_LINK_STATE_U3: USHORT = 3;
733pub const PORT_LINK_STATE_DISABLED: USHORT = 4;
734pub const PORT_LINK_STATE_RX_DETECT: USHORT = 5;
735pub const PORT_LINK_STATE_INACTIVE: USHORT = 6;
736pub const PORT_LINK_STATE_POLLING: USHORT = 7;
737pub const PORT_LINK_STATE_RECOVERY: USHORT = 8;
738pub const PORT_LINK_STATE_HOT_RESET: USHORT = 9;
739pub const PORT_LINK_STATE_COMPLIANCE_MODE: USHORT = 10;
740pub const PORT_LINK_STATE_LOOPBACK: USHORT = 11;
741pub const PORT_LINK_STATE_TEST_MODE: USHORT = 11;
742STRUCT!{#[repr(packed)] struct USB_30_PORT_CHANGE {
743 AsUshort16: USHORT,
744}}
745BITFIELD!{USB_30_PORT_CHANGE AsUshort16: USHORT [
746 ConnectStatusChange set_ConnectStatusChange[0..1],
747 Reserved2 set_Reserved2[1..3],
748 OverCurrentIndicatorChange set_OverCurrentIndicatorChange[3..4],
749 ResetChange set_ResetChange[4..5],
750 BHResetChange set_BHResetChange[5..6],
751 PortLinkStateChange set_PortLinkStateChange[6..7],
752 PortConfigErrorChange set_PortConfigErrorChange[7..8],
753 Reserved3 set_Reserved3[8..16],
754]}
755pub type PUSB_30_PORT_CHANGE = *mut USB_30_PORT_CHANGE;
756UNION!{#[repr(packed)] union USB_PORT_STATUS {
757 [u16; 1],
758 AsUshort16 AsUshort16_mut: USHORT,
759 Usb20PortStatus Usb20PortStatus_mut: USB_20_PORT_STATUS,
760 Usb30PortStatus Usb30PortStatus_mut: USB_30_PORT_STATUS,
761}}
762pub type PUSB_PORT_STATUS = *mut USB_PORT_STATUS;
763UNION!{#[repr(packed)] union USB_PORT_CHANGE {
764 [u16; 1],
765 AsUshort16 AsUshort16_mut: USHORT,
766 Usb20PortChange Usb20PortChange_mut: USB_20_PORT_CHANGE,
767 Usb30PortChange Usb30PortChange_mut: USB_30_PORT_CHANGE,
768}}
769pub type PUSB_PORT_CHANGE = *mut USB_PORT_CHANGE;
770STRUCT!{#[repr(packed)] struct USB_PORT_EXT_STATUS {
771 AsUlong32: ULONG,
772}}
773BITFIELD!{USB_PORT_EXT_STATUS AsUlong32: ULONG [
774 RxSublinkSpeedID set_RxSublinkSpeedID[0..4],
775 TxSublinkSpeedID set_TxSublinkSpeedID[4..8],
776 RxLaneCount set_RxLaneCount[8..12],
777 TxLaneCount set_TxLaneCount[12..16],
778 Reserved set_Reserved[16..32],
779]}
780pub type PUSB_PORT_EXT_STATUS = *mut USB_PORT_EXT_STATUS;
781STRUCT!{#[repr(packed)] struct USB_PORT_STATUS_AND_CHANGE_s {
782 PortStatus: USB_PORT_STATUS,
783 PortChange: USB_PORT_CHANGE,
784}}
785UNION!{#[repr(packed)] union USB_PORT_STATUS_AND_CHANGE {
786 [u32; 1],
787 AsUlong32 AsUlong32_mut: ULONG,
788 s s_mut: USB_PORT_STATUS_AND_CHANGE_s,
789}}
790pub type PUSB_PORT_STATUS_AND_CHANGE = *mut USB_PORT_STATUS_AND_CHANGE;
791STRUCT!{#[repr(packed)] struct USB_PORT_EXT_STATUS_AND_CHANGE_s {
792 PortStatusChange: USB_PORT_STATUS_AND_CHANGE,
793 PortExtStatus: USB_PORT_EXT_STATUS,
794}}
795UNION!{#[repr(packed)] union USB_PORT_EXT_STATUS_AND_CHANGE {
796 [u64; 1],
797 AsUlong64 AsUlong64_mut: ULONG64,
798 s s_mut: USB_PORT_EXT_STATUS_AND_CHANGE_s,
799}}
800pub type PUSB_PORT_EXT_STATUS_AND_CHANGE = *mut USB_PORT_EXT_STATUS_AND_CHANGE;
801STRUCT!{#[repr(packed)] struct USB_HUB_30_PORT_REMOTE_WAKE_MASK {
802 AsUchar8: UCHAR,
803}}
804BITFIELD!{USB_HUB_30_PORT_REMOTE_WAKE_MASK AsUchar8: UCHAR [
805 ConnectRemoteWakeEnable set_ConnectRemoteWakeEnable[0..1],
806 DisconnectRemoteWakeEnable set_DisconnectRemoteWakeEnable[1..2],
807 OverCurrentRemoteWakeEnable set_OverCurrentRemoteWakeEnable[2..3],
808 Reserved0 set_Reserved0[3..8],
809]}
810pub type PUSB_HUB_30_PORT_REMOTE_WAKE_MASK = *mut USB_HUB_30_PORT_REMOTE_WAKE_MASK;
811STRUCT!{#[repr(packed)] struct USB_FUNCTION_SUSPEND_OPTIONS {
812 AsUchar: UCHAR,
813}}
814BITFIELD!{USB_FUNCTION_SUSPEND_OPTIONS AsUchar: UCHAR [
815 PowerState set_PowerState[0..1],
816 RemoteWakeEnabled set_RemoteWakeEnabled[1..2],
817 Reserved0 set_Reserved0[2..8],
818]}
819pub type PUSB_FUNCTION_SUSPEND_OPTIONS = *mut USB_FUNCTION_SUSPEND_OPTIONS;
820pub const USB_FEATURE_INTERFACE_POWER_D0: USHORT = 0x0002;
821pub const USB_FEATURE_INTERFACE_POWER_D1: USHORT = 0x0003;
822pub const USB_FEATURE_INTERFACE_POWER_D2: USHORT = 0x0004;
823pub const USB_FEATURE_INTERFACE_POWER_D3: USHORT = 0x0005;
824pub const USB_SUPPORT_D0_COMMAND: UCHAR = 0x01;
825pub const USB_SUPPORT_D1_COMMAND: UCHAR = 0x02;
826pub const USB_SUPPORT_D2_COMMAND: UCHAR = 0x04;
827pub const USB_SUPPORT_D3_COMMAND: UCHAR = 0x08;
828pub const USB_SUPPORT_D1_WAKEUP: UCHAR = 0x10;
829pub const USB_SUPPORT_D2_WAKEUP: UCHAR = 0x20;
830STRUCT!{#[repr(packed)] struct USB_CONFIGURATION_POWER_DESCRIPTOR {
831 bLength: UCHAR,
832 bDescriptorType: UCHAR,
833 SelfPowerConsumedD0: [UCHAR; 3],
834 bPowerSummaryId: UCHAR,
835 bBusPowerSavingD1: UCHAR,
836 bSelfPowerSavingD1: UCHAR,
837 bBusPowerSavingD2: UCHAR,
838 bSelfPowerSavingD2: UCHAR,
839 bBusPowerSavingD3: UCHAR,
840 bSelfPowerSavingD3: UCHAR,
841 TransitionTimeFromD1: USHORT,
842 TransitionTimeFromD2: USHORT,
843 TransitionTimeFromD3: USHORT,
844}}
845pub type PUSB_CONFIGURATION_POWER_DESCRIPTOR = *mut USB_CONFIGURATION_POWER_DESCRIPTOR;
846STRUCT!{#[repr(packed)] struct USB_INTERFACE_POWER_DESCRIPTOR {
847 bLength: UCHAR,
848 bDescriptorType: UCHAR,
849 bmCapabilitiesFlags: UCHAR,
850 bBusPowerSavingD1: UCHAR,
851 bSelfPowerSavingD1: UCHAR,
852 bBusPowerSavingD2: UCHAR,
853 bSelfPowerSavingD2: UCHAR,
854 bBusPowerSavingD3: UCHAR,
855 bSelfPowerSavingD3: UCHAR,
856 TransitionTimeFromD1: USHORT,
857 TransitionTimeFromD2: USHORT,
858 TransitionTimeFromD3: USHORT,
859}}
860pub type PUSB_INTERFACE_POWER_DESCRIPTOR = *mut USB_INTERFACE_POWER_DESCRIPTOR;