| 1 |
// Licensed under the Apache License, Version 2.0 |
| 2 |
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 3 |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. |
| 4 |
// All files in the project carrying such notice may not be copied, modified, or distributed |
| 5 |
// except according to those terms. |
| 6 |
//! USB Definitions. |
| 7 |
use shared::minwindef::{UCHAR, ULONG, USHORT}; |
| 8 |
use shared::usbspec::{ |
| 9 |
PUSB_CONFIGURATION_DESCRIPTOR, USB_DEVICE_DESCRIPTOR, USB_ENDPOINT_DIRECTION_MASK, |
| 10 |
}; |
| 11 |
use um::winnt::{LONG, PVOID, WCHAR}; |
| 12 |
pub type PRIP = PVOID; |
| 13 |
pub type PMDL = PVOID; |
| 14 |
pub const USBDI_VERSION: ULONG = 0x00000600; |
| 15 |
pub const USB_PORTATTR_NO_CONNECTOR: ULONG = 0x00000001; |
| 16 |
pub const USB_PORTATTR_SHARED_USB2: ULONG = 0x00000002; |
| 17 |
pub const USB_PORTATTR_MINI_CONNECTOR: ULONG = 0x00000004; |
| 18 |
pub const USB_PORTATTR_OEM_CONNECTOR: ULONG = 0x00000008; |
| 19 |
pub const USB_PORTATTR_OWNED_BY_CC: ULONG = 0x01000000; |
| 20 |
pub const USB_PORTATTR_NO_OVERCURRENT_UI: ULONG = 0x02000000; |
| 21 |
ENUM!{enum USB_CONTROLLER_FLAVOR { |
| 22 |
USB_HcGeneric = 0, |
| 23 |
OHCI_Generic = 100, |
| 24 |
OHCI_Hydra, |
| 25 |
OHCI_NEC, |
| 26 |
UHCI_Generic = 200, |
| 27 |
UHCI_Piix4 = 201, |
| 28 |
UHCI_Piix3 = 202, |
| 29 |
UHCI_Ich2 = 203, |
| 30 |
UHCI_Reserved204 = 204, |
| 31 |
UHCI_Ich1 = 205, |
| 32 |
UHCI_Ich3m = 206, |
| 33 |
UHCI_Ich4 = 207, |
| 34 |
UHCI_Ich5 = 208, |
| 35 |
UHCI_Ich6 = 209, |
| 36 |
UHCI_Intel = 249, |
| 37 |
UHCI_VIA = 250, |
| 38 |
UHCI_VIA_x01 = 251, |
| 39 |
UHCI_VIA_x02 = 252, |
| 40 |
UHCI_VIA_x03 = 253, |
| 41 |
UHCI_VIA_x04 = 254, |
| 42 |
UHCI_VIA_x0E_FIFO = 264, |
| 43 |
EHCI_Generic = 1000, |
| 44 |
EHCI_NEC = 2000, |
| 45 |
EHCI_Lucent = 3000, |
| 46 |
EHCI_NVIDIA_Tegra2 = 4000, |
| 47 |
EHCI_NVIDIA_Tegra3 = 4001, |
| 48 |
EHCI_Intel_Medfield = 5001, |
| 49 |
}} |
| 50 |
pub const USB_DEFAULT_DEVICE_ADDRESS: UCHAR = 0; |
| 51 |
pub const USB_DEFAULT_ENDPOINT_ADDRESS: UCHAR = 0; |
| 52 |
pub const USB_DEFAULT_MAX_PACKET: USHORT = 64; |
| 53 |
pub const URB_FUNCTION_SELECT_CONFIGURATION: USHORT = 0x0000; |
| 54 |
pub const URB_FUNCTION_SELECT_INTERFACE: USHORT = 0x0001; |
| 55 |
pub const URB_FUNCTION_ABORT_PIPE: USHORT = 0x0002; |
| 56 |
pub const URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL: USHORT = 0x0003; |
| 57 |
pub const URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL: USHORT = 0x0004; |
| 58 |
pub const URB_FUNCTION_GET_FRAME_LENGTH: USHORT = 0x0005; |
| 59 |
pub const URB_FUNCTION_SET_FRAME_LENGTH: USHORT = 0x0006; |
| 60 |
pub const URB_FUNCTION_GET_CURRENT_FRAME_NUMBER: USHORT = 0x0007; |
| 61 |
pub const URB_FUNCTION_CONTROL_TRANSFER: USHORT = 0x0008; |
| 62 |
pub const URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER: USHORT = 0x0009; |
| 63 |
pub const URB_FUNCTION_ISOCH_TRANSFER: USHORT = 0x000A; |
| 64 |
pub const URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE: USHORT = 0x000B; |
| 65 |
pub const URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE: USHORT = 0x000C; |
| 66 |
pub const URB_FUNCTION_SET_FEATURE_TO_DEVICE: USHORT = 0x000D; |
| 67 |
pub const URB_FUNCTION_SET_FEATURE_TO_INTERFACE: USHORT = 0x000E; |
| 68 |
pub const URB_FUNCTION_SET_FEATURE_TO_ENDPOINT: USHORT = 0x000F; |
| 69 |
pub const URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE: USHORT = 0x0010; |
| 70 |
pub const URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE: USHORT = 0x0011; |
| 71 |
pub const URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT: USHORT = 0x0012; |
| 72 |
pub const URB_FUNCTION_GET_STATUS_FROM_DEVICE: USHORT = 0x0013; |
| 73 |
pub const URB_FUNCTION_GET_STATUS_FROM_INTERFACE: USHORT = 0x0014; |
| 74 |
pub const URB_FUNCTION_GET_STATUS_FROM_ENDPOINT: USHORT = 0x0015; |
| 75 |
pub const URB_FUNCTION_RESERVED_0X0016: USHORT = 0x0016; |
| 76 |
pub const URB_FUNCTION_VENDOR_DEVICE: USHORT = 0x0017; |
| 77 |
pub const URB_FUNCTION_VENDOR_INTERFACE: USHORT = 0x0018; |
| 78 |
pub const URB_FUNCTION_VENDOR_ENDPOINT: USHORT = 0x0019; |
| 79 |
pub const URB_FUNCTION_CLASS_DEVICE: USHORT = 0x001A; |
| 80 |
pub const URB_FUNCTION_CLASS_INTERFACE: USHORT = 0x001B; |
| 81 |
pub const URB_FUNCTION_CLASS_ENDPOINT: USHORT = 0x001C; |
| 82 |
pub const URB_FUNCTION_RESERVE_0X001D: USHORT = 0x001D; |
| 83 |
pub const URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL: USHORT = 0x001E; |
| 84 |
pub const URB_FUNCTION_CLASS_OTHER: USHORT = 0x001F; |
| 85 |
pub const URB_FUNCTION_VENDOR_OTHER: USHORT = 0x0020; |
| 86 |
pub const URB_FUNCTION_GET_STATUS_FROM_OTHER: USHORT = 0x0021; |
| 87 |
pub const URB_FUNCTION_CLEAR_FEATURE_TO_OTHER: USHORT = 0x0022; |
| 88 |
pub const URB_FUNCTION_SET_FEATURE_TO_OTHER: USHORT = 0x0023; |
| 89 |
pub const URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT: USHORT = 0x0024; |
| 90 |
pub const URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT: USHORT = 0x0025; |
| 91 |
pub const URB_FUNCTION_GET_CONFIGURATION: USHORT = 0x0026; |
| 92 |
pub const URB_FUNCTION_GET_INTERFACE: USHORT = 0x0027; |
| 93 |
pub const URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE: USHORT = 0x0028; |
| 94 |
pub const URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE: USHORT = 0x0029; |
| 95 |
pub const URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR: USHORT = 0x002A; |
| 96 |
pub const URB_FUNCTION_SYNC_RESET_PIPE: USHORT = 0x0030; |
| 97 |
pub const URB_FUNCTION_SYNC_CLEAR_STALL: USHORT = 0x0031; |
| 98 |
pub const URB_FUNCTION_CONTROL_TRANSFER_EX: USHORT = 0x0032; |
| 99 |
pub const URB_FUNCTION_RESERVE_0X0033: USHORT = 0x0033; |
| 100 |
pub const URB_FUNCTION_RESERVE_0X0034: USHORT = 0x0034; |
| 101 |
pub const URB_FUNCTION_OPEN_STATIC_STREAMS: USHORT = 0x0035; |
| 102 |
pub const URB_FUNCTION_CLOSE_STATIC_STREAMS: USHORT = 0x0036; |
| 103 |
pub const URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER_USING_CHAINED_MDL: USHORT = 0x0037; |
| 104 |
pub const URB_FUNCTION_ISOCH_TRANSFER_USING_CHAINED_MDL: USHORT = 0x0038; |
| 105 |
pub const URB_FUNCTION_RESERVE_0X002B: USHORT = 0x002B; |
| 106 |
pub const URB_FUNCTION_RESERVE_0X002C: USHORT = 0x002C; |
| 107 |
pub const URB_FUNCTION_RESERVE_0X002D: USHORT = 0x002D; |
| 108 |
pub const URB_FUNCTION_RESERVE_0X002E: USHORT = 0x002E; |
| 109 |
pub const URB_FUNCTION_RESERVE_0X002F: USHORT = 0x002F; |
| 110 |
pub const URB_FUNCTION_RESET_PIPE: USHORT = URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL; |
| 111 |
pub const USBD_SHORT_TRANSFER_OK: ULONG = 0x00000002; |
| 112 |
pub const USBD_START_ISO_TRANSFER_ASAP: ULONG = 0x00000004; |
| 113 |
pub const USBD_DEFAULT_PIPE_TRANSFER: ULONG = 0x00000008; |
| 114 |
pub const USBD_TRANSFER_DIRECTION_OUT: ULONG = 0; |
| 115 |
pub const USBD_TRANSFER_DIRECTION_IN: ULONG = 1; |
| 116 |
pub const USBD_TRANSFER_DIRECTION: ULONG = USBD_TRANSFER_DIRECTION_IN; |
| 117 |
#[inline] |
| 118 |
pub fn USBD_TRANSFER_DIRECTION_FLAG(flags: ULONG) -> ULONG { |
| 119 |
flags & USBD_TRANSFER_DIRECTION |
| 120 |
} |
| 121 |
pub const VALID_TRANSFER_FLAGS_MASK: ULONG = USBD_SHORT_TRANSFER_OK | USBD_TRANSFER_DIRECTION |
| 122 |
| USBD_START_ISO_TRANSFER_ASAP | USBD_DEFAULT_PIPE_TRANSFER; |
| 123 |
pub const USBD_ISO_START_FRAME_RANGE: ULONG = 1024; |
| 124 |
pub type USBD_STATUS = LONG; |
| 125 |
#[inline] |
| 126 |
pub fn USBD_SUCCESS(Status: USBD_STATUS) -> bool { |
| 127 |
Status >= 0 |
| 128 |
} |
| 129 |
#[inline] |
| 130 |
pub fn USBD_PENDING(Status: ULONG) -> bool { |
| 131 |
(Status >> 30) == 1 |
| 132 |
} |
| 133 |
pub const USBD_STATUS_SUCCESS: USBD_STATUS = 0x00000000; |
| 134 |
pub const USBD_STATUS_PORT_OPERATION_PENDING: USBD_STATUS = 0x00000001; |
| 135 |
pub const USBD_STATUS_PENDING: USBD_STATUS = 0x40000000; |
| 136 |
pub const USBD_STATUS_CRC: USBD_STATUS = 0xC0000001; |
| 137 |
pub const USBD_STATUS_BTSTUFF: USBD_STATUS = 0xC0000002; |
| 138 |
pub const USBD_STATUS_DATA_TOGGLE_MISMATCH: USBD_STATUS = 0xC0000003; |
| 139 |
pub const USBD_STATUS_STALL_PID: USBD_STATUS = 0xC0000004; |
| 140 |
pub const USBD_STATUS_DEV_NOT_RESPONDING: USBD_STATUS = 0xC0000005; |
| 141 |
pub const USBD_STATUS_PID_CHECK_FAILURE: USBD_STATUS = 0xC0000006; |
| 142 |
pub const USBD_STATUS_UNEXPECTED_PID: USBD_STATUS = 0xC0000007; |
| 143 |
pub const USBD_STATUS_DATA_OVERRUN: USBD_STATUS = 0xC0000008; |
| 144 |
pub const USBD_STATUS_DATA_UNDERRUN: USBD_STATUS = 0xC0000009; |
| 145 |
pub const USBD_STATUS_RESERVED1: USBD_STATUS = 0xC000000A; |
| 146 |
pub const USBD_STATUS_RESERVED2: USBD_STATUS = 0xC000000B; |
| 147 |
pub const USBD_STATUS_BUFFER_OVERRUN: USBD_STATUS = 0xC000000C; |
| 148 |
pub const USBD_STATUS_BUFFER_UNDERRUN: USBD_STATUS = 0xC000000D; |
| 149 |
pub const USBD_STATUS_NOT_ACCESSED: USBD_STATUS = 0xC000000F; |
| 150 |
pub const USBD_STATUS_FIFO: USBD_STATUS = 0xC0000010; |
| 151 |
pub const USBD_STATUS_XACT_ERROR: USBD_STATUS = 0xC0000011; |
| 152 |
pub const USBD_STATUS_BABBLE_DETECTED: USBD_STATUS = 0xC0000012; |
| 153 |
pub const USBD_STATUS_DATA_BUFFER_ERROR: USBD_STATUS = 0xC0000013; |
| 154 |
pub const USBD_STATUS_NO_PING_RESPONSE: USBD_STATUS = 0xC0000014; |
| 155 |
pub const USBD_STATUS_INVALID_STREAM_TYPE: USBD_STATUS = 0xC0000015; |
| 156 |
pub const USBD_STATUS_INVALID_STREAM_ID: USBD_STATUS = 0xC0000016; |
| 157 |
pub const USBD_STATUS_ENDPOINT_HALTED: USBD_STATUS = 0xC0000030; |
| 158 |
pub const USBD_STATUS_INVALID_URB_FUNCTION: USBD_STATUS = 0x80000200; |
| 159 |
pub const USBD_STATUS_INVALID_PARAMETER: USBD_STATUS = 0x80000300; |
| 160 |
pub const USBD_STATUS_ERROR_BUSY: USBD_STATUS = 0x80000400; |
| 161 |
pub const USBD_STATUS_INVALID_PIPE_HANDLE: USBD_STATUS = 0x80000600; |
| 162 |
pub const USBD_STATUS_NO_BANDWIDTH: USBD_STATUS = 0x80000700; |
| 163 |
pub const USBD_STATUS_INTERNAL_HC_ERROR: USBD_STATUS = 0x80000800; |
| 164 |
pub const USBD_STATUS_ERROR_SHORT_TRANSFER: USBD_STATUS = 0x80000900; |
| 165 |
pub const USBD_STATUS_BAD_START_FRAME: USBD_STATUS = 0xC0000A00; |
| 166 |
pub const USBD_STATUS_ISOCH_REQUEST_FAILED: USBD_STATUS = 0xC0000B00; |
| 167 |
pub const USBD_STATUS_FRAME_CONTROL_OWNED: USBD_STATUS = 0xC0000C00; |
| 168 |
pub const USBD_STATUS_FRAME_CONTROL_NOT_OWNED: USBD_STATUS = 0xC0000D00; |
| 169 |
pub const USBD_STATUS_NOT_SUPPORTED: USBD_STATUS = 0xC0000E00; |
| 170 |
pub const USBD_STATUS_INAVLID_CONFIGURATION_DESCRIPTOR: USBD_STATUS = 0xC0000F00; |
| 171 |
pub const USBD_STATUS_INVALID_CONFIGURATION_DESCRIPTOR: USBD_STATUS = 0xC0000F00; |
| 172 |
pub const USBD_STATUS_INSUFFICIENT_RESOURCES: USBD_STATUS = 0xC0001000; |
| 173 |
pub const USBD_STATUS_SET_CONFIG_FAILED: USBD_STATUS = 0xC0002000; |
| 174 |
pub const USBD_STATUS_BUFFER_TOO_SMALL: USBD_STATUS = 0xC0003000; |
| 175 |
pub const USBD_STATUS_INTERFACE_NOT_FOUND: USBD_STATUS = 0xC0004000; |
| 176 |
pub const USBD_STATUS_INAVLID_PIPE_FLAGS: USBD_STATUS = 0xC0005000; |
| 177 |
pub const USBD_STATUS_TIMEOUT: USBD_STATUS = 0xC0006000; |
| 178 |
pub const USBD_STATUS_DEVICE_GONE: USBD_STATUS = 0xC0007000; |
| 179 |
pub const USBD_STATUS_STATUS_NOT_MAPPED: USBD_STATUS = 0xC0008000; |
| 180 |
pub const USBD_STATUS_HUB_INTERNAL_ERROR: USBD_STATUS = 0xC0009000; |
| 181 |
pub const USBD_STATUS_CANCELED: USBD_STATUS = 0xC0010000; |
| 182 |
pub const USBD_STATUS_ISO_NOT_ACCESSED_BY_HW: USBD_STATUS = 0xC0020000; |
| 183 |
pub const USBD_STATUS_ISO_TD_ERROR: USBD_STATUS = 0xC0030000; |
| 184 |
pub const USBD_STATUS_ISO_NA_LATE_USBPORT: USBD_STATUS = 0xC0040000; |
| 185 |
pub const USBD_STATUS_ISO_NOT_ACCESSED_LATE: USBD_STATUS = 0xC0050000; |
| 186 |
pub const USBD_STATUS_BAD_DESCRIPTOR: USBD_STATUS = 0xC0100000; |
| 187 |
pub const USBD_STATUS_BAD_DESCRIPTOR_BLEN: USBD_STATUS = 0xC0100001; |
| 188 |
pub const USBD_STATUS_BAD_DESCRIPTOR_TYPE: USBD_STATUS = 0xC0100002; |
| 189 |
pub const USBD_STATUS_BAD_INTERFACE_DESCRIPTOR: USBD_STATUS = 0xC0100003; |
| 190 |
pub const USBD_STATUS_BAD_ENDPOINT_DESCRIPTOR: USBD_STATUS = 0xC0100004; |
| 191 |
pub const USBD_STATUS_BAD_INTERFACE_ASSOC_DESCRIPTOR: USBD_STATUS = 0xC0100005; |
| 192 |
pub const USBD_STATUS_BAD_CONFIG_DESC_LENGTH: USBD_STATUS = 0xC0100006; |
| 193 |
pub const USBD_STATUS_BAD_NUMBER_OF_INTERFACES: USBD_STATUS = 0xC0100007; |
| 194 |
pub const USBD_STATUS_BAD_NUMBER_OF_ENDPOINTS: USBD_STATUS = 0xC0100008; |
| 195 |
pub const USBD_STATUS_BAD_ENDPOINT_ADDRESS: USBD_STATUS = 0xC0100009; |
| 196 |
pub type USBD_PIPE_HANDLE = PVOID; |
| 197 |
pub type USBD_CONFIGURATION_HANDLE = PVOID; |
| 198 |
pub type USBD_INTERFACE_HANDLE = PVOID; |
| 199 |
pub const USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE: ULONG = 0xFFFFFFFF; |
| 200 |
STRUCT!{struct USBD_VERSION_INFORMATION { |
| 201 |
USBDI_Version: ULONG, |
| 202 |
Supported_USB_Version: ULONG, |
| 203 |
}} |
| 204 |
pub type PUSBD_VERSION_INFORMATION = *mut USBD_VERSION_INFORMATION; |
| 205 |
ENUM!{enum USBD_PIPE_TYPE { |
| 206 |
UsbdPipeTypeControl, |
| 207 |
UsbdPipeTypeIsochronous, |
| 208 |
UsbdPipeTypeBulk, |
| 209 |
UsbdPipeTypeInterrupt, |
| 210 |
}} |
| 211 |
#[inline] |
| 212 |
pub fn USBD_PIPE_DIRECTION_IN(pipeInformation: &USBD_PIPE_INFORMATION) -> UCHAR { |
| 213 |
pipeInformation.EndpointAddress & USB_ENDPOINT_DIRECTION_MASK |
| 214 |
} |
| 215 |
STRUCT!{struct USBD_DEVICE_INFORMATION { |
| 216 |
OffsetNext: ULONG, |
| 217 |
UsbdDeviceHandle: PVOID, |
| 218 |
DeviceDescriptor: USB_DEVICE_DESCRIPTOR, |
| 219 |
}} |
| 220 |
pub type PUSBD_DEVICE_INFORMATION = *mut USBD_DEVICE_INFORMATION; |
| 221 |
STRUCT!{struct USBD_PIPE_INFORMATION { |
| 222 |
MaximumPacketSize: USHORT, |
| 223 |
EndpointAddress: UCHAR, |
| 224 |
Interval: UCHAR, |
| 225 |
PipeType: USBD_PIPE_TYPE, |
| 226 |
PipeHandle: USBD_PIPE_HANDLE, |
| 227 |
MaximumTransferSize: ULONG, |
| 228 |
PipeFlags: ULONG, |
| 229 |
}} |
| 230 |
pub type PUSBD_PIPE_INFORMATION = *mut USBD_PIPE_INFORMATION; |
| 231 |
pub const USBD_PF_CHANGE_MAX_PACKET: ULONG = 0x00000001; |
| 232 |
pub const USBD_PF_SHORT_PACKET_OPT: ULONG = 0x00000002; |
| 233 |
pub const USBD_PF_ENABLE_RT_THREAD_ACCESS: ULONG = 0x00000004; |
| 234 |
pub const USBD_PF_MAP_ADD_TRANSFERS: ULONG = 0x00000008; |
| 235 |
pub const USBD_PF_VALID_MASK: ULONG = USBD_PF_CHANGE_MAX_PACKET | USBD_PF_SHORT_PACKET_OPT |
| 236 |
| USBD_PF_ENABLE_RT_THREAD_ACCESS | USBD_PF_MAP_ADD_TRANSFERS; |
| 237 |
STRUCT!{struct USBD_INTERFACE_INFORMATION { |
| 238 |
Length: USHORT, |
| 239 |
InterfaceNumber: UCHAR, |
| 240 |
AlternateSetting: UCHAR, |
| 241 |
Class: UCHAR, |
| 242 |
SubClass: UCHAR, |
| 243 |
Protocol: UCHAR, |
| 244 |
Reserved: UCHAR, |
| 245 |
InterfaceHandle: USBD_INTERFACE_HANDLE, |
| 246 |
NumberOfPipes: ULONG, |
| 247 |
Pipes: [USBD_PIPE_INFORMATION; 1], |
| 248 |
}} |
| 249 |
pub type PUSBD_INTERFACE_INFORMATION = *mut USBD_INTERFACE_INFORMATION; |
| 250 |
STRUCT!{struct URB_HCD_AREA { |
| 251 |
Reserved8: [PVOID; 8], |
| 252 |
}} |
| 253 |
STRUCT!{struct URB_HEADER { |
| 254 |
Length: USHORT, |
| 255 |
Function: USHORT, |
| 256 |
Status: USBD_STATUS, |
| 257 |
UsbdDeviceHandle: PVOID, |
| 258 |
UsbdFlags: ULONG, |
| 259 |
}} |
| 260 |
STRUCT!{struct URB_SELECT_INTERFACE { |
| 261 |
Hdr: URB_HEADER, |
| 262 |
ConfigurationHandle: USBD_CONFIGURATION_HANDLE, |
| 263 |
Interface: USBD_INTERFACE_INFORMATION, |
| 264 |
}} |
| 265 |
STRUCT!{struct URB_SELECT_CONFIGURATION { |
| 266 |
Hdr: URB_HEADER, |
| 267 |
ConfigurationDescriptor: PUSB_CONFIGURATION_DESCRIPTOR, |
| 268 |
ConfigurationHandle: USBD_CONFIGURATION_HANDLE, |
| 269 |
Interface: USBD_INTERFACE_INFORMATION, |
| 270 |
}} |
| 271 |
STRUCT!{struct URB_PIPE_REQUEST { |
| 272 |
Hdr: URB_HEADER, |
| 273 |
PipeHandle: USBD_PIPE_HANDLE, |
| 274 |
Reserved: ULONG, |
| 275 |
}} |
| 276 |
STRUCT!{struct URB_FRAME_LENGTH_CONTROL { |
| 277 |
Hdr: URB_HEADER, |
| 278 |
}} |
| 279 |
STRUCT!{struct URB_GET_FRAME_LENGTH { |
| 280 |
Hdr: URB_HEADER, |
| 281 |
FrameLength: ULONG, |
| 282 |
FrameNumber: ULONG, |
| 283 |
}} |
| 284 |
STRUCT!{struct URB_SET_FRAME_LENGTH { |
| 285 |
Hdr: URB_HEADER, |
| 286 |
FrameLengthDelta: LONG, |
| 287 |
}} |
| 288 |
STRUCT!{struct URB_GET_CURRENT_FRAME_NUMBER { |
| 289 |
Hdr: URB_HEADER, |
| 290 |
FrameNumber: ULONG, |
| 291 |
}} |
| 292 |
STRUCT!{struct URB_CONTROL_DESCRIPTOR_REQUEST { |
| 293 |
Hdr: URB_HEADER, |
| 294 |
Reserved: PVOID, |
| 295 |
Reserved0: ULONG, |
| 296 |
TransferBufferLength: ULONG, |
| 297 |
TransferBuffer: PVOID, |
| 298 |
TransferBufferMDL: PMDL, |
| 299 |
UrbLink: *mut URB, |
| 300 |
hca: URB_HCD_AREA, |
| 301 |
Reserved1: USHORT, |
| 302 |
Index: UCHAR, |
| 303 |
DescriptorType: UCHAR, |
| 304 |
LanguageId: USHORT, |
| 305 |
Reserved2: USHORT, |
| 306 |
}} |
| 307 |
STRUCT!{struct URB_CONTROL_GET_STATUS_REQUEST { |
| 308 |
Hdr: URB_HEADER, |
| 309 |
Reserved: PVOID, |
| 310 |
Reserved0: ULONG, |
| 311 |
TransferBufferLength: ULONG, |
| 312 |
TransferBuffer: PVOID, |
| 313 |
TransferBufferMDL: PMDL, |
| 314 |
UrbLink: *mut URB, |
| 315 |
hca: URB_HCD_AREA, |
| 316 |
Reserved1: [UCHAR; 4], |
| 317 |
Index: USHORT, |
| 318 |
Reserved2: USHORT, |
| 319 |
}} |
| 320 |
STRUCT!{struct URB_CONTROL_FEATURE_REQUEST { |
| 321 |
Hdr: URB_HEADER, |
| 322 |
Reserved: PVOID, |
| 323 |
Reserved2: ULONG, |
| 324 |
Reserved3: ULONG, |
| 325 |
Reserved4: PVOID, |
| 326 |
Reserved5: PMDL, |
| 327 |
UrbLink: *mut URB, |
| 328 |
hca: URB_HCD_AREA, |
| 329 |
Reserved0: USHORT, |
| 330 |
FeatureSelector: USHORT, |
| 331 |
Index: USHORT, |
| 332 |
Reserved1: USHORT, |
| 333 |
}} |
| 334 |
STRUCT!{struct URB_CONTROL_VENDOR_OR_CLASS_REQUEST { |
| 335 |
Hdr: URB_HEADER, |
| 336 |
Reserved: PVOID, |
| 337 |
TransferFlags: ULONG, |
| 338 |
TransferBufferLength: ULONG, |
| 339 |
TransferBuffer: PVOID, |
| 340 |
TransferBufferMDL: PMDL, |
| 341 |
UrbLink: *mut URB, |
| 342 |
hca: URB_HCD_AREA, |
| 343 |
RequestTypeReservedBits: UCHAR, |
| 344 |
Request: UCHAR, |
| 345 |
Value: USHORT, |
| 346 |
Index: USHORT, |
| 347 |
Reserved1: USHORT, |
| 348 |
}} |
| 349 |
STRUCT!{struct URB_CONTROL_GET_INTERFACE_REQUEST { |
| 350 |
Hdr: URB_HEADER, |
| 351 |
Reserved: PVOID, |
| 352 |
Reserved0: ULONG, |
| 353 |
TransferBufferLength: ULONG, |
| 354 |
TransferBuffer: PVOID, |
| 355 |
TransferBufferMDL: PMDL, |
| 356 |
UrbLink: *mut URB, |
| 357 |
hca: URB_HCD_AREA, |
| 358 |
Reserved1: [UCHAR; 4], |
| 359 |
Interface: USHORT, |
| 360 |
Reserved2: USHORT, |
| 361 |
}} |
| 362 |
STRUCT!{struct URB_CONTROL_GET_CONFIGURATION_REQUEST { |
| 363 |
Hdr: URB_HEADER, |
| 364 |
Reserved: PVOID, |
| 365 |
Reserved0: ULONG, |
| 366 |
TransferBufferLength: ULONG, |
| 367 |
TransferBuffer: PVOID, |
| 368 |
TransferBufferMDL: PMDL, |
| 369 |
UrbLink: *mut URB, |
| 370 |
hca: URB_HCD_AREA, |
| 371 |
Reserved1: [UCHAR; 8], |
| 372 |
}} |
| 373 |
pub const OS_STRING_DESCRIPTOR_INDEX: UCHAR = 0xEE; |
| 374 |
pub const MS_GENRE_DESCRIPTOR_INDEX: USHORT = 0x0001; |
| 375 |
pub const MS_POWER_DESCRIPTOR_INDEX: USHORT = 0x0002; |
| 376 |
pub const MS_OS_STRING_SIGNATURE: &'static str = "MSFT100"; |
| 377 |
pub const MS_OS_FLAGS_CONTAINERID: UCHAR = 0x02; |
| 378 |
UNION!{union OS_STRING_u { |
| 379 |
[u8; 1], |
| 380 |
bPad bPad_mut: UCHAR, |
| 381 |
bFlags bFlags_mut: UCHAR, |
| 382 |
}} |
| 383 |
STRUCT!{struct OS_STRING { |
| 384 |
bLength: UCHAR, |
| 385 |
bDescriptorType: UCHAR, |
| 386 |
MicrosoftString: [WCHAR; 7], |
| 387 |
bVendorCode: UCHAR, |
| 388 |
u: OS_STRING_u, |
| 389 |
}} |
| 390 |
pub type POS_STRING = *mut OS_STRING; |
| 391 |
STRUCT!{struct URB_OS_FEATURE_DESCRIPTOR_REQUEST { |
| 392 |
Hdr: URB_HEADER, |
| 393 |
Reserved: PVOID, |
| 394 |
Reserved0: ULONG, |
| 395 |
TransferBufferLength: ULONG, |
| 396 |
TransferBuffer: PVOID, |
| 397 |
TransferBufferMDL: PMDL, |
| 398 |
UrbLink: *mut URB, |
| 399 |
hca: URB_HCD_AREA, |
| 400 |
BitField: UCHAR, |
| 401 |
Reserved2: UCHAR, |
| 402 |
InterfaceNumber: UCHAR, |
| 403 |
MS_PageIndex: UCHAR, |
| 404 |
MS_FeatureDescriptorIndex: USHORT, |
| 405 |
Reserved3: USHORT, |
| 406 |
}} |
| 407 |
BITFIELD!{URB_OS_FEATURE_DESCRIPTOR_REQUEST BitField: UCHAR [ |
| 408 |
Recipient set_Recipient[0..5], |
| 409 |
Reserved1 set_Reserved1[5..8], |
| 410 |
]} |
| 411 |
STRUCT!{struct URB_CONTROL_TRANSFER { |
| 412 |
Hdr: URB_HEADER, |
| 413 |
PipeHandle: USBD_PIPE_HANDLE, |
| 414 |
TransferFlags: ULONG, |
| 415 |
TransferBufferLength: ULONG, |
| 416 |
TransferBuffer: PVOID, |
| 417 |
TransferBufferMDL: PMDL, |
| 418 |
UrbLink: *mut URB, |
| 419 |
hca: URB_HCD_AREA, |
| 420 |
SetupPacket: [UCHAR; 8], |
| 421 |
}} |
| 422 |
#[cfg(target_pointer_width = "64")] |
| 423 |
STRUCT!{struct URB_CONTROL_TRANSFER_EX { |
| 424 |
Hdr: URB_HEADER, |
| 425 |
PipeHandle: USBD_PIPE_HANDLE, |
| 426 |
TransferFlags: ULONG, |
| 427 |
TransferBufferLength: ULONG, |
| 428 |
TransferBuffer: PVOID, |
| 429 |
TransferBufferMDL: PMDL, |
| 430 |
Timeout: ULONG, |
| 431 |
Pad: ULONG, |
| 432 |
hca: URB_HCD_AREA, |
| 433 |
SetupPacket: [UCHAR; 8], |
| 434 |
}} |
| 435 |
#[cfg(target_pointer_width = "32")] |
| 436 |
STRUCT!{struct URB_CONTROL_TRANSFER_EX { |
| 437 |
Hdr: URB_HEADER, |
| 438 |
PipeHandle: USBD_PIPE_HANDLE, |
| 439 |
TransferFlags: ULONG, |
| 440 |
TransferBufferLength: ULONG, |
| 441 |
TransferBuffer: PVOID, |
| 442 |
TransferBufferMDL: PMDL, |
| 443 |
Timeout: ULONG, |
| 444 |
hca: URB_HCD_AREA, |
| 445 |
SetupPacket: [UCHAR; 8], |
| 446 |
}} |
| 447 |
STRUCT!{struct URB_BULK_OR_INTERRUPT_TRANSFER { |
| 448 |
Hdr: URB_HEADER, |
| 449 |
PipeHandle: USBD_PIPE_HANDLE, |
| 450 |
TransferFlags: ULONG, |
| 451 |
TransferBufferLength: ULONG, |
| 452 |
TransferBuffer: PVOID, |
| 453 |
TransferBufferMDL: PMDL, |
| 454 |
UrbLink: *mut URB, |
| 455 |
hca: URB_HCD_AREA, |
| 456 |
}} |
| 457 |
STRUCT!{struct USBD_ISO_PACKET_DESCRIPTOR { |
| 458 |
Offset: ULONG, |
| 459 |
Length: ULONG, |
| 460 |
Status: USBD_STATUS, |
| 461 |
}} |
| 462 |
pub type PUSBD_ISO_PACKET_DESCRIPTOR = *mut USBD_ISO_PACKET_DESCRIPTOR; |
| 463 |
STRUCT!{struct URB_ISOCH_TRANSFER { |
| 464 |
Hdr: URB_HEADER, |
| 465 |
PipeHandle: USBD_PIPE_HANDLE, |
| 466 |
TransferFlags: ULONG, |
| 467 |
TransferBufferLength: ULONG, |
| 468 |
TransferBuffer: PVOID, |
| 469 |
TransferBufferMDL: PMDL, |
| 470 |
UrbLink: *mut URB, |
| 471 |
hca: URB_HCD_AREA, |
| 472 |
StartFrame: ULONG, |
| 473 |
NumberOfPackets: ULONG, |
| 474 |
ErrorCount: ULONG, |
| 475 |
IsoPacket: [USBD_ISO_PACKET_DESCRIPTOR; 1], |
| 476 |
}} |
| 477 |
pub const URB_OPEN_STATIC_STREAMS_VERSION_100: USHORT = 0x100; |
| 478 |
STRUCT!{struct USBD_STREAM_INFORMATION { |
| 479 |
PipeHandle: USBD_PIPE_HANDLE, |
| 480 |
StreamID: ULONG, |
| 481 |
MaximumTransferSize: ULONG, |
| 482 |
PipeFlags: ULONG, |
| 483 |
}} |
| 484 |
pub type PUSBD_STREAM_INFORMATION = *mut USBD_STREAM_INFORMATION; |
| 485 |
STRUCT!{struct URB_OPEN_STATIC_STREAMS { |
| 486 |
Hdr: URB_HEADER, |
| 487 |
PipeHandle: USBD_PIPE_HANDLE, |
| 488 |
NumberOfStreams: ULONG, |
| 489 |
StreamInfoVersion: USHORT, |
| 490 |
StreamInfoSize: USHORT, |
| 491 |
Streams: PUSBD_STREAM_INFORMATION, |
| 492 |
}} |
| 493 |
UNION!{union URB_u { |
| 494 |
[u32; 24] [u64; 19], |
| 495 |
UrbHeader UrbHeader_mut: URB_HEADER, |
| 496 |
UrbSelectInterface UrbSelectInterface_mut: URB_SELECT_INTERFACE, |
| 497 |
UrbSelectConfiguration UrbSelectConfiguration_mut: URB_SELECT_CONFIGURATION, |
| 498 |
UrbPipeRequest UrbPipeRequest_mut: URB_PIPE_REQUEST, |
| 499 |
UrbFrameLengthControl UrbFrameLengthControl_mut: URB_FRAME_LENGTH_CONTROL, |
| 500 |
UrbGetFrameLength UrbGetFrameLength_mut: URB_GET_FRAME_LENGTH, |
| 501 |
UrbSetFrameLength UrbSetFrameLength_mut: URB_SET_FRAME_LENGTH, |
| 502 |
UrbGetCurrentFrameNumber UrbGetCurrentFrameNumber_mut: URB_GET_CURRENT_FRAME_NUMBER, |
| 503 |
UrbControlTransfer UrbControlTransfer_mut: URB_CONTROL_TRANSFER, |
| 504 |
UrbControlTransferEx UrbControlTransferEx_mut: URB_CONTROL_TRANSFER_EX, |
| 505 |
UrbBulkOrInterruptTransfer UrbBulkOrInterruptTransfer_mut: URB_BULK_OR_INTERRUPT_TRANSFER, |
| 506 |
UrbIsochronousTransfer UrbIsochronousTransfer_mut: URB_ISOCH_TRANSFER, |
| 507 |
UrbControlDescriptorRequest UrbControlDescriptorRequest_mut: URB_CONTROL_DESCRIPTOR_REQUEST, |
| 508 |
UrbControlGetStatusRequest UrbControlGetStatusRequest_mut: URB_CONTROL_GET_STATUS_REQUEST, |
| 509 |
UrbControlFeatureRequest UrbControlFeatureRequest_mut: URB_CONTROL_FEATURE_REQUEST, |
| 510 |
UrbControlVendorClassRequest UrbControlVendorClassRequest_mut: |
| 511 |
URB_CONTROL_VENDOR_OR_CLASS_REQUEST, |
| 512 |
UrbControlGetInterfaceRequest UrbControlGetInterfaceRequest_mut: |
| 513 |
URB_CONTROL_GET_INTERFACE_REQUEST, |
| 514 |
UrbControlGetConfigurationRequest UrbControlGetConfigurationRequest_mut: |
| 515 |
URB_CONTROL_GET_CONFIGURATION_REQUEST, |
| 516 |
UrbOSFeatureDescriptorRequest UrbOSFeatureDescriptorRequest_mut: |
| 517 |
URB_OS_FEATURE_DESCRIPTOR_REQUEST, |
| 518 |
UrbOpenStaticStreams UrbOpenStaticStreams_mut: URB_OPEN_STATIC_STREAMS, |
| 519 |
}} |
| 520 |
STRUCT!{struct URB { |
| 521 |
u: URB_u, |
| 522 |
}} |
| 523 |
pub type PURB = *mut URB; |