Debian Codegraph @

src/platform/macos_iokit/iokit_c.rs

raw symbols SCIP
1 //! FFI types we're including here, as they're missing from io-kit-sys.
2 //! You may not want to stare too closely at this; it's tweaked bindgen output.
3 //!
4 //! Based on Kate Temkin's [usrs](https://github.com/ktemkin/usrs)
5 //! licensed under MIT OR Apache-2.0.
6 #![allow(
7 non_camel_case_types,
8 non_snake_case,
9 dead_code,
10 non_upper_case_globals
11 )]
12
13 use std::ffi::{c_int, c_void};
14
15 use core_foundation_sys::{
16 base::{kCFAllocatorSystemDefault, mach_port_t, SInt32},
17 dictionary::CFDictionaryRef,
18 mach_port::CFAllocatorRef,
19 runloop::CFRunLoopSourceRef,
20 uuid::{CFUUIDBytes, CFUUIDRef},
21 };
22 use io_kit_sys::{
23 ret::IOReturn,
24 types::{io_iterator_t, io_service_t, IOByteCount},
25 IOAsyncCallback1,
26 };
27
28 //
29 // Constants.
30 //
31 const SYS_IOKIT: c_int = ((0x38) & 0x3f) << 26;
32 const SUB_IOKIT_USB: c_int = ((1) & 0xfff) << 14;
33
34 pub(crate) const kIOUSBUnknownPipeErr: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x61; // 0xe0004061 Pipe ref not recognized
35 pub(crate) const kIOUSBTooManyPipesErr: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x60; // 0xe0004060 Too many pipes
36 pub(crate) const kIOUSBNoAsyncPortErr: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x5f; // 0xe000405f no async port
37 pub(crate) const kIOUSBNotEnoughPipesErr: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x5e; // 0xe000405e not enough pipes in interface
38 pub(crate) const kIOUSBNotEnoughPowerErr: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x5d; // 0xe000405d not enough power for selected configuration
39 pub(crate) const kIOUSBEndpointNotFound: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x57; // 0xe0004057 Endpoint Not found
40 pub(crate) const kIOUSBConfigNotFound: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x56; // 0xe0004056 Configuration Not found
41 pub(crate) const kIOUSBPortWasSuspended: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x52; // 0xe0004052 The transaction was returned because the port was suspended
42 pub(crate) const kIOUSBPipeStalled: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x4f; // 0xe000404f Pipe has stalled, error needs to be cleared
43 pub(crate) const kIOUSBInterfaceNotFound: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x4e; // 0xe000404e Interface ref not recognized
44 pub(crate) const kIOUSBLowLatencyBufferNotPreviouslyAllocated: c_int =
45 SYS_IOKIT | SUB_IOKIT_USB | 0x4d; // 0xe000404d Attempted to use user land low latency isoc calls w/out calling PrepareBuffer (on the data buffer) first
46 pub(crate) const kIOUSBLowLatencyFrameListNotPreviouslyAllocated: c_int =
47 SYS_IOKIT | SUB_IOKIT_USB | 0x4c; // 0xe000404c Attempted to use user land low latency isoc calls w/out calling PrepareBuffer (on the frame list) first
48 pub(crate) const kIOUSBHighSpeedSplitError: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x4b; // 0xe000404b Error to hub on high speed bus trying to do split transaction
49 pub(crate) const kIOUSBSyncRequestOnWLThread: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x4a; // 0xe000404a A synchronous USB request was made on the workloop thread (from a callback?). Only async requests are permitted in that case
50 pub(crate) const kIOUSBDeviceNotHighSpeed: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x49; // 0xe0004049 Name is deprecated, see below
51 pub(crate) const kIOUSBDeviceTransferredToCompanion: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x49; // 0xe0004049 The device has been tranferred to another controller for enumeration
52 pub(crate) const kIOUSBClearPipeStallNotRecursive: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x48; // 0xe0004048 IOUSBPipe::ClearPipeStall should not be called recursively
53 pub(crate) const kIOUSBDevicePortWasNotSuspended: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x47; // 0xe0004047 Port was not suspended
54 pub(crate) const kIOUSBEndpointCountExceeded: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x46; // 0xe0004046 The endpoint was not created because the controller cannot support more endpoints
55 pub(crate) const kIOUSBDeviceCountExceeded: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x45; // 0xe0004045 The device cannot be enumerated because the controller cannot support more devices
56 pub(crate) const kIOUSBStreamsNotSupported: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x44; // 0xe0004044 The request cannot be completed because the XHCI controller does not support streams
57 pub(crate) const kIOUSBInvalidSSEndpoint: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x43; // 0xe0004043 An endpoint found in a SuperSpeed device is invalid (usually because there is no Endpoint Companion Descriptor)
58 pub(crate) const kIOUSBTooManyTransactionsPending: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x42; // 0xe0004042 The transaction cannot be submitted because it would exceed the allowed number of pending transactions
59 pub(crate) const kIOUSBTransactionReturned: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x50;
60 pub(crate) const kIOUSBTransactionTimeout: c_int = SYS_IOKIT | SUB_IOKIT_USB | 0x51;
61
62 pub(crate) const kIOUSBFindInterfaceDontCare: UInt16 = 0xFFFF;
63
64 //
65
66 //
67 // Type aliases.
68 //
69 pub(crate) type REFIID = CFUUIDBytes;
70 pub(crate) type LPVOID = *mut c_void;
71 pub(crate) type HRESULT = SInt32;
72 pub(crate) type UInt8 = ::std::os::raw::c_uchar;
73 pub(crate) type UInt16 = ::std::os::raw::c_ushort;
74 pub(crate) type UInt32 = ::std::os::raw::c_uint;
75 pub(crate) type UInt64 = ::std::os::raw::c_ulonglong;
76 pub(crate) type ULONG = ::std::os::raw::c_ulong;
77 pub(crate) type kern_return_t = ::std::os::raw::c_int;
78 pub(crate) type USBDeviceAddress = UInt16;
79 pub(crate) type AbsoluteTime = UnsignedWide;
80 pub(crate) type Boolean = std::os::raw::c_uchar;
81
82 #[repr(C)]
83 #[derive(Debug, Copy, Clone)]
84 pub struct NumVersion {
85 pub nonRelRev: UInt8,
86 pub stage: UInt8,
87 pub minorAndBugRev: UInt8,
88 pub majorRev: UInt8,
89 }
90
91 #[repr(C, packed(2))]
92 #[derive(Debug, Copy, Clone)]
93 pub struct UnsignedWide {
94 pub lo: UInt32,
95 pub hi: UInt32,
96 }
97
98 #[repr(C)]
99 #[derive(Debug, Copy, Clone)]
100 pub struct IOUSBDevRequest {
101 pub bmRequestType: UInt8,
102 pub bRequest: UInt8,
103 pub wValue: UInt16,
104 pub wIndex: UInt16,
105 pub wLength: UInt16,
106 pub pData: *mut ::std::os::raw::c_void,
107 pub wLenDone: UInt32,
108 }
109
110 #[repr(C)]
111 #[derive(Debug, Copy, Clone)]
112 pub struct IOUSBFindInterfaceRequest {
113 pub bInterfaceClass: UInt16,
114 pub bInterfaceSubClass: UInt16,
115 pub bInterfaceProtocol: UInt16,
116 pub bAlternateSetting: UInt16,
117 }
118
119 #[repr(C)]
120 #[derive(Debug, Copy, Clone)]
121 pub struct IOUSBDevRequestTO {
122 pub bmRequestType: UInt8,
123 pub bRequest: UInt8,
124 pub wValue: UInt16,
125 pub wIndex: UInt16,
126 pub wLength: UInt16,
127 pub pData: *mut ::std::os::raw::c_void,
128 pub wLenDone: UInt32,
129 pub noDataTimeout: UInt32,
130 pub completionTimeout: UInt32,
131 }
132
133 #[repr(C)]
134 #[derive(Debug, Copy, Clone)]
135 pub struct IOUSBIsocFrame {
136 pub frStatus: IOReturn,
137 pub frReqCount: UInt16,
138 pub frActCount: UInt16,
139 }
140
141 #[repr(C)]
142 #[derive(Debug, Copy, Clone)]
143 pub struct IOUSBLowLatencyIsocFrame {
144 pub frStatus: IOReturn,
145 pub frReqCount: UInt16,
146 pub frActCount: UInt16,
147 pub frTimeStamp: AbsoluteTime,
148 }
149
150 #[repr(C, packed)]
151 #[derive(Debug, Copy, Clone)]
152 pub struct IOUSBDescriptorHeader {
153 pub bLength: u8,
154 pub bDescriptorType: u8,
155 }
156
157 #[repr(C)]
158 #[derive(Debug, Copy, Clone)]
159 pub struct IOCFPlugInInterfaceStruct {
160 pub _reserved: *mut ::std::os::raw::c_void,
161 pub QueryInterface: ::std::option::Option<
162 unsafe extern "C" fn(
163 thisPointer: *mut ::std::os::raw::c_void,
164 iid: REFIID,
165 ppv: *mut LPVOID,
166 ) -> HRESULT,
167 >,
168 pub AddRef: ::std::option::Option<
169 unsafe extern "C" fn(thisPointer: *mut ::std::os::raw::c_void) -> ULONG,
170 >,
171 pub Release: ::std::option::Option<
172 unsafe extern "C" fn(thisPointer: *mut ::std::os::raw::c_void) -> ULONG,
173 >,
174 pub version: UInt16,
175 pub revision: UInt16,
176 pub Probe: ::std::option::Option<
177 unsafe extern "C" fn(
178 thisPointer: *mut ::std::os::raw::c_void,
179 propertyTable: CFDictionaryRef,
180 service: io_service_t,
181 order: *mut SInt32,
182 ) -> IOReturn,
183 >,
184 pub Start: ::std::option::Option<
185 unsafe extern "C" fn(
186 thisPointer: *mut ::std::os::raw::c_void,
187 propertyTable: CFDictionaryRef,
188 service: io_service_t,
189 ) -> IOReturn,
190 >,
191 pub Stop: ::std::option::Option<
192 unsafe extern "C" fn(thisPointer: *mut ::std::os::raw::c_void) -> IOReturn,
193 >,
194 }
195 pub type IOCFPlugInInterface = IOCFPlugInInterfaceStruct;
196
197 extern "C" {
198 pub fn CFUUIDGetUUIDBytes(uuid: CFUUIDRef) -> CFUUIDBytes;
199
200 pub fn IOCreatePlugInInterfaceForService(
201 service: io_service_t,
202 pluginType: CFUUIDRef,
203 interfaceType: CFUUIDRef,
204 theInterface: *mut *mut *mut IOCFPlugInInterface,
205 theScore: *mut SInt32,
206 ) -> kern_return_t;
207
208 pub fn CFUUIDGetConstantUUIDWithBytes(
209 alloc: CFAllocatorRef,
210 byte0: UInt8,
211 byte1: UInt8,
212 byte2: UInt8,
213 byte3: UInt8,
214 byte4: UInt8,
215 byte5: UInt8,
216 byte6: UInt8,
217 byte7: UInt8,
218 byte8: UInt8,
219 byte9: UInt8,
220 byte10: UInt8,
221 byte11: UInt8,
222 byte12: UInt8,
223 byte13: UInt8,
224 byte14: UInt8,
225 byte15: UInt8,
226 ) -> CFUUIDRef;
227
228 }
229
230 pub fn kIOUsbDeviceUserClientTypeID() -> CFUUIDRef {
231 unsafe {
232 CFUUIDGetConstantUUIDWithBytes(
233 std::ptr::null(),
234 0x9d,
235 0xc7,
236 0xb7,
237 0x80,
238 0x9e,
239 0xc0,
240 0x11,
241 0xD4,
242 0xa5,
243 0x4f,
244 0x00,
245 0x0a,
246 0x27,
247 0x05,
248 0x28,
249 0x61,
250 )
251 }
252 }
253
254 pub fn kIOUsbInterfaceUserClientTypeID() -> CFUUIDRef {
255 unsafe {
256 CFUUIDGetConstantUUIDWithBytes(
257 std::ptr::null(),
258 0x2d,
259 0x97,
260 0x86,
261 0xc6,
262 0x9e,
263 0xf3,
264 0x11,
265 0xD4,
266 0xad,
267 0x51,
268 0x00,
269 0x0a,
270 0x27,
271 0x05,
272 0x28,
273 0x61,
274 )
275 }
276 }
277
278 pub fn kIOCFPlugInInterfaceID() -> CFUUIDRef {
279 unsafe {
280 CFUUIDGetConstantUUIDWithBytes(
281 std::ptr::null(),
282 0xC2,
283 0x44,
284 0xE8,
285 0x58,
286 0x10,
287 0x9C,
288 0x11,
289 0xD4,
290 0x91,
291 0xD4,
292 0x00,
293 0x50,
294 0xE4,
295 0xC6,
296 0x42,
297 0x6F,
298 )
299 }
300 }
301
302 pub fn kIOUSBDeviceInterfaceID500() -> CFUUIDRef {
303 unsafe {
304 CFUUIDGetConstantUUIDWithBytes(
305 kCFAllocatorSystemDefault,
306 0xA3,
307 0x3C,
308 0xF0,
309 0x47,
310 0x4B,
311 0x5B,
312 0x48,
313 0xE2,
314 0xB5,
315 0x7D,
316 0x02,
317 0x07,
318 0xFC,
319 0xEA,
320 0xE1,
321 0x3B,
322 )
323 }
324 }
325
326 pub fn kIOUSBInterfaceInterfaceID500() -> CFUUIDRef {
327 unsafe {
328 CFUUIDGetConstantUUIDWithBytes(
329 kCFAllocatorSystemDefault,
330 0x6C,
331 0x0D,
332 0x38,
333 0xC3,
334 0xB0,
335 0x93,
336 0x4E,
337 0xA7,
338 0x80,
339 0x9B,
340 0x09,
341 0xFB,
342 0x5D,
343 0xDD,
344 0xAC,
345 0x16,
346 )
347 }
348 }
349
350 #[repr(C, packed)]
351 #[derive(Debug, Copy, Clone)]
352 pub struct IOUSBConfigurationDescriptor {
353 pub bLength: u8,
354 pub bDescriptorType: u8,
355 pub wTotalLength: u16,
356 pub bNumInterfaces: u8,
357 pub bConfigurationValue: u8,
358 pub iConfiguration: u8,
359 pub bmAttributes: u8,
360 pub MaxPower: u8,
361 }
362 pub type IOUSBConfigurationDescriptorPtr = *mut IOUSBConfigurationDescriptor;
363
364 #[repr(C)]
365 #[derive(Debug, Copy, Clone)]
366 pub struct IOUSBDeviceStruct500 {
367 pub _reserved: *mut ::std::os::raw::c_void,
368 pub QueryInterface: ::std::option::Option<
369 unsafe extern "C" fn(
370 thisPointer: *mut ::std::os::raw::c_void,
371 iid: REFIID,
372 ppv: *mut LPVOID,
373 ) -> HRESULT,
374 >,
375 pub AddRef: ::std::option::Option<
376 unsafe extern "C" fn(thisPointer: *mut ::std::os::raw::c_void) -> ULONG,
377 >,
378 pub Release: ::std::option::Option<
379 unsafe extern "C" fn(thisPointer: *mut ::std::os::raw::c_void) -> ULONG,
380 >,
381 pub CreateDeviceAsyncEventSource: ::std::option::Option<
382 unsafe extern "C" fn(
383 self_: *mut ::std::os::raw::c_void,
384 source: *mut CFRunLoopSourceRef,
385 ) -> IOReturn,
386 >,
387 pub GetDeviceAsyncEventSource: ::std::option::Option<
388 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void) -> CFRunLoopSourceRef,
389 >,
390 pub CreateDeviceAsyncPort: ::std::option::Option<
391 unsafe extern "C" fn(
392 self_: *mut ::std::os::raw::c_void,
393 port: *mut mach_port_t,
394 ) -> IOReturn,
395 >,
396 pub GetDeviceAsyncPort: ::std::option::Option<
397 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void) -> mach_port_t,
398 >,
399 pub USBDeviceOpen:
400 ::std::option::Option<unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void) -> IOReturn>,
401 pub USBDeviceClose:
402 ::std::option::Option<unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void) -> IOReturn>,
403 pub GetDeviceClass: ::std::option::Option<
404 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, devClass: *mut UInt8) -> IOReturn,
405 >,
406 pub GetDeviceSubClass: ::std::option::Option<
407 unsafe extern "C" fn(
408 self_: *mut ::std::os::raw::c_void,
409 devSubClass: *mut UInt8,
410 ) -> IOReturn,
411 >,
412 pub GetDeviceProtocol: ::std::option::Option<
413 unsafe extern "C" fn(
414 self_: *mut ::std::os::raw::c_void,
415 devProtocol: *mut UInt8,
416 ) -> IOReturn,
417 >,
418 pub GetDeviceVendor: ::std::option::Option<
419 unsafe extern "C" fn(
420 self_: *mut ::std::os::raw::c_void,
421 devVendor: *mut UInt16,
422 ) -> IOReturn,
423 >,
424 pub GetDeviceProduct: ::std::option::Option<
425 unsafe extern "C" fn(
426 self_: *mut ::std::os::raw::c_void,
427 devProduct: *mut UInt16,
428 ) -> IOReturn,
429 >,
430 pub GetDeviceReleaseNumber: ::std::option::Option<
431 unsafe extern "C" fn(
432 self_: *mut ::std::os::raw::c_void,
433 devRelNum: *mut UInt16,
434 ) -> IOReturn,
435 >,
436 pub GetDeviceAddress: ::std::option::Option<
437 unsafe extern "C" fn(
438 self_: *mut ::std::os::raw::c_void,
439 addr: *mut USBDeviceAddress,
440 ) -> IOReturn,
441 >,
442 pub GetDeviceBusPowerAvailable: ::std::option::Option<
443 unsafe extern "C" fn(
444 self_: *mut ::std::os::raw::c_void,
445 powerAvailable: *mut UInt32,
446 ) -> IOReturn,
447 >,
448 pub GetDeviceSpeed: ::std::option::Option<
449 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, devSpeed: *mut UInt8) -> IOReturn,
450 >,
451 pub GetNumberOfConfigurations: ::std::option::Option<
452 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, numConfig: *mut UInt8) -> IOReturn,
453 >,
454 pub GetLocationID: ::std::option::Option<
455 unsafe extern "C" fn(
456 self_: *mut ::std::os::raw::c_void,
457 locationID: *mut UInt32,
458 ) -> IOReturn,
459 >,
460 pub GetConfigurationDescriptorPtr: ::std::option::Option<
461 unsafe extern "C" fn(
462 self_: *mut ::std::os::raw::c_void,
463 configIndex: UInt8,
464 desc: *mut IOUSBConfigurationDescriptorPtr,
465 ) -> IOReturn,
466 >,
467 pub GetConfiguration: ::std::option::Option<
468 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, configNum: *mut UInt8) -> IOReturn,
469 >,
470 pub SetConfiguration: ::std::option::Option<
471 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, configNum: UInt8) -> IOReturn,
472 >,
473 pub GetBusFrameNumber: ::std::option::Option<
474 unsafe extern "C" fn(
475 self_: *mut ::std::os::raw::c_void,
476 frame: *mut UInt64,
477 atTime: *mut AbsoluteTime,
478 ) -> IOReturn,
479 >,
480 pub ResetDevice:
481 ::std::option::Option<unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void) -> IOReturn>,
482 pub DeviceRequest: ::std::option::Option<
483 unsafe extern "C" fn(
484 self_: *mut ::std::os::raw::c_void,
485 req: *mut IOUSBDevRequest,
486 ) -> IOReturn,
487 >,
488 pub DeviceRequestAsync: ::std::option::Option<
489 unsafe extern "C" fn(
490 self_: *mut ::std::os::raw::c_void,
491 req: *mut IOUSBDevRequest,
492 callback: IOAsyncCallback1,
493 refCon: *mut ::std::os::raw::c_void,
494 ) -> IOReturn,
495 >,
496 pub CreateInterfaceIterator: ::std::option::Option<
497 unsafe extern "C" fn(
498 self_: *mut ::std::os::raw::c_void,
499 req: *mut IOUSBFindInterfaceRequest,
500 iter: *mut io_iterator_t,
501 ) -> IOReturn,
502 >,
503 pub USBDeviceOpenSeize:
504 ::std::option::Option<unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void) -> IOReturn>,
505 pub DeviceRequestTO: ::std::option::Option<
506 unsafe extern "C" fn(
507 self_: *mut ::std::os::raw::c_void,
508 req: *mut IOUSBDevRequestTO,
509 ) -> IOReturn,
510 >,
511 pub DeviceRequestAsyncTO: ::std::option::Option<
512 unsafe extern "C" fn(
513 self_: *mut ::std::os::raw::c_void,
514 req: *mut IOUSBDevRequestTO,
515 callback: IOAsyncCallback1,
516 refCon: *mut ::std::os::raw::c_void,
517 ) -> IOReturn,
518 >,
519 pub USBDeviceSuspend: ::std::option::Option<
520 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, suspend: Boolean) -> IOReturn,
521 >,
522 pub USBDeviceAbortPipeZero:
523 ::std::option::Option<unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void) -> IOReturn>,
524 pub USBGetManufacturerStringIndex: ::std::option::Option<
525 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, msi: *mut UInt8) -> IOReturn,
526 >,
527 pub USBGetProductStringIndex: ::std::option::Option<
528 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, psi: *mut UInt8) -> IOReturn,
529 >,
530 pub USBGetSerialNumberStringIndex: ::std::option::Option<
531 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, snsi: *mut UInt8) -> IOReturn,
532 >,
533 pub USBDeviceReEnumerate: ::std::option::Option<
534 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, options: UInt32) -> IOReturn,
535 >,
536 pub GetBusMicroFrameNumber: ::std::option::Option<
537 unsafe extern "C" fn(
538 self_: *mut ::std::os::raw::c_void,
539 microFrame: *mut UInt64,
540 atTime: *mut AbsoluteTime,
541 ) -> IOReturn,
542 >,
543 pub GetIOUSBLibVersion: ::std::option::Option<
544 unsafe extern "C" fn(
545 self_: *mut ::std::os::raw::c_void,
546 ioUSBLibVersion: *mut NumVersion,
547 usbFamilyVersion: *mut NumVersion,
548 ) -> IOReturn,
549 >,
550 pub GetBusFrameNumberWithTime: ::std::option::Option<
551 unsafe extern "C" fn(
552 self_: *mut ::std::os::raw::c_void,
553 frame: *mut UInt64,
554 atTime: *mut AbsoluteTime,
555 ) -> IOReturn,
556 >,
557 pub GetUSBDeviceInformation: ::std::option::Option<
558 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, info: *mut UInt32) -> IOReturn,
559 >,
560 pub RequestExtraPower: ::std::option::Option<
561 unsafe extern "C" fn(
562 self_: *mut ::std::os::raw::c_void,
563 type_: UInt32,
564 requestedPower: UInt32,
565 powerAvailable: *mut UInt32,
566 ) -> IOReturn,
567 >,
568 pub ReturnExtraPower: ::std::option::Option<
569 unsafe extern "C" fn(
570 self_: *mut ::std::os::raw::c_void,
571 type_: UInt32,
572 powerReturned: UInt32,
573 ) -> IOReturn,
574 >,
575 pub GetExtraPowerAllocated: ::std::option::Option<
576 unsafe extern "C" fn(
577 self_: *mut ::std::os::raw::c_void,
578 type_: UInt32,
579 powerAllocated: *mut UInt32,
580 ) -> IOReturn,
581 >,
582 pub GetBandwidthAvailableForDevice: ::std::option::Option<
583 unsafe extern "C" fn(
584 self_: *mut ::std::os::raw::c_void,
585 bandwidth: *mut UInt32,
586 ) -> IOReturn,
587 >,
588 }
589 pub type IOUSBDeviceInterface500 = IOUSBDeviceStruct500;
590
591 // Tweak: these are just function pointers to thread-safe functions,
592 // so add send and sync to the C-type. (Calling these from multiple threads
593 // may cause odd behavior on the USB bus, though, so we'll still want to wrap the
594 // device in Mutex somewhere up from here.)
595 unsafe impl Send for IOUSBDeviceInterface500 {}
596 unsafe impl Sync for IOUSBDeviceInterface500 {}
597
598 #[repr(C)]
599 #[derive(Debug, Copy, Clone)]
600 pub struct IOUSBInterfaceStruct500 {
601 pub _reserved: *mut ::std::os::raw::c_void,
602 pub QueryInterface: ::std::option::Option<
603 unsafe extern "C" fn(
604 thisPointer: *mut ::std::os::raw::c_void,
605 iid: REFIID,
606 ppv: *mut LPVOID,
607 ) -> HRESULT,
608 >,
609 pub AddRef: ::std::option::Option<
610 unsafe extern "C" fn(thisPointer: *mut ::std::os::raw::c_void) -> ULONG,
611 >,
612 pub Release: ::std::option::Option<
613 unsafe extern "C" fn(thisPointer: *mut ::std::os::raw::c_void) -> ULONG,
614 >,
615 pub CreateInterfaceAsyncEventSource: ::std::option::Option<
616 unsafe extern "C" fn(
617 self_: *mut ::std::os::raw::c_void,
618 source: *mut CFRunLoopSourceRef,
619 ) -> IOReturn,
620 >,
621 pub GetInterfaceAsyncEventSource: ::std::option::Option<
622 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void) -> CFRunLoopSourceRef,
623 >,
624 pub CreateInterfaceAsyncPort: ::std::option::Option<
625 unsafe extern "C" fn(
626 self_: *mut ::std::os::raw::c_void,
627 port: *mut mach_port_t,
628 ) -> IOReturn,
629 >,
630 pub GetInterfaceAsyncPort: ::std::option::Option<
631 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void) -> mach_port_t,
632 >,
633 pub USBInterfaceOpen:
634 ::std::option::Option<unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void) -> IOReturn>,
635 pub USBInterfaceClose:
636 ::std::option::Option<unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void) -> IOReturn>,
637 pub GetInterfaceClass: ::std::option::Option<
638 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, intfClass: *mut UInt8) -> IOReturn,
639 >,
640 pub GetInterfaceSubClass: ::std::option::Option<
641 unsafe extern "C" fn(
642 self_: *mut ::std::os::raw::c_void,
643 intfSubClass: *mut UInt8,
644 ) -> IOReturn,
645 >,
646 pub GetInterfaceProtocol: ::std::option::Option<
647 unsafe extern "C" fn(
648 self_: *mut ::std::os::raw::c_void,
649 intfProtocol: *mut UInt8,
650 ) -> IOReturn,
651 >,
652 pub GetDeviceVendor: ::std::option::Option<
653 unsafe extern "C" fn(
654 self_: *mut ::std::os::raw::c_void,
655 devVendor: *mut UInt16,
656 ) -> IOReturn,
657 >,
658 pub GetDeviceProduct: ::std::option::Option<
659 unsafe extern "C" fn(
660 self_: *mut ::std::os::raw::c_void,
661 devProduct: *mut UInt16,
662 ) -> IOReturn,
663 >,
664 pub GetDeviceReleaseNumber: ::std::option::Option<
665 unsafe extern "C" fn(
666 self_: *mut ::std::os::raw::c_void,
667 devRelNum: *mut UInt16,
668 ) -> IOReturn,
669 >,
670 pub GetConfigurationValue: ::std::option::Option<
671 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, configVal: *mut UInt8) -> IOReturn,
672 >,
673 pub GetInterfaceNumber: ::std::option::Option<
674 unsafe extern "C" fn(
675 self_: *mut ::std::os::raw::c_void,
676 intfNumber: *mut UInt8,
677 ) -> IOReturn,
678 >,
679 pub GetAlternateSetting: ::std::option::Option<
680 unsafe extern "C" fn(
681 self_: *mut ::std::os::raw::c_void,
682 intfAltSetting: *mut UInt8,
683 ) -> IOReturn,
684 >,
685 pub GetNumEndpoints: ::std::option::Option<
686 unsafe extern "C" fn(
687 self_: *mut ::std::os::raw::c_void,
688 intfNumEndpoints: *mut UInt8,
689 ) -> IOReturn,
690 >,
691 pub GetLocationID: ::std::option::Option<
692 unsafe extern "C" fn(
693 self_: *mut ::std::os::raw::c_void,
694 locationID: *mut UInt32,
695 ) -> IOReturn,
696 >,
697 pub GetDevice: ::std::option::Option<
698 unsafe extern "C" fn(
699 self_: *mut ::std::os::raw::c_void,
700 device: *mut io_service_t,
701 ) -> IOReturn,
702 >,
703 pub SetAlternateInterface: ::std::option::Option<
704 unsafe extern "C" fn(
705 self_: *mut ::std::os::raw::c_void,
706 alternateSetting: UInt8,
707 ) -> IOReturn,
708 >,
709 pub GetBusFrameNumber: ::std::option::Option<
710 unsafe extern "C" fn(
711 self_: *mut ::std::os::raw::c_void,
712 frame: *mut UInt64,
713 atTime: *mut AbsoluteTime,
714 ) -> IOReturn,
715 >,
716 pub ControlRequest: ::std::option::Option<
717 unsafe extern "C" fn(
718 self_: *mut ::std::os::raw::c_void,
719 pipeRef: UInt8,
720 req: *mut IOUSBDevRequest,
721 ) -> IOReturn,
722 >,
723 pub ControlRequestAsync: ::std::option::Option<
724 unsafe extern "C" fn(
725 self_: *mut ::std::os::raw::c_void,
726 pipeRef: UInt8,
727 req: *mut IOUSBDevRequest,
728 callback: IOAsyncCallback1,
729 refCon: *mut ::std::os::raw::c_void,
730 ) -> IOReturn,
731 >,
732 pub GetPipeProperties: ::std::option::Option<
733 unsafe extern "C" fn(
734 self_: *mut ::std::os::raw::c_void,
735 pipeRef: UInt8,
736 direction: *mut UInt8,
737 number: *mut UInt8,
738 transferType: *mut UInt8,
739 maxPacketSize: *mut UInt16,
740 interval: *mut UInt8,
741 ) -> IOReturn,
742 >,
743 pub GetPipeStatus: ::std::option::Option<
744 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, pipeRef: UInt8) -> IOReturn,
745 >,
746 pub AbortPipe: ::std::option::Option<
747 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, pipeRef: UInt8) -> IOReturn,
748 >,
749 pub ResetPipe: ::std::option::Option<
750 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, pipeRef: UInt8) -> IOReturn,
751 >,
752 pub ClearPipeStall: ::std::option::Option<
753 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, pipeRef: UInt8) -> IOReturn,
754 >,
755 pub ReadPipe: ::std::option::Option<
756 unsafe extern "C" fn(
757 self_: *mut ::std::os::raw::c_void,
758 pipeRef: UInt8,
759 buf: *mut ::std::os::raw::c_void,
760 size: *mut UInt32,
761 ) -> IOReturn,
762 >,
763 pub WritePipe: ::std::option::Option<
764 unsafe extern "C" fn(
765 self_: *mut ::std::os::raw::c_void,
766 pipeRef: UInt8,
767 buf: *mut ::std::os::raw::c_void,
768 size: UInt32,
769 ) -> IOReturn,
770 >,
771 pub ReadPipeAsync: ::std::option::Option<
772 unsafe extern "C" fn(
773 self_: *mut ::std::os::raw::c_void,
774 pipeRef: UInt8,
775 buf: *mut ::std::os::raw::c_void,
776 size: UInt32,
777 callback: IOAsyncCallback1,
778 refcon: *mut ::std::os::raw::c_void,
779 ) -> IOReturn,
780 >,
781 pub WritePipeAsync: ::std::option::Option<
782 unsafe extern "C" fn(
783 self_: *mut ::std::os::raw::c_void,
784 pipeRef: UInt8,
785 buf: *mut ::std::os::raw::c_void,
786 size: UInt32,
787 callback: IOAsyncCallback1,
788 refcon: *mut ::std::os::raw::c_void,
789 ) -> IOReturn,
790 >,
791 pub ReadIsochPipeAsync: ::std::option::Option<
792 unsafe extern "C" fn(
793 self_: *mut ::std::os::raw::c_void,
794 pipeRef: UInt8,
795 buf: *mut ::std::os::raw::c_void,
796 frameStart: UInt64,
797 numFrames: UInt32,
798 frameList: *mut IOUSBIsocFrame,
799 callback: IOAsyncCallback1,
800 refcon: *mut ::std::os::raw::c_void,
801 ) -> IOReturn,
802 >,
803 pub WriteIsochPipeAsync: ::std::option::Option<
804 unsafe extern "C" fn(
805 self_: *mut ::std::os::raw::c_void,
806 pipeRef: UInt8,
807 buf: *mut ::std::os::raw::c_void,
808 frameStart: UInt64,
809 numFrames: UInt32,
810 frameList: *mut IOUSBIsocFrame,
811 callback: IOAsyncCallback1,
812 refcon: *mut ::std::os::raw::c_void,
813 ) -> IOReturn,
814 >,
815 pub ControlRequestTO: ::std::option::Option<
816 unsafe extern "C" fn(
817 self_: *mut ::std::os::raw::c_void,
818 pipeRef: UInt8,
819 req: *mut IOUSBDevRequestTO,
820 ) -> IOReturn,
821 >,
822 pub ControlRequestAsyncTO: ::std::option::Option<
823 unsafe extern "C" fn(
824 self_: *mut ::std::os::raw::c_void,
825 pipeRef: UInt8,
826 req: *mut IOUSBDevRequestTO,
827 callback: IOAsyncCallback1,
828 refCon: *mut ::std::os::raw::c_void,
829 ) -> IOReturn,
830 >,
831 pub ReadPipeTO: ::std::option::Option<
832 unsafe extern "C" fn(
833 self_: *mut ::std::os::raw::c_void,
834 pipeRef: UInt8,
835 buf: *mut ::std::os::raw::c_void,
836 size: *mut UInt32,
837 noDataTimeout: UInt32,
838 completionTimeout: UInt32,
839 ) -> IOReturn,
840 >,
841 pub WritePipeTO: ::std::option::Option<
842 unsafe extern "C" fn(
843 self_: *mut ::std::os::raw::c_void,
844 pipeRef: UInt8,
845 buf: *mut ::std::os::raw::c_void,
846 size: UInt32,
847 noDataTimeout: UInt32,
848 completionTimeout: UInt32,
849 ) -> IOReturn,
850 >,
851 pub ReadPipeAsyncTO: ::std::option::Option<
852 unsafe extern "C" fn(
853 self_: *mut ::std::os::raw::c_void,
854 pipeRef: UInt8,
855 buf: *mut ::std::os::raw::c_void,
856 size: UInt32,
857 noDataTimeout: UInt32,
858 completionTimeout: UInt32,
859 callback: IOAsyncCallback1,
860 refcon: *mut ::std::os::raw::c_void,
861 ) -> IOReturn,
862 >,
863 pub WritePipeAsyncTO: ::std::option::Option<
864 unsafe extern "C" fn(
865 self_: *mut ::std::os::raw::c_void,
866 pipeRef: UInt8,
867 buf: *mut ::std::os::raw::c_void,
868 size: UInt32,
869 noDataTimeout: UInt32,
870 completionTimeout: UInt32,
871 callback: IOAsyncCallback1,
872 refcon: *mut ::std::os::raw::c_void,
873 ) -> IOReturn,
874 >,
875 pub USBInterfaceGetStringIndex: ::std::option::Option<
876 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, si: *mut UInt8) -> IOReturn,
877 >,
878 pub USBInterfaceOpenSeize:
879 ::std::option::Option<unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void) -> IOReturn>,
880 pub ClearPipeStallBothEnds: ::std::option::Option<
881 unsafe extern "C" fn(self_: *mut ::std::os::raw::c_void, pipeRef: UInt8) -> IOReturn,
882 >,
883 pub SetPipePolicy: ::std::option::Option<
884 unsafe extern "C" fn(
885 self_: *mut ::std::os::raw::c_void,
886 pipeRef: UInt8,
887 maxPacketSize: UInt16,
888 maxInterval: UInt8,
889 ) -> IOReturn,
890 >,
891 pub GetBandwidthAvailable: ::std::option::Option<
892 unsafe extern "C" fn(
893 self_: *mut ::std::os::raw::c_void,
894 bandwidth: *mut UInt32,
895 ) -> IOReturn,
896 >,
897 pub GetEndpointProperties: ::std::option::Option<
898 unsafe extern "C" fn(
899 self_: *mut ::std::os::raw::c_void,
900 alternateSetting: UInt8,
901 endpointNumber: UInt8,
902 direction: UInt8,
903 transferType: *mut UInt8,
904 maxPacketSize: *mut UInt16,
905 interval: *mut UInt8,
906 ) -> IOReturn,
907 >,
908 pub LowLatencyReadIsochPipeAsync: ::std::option::Option<
909 unsafe extern "C" fn(
910 self_: *mut ::std::os::raw::c_void,
911 pipeRef: UInt8,
912 buf: *mut ::std::os::raw::c_void,
913 frameStart: UInt64,
914 numFrames: UInt32,
915 updateFrequency: UInt32,
916 frameList: *mut IOUSBLowLatencyIsocFrame,
917 callback: IOAsyncCallback1,
918 refcon: *mut ::std::os::raw::c_void,
919 ) -> IOReturn,
920 >,
921 pub LowLatencyWriteIsochPipeAsync: ::std::option::Option<
922 unsafe extern "C" fn(
923 self_: *mut ::std::os::raw::c_void,
924 pipeRef: UInt8,
925 buf: *mut ::std::os::raw::c_void,
926 frameStart: UInt64,
927 numFrames: UInt32,
928 updateFrequency: UInt32,
929 frameList: *mut IOUSBLowLatencyIsocFrame,
930 callback: IOAsyncCallback1,
931 refcon: *mut ::std::os::raw::c_void,
932 ) -> IOReturn,
933 >,
934 pub LowLatencyCreateBuffer: ::std::option::Option<
935 unsafe extern "C" fn(
936 self_: *mut ::std::os::raw::c_void,
937 buffer: *mut *mut ::std::os::raw::c_void,
938 size: IOByteCount,
939 bufferType: UInt32,
940 ) -> IOReturn,
941 >,
942 pub LowLatencyDestroyBuffer: ::std::option::Option<
943 unsafe extern "C" fn(
944 self_: *mut ::std::os::raw::c_void,
945 buffer: *mut ::std::os::raw::c_void,
946 ) -> IOReturn,
947 >,
948 pub GetBusMicroFrameNumber: ::std::option::Option<
949 unsafe extern "C" fn(
950 self_: *mut ::std::os::raw::c_void,
951 microFrame: *mut UInt64,
952 atTime: *mut AbsoluteTime,
953 ) -> IOReturn,
954 >,
955 pub GetFrameListTime: ::std::option::Option<
956 unsafe extern "C" fn(
957 self_: *mut ::std::os::raw::c_void,
958 microsecondsInFrame: *mut UInt32,
959 ) -> IOReturn,
960 >,
961 pub GetIOUSBLibVersion: ::std::option::Option<
962 unsafe extern "C" fn(
963 self_: *mut ::std::os::raw::c_void,
964 ioUSBLibVersion: *mut NumVersion,
965 usbFamilyVersion: *mut NumVersion,
966 ) -> IOReturn,
967 >,
968 pub FindNextAssociatedDescriptor: ::std::option::Option<
969 unsafe extern "C" fn(
970 self_: *mut ::std::os::raw::c_void,
971 currentDescriptor: *const ::std::os::raw::c_void,
972 descriptorType: UInt8,
973 ) -> *mut IOUSBDescriptorHeader,
974 >,
975 pub FindNextAltInterface: ::std::option::Option<
976 unsafe extern "C" fn(
977 self_: *mut ::std::os::raw::c_void,
978 current: *const ::std::os::raw::c_void,
979 request: *mut IOUSBFindInterfaceRequest,
980 ) -> *mut IOUSBDescriptorHeader,
981 >,
982 pub GetBusFrameNumberWithTime: ::std::option::Option<
983 unsafe extern "C" fn(
984 self_: *mut ::std::os::raw::c_void,
985 frame: *mut UInt64,
986 atTime: *mut AbsoluteTime,
987 ) -> IOReturn,
988 >,
989 pub GetPipePropertiesV2: ::std::option::Option<
990 unsafe extern "C" fn(
991 self_: *mut ::std::os::raw::c_void,
992 pipeRef: UInt8,
993 direction: *mut UInt8,
994 number: *mut UInt8,
995 transferType: *mut UInt8,
996 maxPacketSize: *mut UInt16,
997 interval: *mut UInt8,
998 maxBurst: *mut UInt8,
999 mult: *mut UInt8,
1000 bytesPerInterval: *mut UInt16,
1001 ) -> IOReturn,
1002 >,
1003 }
1004
1005 // Tweak: these are just function pointers to thread-safe functions,
1006 // so add send and sync to the C-type. (Calling these from multiple threads
1007 // may cause odd behavior on the USB bus, though, so we'll still want to wrap the
1008 // device in Mutex somewhere up from here.)
1009 unsafe impl Send for IOUSBInterfaceStruct500 {}
1010 unsafe impl Sync for IOUSBInterfaceStruct500 {}