Root/
Source at commit 2741 created 8 years 11 months ago. By ifabio, Add data for new logo and clut (grey) from macosxbootloader (Credits to Pike R. Alpha) | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
6 | * This file contains Original Code and/or Modifications of Original Code␊ |
7 | * as defined in and that are subject to the Apple Public Source License␊ |
8 | * Version 2.0 (the 'License'). You may not use this file except in␊ |
9 | * compliance with the License. Please obtain a copy of the License at␊ |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this␊ |
11 | * file.␊ |
12 | * ␊ |
13 | * The Original Code and all software distributed under the License are␊ |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.␊ |
18 | * Please see the License for the specific language governing rights and␊ |
19 | * limitations under the License.␊ |
20 | * ␊ |
21 | * @APPLE_LICENSE_HEADER_END@␊ |
22 | */␊ |
23 | ␊ |
24 | #ifndef _USB_H␊ |
25 | #define _USB_H␊ |
26 | ␊ |
27 | #if KERNEL␊ |
28 | ␉#include <libkern/OSByteOrder.h>␊ |
29 | ␉#include <IOKit/IOMemoryDescriptor.h>␊ |
30 | #else␊ |
31 | ␉#include <libkern/OSByteOrder.h>␊ |
32 | #endif␊ |
33 | ␊ |
34 | #include <IOKit/IOTypes.h>␊ |
35 | ␊ |
36 | #if !defined(__USB__)␊ |
37 | # include <IOKit/usb/USBSpec.h>␊ |
38 | #endif␊ |
39 | ␊ |
40 | #ifdef __cplusplus␊ |
41 | extern "C" {␊ |
42 | #endif␊ |
43 | ␊ |
44 | /*!␊ |
45 | @header␉␉USB.h␊ |
46 | @abstract␉Public Interfaces to the USB implementation in Mac OS X.␊ |
47 | @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.␊ |
48 | */␊ |
49 | ␊ |
50 | /*!␊ |
51 | @defined␉Endian conversion definitions␊ |
52 | @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␊ |
53 | 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␊ |
54 | in-kernel use and for user space use.␊ |
55 | */␊ |
56 | #define USBToHostWord OSSwapLittleToHostInt16␊ |
57 | #define HostToUSBWord OSSwapHostToLittleInt16␊ |
58 | #define USBToHostLong OSSwapLittleToHostInt32␊ |
59 | #define HostToUSBLong OSSwapHostToLittleInt32␊ |
60 | ␊ |
61 | /*!␊ |
62 | @enum Miscellaneous Constants␊ |
63 | @discussion ␊ |
64 | */␊ |
65 | enum {␊ |
66 | kUSBDeviceIDShift = 7,␊ |
67 | kUSBMaxDevices = 128,␊ |
68 | kUSBMaxDevice = kUSBMaxDevices-1,␊ |
69 | kUSBDeviceIDMask = 0x7f,␊ |
70 | ␊ |
71 | kUSBPipeIDMask = 0xf,␊ |
72 | kUSBMaxPipes = 32,␉// In and Out pipes can have same pipe number.␊ |
73 | ␊ |
74 | kUSBInterfaceIDShift = 8,␊ |
75 | kUSBMaxInterfaces = 1 << kUSBInterfaceIDShift,␊ |
76 | kUSBInterfaceIDMask = kUSBMaxInterfaces-1,␊ |
77 | ␊ |
78 | kUSBEndPtShift = 7,␊ |
79 | kUSBDeviceMask = ((1 << kUSBEndPtShift) -1),␊ |
80 | ␊ |
81 | kUSBNoPipeIdx = -1␊ |
82 | };␊ |
83 | ␊ |
84 | /*!␊ |
85 | @enum bRequest Shifts and Masks ␊ |
86 | @discussion These are used to create the macro to encode the bRequest filed of a Device Request␊ |
87 | */␊ |
88 | enum {␊ |
89 | kUSBRqDirnShift = 7,␊ |
90 | kUSBRqDirnMask = 1,␊ |
91 | ␊ |
92 | kUSBRqTypeShift = 5,␊ |
93 | kUSBRqTypeMask = 3,␊ |
94 | ␊ |
95 | kUSBRqRecipientMask = 0X1F␊ |
96 | };␊ |
97 | ␊ |
98 | /*!␊ |
99 | @defined USBmakebmRequestType ␊ |
100 | @discussion Macro to encode the bRequest field of a Device Request. It is used when constructing an IOUSBDevRequest.␊ |
101 | */␊ |
102 | #define USBmakebmRequestType(direction, type, recipient)␉␉\␊ |
103 | ((direction & kUSBRqDirnMask) << kUSBRqDirnShift) |␉␉␉\␊ |
104 | ((type & kUSBRqTypeMask) << kUSBRqTypeShift) |␉␉␉\␊ |
105 | (recipient & kUSBRqRecipientMask)␊ |
106 | ␊ |
107 | /*!␊ |
108 | @enum kUSBMaxIsocFrameReqCount ␊ |
109 | @discussion Maximum size in bytes allowed for one Isochronous frame␊ |
110 | */␊ |
111 | enum {␊ |
112 | kUSBMaxFSIsocEndpointReqCount = 1023,␉// max size (bytes) of any one Isoc frame for 1 FS endpoint␊ |
113 | ␉kUSBMaxHSIsocEndpointReqCount = 3072,␉// max size (bytes) of any one Isoc frame for 1 HS endpoint␊ |
114 | ␉kUSBMaxHSIsocFrameCount = 7168␉␉␉// max size (bytes) of all Isoc transfers in a HS frame␊ |
115 | };␊ |
116 | ␊ |
117 | /*!␊ |
118 | @defined EncodeRequest ␊ |
119 | @discussion Macro that encodes the bRequest and bRequestType fields of a IOUSBDevRequest into a single value. It is useful when one needs␊ |
120 | to know what type of request the IOUSBDevRequest encodes and simplifies comparisons.␊ |
121 | */␊ |
122 | #define EncodeRequest(request, direction, type, recipient)␉␉\␊ |
123 | (((UInt16)request << 8) +␉ ␉␉␉␉␉\␊ |
124 | ((UInt16)recipient +␉␉␉␉␉\␊ |
125 | ((UInt16)type << kUSBRqTypeShift) +␉␉\␊ |
126 | ((UInt16)direction << kUSBRqDirnShift)))␊ |
127 | ␊ |
128 | ␊ |
129 | /*!␊ |
130 | @enum Standard Device Requests␊ |
131 | @discussion Encoding of the standard device requests.␊ |
132 | <tt>␊ |
133 | <pre><b>␊ |
134 | bmRequestType bRequest wValue wIndex wLength Data</b>␊ |
135 | 00000000B CLEAR_FEATURE Feature Zero Zero None (device)␊ |
136 | 00000001B Feature Interface Zero None (Interface)␊ |
137 | 00000010B Feature Endpoint Zero None (Endpoint)␊ |
138 | ␊ |
139 | 10000000B GET_CONFIGURATION Zero Zero One Configuration␊ |
140 | 10000000B GET_DESCRIPTOR Type LangID Length Descriptor␊ |
141 | 10000001B GET_INTERFACE Zero Interface One Alternate␊ |
142 | ␊ |
143 | 10000000B GET_STATUS Zero Zero Two status (device)␊ |
144 | 10000001B Zero Interface Two status (Interface)␊ |
145 | 10000010B Zero Endpoint Two status (Endpoint)␊ |
146 | ␊ |
147 | 00000000B SET_ADDRESS Address Zero Zero None␊ |
148 | 00000000B SET_CONFIGURATION Configuration Zero Zero None␊ |
149 | 00000000B SET_DESCRIPTOR Type LangID Length Descriptor␊ |
150 | ␊ |
151 | 00000000B SET_FEATURE Feature Zero Zero None (device)␊ |
152 | 00000001B Feature Interface Zero None (Interface)␊ |
153 | 00000010B Feature Endpoint Zero None (Endpoint)␊ |
154 | ␊ |
155 | 00000001B SET_INTERFACE Alternate Interface Zero None␊ |
156 | 10000010B SYNCH_FRAME Zero Endpoint Two Frame Number␊ |
157 | </pre>␊ |
158 | </tt>␊ |
159 | */␊ |
160 | enum {␊ |
161 | kClearDeviceFeature = EncodeRequest(kUSBRqClearFeature, kUSBOut, kUSBStandard, kUSBDevice),␊ |
162 | kClearInterfaceFeature = EncodeRequest(kUSBRqClearFeature, kUSBOut, kUSBStandard, kUSBInterface),␊ |
163 | kClearEndpointFeature = EncodeRequest(kUSBRqClearFeature, kUSBOut, kUSBStandard, kUSBEndpoint),␊ |
164 | kGetConfiguration = EncodeRequest(kUSBRqGetConfig, kUSBIn, kUSBStandard, kUSBDevice),␊ |
165 | kGetDescriptor = EncodeRequest(kUSBRqGetDescriptor, kUSBIn, kUSBStandard, kUSBDevice),␊ |
166 | kGetInterface = EncodeRequest(kUSBRqGetInterface, kUSBIn, kUSBStandard, kUSBInterface),␊ |
167 | kGetDeviceStatus = EncodeRequest(kUSBRqGetStatus, kUSBIn, kUSBStandard, kUSBDevice),␊ |
168 | kGetInterfaceStatus = EncodeRequest(kUSBRqGetStatus, kUSBIn, kUSBStandard, kUSBInterface),␊ |
169 | kGetEndpointStatus = EncodeRequest(kUSBRqGetStatus, kUSBIn, kUSBStandard, kUSBEndpoint),␊ |
170 | kSetAddress = EncodeRequest(kUSBRqSetAddress, kUSBOut, kUSBStandard, kUSBDevice),␊ |
171 | kSetConfiguration = EncodeRequest(kUSBRqSetConfig, kUSBOut, kUSBStandard, kUSBDevice),␊ |
172 | kSetDescriptor = EncodeRequest(kUSBRqSetDescriptor, kUSBOut, kUSBStandard, kUSBDevice),␊ |
173 | kSetDeviceFeature = EncodeRequest(kUSBRqSetFeature, kUSBOut, kUSBStandard, kUSBDevice),␊ |
174 | kSetInterfaceFeature = EncodeRequest(kUSBRqSetFeature, kUSBOut, kUSBStandard, kUSBInterface),␊ |
175 | kSetEndpointFeature = EncodeRequest(kUSBRqSetFeature, kUSBOut, kUSBStandard, kUSBEndpoint),␊ |
176 | kSetInterface = EncodeRequest(kUSBRqSetInterface, kUSBOut, kUSBStandard, kUSBInterface),␊ |
177 | kSyncFrame = EncodeRequest(kUSBRqSyncFrame, kUSBIn, kUSBStandard, kUSBEndpoint),␊ |
178 | };␊ |
179 | ␊ |
180 | /*!␊ |
181 | @defined kCallInterfaceOpenWithGate␊ |
182 | @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.␊ |
183 | */␊ |
184 | #define kCallInterfaceOpenWithGate␉"kCallInterfaceOpenWithGate"␊ |
185 | ␊ |
186 | // TYPES␊ |
187 | ␊ |
188 | typedef UInt16 USBDeviceAddress;␊ |
189 | ␊ |
190 | typedef uint32_t USBPhysicalAddress32;␊ |
191 | ␊ |
192 | /*!␊ |
193 | @typedef IOUSBIsocFrame␊ |
194 | @discussion Structure used to encode information about each isoc frame.␊ |
195 | @param frStatus Returns status associated with the frame.␊ |
196 | @param frReqCount Input specifiying how many bytes to read or write.␊ |
197 | @param frActCount Actual # of bytes transferred.␊ |
198 | */␊ |
199 | typedef struct IOUSBIsocFrame {␊ |
200 | IOReturn frStatus;␊ |
201 | UInt16 frReqCount;␊ |
202 | UInt16 frActCount;␊ |
203 | } IOUSBIsocFrame;␊ |
204 | ␊ |
205 | ␊ |
206 | /*!␊ |
207 | @typedef IOUSBLowLatencyIsocFrame␊ |
208 | @discussion Structure used to encode information about each isoc frame that is processed␊ |
209 | at hardware interrupt time (low latency).␊ |
210 | @param frStatus Returns status associated with the frame.␊ |
211 | @param frReqCount Input specifiying how many bytes to read or write.␊ |
212 | @param frActCount Actual # of bytes transferred.␊ |
213 | @param frTimeStamp Time stamp that indicates time when frame was procesed.␊ |
214 | */␊ |
215 | struct IOUSBLowLatencyIsocFrame {␊ |
216 | IOReturn frStatus;␊ |
217 | UInt16 frReqCount;␊ |
218 | UInt16 frActCount;␊ |
219 | AbsoluteTime␉␉ frTimeStamp;␊ |
220 | };␊ |
221 | typedef struct IOUSBLowLatencyIsocFrame IOUSBLowLatencyIsocFrame;␊ |
222 | ␊ |
223 | /*!␊ |
224 | @typedef IOUSBCompletionAction␊ |
225 | @discussion Function called when USB I/O completes.␊ |
226 | @param target The target specified in the IOUSBCompletion struct.␊ |
227 | @param parameter The parameter specified in the IOUSBCompletion struct.␊ |
228 | @param status Completion status.␊ |
229 | @param bufferSizeRemaining Bytes left to be transferred.␊ |
230 | */␊ |
231 | typedef void (*IOUSBCompletionAction)(␊ |
232 | void *␉␉␉target,␊ |
233 | void *␉␉␉parameter,␊ |
234 | IOReturn␉␉status,␊ |
235 | UInt32␉␉␉bufferSizeRemaining);␊ |
236 | ␊ |
237 | /*!␊ |
238 | @typedef IOUSBCompletionActionWithTimeStamp␊ |
239 | @discussion Function called when USB I/O completes.␊ |
240 | @param target The target specified in the IOUSBCompletion struct.␊ |
241 | @param parameter The parameter specified in the IOUSBCompletion struct.␊ |
242 | @param status Completion status.␊ |
243 | @param bufferSizeRemaining Bytes left to be transferred.␊ |
244 | @param timeStamp Time at which the transaction was processed.␊ |
245 | */␊ |
246 | typedef void (*IOUSBCompletionActionWithTimeStamp)(␊ |
247 | void *␉␉target,␊ |
248 | void *␉␉parameter,␊ |
249 | IOReturn␉␉status,␊ |
250 | UInt32␉␉bufferSizeRemaining,␊ |
251 | AbsoluteTime␉timeStamp);␊ |
252 | ␊ |
253 | /*!␊ |
254 | @typedef IOUSBIsocCompletionAction␊ |
255 | @discussion Function called when Isochronous USB I/O completes.␊ |
256 | @param target The target specified in the IOUSBIsocCompletionn struct.␊ |
257 | @param parameter The parameter specified in the IOUSBIsocCompletion struct.␊ |
258 | @param status Completion status.␊ |
259 | @param pFrames Pointer to the frame list containing the status for each frame transferred.␊ |
260 | */␊ |
261 | typedef void (*IOUSBIsocCompletionAction)(␊ |
262 | void *␉␉␉target,␊ |
263 | void *␉␉␉parameter,␊ |
264 | IOReturn␉␉status,␊ |
265 | IOUSBIsocFrame␉␉*pFrames);␊ |
266 | ␊ |
267 | /*!␊ |
268 | @typedef IOUSBLowLatencyIsocCompletionAction␊ |
269 | @discussion Function called when Low Latency Isochronous USB I/O completes.␊ |
270 | @param target The target specified in the IOUSBLowLatencyIsocCompletion struct.␊ |
271 | @param parameter The parameter specified in the IOUSBLowLatencyIsocCompletion struct.␊ |
272 | @param status Completion status.␊ |
273 | @param pFrames Pointer to the low latency frame list containing the status for each frame transferred.␊ |
274 | */␊ |
275 | typedef void (*IOUSBLowLatencyIsocCompletionAction)(␊ |
276 | void *␉␉␉␉target,␊ |
277 | void *␉␉␉␉parameter,␊ |
278 | IOReturn␉␉␉status,␊ |
279 | IOUSBLowLatencyIsocFrame␉*pFrames);␊ |
280 | ␊ |
281 | /*!␊ |
282 | @typedef IOUSBCompletion␊ |
283 | @discussion Struct specifying action to perform when a USB I/O completes.␊ |
284 | @param target The target to pass to the action function.␊ |
285 | @param action The function to call.␊ |
286 | @param parameter The parameter to pass to the action function.␊ |
287 | */␊ |
288 | typedef struct IOUSBCompletion {␊ |
289 | void * ␉␉␉target;␊ |
290 | IOUSBCompletionAction␉action;␊ |
291 | void *␉␉␉parameter;␊ |
292 | } IOUSBCompletion;␊ |
293 | ␊ |
294 | /*!␊ |
295 | @typedef IOUSBCompletionWithTimeStamp␊ |
296 | @discussion Struct specifying action to perform when a USB I/O completes.␊ |
297 | @param target The target to pass to the action function.␊ |
298 | @param action The function to call.␊ |
299 | @param parameter The parameter to pass to the action function.␊ |
300 | */␊ |
301 | typedef struct IOUSBCompletionWithTimeStamp {␊ |
302 | void * ␉␉␉␉target;␊ |
303 | IOUSBCompletionActionWithTimeStamp␉action;␊ |
304 | void *␉␉␉␉parameter;␊ |
305 | } IOUSBCompletionWithTimeStamp;␊ |
306 | ␊ |
307 | /*!␊ |
308 | @typedef IOUSBIsocCompletion␊ |
309 | @discussion Struct specifying action to perform when an Isochronous USB I/O completes.␊ |
310 | @param target The target to pass to the action function.␊ |
311 | @param action The function to call.␊ |
312 | @param parameter The parameter to pass to the action function.␊ |
313 | */␊ |
314 | typedef struct IOUSBIsocCompletion {␊ |
315 | void * ␉␉␉target;␊ |
316 | IOUSBIsocCompletionAction␉action;␊ |
317 | void *␉␉␉parameter;␊ |
318 | } IOUSBIsocCompletion;␊ |
319 | ␊ |
320 | /*!␊ |
321 | @typedef IOUSBLowLatencyIsocCompletion␊ |
322 | @discussion Struct specifying action to perform when an Low Latency Isochronous USB I/O completes.␊ |
323 | @param target The target to pass to the action function.␊ |
324 | @param action The function to call.␊ |
325 | @param parameter The parameter to pass to the action function.␊ |
326 | */␊ |
327 | typedef struct IOUSBLowLatencyIsocCompletion {␊ |
328 | void * ␉␉␉␉target;␊ |
329 | IOUSBLowLatencyIsocCompletionAction␉action;␊ |
330 | void *␉␉␉␉parameter;␊ |
331 | } IOUSBLowLatencyIsocCompletion;␊ |
332 | ␊ |
333 | ␊ |
334 | /*!␊ |
335 | @defined IOUSBFamily error codes␊ |
336 | @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.␊ |
337 | */␊ |
338 | #define␉iokit_usb_err(return) (sys_iokit|sub_iokit_usb|return)␊ |
339 | #define kIOUSBUnknownPipeErr iokit_usb_err(0x61)␉␉␉// 0xe0004061 Pipe ref not recognized␊ |
340 | #define kIOUSBTooManyPipesErr iokit_usb_err(0x60)␉␉␉// 0xe0004060 Too many pipes␊ |
341 | #define kIOUSBNoAsyncPortErr iokit_usb_err(0x5f)␉␉␉// 0xe000405f no async port␊ |
342 | #define kIOUSBNotEnoughPipesErr iokit_usb_err(0x5e)␉␉␉// 0xe000405e not enough pipes in interface␊ |
343 | #define kIOUSBNotEnoughPowerErr iokit_usb_err(0x5d)␉␉␉// 0xe000405d not enough power for selected configuration␊ |
344 | #define kIOUSBEndpointNotFound iokit_usb_err(0x57)␉␉␉// 0xe0004057 Endpoint Not found␊ |
345 | #define kIOUSBConfigNotFound iokit_usb_err(0x56)␉␉␉// 0xe0004056 Configuration Not found␊ |
346 | #define kIOUSBTransactionTimeout iokit_usb_err(0x51)␉␉␉// 0xe0004051 Transaction timed out␊ |
347 | #define kIOUSBTransactionReturned iokit_usb_err(0x50)␉␉␉// 0xe0004050 The transaction has been returned to the caller␊ |
348 | #define kIOUSBPipeStalled iokit_usb_err(0x4f)␉␉␉// 0xe000404f Pipe has stalled, error needs to be cleared␊ |
349 | #define kIOUSBInterfaceNotFound iokit_usb_err(0x4e)␉␉␉// 0xe000404e Interface ref not recognized␊ |
350 | #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 ␊ |
351 | #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␊ |
352 | #define kIOUSBHighSpeedSplitError iokit_usb_err(0x4b)␉␉// 0xe000404b Error to hub on high speed bus trying to do split transaction␊ |
353 | #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␊ |
354 | #define kIOUSBDeviceNotHighSpeed␉iokit_usb_err(0x49)␉␉␉// 0xe0004049 The device is not a high speed device, so the EHCI driver returns an error␊ |
355 | #define kIOUSBDevicePortWasNotSuspended iokit_usb_err(0x50)␉␉// 0xe0004050 Port was not suspended␊ |
356 | ␉␊ |
357 | /*!␊ |
358 | @defined IOUSBFamily hardware error codes␊ |
359 | @discussion These errors are returned by the OHCI controller. The # in parenthesis (xx) corresponds to the OHCI Completion Code.␊ |
360 | For the following Completion codes, we return a generic IOKit error instead of a USB specific error. ␊ |
361 | <tt>␊ |
362 | <pre>␊ |
363 | Completion Code Error Returned Description␊ |
364 | 9 kIOReturnUnderrun (Data Underrun) EP returned less data than max packet size␊ |
365 | 8 kIOReturnOverrun (Data Overrun) Packet too large or more data than buffer␊ |
366 | 5 kIOReturnNotResponding Device Not responding␊ |
367 | 4 kIOUSBPipeStalled Endpoint returned a STALL PID␊ |
368 | </pre>␊ |
369 | </tt>␊ |
370 | */␊ |
371 | #define kIOUSBLinkErr iokit_usb_err(0x10)␉␉// 0xe0004010␊ |
372 | #define kIOUSBNotSent2Err iokit_usb_err(0x0f)␉␉// 0xe000400f Transaction not sent␊ |
373 | #define kIOUSBNotSent1Err iokit_usb_err(0x0e)␉␉// 0xe000400e Transaction not sent␊ |
374 | #define kIOUSBBufferUnderrunErr iokit_usb_err(0x0d)␉␉// 0xe000400d Buffer Underrun (Host hardware failure on data out, PCI busy?)␊ |
375 | #define kIOUSBBufferOverrunErr iokit_usb_err(0x0c)␉␉// 0xe000400c Buffer Overrun (Host hardware failure on data out, PCI busy?)␊ |
376 | #define kIOUSBReserved2Err iokit_usb_err(0x0b)␉␉// 0xe000400b Reserved␊ |
377 | #define kIOUSBReserved1Err iokit_usb_err(0x0a)␉␉// 0xe000400a Reserved␊ |
378 | #define kIOUSBWrongPIDErr iokit_usb_err(0x07)␉␉// 0xe0004007 Pipe stall, Bad or wrong PID␊ |
379 | #define kIOUSBPIDCheckErr iokit_usb_err(0x06)␉␉// 0xe0004006 Pipe stall, PID CRC error␊ |
380 | #define kIOUSBDataToggleErr iokit_usb_err(0x03)␉␉// 0xe0004003 Pipe stall, Bad data toggle␊ |
381 | #define kIOUSBBitstufErr iokit_usb_err(0x02)␉␉// 0xe0004002 Pipe stall, bitstuffing␊ |
382 | #define kIOUSBCRCErr iokit_usb_err(0x01)␉␉// 0xe0004001 Pipe stall, bad CRC␊ |
383 | ␊ |
384 | /*!␊ |
385 | @defined IOUSBFamily message codes␊ |
386 | @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.␊ |
387 | */␊ |
388 | #define iokit_usb_msg(message)␉␉␉␉␉␉(UInt32)(sys_iokit|sub_iokit_usb|message)␊ |
389 | #define kIOUSBMessageHubResetPort␉␉␉␉␉iokit_usb_msg(0x01)␉␉// 0xe0004001 Message sent to a hub to reset a particular port␊ |
390 | #define kIOUSBMessageHubSuspendPort␉␉␉␉␉iokit_usb_msg(0x02)␉␉// 0xe0004002 Message sent to a hub to suspend a particular port␊ |
391 | #define kIOUSBMessageHubResumePort␉␉␉␉␉iokit_usb_msg(0x03)␉␉// 0xe0004003 Message sent to a hub to resume a particular port␊ |
392 | #define kIOUSBMessageHubIsDeviceConnected␉␉␉iokit_usb_msg(0x04)␉␉// 0xe0004004 Message sent to a hub to inquire whether a particular port has a device connected or not␊ |
393 | #define kIOUSBMessageHubIsPortEnabled␉␉␉␉iokit_usb_msg(0x05)␉␉// 0xe0004005 Message sent to a hub to inquire whether a particular port is enabled or not␊ |
394 | #define kIOUSBMessageHubReEnumeratePort␉␉␉␉iokit_usb_msg(0x06)␉␉// 0xe0004006 Message sent to a hub to reenumerate the device attached to a particular port␊ |
395 | #define kIOUSBMessagePortHasBeenReset␉␉␉␉iokit_usb_msg(0x0a)␉␉// 0xe000400a Message sent to a device indicating that the port it is attached to has been reset␊ |
396 | #define kIOUSBMessagePortHasBeenResumed␉␉␉␉iokit_usb_msg(0x0b)␉␉// 0xe000400b Message sent to a device indicating that the port it is attached to has been resumed␊ |
397 | #define kIOUSBMessageHubPortClearTT␉␉␉␉␉iokit_usb_msg(0x0c)␉␉// 0xe000400c Message sent to a hub to clear the transaction translator␊ |
398 | #define kIOUSBMessagePortHasBeenSuspended␉␉␉iokit_usb_msg(0x0d)␉␉// 0xe000400d Message sent to a device indicating that the port it is attached to has been suspended␊ |
399 | #define kIOUSBMessageFromThirdParty␉␉␉␉␉iokit_usb_msg(0x0e)␉␉// 0xe000400e Message sent from a third party. Uses IOUSBThirdPartyParam to encode the sender's ID␊ |
400 | #define kIOUSBMessagePortWasNotSuspended␉␉␉iokit_usb_msg(0x0f)␉␉// 0xe000400f Message indicating that the hub driver received a resume request for a port that was not suspended␊ |
401 | #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␊ |
402 | #define kIOUSBMessageCompositeDriverReconfigured iokit_usb_msg(0x11)␉␉// 0xe0004011 Message from the composite driver indicating that it has finished re-configuring the device after a reset␊ |
403 | #define kIOUSBMessageHubSetPortRecoveryTime␉␉␉iokit_usb_msg(0x12)␉␉// 0xe0004012 Message sent to a hub to set the # of ms required when resuming a particular port␊ |
404 | #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␊ |
405 | #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␊ |
406 | #define kIOUSBMessageController␉␉␉␉␉␉iokit_usb_msg(0x15)␉␉// 0xe0004015 Generic message sent from controller user client to controllers ␊ |
407 | #define␉kIOUSBMessageRootHubWakeEvent␉␉␉␉iokit_usb_msg(0x16)␉␉// 0xe0004016 Message from the HC Wakeup code indicating that a Root Hub port has a wake event␊ |
408 | ␊ |
409 | // Obsolete␊ |
410 | //␊ |
411 | struct IOUSBMouseData {␊ |
412 | UInt16 ␉␉␉␉buttons;␊ |
413 | SInt16 ␉␉␉␉XDelta;␊ |
414 | SInt16 ␉␉␉␉YDelta;␊ |
415 | };␊ |
416 | typedef struct IOUSBMouseData␉␉IOUSBMouseData;␊ |
417 | typedef IOUSBMouseData *␉␉IOUSBMouseDataPtr;␊ |
418 | ␊ |
419 | // Obsolete␊ |
420 | //␊ |
421 | struct IOUSBKeyboardData {␊ |
422 | UInt16 ␉␉␉␉keycount;␊ |
423 | UInt16 ␉␉␉␉usbkeycode[32];␊ |
424 | };␊ |
425 | typedef struct IOUSBKeyboardData␉IOUSBKeyboardData;␊ |
426 | typedef IOUSBKeyboardData *␉␉IOUSBKeyboardDataPtr;␊ |
427 | ␊ |
428 | // Obsolete␊ |
429 | //␊ |
430 | union IOUSBHIDData {␊ |
431 | IOUSBKeyboardData ␉␉␉kbd;␊ |
432 | IOUSBMouseData ␉␉␉mouse;␊ |
433 | };␊ |
434 | typedef union IOUSBHIDData␉␉IOUSBHIDData;␊ |
435 | typedef IOUSBHIDData *␉␉␉IOUSBHIDDataPtr;␊ |
436 | ␊ |
437 | /*!␊ |
438 | @typedef IOUSBDeviceDescriptor␊ |
439 | @discussion Descriptor for a USB Device. See the USB Specification at <a href="http://www.usb.org"TARGET="_blank">http://www.usb.org</a>.␊ |
440 | */␊ |
441 | struct IOUSBDeviceDescriptor {␊ |
442 | ␉UInt8 ␉␉␉bLength;␊ |
443 | ␉UInt8 ␉␉␉bDescriptorType;␊ |
444 | ␉UInt16 ␉␉␉bcdUSB;␊ |
445 | ␉UInt8 ␉␉␉bDeviceClass;␊ |
446 | ␉UInt8 ␉␉␉bDeviceSubClass;␊ |
447 | ␉UInt8 ␉␉␉bDeviceProtocol;␊ |
448 | ␉UInt8 ␉␉␉bMaxPacketSize0;␊ |
449 | ␉UInt16 ␉␉␉idVendor;␊ |
450 | ␉UInt16 ␉␉␉idProduct;␊ |
451 | ␉UInt16 ␉␉␉bcdDevice;␊ |
452 | ␉UInt8 ␉␉␉iManufacturer;␊ |
453 | ␉UInt8 ␉␉␉iProduct;␊ |
454 | ␉UInt8 ␉␉␉iSerialNumber;␊ |
455 | ␉UInt8 ␉␉␉bNumConfigurations;␊ |
456 | };␊ |
457 | typedef struct IOUSBDeviceDescriptor␉␉IOUSBDeviceDescriptor;␊ |
458 | typedef IOUSBDeviceDescriptor *␉␉␉IOUSBDeviceDescriptorPtr;␊ |
459 | ␊ |
460 | /*!␊ |
461 | @typedef IOUSBDescriptorHeader␊ |
462 | @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.␊ |
463 | */␊ |
464 | struct IOUSBDescriptorHeader {␊ |
465 | ␉UInt8 ␉␉␉bLength;␊ |
466 | ␉UInt8 ␉␉␉bDescriptorType;␊ |
467 | };␊ |
468 | typedef struct IOUSBDescriptorHeader␉␉IOUSBDescriptorHeader;␊ |
469 | typedef IOUSBDescriptorHeader *␉␉␉IOUSBDescriptorHeaderPtr;␊ |
470 | ␊ |
471 | /*!␊ |
472 | @typedef IOUSBConfigurationDescriptor␊ |
473 | @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.␊ |
474 | See the USB Specification at <a href="http://www.usb.org"TARGET="_blank">http://www.usb.org</a>.␊ |
475 | */␊ |
476 | struct IOUSBConfigurationDescriptor {␊ |
477 | ␉UInt8 ␉␉␉bLength;␊ |
478 | ␉UInt8 ␉␉␉bDescriptorType;␊ |
479 | ␉UInt16 ␉␉␉wTotalLength;␊ |
480 | ␉UInt8 ␉␉␉bNumInterfaces;␊ |
481 | ␉UInt8 ␉␉␉bConfigurationValue;␊ |
482 | ␉UInt8 ␉␉␉iConfiguration;␊ |
483 | ␉UInt8 ␉␉␉bmAttributes;␊ |
484 | ␉UInt8 ␉␉␉MaxPower;␊ |
485 | };␊ |
486 | typedef struct IOUSBConfigurationDescriptor ␉IOUSBConfigurationDescriptor;␊ |
487 | typedef IOUSBConfigurationDescriptor *␉␉IOUSBConfigurationDescriptorPtr;␊ |
488 | ␊ |
489 | /*!␊ |
490 | @typedef IOUSBConfigurationDescHeader␊ |
491 | @discussion Header of a IOUSBConfigurationDescriptor. Used to get the total length of the descriptor.␊ |
492 | */␊ |
493 | struct IOUSBConfigurationDescHeader {␊ |
494 | ␉UInt8 ␉␉␉bLength;␊ |
495 | ␉UInt8 ␉␉␉bDescriptorType;␊ |
496 | ␉UInt16 ␉␉␉wTotalLength;␊ |
497 | };␊ |
498 | typedef struct IOUSBConfigurationDescHeader ␉IOUSBConfigurationDescHeader;␊ |
499 | typedef IOUSBConfigurationDescHeader *␉␉IOUSBConfigurationDescHeaderPtr;␊ |
500 | ␊ |
501 | /*!␊ |
502 | @typedef IOUSBInterfaceDescriptor␊ |
503 | @discussion Descriptor for a USB Interface. See the USB Specification at <a href="http://www.usb.org"TARGET="_blank">http://www.usb.org</a>.␊ |
504 | */␊ |
505 | struct IOUSBInterfaceDescriptor {␊ |
506 | ␉UInt8 ␉␉␉bLength;␊ |
507 | ␉UInt8 ␉␉␉bDescriptorType;␊ |
508 | ␉UInt8 ␉␉␉bInterfaceNumber;␊ |
509 | ␉UInt8 ␉␉␉bAlternateSetting;␊ |
510 | ␉UInt8 ␉␉␉bNumEndpoints;␊ |
511 | ␉UInt8 ␉␉␉bInterfaceClass;␊ |
512 | ␉UInt8 ␉␉␉bInterfaceSubClass;␊ |
513 | ␉UInt8 ␉␉␉bInterfaceProtocol;␊ |
514 | ␉UInt8 ␉␉␉iInterface;␊ |
515 | };␊ |
516 | typedef struct IOUSBInterfaceDescriptor␉IOUSBInterfaceDescriptor;␊ |
517 | typedef IOUSBInterfaceDescriptor *␉IOUSBInterfaceDescriptorPtr;␊ |
518 | ␊ |
519 | /*!␊ |
520 | @typedef IOUSBEndpointDescriptor␊ |
521 | @discussion Descriptor for a USB Endpoint. See the USB Specification at <a href="http://www.usb.org"TARGET="_blank">http://www.usb.org</a>.␊ |
522 | */␊ |
523 | struct IOUSBEndpointDescriptor {␊ |
524 | ␉UInt8 ␉␉␉bLength;␊ |
525 | ␉UInt8 ␉␉␉bDescriptorType;␊ |
526 | ␉UInt8 ␉␉␉bEndpointAddress;␊ |
527 | ␉UInt8 ␉␉␉bmAttributes;␊ |
528 | ␉UInt16 ␉␉␉wMaxPacketSize;␉␊ |
529 | ␉UInt8 ␉␉␉bInterval;␊ |
530 | };␊ |
531 | typedef struct IOUSBEndpointDescriptor␉IOUSBEndpointDescriptor;␊ |
532 | typedef IOUSBEndpointDescriptor *␉IOUSBEndpointDescriptorPtr;␊ |
533 | ␊ |
534 | enum{addPacketShift = 11}; // Bits for additional packets in maxPacketField. (Table 9-13)␊ |
535 | #define mungeMaxPacketSize(w) ((w>1024)?(((w>>(addPacketShift))+1)*(w&((1<<addPacketShift)-1))):w)␊ |
536 | ␊ |
537 | /*!␊ |
538 | @typedef IOUSBHIDDescriptor␊ |
539 | @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␊ |
540 | should have used the #pragma pack(1) compiler directive to get byte alignment.␊ |
541 | */␊ |
542 | struct IOUSBHIDDescriptor {␊ |
543 | ␉UInt8 ␉␉␉descLen;␊ |
544 | ␉UInt8 ␉␉␉descType;␊ |
545 | ␉UInt16 ␉␉␉descVersNum;␊ |
546 | ␉UInt8 ␉␉␉hidCountryCode;␊ |
547 | ␉UInt8 ␉␉␉hidNumDescriptors;␊ |
548 | ␉UInt8 ␉␉␉hidDescriptorType;␊ |
549 | ␉UInt8 ␉␉␉hidDescriptorLengthLo;␊ |
550 | ␉UInt8 ␉␉␉hidDescriptorLengthHi;␊ |
551 | };␊ |
552 | typedef struct IOUSBHIDDescriptor␉IOUSBHIDDescriptor;␊ |
553 | typedef IOUSBHIDDescriptor *IOUSBHIDDescriptorPtr;␊ |
554 | ␊ |
555 | /*!␊ |
556 | @typedef IOUSBHIDReportDesc␊ |
557 | @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␊ |
558 | should have used the #pragma pack(1) compiler directive to get byte alignment.␊ |
559 | */␊ |
560 | struct IOUSBHIDReportDesc {␊ |
561 | ␉UInt8 ␉␉␉hidDescriptorType;␊ |
562 | ␉UInt8 ␉␉␉hidDescriptorLengthLo;␉␊ |
563 | ␉UInt8 ␉␉␉hidDescriptorLengthHi;␊ |
564 | };␊ |
565 | typedef struct IOUSBHIDReportDesc␉IOUSBHIDReportDesc;␊ |
566 | typedef IOUSBHIDReportDesc *␉␉IOUSBHIDReportDescPtr;␊ |
567 | ␊ |
568 | /*!␊ |
569 | @typedef IOUSBDeviceQualifierDescriptor␊ |
570 | @discussion USB Device Qualifier Descriptor. See the USB Specification at <a href="http://www.usb.org"TARGET="_blank">http://www.usb.org</a>.␊ |
571 | */␊ |
572 | #pragma pack(1)␊ |
573 | struct IOUSBDeviceQualifierDescriptor␊ |
574 | {␊ |
575 | ␉UInt8 ␉␉␉bLength;␊ |
576 | ␉UInt8 ␉␉␉bDescriptorType;␊ |
577 | ␉UInt16 ␉␉␉bcdUSB;␊ |
578 | ␉UInt8 ␉␉␉bDeviceClass;␊ |
579 | ␉UInt8 ␉␉␉bDeviceSubClass;␊ |
580 | ␉UInt8 ␉␉␉bDeviceProtocol;␊ |
581 | ␉UInt8 ␉␉␉bMaxPacketSize0;␊ |
582 | ␉UInt8 ␉␉␉bNumConfigurations;␊ |
583 | ␉UInt8 ␉␉␉bReserved;␊ |
584 | };␊ |
585 | typedef struct IOUSBDeviceQualifierDescriptor␉IOUSBDeviceQualifierDescriptor;␊ |
586 | typedef IOUSBDeviceQualifierDescriptor *␉IOUSBDeviceQualifierDescriptorPtr;␊ |
587 | #pragma options align=reset␊ |
588 | ␊ |
589 | /*!␊ |
590 | @typedef IOUSBDFUDescriptor␊ |
591 | @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>.␊ |
592 | */␊ |
593 | #pragma pack(1)␊ |
594 | struct IOUSBDFUDescriptor ␊ |
595 | {␊ |
596 | UInt8 ␉␉␉bLength;␊ |
597 | UInt8 ␉␉␉bDescriptorType;␊ |
598 | UInt8 ␉␉␉bmAttributes;␊ |
599 | UInt16 ␉␉␉wDetachTimeout;␊ |
600 | UInt16 ␉␉␉wTransferSize;␊ |
601 | };␊ |
602 | typedef struct ␉IOUSBDFUDescriptor ␉␉IOUSBDFUDescriptor;␊ |
603 | typedef ␉␉IOUSBDFUDescriptor *␉IOUSBDFUDescriptorPtr;␊ |
604 | ␊ |
605 | #pragma options align=reset␊ |
606 | ␊ |
607 | /*!␊ |
608 | @typedef IOUSBInterfaceAssociationDescriptor␊ |
609 | @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>.␊ |
610 | */␊ |
611 | #pragma pack(1)␊ |
612 | struct IOUSBInterfaceAssociationDescriptor␊ |
613 | {␊ |
614 | UInt8 ␉␉␉bLength;␊ |
615 | UInt8 ␉␉␉bDescriptorType;␊ |
616 | UInt8 ␉␉␉bFirstInterface;␊ |
617 | UInt8 ␉␉␉bInterfaceCount;␊ |
618 | UInt8 ␉␉␉bFunctionClass;␊ |
619 | UInt8 ␉␉␉bFunctionSubClass;␊ |
620 | UInt8 ␉␉␉bFunctionProtocol;␊ |
621 | UInt8␉␉␉iFunction;␊ |
622 | };␊ |
623 | typedef struct IOUSBInterfaceAssociationDescriptor␉IOUSBInterfaceAssociationDescriptor;␊ |
624 | typedef IOUSBInterfaceAssociationDescriptor *␉IOUSBInterfaceAssociationDescriptorPtr;␊ |
625 | #pragma options align=reset␊ |
626 | ␊ |
627 | /*!␊ |
628 | @typedef USBStatus␊ |
629 | @discussion Type used to get a DeviceStatus as a single quantity.␊ |
630 | */␊ |
631 | typedef UInt16␉␉␉␉USBStatus;␊ |
632 | typedef USBStatus *␉␉␉USBStatusPtr;␊ |
633 | ␊ |
634 | // These constants are obsolete␊ |
635 | //␊ |
636 | enum {␊ |
637 | kIOUSBAnyClass␉= 0xFFFF,␊ |
638 | kIOUSBAnySubClass␉= 0xFFFF,␊ |
639 | kIOUSBAnyProtocol␉= 0xFFFF,␊ |
640 | kIOUSBAnyVendor␉= 0xFFFF,␊ |
641 | kIOUSBAnyProduct␉= 0xFFFF␊ |
642 | };␊ |
643 | ␊ |
644 | // This structure are obsolete␊ |
645 | //␊ |
646 | typedef struct IOUSBMatch {␊ |
647 | UInt16␉usbClass;␊ |
648 | UInt16␉usbSubClass;␊ |
649 | UInt16␉usbProtocol;␊ |
650 | UInt16␉usbVendor;␊ |
651 | UInt16␉usbProduct;␊ |
652 | } IOUSBMatch;␊ |
653 | ␊ |
654 | /*!␊ |
655 | @typedef IOUSBFindEndpointRequest␊ |
656 | @discussion Struct used to find endpoints of an interface␊ |
657 | type and direction are used to match endpoints,␊ |
658 | type, direction, maxPacketSize and interval are updated␊ |
659 | with the properties of the found endpoint.␊ |
660 | @field type Type of endpoint: kUSBControl, kUSBIsoc, kUSBBulk, kUSBInterrupt, kUSBAnyType. If kUSBAnyType is specified, this field is treated as a don't care.␊ |
661 | @field direction Direction of endpoint: kUSBOut, kUSBIn, kUSBAnyDirn. If kUSBAnyDirn is specified, this field is treated as a don't care.␊ |
662 | @field maxPacketSize maximum packet size of endpoint.␊ |
663 | @field interval Polling interval in mSec for endpoint.␊ |
664 | */␊ |
665 | typedef struct {␊ |
666 | ␉UInt8 type;␉␊ |
667 | ␉UInt8 direction;␊ |
668 | UInt16 maxPacketSize;␊ |
669 | UInt8 interval;␊ |
670 | } IOUSBFindEndpointRequest;␊ |
671 | ␊ |
672 | /*!␊ |
673 | @struct IOUSBDevRequest␊ |
674 | @discussion Parameter block for control requests, using a simple pointer␊ |
675 | for the data to be transferred.␊ |
676 | @field bmRequestType Request type: kUSBStandard, kUSBClass or kUSBVendor␊ |
677 | @field bRequest Request code␊ |
678 | @field wValue 16 bit parameter for request, host endianess␊ |
679 | @field wIndex 16 bit parameter for request, host endianess␊ |
680 | @field wLength Length of data part of request, 16 bits, host endianess␊ |
681 | @field pData Pointer to data for request - data returned in bus endianess␊ |
682 | @field wLenDone Set by standard completion routine to number of data bytes␊ |
683 | ␉actually transferred␊ |
684 | */␊ |
685 | typedef struct {␊ |
686 | UInt8 bmRequestType;␊ |
687 | UInt8 bRequest;␊ |
688 | UInt16 wValue;␊ |
689 | UInt16 wIndex;␊ |
690 | UInt16 wLength;␊ |
691 | void * pData;␊ |
692 | UInt32 wLenDone;␊ |
693 | } IOUSBDevRequest;␊ |
694 | typedef IOUSBDevRequest * IOUSBDeviceRequestPtr;␊ |
695 | ␊ |
696 | /*!␊ |
697 | @struct IOUSBDevRequestTO␊ |
698 | @discussion Parameter block for control requests with timeouts, using a simple pointer␊ |
699 | for the data to be transferred. Same as a IOUSBDevRequest except for the two extra timeout fields.␊ |
700 | @field bmRequestType Request type: kUSBStandard, kUSBClass or kUSBVendor␊ |
701 | @field bRequest Request code␊ |
702 | @field wValue 16 bit parameter for request, host endianess␊ |
703 | @field wIndex 16 bit parameter for request, host endianess␊ |
704 | @field wLength Length of data part of request, 16 bits, host endianess␊ |
705 | @field pData Pointer to data for request - data returned in bus endianess␊ |
706 | @field wLenDone Set by standard completion routine to number of data bytes␊ |
707 | ␉actually transferred␊ |
708 | @field noDataTimeout Specifies a time value in milliseconds. Once the request is queued on the bus, if no data is transferred in this amount of time, the request will be aborted and returned.␊ |
709 | @field completionTimeout Specifies a time value in milliseconds. Once the request is queued on the bus, if the entire request is not completed in this amount of time, the request will be aborted and returned ␊ |
710 | */␊ |
711 | typedef struct {␊ |
712 | UInt8 bmRequestType;␊ |
713 | UInt8 bRequest;␊ |
714 | UInt16 wValue;␊ |
715 | UInt16 wIndex;␊ |
716 | UInt16 wLength;␊ |
717 | void * pData;␊ |
718 | UInt32 wLenDone;␊ |
719 | UInt32 noDataTimeout;␊ |
720 | UInt32 completionTimeout;␊ |
721 | } IOUSBDevRequestTO;␊ |
722 | ␊ |
723 | /*!␊ |
724 | @enum Default timeout values␊ |
725 | @discussion default values used for data and completion timeouts.␊ |
726 | */␊ |
727 | enum␊ |
728 | {␊ |
729 | kUSBDefaultControlNoDataTimeoutMS = 5000,␊ |
730 | kUSBDefaultControlCompletionTimeoutMS = 0␊ |
731 | };␊ |
732 | ␊ |
733 | // Internal structure to pass parameters between IOUSBLib and UserClient␊ |
734 | //␊ |
735 | typedef struct␊ |
736 | {␊ |
737 | UInt32 pipeRef;␊ |
738 | void * buf;␊ |
739 | UInt32 size;␊ |
740 | UInt32 noDataTimeout;␊ |
741 | UInt32 completionTimeout;␊ |
742 | } IOUSBBulkPipeReq;␊ |
743 | ␊ |
744 | ␊ |
745 | #if KERNEL␊ |
746 | /*!␊ |
747 | @struct IOUSBDevRequestDesc␊ |
748 | @discussion Parameter block for control requests, using a memory descriptor␊ |
749 | for the data to be transferred. Only available in the kernel.␊ |
750 | @field bmRequestType Request type: kUSBStandard, kUSBClass or kUSBVendor␊ |
751 | @field bRequest Request code␊ |
752 | @field wValue 16 bit parameter for request, host endianess␊ |
753 | @field wIndex 16 bit parameter for request, host endianess␊ |
754 | @field wLength Length of data part of request, 16 bits, host endianess␊ |
755 | @field pData Pointer to memory descriptor for data for request - data returned in bus endianess␊ |
756 | @field wLenDone Set by standard completion routine to number of data bytes␊ |
757 | actually transferred␊ |
758 | */␊ |
759 | typedef struct {␊ |
760 | UInt8 bmRequestType;␊ |
761 | UInt8 bRequest;␊ |
762 | UInt16 wValue;␊ |
763 | UInt16 wIndex;␊ |
764 | UInt16 wLength;␊ |
765 | IOMemoryDescriptor * pData;␊ |
766 | UInt32 wLenDone;␊ |
767 | } IOUSBDevRequestDesc;␊ |
768 | ␊ |
769 | ␊ |
770 | /*!␊ |
771 | @enum IOOptionBits␊ |
772 | @discussion Parameter passed to an IOService::open() call.␊ |
773 | @constant kIOUSBInterfaceOpenAlt Open the alternate interface specified when creating the interface.␊ |
774 | */␊ |
775 | enum {␊ |
776 | kIOUSBInterfaceOpenAlt␉= 0x00010000␊ |
777 | };␊ |
778 | ␊ |
779 | #endif␊ |
780 | ␊ |
781 | // Internal structure to pass parameters between IOUSBLib and UserClient␊ |
782 | //␊ |
783 | // use a structure because there's a limit of 6 total arguments␊ |
784 | // to a user client method.␊ |
785 | typedef struct {␊ |
786 | UInt8 ␉bmRequestType;␊ |
787 | UInt8 ␉bRequest;␊ |
788 | UInt16 ␉wValue;␊ |
789 | UInt16 ␉wIndex;␊ |
790 | UInt16␉wLength;␊ |
791 | void * ␉pData;␉␉// data pointer␊ |
792 | UInt32␉wLenDone;␉// # bytes transferred␊ |
793 | UInt8␉pipeRef;␊ |
794 | } IOUSBDevReqOOL;␊ |
795 | ␊ |
796 | // Internal structure to pass parameters between IOUSBLib and UserClient␊ |
797 | //␊ |
798 | typedef struct {␊ |
799 | UInt8 ␉bmRequestType;␊ |
800 | UInt8 ␉bRequest;␊ |
801 | UInt16 ␉wValue;␊ |
802 | UInt16 ␉wIndex;␊ |
803 | UInt16␉wLength;␊ |
804 | void * ␉pData;␉␉// data pointer␊ |
805 | UInt32␉wLenDone;␉// # bytes transferred␊ |
806 | UInt8␉pipeRef;␊ |
807 | UInt32␉noDataTimeout;␊ |
808 | UInt32␉completionTimeout;␊ |
809 | } IOUSBDevReqOOLTO;␊ |
810 | ␊ |
811 | // Internal structure to pass parameters between IOUSBLib and UserClient␊ |
812 | //␊ |
813 | // Structure to request isochronous transfer␊ |
814 | //␊ |
815 | typedef struct {␊ |
816 | UInt32 ␉␉fPipe;␊ |
817 | void ␉␉*fBuffer;␊ |
818 | UInt32 ␉␉fBufSize;␊ |
819 | UInt64 ␉␉fStartFrame;␊ |
820 | UInt32 ␉␉fNumFrames;␊ |
821 | IOUSBIsocFrame ␉*fFrameCounts;␊ |
822 | } IOUSBIsocStruct;␊ |
823 | ␊ |
824 | // Internal structure to pass parameters between IOUSBLib and UserClient␊ |
825 | //␊ |
826 | // Structure to request low latency isochronous transfer␊ |
827 | //␊ |
828 | struct IOUSBLowLatencyIsocStruct {␊ |
829 | UInt32 ␉␉␉fPipe;␊ |
830 | UInt32 ␉␉␉fBufSize;␊ |
831 | UInt64 ␉␉␉fStartFrame;␊ |
832 | UInt32 ␉␉␉fNumFrames;␊ |
833 | UInt32␉␉␉fUpdateFrequency;␊ |
834 | UInt32␉␉␉fDataBufferCookie;␊ |
835 | UInt32␉␉␉fDataBufferOffset;␊ |
836 | UInt32␉␉␉fFrameListBufferCookie;␊ |
837 | UInt32␉␉␉fFrameListBufferOffset;␊ |
838 | };␊ |
839 | ␊ |
840 | typedef struct IOUSBLowLatencyIsocStruct IOUSBLowLatencyIsocStruct;␊ |
841 | ␊ |
842 | ␊ |
843 | /*!␊ |
844 | @struct IOUSBGetFrameStruct␊ |
845 | @discussion Structure used from user space to return the frame number and a timestamp on when the frame register was read.␊ |
846 | @field frame frame number␊ |
847 | @field timeStamp AbsoluteTime when the frame was updated␊ |
848 | */␊ |
849 | typedef struct {␊ |
850 | UInt64␉␉␉frame;␊ |
851 | AbsoluteTime␉timeStamp;␊ |
852 | } IOUSBGetFrameStruct;␊ |
853 | ␊ |
854 | ␊ |
855 | /*!␊ |
856 | @struct IOUSBFindInterfaceRequest␊ |
857 | @discussion Structure used with FindNextInterface.␊ |
858 | */␊ |
859 | typedef struct {␊ |
860 | UInt16␉bInterfaceClass;␉␉// requested class␊ |
861 | UInt16 ␉bInterfaceSubClass;␉␉// requested subclass␊ |
862 | UInt16 ␉bInterfaceProtocol;␉␉// requested protocol␊ |
863 | UInt16␉bAlternateSetting;␉␉// requested alt setting␊ |
864 | } IOUSBFindInterfaceRequest;␊ |
865 | ␊ |
866 | /*!␊ |
867 | @enum kIOUSBFindInterfaceDontCare␊ |
868 | @discussion Constant that can be used for the fields of IOUSBFindInterfaceRequest to specify that they should not be matched. ␊ |
869 | */␊ |
870 | enum {␊ |
871 | kIOUSBFindInterfaceDontCare␉␉= 0xFFFF␊ |
872 | };␊ |
873 | ␊ |
874 | /*!␊ |
875 | @enum kIOUSBVendorIDAppleComputer␊ |
876 | @discussion USB Vendor ID for Apple Computer, Inc. ␊ |
877 | */␊ |
878 | enum {␊ |
879 | ␉kIOUSBVendorIDAppleComputer␉␉= 0x05AC␊ |
880 | };␊ |
881 | ␊ |
882 | /*!␊ |
883 | @enum USBDeviceSpeed␊ |
884 | @discussion Returns the speed of a particular USB device. ␊ |
885 | @constant␉kUSBDeviceSpeedLow␉The device a low speed device.␊ |
886 | @constant␉kUSBDeviceSpeedFull␉The device a full speed device.␊ |
887 | @constant␉kUSBDeviceSpeedHigh␉The device a high speed device.␊ |
888 | */␊ |
889 | enum {␊ |
890 | kUSBDeviceSpeedLow␉␉= 0,␊ |
891 | kUSBDeviceSpeedFull␉␉= 1,␊ |
892 | kUSBDeviceSpeedHigh␉␉= 2␊ |
893 | };␊ |
894 | ␊ |
895 | /*!␊ |
896 | @enum MicrosecondsInFrame␊ |
897 | @discussion Returns the number of microseconds in a USB frame. ␊ |
898 | @constant␉kUSBFullSpeedMicrosecondsInFrame␉The device is attached to a bus running at full speed (1 ms / frame).␊ |
899 | @constant␉kUSBHighSpeedMicrosecondsInFrame␉The device is attached to a bus running at high speed (125 microseconds / frame).␊ |
900 | */␊ |
901 | enum {␊ |
902 | kUSBFullSpeedMicrosecondsInFrame␉␉= 1000,␉␊ |
903 | kUSBHighSpeedMicrosecondsInFrame␉␉= 125␊ |
904 | };␊ |
905 | ␊ |
906 | // During low latency transfers, the stack will set the frStatus for each frame to this value. A client can check that to see if the transfer has completed. We set the frStatus to a ␊ |
907 | // valid return code when the transfer completes.␊ |
908 | //␊ |
909 | enum {␊ |
910 | kUSBLowLatencyIsochTransferKey␉= 'llit'␉// Set frStatus field of first frame in isoch transfer to designate as low latency␊ |
911 | };␊ |
912 | ␊ |
913 | // This structure is DEPRECATED. See the LowLatencyUserBufferInfoV2 ␊ |
914 | //␊ |
915 | typedef struct LowLatencyUserBufferInfo LowLatencyUserBufferInfo;␊ |
916 | ␊ |
917 | struct LowLatencyUserBufferInfo {␊ |
918 | UInt32␉␉␉␉cookie;␊ |
919 | void *␉␉␉␉bufferAddress;␊ |
920 | IOByteCount␉␉␉bufferSize;␊ |
921 | UInt32␉␉␉␉bufferType;␊ |
922 | Boolean␉␉␉␉isPrepared;␊ |
923 | LowLatencyUserBufferInfo *␉nextBuffer;␊ |
924 | };␊ |
925 | ␊ |
926 | // This structure is DEPRECATED. See the LowLatencyUserBufferInfoV3 ␊ |
927 | ␊ |
928 | typedef struct LowLatencyUserBufferInfoV2 LowLatencyUserBufferInfoV2;␊ |
929 | ␊ |
930 | struct LowLatencyUserBufferInfoV2 ␊ |
931 | {␊ |
932 | ␉UInt32␉␉␉␉␉␉␉cookie;␊ |
933 | ␉void *␉␉␉␉␉␉␉bufferAddress;␊ |
934 | ␉IOByteCount␉␉␉␉␉␉bufferSize;␊ |
935 | ␉UInt32␉␉␉␉␉␉␉bufferType;␊ |
936 | ␉Boolean␉␉␉␉␉␉␉isPrepared;␊ |
937 | ␉void *␉␉␉␉␉␉␉mappedUHCIAddress;␊ |
938 | ␉LowLatencyUserBufferInfoV2 *␉nextBuffer;␊ |
939 | };␊ |
940 | ␊ |
941 | ␉␊ |
942 | // This structure is used to pass information for the low latency calls between user space and the kernel. ␊ |
943 | //␊ |
944 | typedef struct LowLatencyUserBufferInfoV3 LowLatencyUserBufferInfoV3;␊ |
945 | ␊ |
946 | struct LowLatencyUserBufferInfoV3 ␊ |
947 | {␊ |
948 | ␉uint64_t␉␉␉␉␉␉cookie;␊ |
949 | ␉mach_vm_address_t␉␉␉␉bufferAddress;␊ |
950 | ␉mach_vm_size_t␉␉␉␉␉bufferSize;␊ |
951 | ␉uint64_t␉␉␉␉␉␉bufferType;␊ |
952 | ␉uint64_t␉␉␉␉␉␉isPrepared;␊ |
953 | ␉mach_vm_address_t␉␉␉␉mappedUHCIAddress;␊ |
954 | ␉LowLatencyUserBufferInfoV3 *␉nextBuffer;␊ |
955 | };␊ |
956 | ␉␊ |
957 | ␉␊ |
958 | ␉/*!␊ |
959 | @enum USBLowLatencyBufferType␊ |
960 | @discussion Used to specify what kind of buffer to create when calling LowLatencyCreateBuffer(). ␊ |
961 | @constant␉kUSBLowLatencyWriteBuffer␉The buffer will be used to write data out to a device.␊ |
962 | @constant␉kUSBLowLatencyReadBuffer␉The buffer will be used to read data from a device.␊ |
963 | @constant␉kUSBLowLatencyFrameListBuffer␉The buffer will be used for a low latency isoch frame list.␊ |
964 | */␊ |
965 | typedef enum {␊ |
966 | kUSBLowLatencyWriteBuffer ␉␉= 0,␊ |
967 | kUSBLowLatencyReadBuffer␉␉= 1,␊ |
968 | kUSBLowLatencyFrameListBuffer␉= 2␊ |
969 | } USBLowLatencyBufferType;␊ |
970 | ␊ |
971 | // USB User Notification Types␊ |
972 | //␊ |
973 | enum {␊ |
974 | kUSBNoUserNotificationType␉␉␉= 0,␊ |
975 | kUSBNotEnoughPowerNotificationType␉␉= 1,␊ |
976 | kUSBIndividualOverCurrentNotificationType␉= 2,␊ |
977 | kUSBGangOverCurrentNotificationType␉␉= 3␊ |
978 | };␊ |
979 | ␊ |
980 | /*!␊ |
981 | @defined Property Definitions␊ |
982 | @discussion Useful property names in USB land. ␊ |
983 | */␊ |
984 | #define kUSBDevicePropertySpeed "Device Speed"␊ |
985 | #define kUSBDevicePropertyBusPowerAvailable "Bus Power Available"␊ |
986 | #define kUSBDevicePropertyAddress "USB Address"␊ |
987 | #define kUSBDevicePropertyLocationID "locationID"␊ |
988 | #define kUSBProductIDMask␉␉␉␉␉␉"idProductMask"␊ |
989 | #define kUSBPreferredConfiguration␉␉␉␉"Preferred Configuration"␊ |
990 | #define kUSBSuspendPort␉␉␉␉␉␉␉"kSuspendPort"␊ |
991 | #define kUSBExpressCardCantWake␉␉␉␉␉"ExpressCardCantWake"␊ |
992 | #define kUSBControllerNeedsContiguousMemoryForIsoch␉"Need contiguous memory for isoch"␊ |
993 | #define kUSBHubDontAllowLowPower␉␉␉␉"kUSBHubDontAllowLowPower"␊ |
994 | #define kUSBDeviceResumeRecoveryTime␉␉␉"kUSBDeviceResumeRecoveryTime"␊ |
995 | #define kUSBOutOfSpecMPSOK␉␉␉␉␉␉"Out of spec MPS OK"␊ |
996 | #define kConfigurationDescriptorOverride␉␉"ConfigurationDescriptorOverride"␊ |
997 | #define kOverrideIfAtLocationID␉␉␉␉␉"OverrideIfAtLocationID"␊ |
998 | ␊ |
999 | /*!␊ |
1000 | @enum USBReEnumerateOptions␊ |
1001 | @discussion Options used when calling ReEnumerateDevice. ␊ |
1002 | @constant␉kUSBAddExtraResetTimeBit␉Setting this bit will cause the Hub driver to wait 100ms before addressing the device after the reset following the re-enumeration.␊ |
1003 | */␊ |
1004 | typedef enum {␊ |
1005 | kUSBAddExtraResetTimeBit ␉␉= 31,␊ |
1006 | kUSBAddExtraResetTimeMask␉␉= ( 1 << kUSBAddExtraResetTimeBit)␊ |
1007 | } USBReEnumerateOptions;␊ |
1008 | ␊ |
1009 | /*!␊ |
1010 | @enum USBDeviceInformationBits␊ |
1011 | @discussion ␉GetUSBDeviceInformation will return a unit32_t value with bits set indicating that a particular state is present in the USB device. These bits are described here ␊ |
1012 | ␊ |
1013 | @constant␉kUSBInformationDeviceIsCaptiveBit␉␉␉The USB device is directly attached to its hub and cannot be removed.␊ |
1014 | @constant␉kUSBInformationDeviceIsAttachedToRootHubBit␉The USB device is directly attached to the root hub␊ |
1015 | @constant␉kUSBInformationDeviceIsInternalBit␉␉␉The USB device is internal to the computer (all the hubs it attaches to are captive)␊ |
1016 | @constant␉kUSBInformationDeviceIsConnectedBit␉␉␉The USB device is connected to its hub␊ |
1017 | @constant␉kUSBInformationDeviceIsEnabledBit␉␉␉The hub port to which the USB device is attached is enabled␊ |
1018 | @constant␉kUSBInformationDeviceIsSuspendedBit␉␉␉The hub port to which the USB device is attached is suspended␊ |
1019 | @constant␉kUSBInformationDeviceIsInResetBit␉␉␉The hub port to which the USB device is attached is being reset␊ |
1020 | @constant␉kUSBInformationDeviceOvercurrentBit␉␉␉The USB device generated an overcurrent␊ |
1021 | @constant␉kUSBInformationDevicePortIsInTestModeBit␉The hub port to which the USB device is attached is in test mode␊ |
1022 | @constant kUSBInformationDeviceIsRootHub␉␉␉␉The device is actually the root hub simulation␊ |
1023 | @constant kUSBInformationRootHubisBuiltIn␉␉␉␉If this is a root hub simulation and it's built into the machine, this bit is set. If it's on an expansion card, it will be cleared␊ |
1024 | ␊ |
1025 | */␊ |
1026 | ␉typedef enum {␊ |
1027 | ␉␉kUSBInformationDeviceIsCaptiveBit␉␉␉␉= 0,␊ |
1028 | ␉␉kUSBInformationDeviceIsAttachedToRootHubBit␉␉= 1,␊ |
1029 | ␉␉kUSBInformationDeviceIsInternalBit␉␉␉␉= 2,␊ |
1030 | ␉␉kUSBInformationDeviceIsConnectedBit␉␉␉␉= 3,␊ |
1031 | ␉␉kUSBInformationDeviceIsEnabledBit␉␉␉␉= 4,␊ |
1032 | ␉␉kUSBInformationDeviceIsSuspendedBit␉␉␉␉= 5,␊ |
1033 | ␉␉kUSBInformationDeviceIsInResetBit␉␉␉␉= 6,␊ |
1034 | ␉␉kUSBInformationDeviceOvercurrentBit␉␉␉␉= 7,␊ |
1035 | ␉␉kUSBInformationDevicePortIsInTestModeBit␉␉= 8,␊ |
1036 | ␉␉kUSBInformationDeviceIsRootHub␉␉␉␉␉= 9,␊ |
1037 | ␉␉kUSBInformationRootHubisBuiltIn␉␉␉␉␉= 10,␊ |
1038 | ␉␉kUSBInformationDeviceIsRemote␉␉␉␉␉= 11,␊ |
1039 | ␉␉kUSBInformationDeviceIsCaptiveMask␉␉␉␉= (1 << kUSBInformationDeviceIsCaptiveBit),␊ |
1040 | ␉␉kUSBInformationDeviceIsAttachedToRootHubMask␉= (1 << kUSBInformationDeviceIsAttachedToRootHubBit),␊ |
1041 | ␉␉kUSBInformationDeviceIsInternalMask␉␉␉␉= (1 << kUSBInformationDeviceIsInternalBit),␊ |
1042 | ␉␉kUSBInformationDeviceIsConnectedMask␉␉␉= (1 << kUSBInformationDeviceIsConnectedBit),␊ |
1043 | ␉␉kUSBInformationDeviceIsEnabledMask␉␉␉␉= (1 << kUSBInformationDeviceIsEnabledBit),␊ |
1044 | ␉␉kUSBInformationDeviceIsSuspendedMask␉␉␉= (1 << kUSBInformationDeviceIsSuspendedBit),␊ |
1045 | ␉␉kUSBInformationDeviceIsInResetMask␉␉␉␉= (1 << kUSBInformationDeviceIsInResetBit),␊ |
1046 | ␉␉kUSBInformationDeviceOvercurrentMask␉␉␉= (1 << kUSBInformationDeviceOvercurrentBit),␊ |
1047 | ␉␉kUSBInformationDevicePortIsInTestModeMask␉␉= (1 << kUSBInformationDevicePortIsInTestModeBit),␊ |
1048 | ␉␉kUSBInformationDeviceIsRootHubMask␉␉␉␉= (1 << kUSBInformationDeviceIsRootHub),␊ |
1049 | ␉␉kUSBInformationRootHubisBuiltInMask␉␉␉␉= (1 << kUSBInformationRootHubisBuiltIn),␊ |
1050 | ␉␉kUSBInformationDeviceIsRemoteMask␉␉␉␉= (1 << kUSBInformationDeviceIsRemote)␊ |
1051 | ␉} USBDeviceInformationBits;␊ |
1052 | ␉␊ |
1053 | ␉/*!␊ |
1054 | ␉ @enum USBPowerRequestTypes␊ |
1055 | ␉ @discussion Used to specify what kind of power will be reserved using the IOUSBDevice RequestExtraPower and ReturnExtraPower APIs. ␊ |
1056 | ␉ @constant␉kUSBPowerDuringSleep␉The power is to be used during sleep.␊ |
1057 | ␉ @constant␉kUSBPowerDuringWake␉␉The power is to be used while the system is awake (i.e not sleeping)␊ |
1058 | ␉ */␊ |
1059 | ␉typedef enum {␊ |
1060 | ␉␉kUSBPowerDuringSleep ␉␉= 0,␊ |
1061 | ␉␉kUSBPowerDuringWake␉␉␉= 1␊ |
1062 | ␉} USBPowerRequestTypes;␊ |
1063 | ␉␊ |
1064 | ␉// Apple specific properties␊ |
1065 | #define kAppleCurrentAvailable␉␉"AAPL,current-available"␊ |
1066 | #define kAppleCurrentInSleep␉␉"AAPL,current-in-sleep"␊ |
1067 | #define kAppleCurrentExtra␉␉␉"AAPL,current-extra"␊ |
1068 | #define kAppleInternalUSBDevice␉␉"AAPL,device-internal"␊ |
1069 | #define kUSBBusID␉␉␉␉␉"AAPL,bus-id"␊ |
1070 | ␉␊ |
1071 | ␊ |
1072 | #ifdef __cplusplus␊ |
1073 | } ␊ |
1074 | #endif␊ |
1075 | ␊ |
1076 | #endif /* _USB_H */␊ |
1077 |