-
Notifications
You must be signed in to change notification settings - Fork 651
/
USB.h
1516 lines (1352 loc) · 67.7 KB
/
USB.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright © 1998-2014 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _USB_H
#define _USB_H
#if KERNEL
#include <libkern/OSByteOrder.h>
#include <IOKit/IOMemoryDescriptor.h>
#ifndef __IOUSBFAMILY__
#warning "Deprecated header file. See IOUSBHostFamily for USB-Host KPI."
#endif
#else
#include <libkern/OSByteOrder.h>
#endif
#include <IOKit/IOTypes.h>
#if !defined(__USB__)
# include <IOKit/usb/USBSpec.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*!
@header USB.h
@abstract Public Interfaces to the USB implementation in Mac OS X.
@discussion This header file contains definitions and structures that are used in the different USB API's in Mac OS X, both in the kernel and in the user space.
*/
/*!
@defineblock Endian conversion definitions
@discussion The USB API's use a convention of specifying parameters in the host order. The USB spec specifies that multi-byte items should be
formatted in little endian order. The following macros allow one to translate multi-byte values from Host order to USB order and vice versa. There are separate macros for
in-kernel use and for user space use.
*/
#define USBToHostWord OSSwapLittleToHostInt16
#define HostToUSBWord OSSwapHostToLittleInt16
#define USBToHostLong OSSwapLittleToHostInt32
#define HostToUSBLong OSSwapHostToLittleInt32
/*! @/defineblock */
#ifndef USBBitRange
#define USBBitRange(start, end) \
( \
((((UInt32) 0xFFFFFFFF) << (31 - (end))) >> \
((31 - (end)) + (start))) << \
(start) \
)
#endif
#ifndef USBBitRangePhase
#define USBBitRangePhase(start, end) \
(start)
#endif
/*!
@enum Miscellaneous Constants
@discussion
*/
enum {
kUSBDeviceIDShift = 7,
kUSBMaxDevices = 128,
kUSBMaxDevice = kUSBMaxDevices-1,
kUSBDeviceIDMask = 0x7f,
kUSBTooManyDevicesAddress = 0xfffe,
kUSBPipeIDMask = 0xf,
kUSBMaxPipes = 32, // In and Out pipes can have same pipe number.
kUSBInterfaceIDShift = 8,
kUSBMaxInterfaces = 1 << kUSBInterfaceIDShift,
kUSBInterfaceIDMask = kUSBMaxInterfaces-1,
kUSBEndPtShift = 7,
kUSBDeviceMask = ((1 << kUSBEndPtShift) -1),
kUSBNoPipeIdx = -1,
#ifndef __OPEN_SOURCE__
// In order to ameliorate the effects of PCI Pause on drivers that do not subscribe to the USB Notifications for it, we have decided to sleep threads that come into the UIM
// while we are in PCI Pause. We will wake those threads up after the root hub drivers are back ON. However, we needed a way to detect that an I/O was coming from user space.
// One way to solve that would be to power manage the user client and do the sleep/wake there, but that was a big undertaking. Another way is for the user client to somehow
// let the UIM know through some APIs. We decided on a quick way by using bits that are part of the API to communicate that the request is coming from user space. For device
// requests we use the wLenDone field, a 32-bit quantity, but whose maximum value is only 16 bits. Same goes for the streamID of bulk requests. Those bits are set by the user
// client and cleared by the controller after checking them. If they are set and PCI Pause is active, we will sleep that request.
#endif
kUSBUCRequestWithoutUSBNotificationMask = (1 << 30),
kUSBEndpointTransferTypeUCMask = (1 << 7),
// Constants for streams
kUSBStream0 = 0,
kUSBMaxStream = 65533,
kUSBPRimeStream = 0xfffe,
kUSBNoStream = 0xffff,
kUSBAllStreams = 0xffffffff, // Obsolete, use kUSBStreamIDAllStreamsMask
kUSBStreamIDMask = 0xffff,
kUSBStreamIDAllStreamsMask = (1 << 31)
};
/*!
@enum bRequest Shifts and Masks
@discussion These are used to create the macro to encode the bRequest filed of a Device Request
*/
enum {
kUSBRqDirnShift = 7,
kUSBRqDirnMask = 1,
kUSBRqTypeShift = 5,
kUSBRqTypeMask = 3,
kUSBRqRecipientMask = 0X1F
};
/*!
@defined USBmakebmRequestType
@discussion Macro to encode the bRequest field of a Device Request. It is used when constructing an IOUSBDevRequest.
*/
#define USBmakebmRequestType(direction, type, recipient) \
(((direction & kUSBRqDirnMask) << kUSBRqDirnShift) | \
((type & kUSBRqTypeMask) << kUSBRqTypeShift) | \
(recipient & kUSBRqRecipientMask))
/*!
@enum kUSBMaxIsocFrameReqCount
@discussion Maximum size in bytes allowed for one Isochronous frame
*/
enum {
kUSBMaxFSIsocEndpointReqCount = 1023, // max size (bytes) of any one Isoc frame for 1 FS endpoint
kUSBMaxHSIsocEndpointReqCount = 3072, // max size (bytes) of any one Isoc frame for 1 HS endpoint
kUSBMaxHSIsocFrameCount = 7168 // max size (bytes) of all Isoc transfers in a HS frame
};
/*!
@defined EncodeRequest
@discussion Macro that encodes the bRequest and bRequestType fields of a IOUSBDevRequest into a single value. It is useful when one needs
to know what type of request the IOUSBDevRequest encodes and simplifies comparisons.
*/
#define EncodeRequest(request, direction, type, recipient) \
(((UInt16)request << 8) + \
((UInt16)recipient + \
((UInt16)type << kUSBRqTypeShift) + \
((UInt16)direction << kUSBRqDirnShift)))
/*!
@enum Standard Device Requests
@discussion Encoding of the standard device requests.
<tt>
<pre><b>
bmRequestType bRequest wValue wIndex wLength Data</b>
00000000B CLEAR_FEATURE Feature Zero Zero None (device)
00000001B Feature Interface Zero None (Interface)
00000010B Feature Endpoint Zero None (Endpoint)
10000000B GET_CONFIGURATION Zero Zero One Configuration
10000000B GET_DESCRIPTOR Type LangID Length Descriptor
10000001B GET_INTERFACE Zero Interface One Alternate
10000000B GET_STATUS Zero Zero Two status (device)
10000001B Zero Interface Two status (Interface)
10000010B Zero Endpoint Two status (Endpoint)
00000000B SET_ADDRESS Address Zero Zero None
00000000B SET_CONFIGURATION Configuration Zero Zero None
00000000B SET_DESCRIPTOR Type LangID Length Descriptor
00000000B SET_FEATURE Feature Zero Zero None (device)
00000001B Feature Interface Zero None (Interface)
00000010B Feature Endpoint Zero None (Endpoint)
00000001B SET_INTERFACE Alternate Interface Zero None
10000010B SYNCH_FRAME Zero Endpoint Two Frame Number
</pre>
</tt>
*/
enum {
kClearDeviceFeature = EncodeRequest(kUSBRqClearFeature, kUSBOut, kUSBStandard, kUSBDevice),
kClearInterfaceFeature = EncodeRequest(kUSBRqClearFeature, kUSBOut, kUSBStandard, kUSBInterface),
kClearEndpointFeature = EncodeRequest(kUSBRqClearFeature, kUSBOut, kUSBStandard, kUSBEndpoint),
kGetConfiguration = EncodeRequest(kUSBRqGetConfig, kUSBIn, kUSBStandard, kUSBDevice),
kGetDescriptor = EncodeRequest(kUSBRqGetDescriptor, kUSBIn, kUSBStandard, kUSBDevice),
kGetInterface = EncodeRequest(kUSBRqGetInterface, kUSBIn, kUSBStandard, kUSBInterface),
kGetDeviceStatus = EncodeRequest(kUSBRqGetStatus, kUSBIn, kUSBStandard, kUSBDevice),
kGetInterfaceStatus = EncodeRequest(kUSBRqGetStatus, kUSBIn, kUSBStandard, kUSBInterface),
kGetEndpointStatus = EncodeRequest(kUSBRqGetStatus, kUSBIn, kUSBStandard, kUSBEndpoint),
kSetAddress = EncodeRequest(kUSBRqSetAddress, kUSBOut, kUSBStandard, kUSBDevice),
kSetConfiguration = EncodeRequest(kUSBRqSetConfig, kUSBOut, kUSBStandard, kUSBDevice),
kSetDescriptor = EncodeRequest(kUSBRqSetDescriptor, kUSBOut, kUSBStandard, kUSBDevice),
kSetDeviceFeature = EncodeRequest(kUSBRqSetFeature, kUSBOut, kUSBStandard, kUSBDevice),
kSetInterfaceFeature = EncodeRequest(kUSBRqSetFeature, kUSBOut, kUSBStandard, kUSBInterface),
kSetEndpointFeature = EncodeRequest(kUSBRqSetFeature, kUSBOut, kUSBStandard, kUSBEndpoint),
kSetInterface = EncodeRequest(kUSBRqSetInterface, kUSBOut, kUSBStandard, kUSBInterface),
kSyncFrame = EncodeRequest(kUSBRqSyncFrame, kUSBIn, kUSBStandard, kUSBEndpoint),
};
/*!
@defined kCallInterfaceOpenWithGate
@discussion If the USB Device has this property, drivers for any of its interfaces will have their handleOpen method called while holding the workloop gate.
*/
#define kCallInterfaceOpenWithGate "kCallInterfaceOpenWithGate"
// TYPES
typedef UInt16 USBDeviceAddress;
typedef uint32_t USBPhysicalAddress32;
/*!
@typedef IOUSBIsocFrame
@discussion Structure used to encode information about each isoc frame.
@param frStatus Returns status associated with the frame.
@param frReqCount Input specifiying how many bytes to read or write.
@param frActCount Actual # of bytes transferred.
*/
typedef struct IOUSBIsocFrame {
IOReturn frStatus;
UInt16 frReqCount;
UInt16 frActCount;
} IOUSBIsocFrame;
/*!
@typedef IOUSBLowLatencyIsocFrame
@discussion Structure used to encode information about each isoc frame that is processed
at hardware interrupt time (low latency).
@param frStatus Returns status associated with the frame.
@param frReqCount Input specifiying how many bytes to read or write.
@param frActCount Actual # of bytes transferred.
@param frTimeStamp Time stamp that indicates time when frame was procesed.
*/
struct IOUSBLowLatencyIsocFrame {
IOReturn frStatus;
UInt16 frReqCount;
UInt16 frActCount;
AbsoluteTime frTimeStamp;
};
typedef struct IOUSBLowLatencyIsocFrame IOUSBLowLatencyIsocFrame;
/*!
@typedef IOUSBCompletionAction
@discussion Function called when USB I/O completes.
@param target The target specified in the IOUSBCompletion struct.
@param parameter The parameter specified in the IOUSBCompletion struct.
@param status Completion status.
@param bufferSizeRemaining Bytes left to be transferred.
*/
typedef void (*IOUSBCompletionAction)(
void * target,
void * parameter,
IOReturn status,
UInt32 bufferSizeRemaining);
/*!
@typedef IOUSBCompletionActionWithTimeStamp
@discussion Function called when USB I/O completes.
@param target The target specified in the IOUSBCompletion struct.
@param parameter The parameter specified in the IOUSBCompletion struct.
@param status Completion status.
@param bufferSizeRemaining Bytes left to be transferred.
@param timeStamp Time at which the transaction was processed.
*/
typedef void (*IOUSBCompletionActionWithTimeStamp)(
void * target,
void * parameter,
IOReturn status,
UInt32 bufferSizeRemaining,
AbsoluteTime timeStamp);
/*!
@typedef IOUSBIsocCompletionAction
@discussion Function called when Isochronous USB I/O completes.
@param target The target specified in the IOUSBIsocCompletionn struct.
@param parameter The parameter specified in the IOUSBIsocCompletion struct.
@param status Completion status.
@param pFrames Pointer to the frame list containing the status for each frame transferred.
*/
typedef void (*IOUSBIsocCompletionAction)(
void * target,
void * parameter,
IOReturn status,
IOUSBIsocFrame *pFrames);
/*!
@typedef IOUSBLowLatencyIsocCompletionAction
@discussion Function called when Low Latency Isochronous USB I/O completes.
@param target The target specified in the IOUSBLowLatencyIsocCompletion struct.
@param parameter The parameter specified in the IOUSBLowLatencyIsocCompletion struct.
@param status Completion status.
@param pFrames Pointer to the low latency frame list containing the status for each frame transferred.
*/
typedef void (*IOUSBLowLatencyIsocCompletionAction)(
void * target,
void * parameter,
IOReturn status,
IOUSBLowLatencyIsocFrame *pFrames);
/*!
@typedef IOUSBCompletion
@discussion Struct specifying action to perform when a USB I/O completes.
@param target The target to pass to the action function.
@param action The function to call.
@param parameter The parameter to pass to the action function.
*/
typedef struct IOUSBCompletion {
void * target;
IOUSBCompletionAction action;
void * parameter;
} IOUSBCompletion;
/*!
@typedef IOUSBCompletionWithTimeStamp
@discussion Struct specifying action to perform when a USB I/O completes.
@param target The target to pass to the action function.
@param action The function to call.
@param parameter The parameter to pass to the action function.
*/
typedef struct IOUSBCompletionWithTimeStamp {
void * target;
IOUSBCompletionActionWithTimeStamp action;
void * parameter;
} IOUSBCompletionWithTimeStamp;
/*!
@typedef IOUSBIsocCompletion
@discussion Struct specifying action to perform when an Isochronous USB I/O completes.
@param target The target to pass to the action function.
@param action The function to call.
@param parameter The parameter to pass to the action function.
*/
typedef struct IOUSBIsocCompletion {
void * target;
IOUSBIsocCompletionAction action;
void * parameter;
} IOUSBIsocCompletion;
/*!
@typedef IOUSBLowLatencyIsocCompletion
@discussion Struct specifying action to perform when an Low Latency Isochronous USB I/O completes.
@param target The target to pass to the action function.
@param action The function to call.
@param parameter The parameter to pass to the action function.
*/
typedef struct IOUSBLowLatencyIsocCompletion {
void * target;
IOUSBLowLatencyIsocCompletionAction action;
void * parameter;
} IOUSBLowLatencyIsocCompletion;
/*!
@defineblock IOUSBFamily error codes
@discussion Errors specific to the IOUSBFamily. Note that the iokit_usb_err(x) translates to 0xe0004xxx, where xxx is the value in parenthesis as a hex number.
*/
#define iokit_usb_err(return) (IOReturn)(sys_iokit|sub_iokit_usb|return)
#define kIOUSBUnknownPipeErr iokit_usb_err(0x61) // 0xe0004061 Pipe ref not recognized
#define kIOUSBTooManyPipesErr iokit_usb_err(0x60) // 0xe0004060 Too many pipes
#define kIOUSBNoAsyncPortErr iokit_usb_err(0x5f) // 0xe000405f no async port
#define kIOUSBNotEnoughPipesErr iokit_usb_err(0x5e) // 0xe000405e not enough pipes in interface
#define kIOUSBNotEnoughPowerErr iokit_usb_err(0x5d) // 0xe000405d not enough power for selected configuration
#define kIOUSBEndpointNotFound iokit_usb_err(0x57) // 0xe0004057 Endpoint Not found
#define kIOUSBConfigNotFound iokit_usb_err(0x56) // 0xe0004056 Configuration Not found
#define kIOUSBTransactionTimeout iokit_usb_err(0x51) // 0xe0004051 Transaction timed out
#define kIOUSBTransactionReturned iokit_usb_err(0x50) // 0xe0004050 The transaction has been returned to the caller
#define kIOUSBPipeStalled iokit_usb_err(0x4f) // 0xe000404f Pipe has stalled, error needs to be cleared
#define kIOUSBInterfaceNotFound iokit_usb_err(0x4e) // 0xe000404e Interface ref not recognized
#define kIOUSBLowLatencyBufferNotPreviouslyAllocated iokit_usb_err(0x4d) // 0xe000404d Attempted to use user land low latency isoc calls w/out calling PrepareBuffer (on the data buffer) first
#define kIOUSBLowLatencyFrameListNotPreviouslyAllocated iokit_usb_err(0x4c) // 0xe000404c Attempted to use user land low latency isoc calls w/out calling PrepareBuffer (on the frame list) first
#define kIOUSBHighSpeedSplitError iokit_usb_err(0x4b) // 0xe000404b Error to hub on high speed bus trying to do split transaction
#define kIOUSBSyncRequestOnWLThread iokit_usb_err(0x4a) // 0xe000404a A synchronous USB request was made on the workloop thread (from a callback?). Only async requests are permitted in that case
#define kIOUSBDeviceNotHighSpeed iokit_usb_err(0x49) // 0xe0004049 Name is deprecated, see below
#define kIOUSBDeviceTransferredToCompanion iokit_usb_err(0x49) // 0xe0004049 The device has been tranferred to another controller for enumeration
#define kIOUSBClearPipeStallNotRecursive iokit_usb_err(0x48) // 0xe0004048 IOUSBPipe::ClearPipeStall should not be called recursively
#define kIOUSBDevicePortWasNotSuspended iokit_usb_err(0x47) // 0xe0004047 Port was not suspended
#define kIOUSBEndpointCountExceeded iokit_usb_err(0x46) // 0xe0004046 The endpoint was not created because the controller cannot support more endpoints
#define kIOUSBDeviceCountExceeded iokit_usb_err(0x45) // 0xe0004045 The device cannot be enumerated because the controller cannot support more devices
#define kIOUSBStreamsNotSupported iokit_usb_err(0x44) // 0xe0004044 The request cannot be completed because the XHCI controller does not support streams
#define kIOUSBInvalidSSEndpoint iokit_usb_err(0x43) // 0xe0004043 An endpoint found in a SuperSpeed device is invalid (usually because there is no Endpoint Companion Descriptor)
#define kIOUSBTooManyTransactionsPending iokit_usb_err(0x42) // 0xe0004042 The transaction cannot be submitted because it would exceed the allowed number of pending transactions
/*!
@definedblock IOUSBFamily hardware error codes
@discussion These errors are returned by the OHCI controller. The # in parenthesis (xx) corresponds to the OHCI Completion Code.
For the following Completion codes, we return a generic IOKit error instead of a USB specific error.
<tt>
<pre>
Completion Code Error Returned Description
9 kIOReturnUnderrun (Data Underrun) EP returned less data than max packet size
8 kIOReturnOverrun (Data Overrun) Packet too large or more data than buffer
5 kIOReturnNotResponding Device Not responding
4 kIOUSBPipeStalled Endpoint returned a STALL PID
</pre>
</tt>
*/
#define kIOUSBLinkErr iokit_usb_err(0x10) // 0xe0004010
#define kIOUSBNotSent2Err iokit_usb_err(0x0f) // 0xe000400f Transaction not sent
#define kIOUSBNotSent1Err iokit_usb_err(0x0e) // 0xe000400e Transaction not sent
#define kIOUSBBufferUnderrunErr iokit_usb_err(0x0d) // 0xe000400d Buffer Underrun (Host hardware failure on data out, PCI busy?)
#define kIOUSBBufferOverrunErr iokit_usb_err(0x0c) // 0xe000400c Buffer Overrun (Host hardware failure on data out, PCI busy?)
#define kIOUSBReserved2Err iokit_usb_err(0x0b) // 0xe000400b Reserved
#define kIOUSBReserved1Err iokit_usb_err(0x0a) // 0xe000400a Reserved
#define kIOUSBWrongPIDErr iokit_usb_err(0x07) // 0xe0004007 Pipe stall, Bad or wrong PID
#define kIOUSBPIDCheckErr iokit_usb_err(0x06) // 0xe0004006 Pipe stall, PID CRC error
#define kIOUSBDataToggleErr iokit_usb_err(0x03) // 0xe0004003 Pipe stall, Bad data toggle
#define kIOUSBBitstufErr iokit_usb_err(0x02) // 0xe0004002 Pipe stall, bitstuffing
#define kIOUSBCRCErr iokit_usb_err(0x01) // 0xe0004001 Pipe stall, bad CRC
/*! @/definedblock */
/*!
@defineblock IOUSBFamily message codes
@discussion Messages specific to the IOUSBFamily. Note that the iokit_usb_msg(x) translates to 0xe0004xxx, where xxx is the value in parenthesis as a hex number.
*/
#define iokit_usb_msg(message) (UInt32)(sys_iokit|sub_iokit_usb|message)
#define kIOUSBMessageHubResetPort iokit_usb_msg(0x01) // 0xe0004001 Message sent to a hub to reset a particular port
#define kIOUSBMessageHubSuspendPort iokit_usb_msg(0x02) // 0xe0004002 Message sent to a hub to suspend a particular port
#define kIOUSBMessageHubResumePort iokit_usb_msg(0x03) // 0xe0004003 Message sent to a hub to resume a particular port
#define kIOUSBMessageHubIsDeviceConnected iokit_usb_msg(0x04) // 0xe0004004 Message sent to a hub to inquire whether a particular port has a device connected or not
#define kIOUSBMessageHubIsPortEnabled iokit_usb_msg(0x05) // 0xe0004005 Message sent to a hub to inquire whether a particular port is enabled or not
#define kIOUSBMessageHubReEnumeratePort iokit_usb_msg(0x06) // 0xe0004006 Message sent to a hub to reenumerate the device attached to a particular port
#define kIOUSBMessagePortHasBeenReset iokit_usb_msg(0x0a) // 0xe000400a Message sent to a device indicating that the port it is attached to has been reset
#define kIOUSBMessagePortHasBeenResumed iokit_usb_msg(0x0b) // 0xe000400b Message sent to a device indicating that the port it is attached to has been resumed
#define kIOUSBMessageHubPortClearTT iokit_usb_msg(0x0c) // 0xe000400c Message sent to a hub to clear the transaction translator
#define kIOUSBMessagePortHasBeenSuspended iokit_usb_msg(0x0d) // 0xe000400d Message sent to a device indicating that the port it is attached to has been suspended
#define kIOUSBMessageFromThirdParty iokit_usb_msg(0x0e) // 0xe000400e Message sent from a third party. Uses IOUSBThirdPartyParam to encode the sender's ID
#define kIOUSBMessagePortWasNotSuspended iokit_usb_msg(0x0f) // 0xe000400f Message indicating that the hub driver received a resume request for a port that was not suspended
#define kIOUSBMessageExpressCardCantWake iokit_usb_msg(0x10) // 0xe0004010 Message from a driver to a bus that an express card will disconnect on sleep and thus shouldn't wake
#define kIOUSBMessageCompositeDriverReconfigured iokit_usb_msg(0x11) // 0xe0004011 Message from the composite driver indicating that it has finished re-configuring the device after a reset
#define kIOUSBMessageHubSetPortRecoveryTime iokit_usb_msg(0x12) // 0xe0004012 Message sent to a hub to set the # of ms required when resuming a particular port
#define kIOUSBMessageOvercurrentCondition iokit_usb_msg(0x13) // 0xe0004013 Message sent to the clients of the device's hub parent, when a device causes an overcurrent condition. The message argument contains the locationID of the device
#define kIOUSBMessageNotEnoughPower iokit_usb_msg(0x14) // 0xe0004014 Message sent to the clients of the device's hub parent, when a device causes an low power notice to be displayed. The message argument contains the locationID of the device
#define kIOUSBMessageController iokit_usb_msg(0x15) // 0xe0004015 Generic message sent from controller user client to controllers
#define kIOUSBMessageRootHubWakeEvent iokit_usb_msg(0x16) // 0xe0004016 Message from the HC Wakeup code indicating that a Root Hub port has a wake event
#define kIOUSBMessageReleaseExtraCurrent iokit_usb_msg(0x17) // 0xe0004017 Message to ask any clients using extra current to release it if possible
#define kIOUSBMessageReallocateExtraCurrent iokit_usb_msg(0x18) // 0xe0004018 Message to ask any clients using extra current to attempt to allocate it some more
#define kIOUSBMessageEndpointCountExceeded iokit_usb_msg(0x19) // 0xe0004019 Message sent to a device when endpoints cannot be created because the USB controller ran out of resources
#define kIOUSBMessageDeviceCountExceeded iokit_usb_msg(0x1a) // 0xe000401a Message sent by a hub when a device cannot be enumerated because the USB controller ran out of resources
#define kIOUSBMessageHubPortDeviceDisconnected iokit_usb_msg(0x1b) // 0xe000401b Message sent by a built-in hub when a device was disconnected
#define kIOUSBMessageUnsupportedConfiguration iokit_usb_msg(0x1c) // 0xe000401c Message sent to the clients of the device when a device is not supported in the current configuration. The message argument contains the locationID of the device
#define kIOUSBMessageHubCountExceeded iokit_usb_msg(0x1d) // 0xe000401d Message sent when a 6th hub was plugged in and was not enumerated, as the USB spec only support 5 hubs in a chain
#define kIOUSBMessageTDMLowBattery iokit_usb_msg(0x1e) // 0xe000401e Message sent when when an attached TDM system battery is running low.
#define kIOUSBMessageLegacySuspendDevice iokit_usb_msg(0x1f) // 0xe000401f Message sent to legacy interfaces when SuspedDevice() is called .
#define kIOUSBMessageLegacyResetDevice iokit_usb_msg(0x20) // 0xe0004020 Message sent to legacy interfaces when ResetDevice() is called .
#define kIOUSBMessageLegacyReEnumerateDevice iokit_usb_msg(0x21) // 0xe0004021 Message sent to legacy interfaces when ReEnumerateDevice() is called .
#define kIOUSBMessageConfigurationSet iokit_usb_msg(0x22) // 0xe0004022 Message sent upon a SetConfiguration call
/*! @/defineblock */
// Obsolete
//
struct IOUSBMouseData {
UInt16 buttons;
SInt16 XDelta;
SInt16 YDelta;
};
typedef struct IOUSBMouseData IOUSBMouseData;
typedef IOUSBMouseData * IOUSBMouseDataPtr;
// Obsolete
//
struct IOUSBKeyboardData {
UInt16 keycount;
UInt16 usbkeycode[32];
};
typedef struct IOUSBKeyboardData IOUSBKeyboardData;
typedef IOUSBKeyboardData * IOUSBKeyboardDataPtr;
// Obsolete
//
union IOUSBHIDData {
IOUSBKeyboardData kbd;
IOUSBMouseData mouse;
};
typedef union IOUSBHIDData IOUSBHIDData;
typedef IOUSBHIDData * IOUSBHIDDataPtr;
/*!
@typedef IOUSBDeviceDescriptor
@discussion Descriptor for a USB Device. See the USB Specification at <a href="http://www.usb.org" target="_blank">http://www.usb.org</a>.
*/
struct IOUSBDeviceDescriptor {
UInt8 bLength;
UInt8 bDescriptorType;
UInt16 bcdUSB;
UInt8 bDeviceClass;
UInt8 bDeviceSubClass;
UInt8 bDeviceProtocol;
UInt8 bMaxPacketSize0;
UInt16 idVendor;
UInt16 idProduct;
UInt16 bcdDevice;
UInt8 iManufacturer;
UInt8 iProduct;
UInt8 iSerialNumber;
UInt8 bNumConfigurations;
};
typedef struct IOUSBDeviceDescriptor IOUSBDeviceDescriptor;
typedef IOUSBDeviceDescriptor * IOUSBDeviceDescriptorPtr;
/*!
@typedef IOUSBDescriptorHeader
@discussion Standard header used for all USB descriptors. Used to read the length of a descriptor so that we can allocate storage for the whole descriptor later on.
*/
struct IOUSBDescriptorHeader {
UInt8 bLength;
UInt8 bDescriptorType;
};
typedef struct IOUSBDescriptorHeader IOUSBDescriptorHeader;
typedef IOUSBDescriptorHeader * IOUSBDescriptorHeaderPtr;
#pragma pack(1)
/*!
@typedef IOUSBBOSDescriptor
@discussion BOS Descriptor for a USB Device. .
*/
struct IOUSBBOSDescriptor {
UInt8 bLength;
UInt8 bDescriptorType;
UInt16 wTotalLength;
UInt8 bNumDeviceCaps;
};
typedef struct IOUSBBOSDescriptor IOUSBBOSDescriptor;
typedef IOUSBBOSDescriptor * IOUSBBOSDescriptorPtr;
/*!
@typedef IOUSBDeviceCapabilityDescriptorHeader
@discussion Header for a Device Capability Descriptor for a USB Device. .
*/
struct IOUSBDeviceCapabilityDescriptorHeader {
UInt8 bLength;
UInt8 bDescriptorType;
UInt8 bDevCapabilityType;
UInt8 bNumDeviceCaps;
};
typedef struct IOUSBDeviceCapabilityDescriptorHeader IOUSBDeviceCapabilityDescriptorHeader;
typedef IOUSBDeviceCapabilityDescriptorHeader * IOUSBDeviceCapabilityDescriptorHeaderPtr;
/*!
@typedef IOUSBDeviceCapabilityUSB2Extension
@discussion Device Capability USB 2.0 Extension
*/
struct IOUSBDeviceCapabilityUSB2Extension {
UInt8 bLength;
UInt8 bDescriptorType;
UInt8 bDevCapabilityType;
UInt32 bmAttributes;
};
typedef struct IOUSBDeviceCapabilityUSB2Extension IOUSBDeviceCapabilityUSB2Extension;
typedef IOUSBDeviceCapabilityUSB2Extension * IOUSBDeviceCapabilityUSB2ExtensionPtr;
/*!
@typedef IOUSBDeviceCapabilitySuperSpeedUSB
@discussion Device Capability SuperSpeed USB
*/
struct IOUSBDeviceCapabilitySuperSpeedUSB {
UInt8 bLength;
UInt8 bDescriptorType;
UInt8 bDevCapabilityType;
UInt8 bmAttributes;
UInt16 wSpeedsSupported;
UInt8 bFunctionalitySupport;
UInt8 bU1DevExitLat;
UInt16 wU2DevExitLat;
};
typedef struct IOUSBDeviceCapabilitySuperSpeedUSB IOUSBDeviceCapabilitySuperSpeedUSB;
typedef IOUSBDeviceCapabilitySuperSpeedUSB * IOUSBDeviceCapabilitySuperSpeedUSBPtr;
/*!
@typedef IOUSBDeviceCapabilityContainerID
@discussion Device Capability Container ID
*/
struct IOUSBDeviceCapabilityContainerID {
UInt8 bLength;
UInt8 bDescriptorType;
UInt8 bDevCapabilityType;
UInt8 bReservedID;
UInt8 containerID[16];
};
typedef struct IOUSBDeviceCapabilityContainerID IOUSBDeviceCapabilityContainerID;
typedef IOUSBDeviceCapabilityContainerID * IOUSBDeviceCapabilityContainerIDPtr;
/*!
@typedef IOUSBDeviceCapabilityBillboardAltConfig
@discussion Device Capability Billboard Alternate Setting Info
*/
struct IOUSBDeviceCapabilityBillboardAltConfig {
UInt16 wSVID;
UInt8 bAltenateMode;
UInt8 iAlternateModeString;
};
typedef struct IOUSBDeviceCapabilityBillboardAltConfig IOUSBDeviceCapabilityBillboardAltConfig;
typedef IOUSBDeviceCapabilityBillboardAltConfig * IOUSBDeviceCapabilityBillboardAltConfigPtr;
/*!
@typedef IOUSBDeviceCapabilityBillboard
@discussion Device Capability Billboard
*/
struct IOUSBDeviceCapabilityBillboard {
UInt8 bLength;
UInt8 bDescriptorType;
UInt8 bDevCapabilityType;
UInt8 iAdditionalInfoURL;
UInt8 bNumberOfAlternateModes;
UInt8 bPreferredAlternateMode;
UInt16 vCONNPower;
UInt8 bmConfigured[32];
UInt16 bcdVersion;
UInt8 bAdditionalFailureInfo;
UInt8 bReserved;
IOUSBDeviceCapabilityBillboardAltConfig pAltConfigurations[];
};
typedef struct IOUSBDeviceCapabilityBillboard IOUSBDeviceCapabilityBillboard;
typedef IOUSBDeviceCapabilityBillboard * IOUSBDeviceCapabilityBillboardPtr;
/*!
@typedef IOUSBDeviceCapabilityBillboardAltMode
@discussion Device Capability Billboard Alternate mode
*/
struct IOUSBDeviceCapabilityBillboardAltMode
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDevCapabilityType;
uint8_t bIndex;
uint16_t dwAlternateModeVdo;
};
typedef struct IOUSBDeviceCapabilityBillboardAltMode IOUSBDeviceCapabilityBillboardAltMode;
typedef IOUSBDeviceCapabilityBillboardAltMode * IOUSBDeviceCapabilityBillboardAltModePtr;
#pragma options align=reset
/*!
@typedef IOUSBConfigurationDescriptor
@discussion Standard USB Configuration Descriptor. It is variable length, so this only specifies the known fields. We use the wTotalLength field to read the whole descriptor.
See the USB Specification at <a href="http://www.usb.org" target="_blank">http://www.usb.org</a>.
*/
struct IOUSBConfigurationDescriptor {
UInt8 bLength;
UInt8 bDescriptorType;
UInt16 wTotalLength;
UInt8 bNumInterfaces;
UInt8 bConfigurationValue;
UInt8 iConfiguration;
UInt8 bmAttributes;
UInt8 MaxPower;
};
typedef struct IOUSBConfigurationDescriptor IOUSBConfigurationDescriptor;
typedef IOUSBConfigurationDescriptor * IOUSBConfigurationDescriptorPtr;
/*!
@typedef IOUSBConfigurationDescHeader
@discussion Header of a IOUSBConfigurationDescriptor. Used to get the total length of the descriptor.
*/
struct IOUSBConfigurationDescHeader {
UInt8 bLength;
UInt8 bDescriptorType;
UInt16 wTotalLength;
};
typedef struct IOUSBConfigurationDescHeader IOUSBConfigurationDescHeader;
typedef IOUSBConfigurationDescHeader * IOUSBConfigurationDescHeaderPtr;
/*!
@typedef IOUSBInterfaceDescriptor
@discussion Descriptor for a USB Interface. See the USB Specification at <a href="http://www.usb.org" target="_blank">http://www.usb.org</a>.
*/
struct IOUSBInterfaceDescriptor {
UInt8 bLength;
UInt8 bDescriptorType;
UInt8 bInterfaceNumber;
UInt8 bAlternateSetting;
UInt8 bNumEndpoints;
UInt8 bInterfaceClass;
UInt8 bInterfaceSubClass;
UInt8 bInterfaceProtocol;
UInt8 iInterface;
};
typedef struct IOUSBInterfaceDescriptor IOUSBInterfaceDescriptor;
typedef IOUSBInterfaceDescriptor * IOUSBInterfaceDescriptorPtr;
/*!
@typedef IOUSBEndpointDescriptor
@discussion Descriptor for a USB Endpoint. See the USB Specification at <a href="http://www.usb.org" target="_blank">http://www.usb.org</a>.
*/
struct IOUSBEndpointDescriptor {
UInt8 bLength;
UInt8 bDescriptorType;
UInt8 bEndpointAddress;
UInt8 bmAttributes;
UInt16 wMaxPacketSize;
UInt8 bInterval;
};
typedef struct IOUSBEndpointDescriptor IOUSBEndpointDescriptor;
typedef IOUSBEndpointDescriptor * IOUSBEndpointDescriptorPtr;
enum {
kUSB_EPDesc_bmAttributes_TranType_Mask = USBBitRange(0,1),
kUSB_EPDesc_bmAttributes_TranType_Shift = USBBitRangePhase(0,1),
kUSB_EPDesc_bmAttributes_SyncType_Mask = USBBitRange(2, 3),
kUSB_EPDesc_bmAttributes_SyncType_Shift = USBBitRangePhase(2, 3),
kUSB_EPDesc_bmAttributes_UsageType_Mask = USBBitRange(4, 5),
kUSB_EPDesc_bmAttributes_UsageType_Shift = USBBitRangePhase(4, 5),
kUSB_EPDesc_wMaxPacketSize_MPS_Mask = USBBitRange(0, 10),
kUSB_EPDesc_wMaxPacketSize_MPS_Shift = USBBitRangePhase(0, 10),
kUSB_EPDesc_MaxMPS = 1024, // this is the maximum no matter what
kUSB_HSFSEPDesc_wMaxPacketSize_Mult_Mask = USBBitRange(11, 12),
kUSB_HSFSEPDesc_wMaxPacketSize_Mult_Shift = USBBitRangePhase(11, 12)
};
#pragma pack(1)
/*!
@typedef IOUSBSuperSpeedEndpointCompanionDescriptor
@discussion Descriptor for a SuperSpeed USB Endpoint Companion. See the USB Specification at <a href="http://www.usb.org"TARGET="_blank">http://www.usb.org</a>.
*/
struct IOUSBSuperSpeedEndpointCompanionDescriptor {
UInt8 bLength;
UInt8 bDescriptorType;
UInt8 bMaxBurst;
UInt8 bmAttributes;
UInt16 wBytesPerInterval;
};
typedef struct IOUSBSuperSpeedEndpointCompanionDescriptor IOUSBSuperSpeedEndpointCompanionDescriptor;
typedef IOUSBSuperSpeedEndpointCompanionDescriptor * IOUSBSuperSpeedEndpointCompanionDescriptorPtr;
enum {
kUSB_SSCompDesc_Bulk_MaxStreams_Mask = USBBitRange(0, 4),
kUSB_SSCompDesc_Bulk_MaxStreams_Shift = USBBitRangePhase(0, 4),
kUSB_SSCompDesc_Isoc_Mult_Mask = USBBitRange(0, 1),
kUSB_SSCompDesc_Isoc_Mult_Shift = USBBitRangePhase(0, 1)
};
#ifndef __OPEN_SOURCE__
// Leave this here because it has existed for many years, but it never really belonged here in the first place
#endif
// these following 2 lines are deprecated and should not be used.
enum{addPacketShift = 11}; // Bits for additional packets in maxPacketField. (Table 9-13)
#define mungeMaxPacketSize(w) ((w>1024)?(((w>>(addPacketShift))+1)*(w&((1<<addPacketShift)-1))):w)
/*!
@typedef IOUSBEndpointProperties
@discussion Structure used with the IOUSBLib GetEndpointPropertiesV3 and GetPipePropertiesV3 API. Most of the fields are taken directly from corresponding Standard Endpoint Descriptor and SuperSpeed Endpoint Companion Descriptor. wBytesPerInterval will be synthesized for High Speed High Bandwidth Isochronous endpoints.
@field bVersion Version of the structure. Currently kUSBEndpointPropertiesVersion3. Need to set this when using this structure
@field bAlternateSetting Used as an input for GetEndpointPropertiesV3. Used as an output for GetPipePropertiesV3
@field bDirection Used as an input for GetEndpointPropertiesV3. Used as an output for GetPipePropertiesV3. One of kUSBIn or kUSBOut.
@field bEndpointNumber Used as an input for GetEndpointPropertiesV3. Used as an output for GetPipePropertiesV3
@field bTransferType One of kUSBControl, kUSBBulk, kUSBIsoc, or kUSBInterrupt
@field bUsageType For interrupt and isoc endpoints, the usage type. For Bulk endpoints of the UAS Mass Storage Protocol, the pipe ID.
@field bSyncType For isoc endpoints only
@field bInterval The bInterval field from the Standard Endpoint descriptor.
@field wMaxPacketSize The meaning of this value depends on whether this is called with GetPipePropertiesV3 or GetEndpointPropertiesV3. See the documentation of those calls for more info.
@field bMaxBurst For SuperSpeed endpoints, maximum number of packets the endpoint can send or receive as part of a burst
@field bMaxStreams For SuperSpeed bulk endpoints, maximum number of streams this endpoint supports.
@field bMult For SuperSpeed isoc endpoints, this is the mult value from the SuperSpeed Endpoint Companion Descriptor. For High Speed isoc and interrupt endpoints, this is bits 11 and 12 of the Standard Endpoint Descriptor, which represents a similar value.
@field wBytesPerInterval For SuperSpeed interrupt and isoc endpoints, this is the wBytesPerInterval from the SuperSpeed Endpoint Companion Descriptor. For High Speed High Bandwidth isoc endpoints, this will be equal to wMaxPacketSize * (bMult+1).
*/
struct IOUSBEndpointProperties {
UInt8 bVersion;
UInt8 bAlternateSetting;
UInt8 bDirection;
UInt8 bEndpointNumber;
UInt8 bTransferType;
UInt8 bUsageType;
UInt8 bSyncType;
UInt8 bInterval;
UInt16 wMaxPacketSize;
UInt8 bMaxBurst;
UInt8 bMaxStreams;
UInt8 bMult;
UInt16 wBytesPerInterval;
};
typedef struct IOUSBEndpointProperties IOUSBEndpointProperties;
typedef IOUSBEndpointProperties * IOUSBEndpointPropertiesPtr;
/*!
@enum USBGetEndpointVersion
@discussion Version of the IOUSBEndpointProperties structure.
@constant kUSBEndpointPropertiesVersion3 Version that has support for USB3 SuperSpeed Endpoint Companion fields.
*/
enum {
kUSBEndpointPropertiesVersion3 = 0x03
};
/*!
@typedef UASPipeDescriptor
@discussion Structure used to specify the Mass Storage Specific UAS pipe usage descriptor
*/
struct UASPipeDescriptor {
UInt8 bLength;
UInt8 bDescriptorType;
UInt8 bPipeID;
UInt8 bReserved;
};
typedef struct UASPipeDescriptor UASPipeDescriptor;
typedef UASPipeDescriptor * UASPipeDescriptorPtr;
#pragma options align=reset
/*!
@typedef IOUSBHIDDescriptor
@discussion USB HID Descriptor. See the USB HID Specification at <a href="http://www.usb.org" target="_blank">http://www.usb.org</a>. (This structure
should have used the #pragma pack(1) compiler directive to get byte alignment.
*/
struct IOUSBHIDDescriptor {
UInt8 descLen;
UInt8 descType;
UInt16 descVersNum;
UInt8 hidCountryCode;
UInt8 hidNumDescriptors;
UInt8 hidDescriptorType;
UInt8 hidDescriptorLengthLo;
UInt8 hidDescriptorLengthHi;
};
typedef struct IOUSBHIDDescriptor IOUSBHIDDescriptor;
typedef IOUSBHIDDescriptor *IOUSBHIDDescriptorPtr;
/*!
@typedef IOUSBHIDReportDesc
@discussion USB HID Report Descriptor header. See the USB HID Specification at <a href="http://www.usb.org" target="_blank">http://www.usb.org</a>. (This structure
should have used the #pragma pack(1) compiler directive to get byte alignment.
*/
struct IOUSBHIDReportDesc {
UInt8 hidDescriptorType;
UInt8 hidDescriptorLengthLo;
UInt8 hidDescriptorLengthHi;
};
typedef struct IOUSBHIDReportDesc IOUSBHIDReportDesc;
typedef IOUSBHIDReportDesc * IOUSBHIDReportDescPtr;
/*!
@typedef IOUSBDeviceQualifierDescriptor
@discussion USB Device Qualifier Descriptor. See the USB Specification at <a href="http://www.usb.org" target="_blank">http://www.usb.org</a>.
*/
#pragma pack(1)
struct IOUSBDeviceQualifierDescriptor
{
UInt8 bLength;
UInt8 bDescriptorType;
UInt16 bcdUSB;
UInt8 bDeviceClass;
UInt8 bDeviceSubClass;
UInt8 bDeviceProtocol;
UInt8 bMaxPacketSize0;
UInt8 bNumConfigurations;
UInt8 bReserved;
};
typedef struct IOUSBDeviceQualifierDescriptor IOUSBDeviceQualifierDescriptor;
typedef IOUSBDeviceQualifierDescriptor * IOUSBDeviceQualifierDescriptorPtr;
#pragma options align=reset
/*!
@typedef IOUSBDFUDescriptor
@discussion USB Device Firmware Update Descriptor. See the USB Device Firmware Update Specification at <a href="http://www.usb.org" target="_blank">http://www.usb.org</a>.
*/
#pragma pack(1)
struct IOUSBDFUDescriptor
{
UInt8 bLength;
UInt8 bDescriptorType;
UInt8 bmAttributes;
UInt16 wDetachTimeout;
UInt16 wTransferSize;
};
typedef struct IOUSBDFUDescriptor IOUSBDFUDescriptor;
typedef IOUSBDFUDescriptor * IOUSBDFUDescriptorPtr;
#pragma options align=reset
/*!
@typedef IOUSBInterfaceAssociationDescriptor
@discussion USB Inerface Association Descriptor. ECN to the USB 2.0 Spec. See the USB Specification at <a href="http://www.usb.org" target="_blank">http://www.usb.org</a>.
*/
#pragma pack(1)
struct IOUSBInterfaceAssociationDescriptor
{
UInt8 bLength;
UInt8 bDescriptorType;
UInt8 bFirstInterface;
UInt8 bInterfaceCount;
UInt8 bFunctionClass;
UInt8 bFunctionSubClass;
UInt8 bFunctionProtocol;
UInt8 iFunction;
};
typedef struct IOUSBInterfaceAssociationDescriptor IOUSBInterfaceAssociationDescriptor;
typedef IOUSBInterfaceAssociationDescriptor * IOUSBInterfaceAssociationDescriptorPtr;
#pragma options align=reset
/*!
@typedef USBStatus
@discussion Type used to get a DeviceStatus as a single quantity.
*/
typedef UInt16 USBStatus;
typedef USBStatus * USBStatusPtr;
// These constants are obsolete
//
enum {
kIOUSBAnyClass = 0xFFFF,
kIOUSBAnySubClass = 0xFFFF,
kIOUSBAnyProtocol = 0xFFFF,
kIOUSBAnyVendor = 0xFFFF,
kIOUSBAnyProduct = 0xFFFF
};
// This structure are obsolete
//
typedef struct IOUSBMatch {
UInt16 usbClass;
UInt16 usbSubClass;
UInt16 usbProtocol;
UInt16 usbVendor;
UInt16 usbProduct;
} IOUSBMatch;
/*!
@typedef IOUSBFindEndpointRequest
@discussion Struct used to find endpoints of an interface
type and direction are used to match endpoints,
type, direction, maxPacketSize and interval are updated
with the properties of the found endpoint.
@field type Type of endpoint: kUSBControl, kUSBIsoc, kUSBBulk, kUSBInterrupt, kUSBAnyType. If kUSBAnyType is specified, this field is treated as a don't care.
@field direction Direction of endpoint: kUSBOut, kUSBIn, kUSBAnyDirn. If kUSBAnyDirn is specified, this field is treated as a don't care.
@field maxPacketSize maximum packet size of endpoint.
@field interval Polling interval in mSec for endpoint.
*/
typedef struct {
UInt8 type;
UInt8 direction;
UInt16 maxPacketSize;
UInt8 interval;
} IOUSBFindEndpointRequest;
/*!
@struct IOUSBDevRequest
@discussion Parameter block for control requests, using a simple pointer
for the data to be transferred.
@field bmRequestType Request type: kUSBStandard, kUSBClass or kUSBVendor
@field bRequest Request code
@field wValue 16 bit parameter for request, host endianess
@field wIndex 16 bit parameter for request, host endianess
@field wLength Length of data part of request, 16 bits, host endianess
@field pData Pointer to data for request - data returned in bus endianess
@field wLenDone Set by standard completion routine to number of data bytes
actually transferred
*/
typedef struct {
UInt8 bmRequestType;
UInt8 bRequest;
UInt16 wValue;
UInt16 wIndex;
UInt16 wLength;
void * pData;
UInt32 wLenDone;
} IOUSBDevRequest;
typedef IOUSBDevRequest * IOUSBDeviceRequestPtr;
/*!
@struct IOUSBDevRequestTO
@discussion Parameter block for control requests with timeouts, using a simple pointer
for the data to be transferred. Same as a IOUSBDevRequest except for the two extra timeout fields.