Root/
Source at commit 1548 created 12 years 10 months ago. By blackosx, Added detection for FAT format created by Lion's Disk Utility. Enhanced install log. | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 1998-2007 Apple 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 _IOKIT_IOUSBINTERFACE_H␊ |
25 | #define _IOKIT_IOUSBINTERFACE_H␊ |
26 | ␊ |
27 | #include <IOKit/IOService.h>␊ |
28 | #include <libkern/c++/OSData.h>␊ |
29 | ␊ |
30 | #include <IOKit/usb/USB.h>␊ |
31 | #include <IOKit/usb/IOUSBNub.h>␊ |
32 | #include <IOKit/usb/IOUSBDevice.h>␊ |
33 | ␊ |
34 | /*!␊ |
35 | @class IOUSBInterface␊ |
36 | @abstract The object representing an interface of a device on the USB bus.␊ |
37 | @discussion This class provides functionality to find the pipes of an interface and␊ |
38 | ␉to read the descriptors associated with an interface. When an interface is open()ed,␊ |
39 | ␉all its pipes are created␊ |
40 | */␊ |
41 | class IOUSBInterface : public IOUSBNub␊ |
42 | {␊ |
43 | friend class IOUSBInterfaceUserClientV2;␊ |
44 | ␊ |
45 | OSDeclareDefaultStructors(IOUSBInterface)␊ |
46 | ␊ |
47 | protected:␊ |
48 | IOUSBPipe * ␉␉␉_pipeList[kUSBMaxPipes];␊ |
49 | const IOUSBConfigurationDescriptor *_configDesc;␊ |
50 | const IOUSBInterfaceDescriptor *␉_interfaceDesc;␊ |
51 | IOUSBDevice *␉␉␉_device;␊ |
52 | ␊ |
53 | // these variable are the parsed interface descriptor␊ |
54 | UInt8␉␉␉␉_bInterfaceNumber;␊ |
55 | UInt8␉␉␉␉_bAlternateSetting;␊ |
56 | UInt8␉␉␉␉_bNumEndpoints;␊ |
57 | UInt8␉␉␉␉_bInterfaceClass;␊ |
58 | UInt8␉␉␉␉_bInterfaceSubClass;␊ |
59 | UInt8␉␉␉␉_bInterfaceProtocol;␊ |
60 | UInt8␉␉␉␉_iInterface;␊ |
61 | ␊ |
62 | struct ExpansionData {␊ |
63 | IOCommandGate␉␉*_gate;␊ |
64 | IOWorkLoop␉␉␉*_workLoop;␊ |
65 | ␉␉bool␉␉␉␉_needToClose;␊ |
66 | ␉␉IOLock *␉␉␉_pipeObjLock;␉␉␉␉␉␉␉␉␉␉␉// Lock to synchronize accesses to our pipeObjects␊ |
67 | };␊ |
68 | ExpansionData * _expansionData;␊ |
69 | ␊ |
70 | // private methods␊ |
71 | virtual void␉␉ClosePipes(void);␉␉␉␉// close all pipes (except pipe zero)␊ |
72 | virtual IOReturn␉CreatePipes(void);␉␉␉␉// open all pipes in the current interface/alt interface␊ |
73 | virtual void␉␉SetProperties(void);␉␉␉// update my property table with the correct properties␉␉␊ |
74 | ␉␊ |
75 | public:␊ |
76 | ␉// static methods␊ |
77 | static IOUSBInterface *withDescriptors(const IOUSBConfigurationDescriptor *cfDesc, const IOUSBInterfaceDescriptor *ifDesc);␊ |
78 | static IOReturn␉CallSuperOpen(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);␊ |
79 | static IOReturn CallSuperClose(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);␊ |
80 | ␉static UInt8 hex2char( UInt8 digit );␊ |
81 | ␊ |
82 | ␉// IOService methods␊ |
83 | virtual bool␉␉start(IOService * provider);␊ |
84 | virtual bool␉␉handleOpen(IOService *forClient, IOOptionBits options = 0, void *arg = 0 );␊ |
85 | virtual bool␉␉open(IOService *forClient, IOOptionBits options = 0, void *arg = 0 );␊ |
86 | virtual void␉␉close(IOService *forClient, IOOptionBits options = 0);␊ |
87 | virtual void␉␉handleClose(IOService *forClient, IOOptionBits options = 0);␊ |
88 | virtual IOReturn ␉message( UInt32 type, IOService * provider, void * argument = 0 );␊ |
89 | virtual bool␉␉finalize(IOOptionBits options);␊ |
90 | virtual void␉␉stop(IOService * provider);␊ |
91 | virtual bool␉␉terminate( IOOptionBits options = 0 );␊ |
92 | virtual void␉␉free();␉␊ |
93 | ␊ |
94 | ␉// IOUSBInterface class methods␊ |
95 | ␉virtual bool␉␉init(␉const IOUSBConfigurationDescriptor *cfDesc,␊ |
96 | ␉␉␉␉␉␉␉ const IOUSBInterfaceDescriptor *ifDesc);␊ |
97 | /*!␊ |
98 | @function FindNextAltInterface␊ |
99 | return alternate interface descriptor satisfying the requirements specified in request, or NULL if there aren't any.␊ |
100 | request is updated with the properties of the returned interface.␊ |
101 | @param current interface descriptor to start searching from, NULL to start at alternate interface 0.␊ |
102 | @param request specifies what properties an interface must have to match.␊ |
103 | @result Pointer to a matching interface descriptor, or NULL if none match.␊ |
104 | */␊ |
105 | virtual const IOUSBInterfaceDescriptor *FindNextAltInterface(const IOUSBInterfaceDescriptor *current,␊ |
106 | IOUSBFindInterfaceRequest *request);␊ |
107 | ␊ |
108 | /*!␊ |
109 | ␉@function FindNextPipe␊ |
110 | ␉Find a pipe of the interface that matches the requirements, either␊ |
111 | ␉starting from the beginning of the interface's pipe list or from a specified␊ |
112 | ␉pipe.␊ |
113 | ␉@param current Pipe to start searching from, NULL to start from beginning of list.␊ |
114 | ␉@param request Requirements for pipe to match, updated with the found pipe's␊ |
115 | ␉properties.␊ |
116 | ␉@result Pointer to the pipe, or NULL if no pipe matches the request.␊ |
117 | */␊ |
118 | virtual IOUSBPipe *FindNextPipe(IOUSBPipe *current, IOUSBFindEndpointRequest *request);␊ |
119 | ␊ |
120 | /*!␊ |
121 | @function FindNextAssociatedDescriptor␊ |
122 | Find the next descriptor of the requested type associated with the interface.␊ |
123 | ␉@param current Descriptor to start searching from, NULL to start from beginning of list.␊ |
124 | ␉@param type Descriptor type to search for, or kUSBAnyDesc to return any descriptor type.␊ |
125 | ␉@result Pointer to the descriptor, or NULL if no matching descriptors found.␊ |
126 | */␊ |
127 | virtual const IOUSBDescriptorHeader * FindNextAssociatedDescriptor(const void *current, UInt8 type);␊ |
128 | ␊ |
129 | /*!␊ |
130 | @function SetAlternateInterface␊ |
131 | Select the specified alternate interface.␊ |
132 | @param forClient The client requesting the alternate setting. This client must have the interface open in order to perform the request.␊ |
133 | ␉@param alternateSetting Alternate setting (from the alternate interface's interface descriptor).␊ |
134 | @result exclusive access error if the interface is not open. otherwise the result of the transaction␊ |
135 | */␊ |
136 | virtual IOReturn SetAlternateInterface(IOService *forClient, UInt16 alternateSetting);␊ |
137 | ␊ |
138 | /*!␊ |
139 | @function GetPipeObj␊ |
140 | ␉returns a handle to the pipe at the corresponding index␊ |
141 | @param index value from zero to kUSBMaxPipes-1␊ |
142 | ␉@result The IOUSBPipe object. Note that the client does not own a reference to this pipe, so the client should retain() the IOUSBPipe object if necessary.␊ |
143 | */␊ |
144 | virtual IOUSBPipe *GetPipeObj(UInt8 index);␊ |
145 | /*!␊ |
146 | @function GetConfigValue␊ |
147 | ␉returns the device configuration value for the interface␊ |
148 | ␉@result The device configuration value.␊ |
149 | */␊ |
150 | virtual UInt8 GetConfigValue();␊ |
151 | /*!␊ |
152 | @function GetDevice␊ |
153 | returns the device the interface is part of.␊ |
154 | ␉@result Pointer to the IOUSBDevice object which is the parent of this IOUSBInterface object.␊ |
155 | */␊ |
156 | virtual IOUSBDevice *GetDevice();␊ |
157 | /*!␊ |
158 | @function GetInterfaceNumber␊ |
159 | returns the zero based value identifying the index in the array of concurrent␊ |
160 | interfaces supported by the current configuration␊ |
161 | @result the interface index␊ |
162 | */␊ |
163 | virtual UInt8 GetInterfaceNumber();␊ |
164 | /*!␊ |
165 | @function GetAlternateSetting␊ |
166 | returns the alternate setting for this interface.␊ |
167 | @result the alternate setting␊ |
168 | */␊ |
169 | virtual UInt8 GetAlternateSetting();␊ |
170 | /*!␊ |
171 | @function GetNumEndpoints␊ |
172 | returns the number of endpoints used by this interface (excluding␊ |
173 | device endpoint zero. If the value is zero, this interface only␊ |
174 | uses endpoint zero.␊ |
175 | @result the number of endpoints␊ |
176 | */␊ |
177 | virtual UInt8 GetNumEndpoints();␊ |
178 | /*!␊ |
179 | @function GetInterfaceClass␊ |
180 | returns the class code for this interface (assigned by the USB)␊ |
181 | a value of zero is reserved␊ |
182 | if the value is FFh, the interface class is vendor-specific␊ |
183 | all other values are reserved for assignment by the USB␊ |
184 | @result the interface class␊ |
185 | */␊ |
186 | virtual UInt8 GetInterfaceClass();␊ |
187 | /*!␊ |
188 | @function GetInterfaceSubClass␊ |
189 | returns the subclass code (assigned by the USB).␊ |
190 | These codes are qualified by the value returned by GetInterfaceClass␊ |
191 | @result the interface subclass␊ |
192 | */␊ |
193 | virtual UInt8 GetInterfaceSubClass();␊ |
194 | /*!␊ |
195 | @function GetInterfaceProtocol␊ |
196 | returns the protocol code (assigned by the USB).␊ |
197 | @result the interface index␊ |
198 | */␊ |
199 | virtual UInt8 GetInterfaceProtocol();␊ |
200 | /*!␊ |
201 | @function GetInterfaceStringIndex␊ |
202 | returns the index of the string descriptor describing the interface␊ |
203 | @result the string index␊ |
204 | */␊ |
205 | virtual UInt8 GetInterfaceStringIndex();␊ |
206 | ␊ |
207 | /*!␊ |
208 | ␉@function DeviceRequest␊ |
209 | @abstract Sends a control request to the default control pipe in the device (pipe zero)␊ |
210 | @param request The parameter block to send to the device␊ |
211 | ␉␉@param completion Function to call when request completes. If omitted then␊ |
212 | DeviceRequest() executes synchronously, blocking until the request is complete. If the request is asynchronous, the client must make sure that␊ |
213 | ␉␉the IOUSBDevRequest is not released until the callback has occurred.␊ |
214 | */␊ |
215 | virtual IOReturn DeviceRequest(IOUSBDevRequest *request, IOUSBCompletion *completion = 0); ␊ |
216 | ␊ |
217 | /*!␊ |
218 | ␉ @function DeviceRequest␊ |
219 | ␉ @abstract Sends a control request to the default control pipe in the device (pipe zero)␊ |
220 | ␉ @param request The parameter block to send to the device (with the pData as an IOMemoryDesriptor)␊ |
221 | ␉ @param completion Function to call when request completes. If omitted then␊ |
222 | ␉ DeviceRequest() executes synchronously, blocking until the request is complete. If the request is asynchronous, the client must make sure that␊ |
223 | ␉ the IOUSBDevRequest is not released until the callback has occurred.␊ |
224 | ␉ */␊ |
225 | virtual IOReturn DeviceRequest(IOUSBDevRequestDesc *request, IOUSBCompletion *completion = 0);␊ |
226 | ␊ |
227 | virtual bool matchPropertyTable(OSDictionary * table, SInt32 *score);␊ |
228 | ␊ |
229 | OSMetaClassDeclareReservedUsed(IOUSBInterface, 0);␊ |
230 | /*!␊ |
231 | ␉@function GetEndpointProperties␊ |
232 | @abstract Returns the properties of an endpoint, possibly in an alternate interface.␊ |
233 | @param alternateSetting specifies the desired alternate setting␊ |
234 | @param endpointNumber specifies the endpoint number␊ |
235 | @param direction specifies the direction (kUSBIn, kUSBOut)␊ |
236 | @param transferType a pointer to hold the transfer type (kUSBControl, kUSBBulk, etc.) of the endpoint if found.␊ |
237 | @param maxPacketSize a pointer to hold the maxPacketSize in the endpoint descriptor.␊ |
238 | @param interval a pointer to hold the interval value in the endpoint descriptor.␊ |
239 | ␉@result returns kIOReturnSuccess if the endpoint is found, and kIOUSBEndpointNotFound if it is not.␊ |
240 | */␊ |
241 | virtual IOReturn GetEndpointProperties(UInt8 alternateSetting, UInt8 endpointNumber, UInt8 direction, UInt8 *transferType, UInt16 *maxPacketSize, UInt8 *interval);␊ |
242 | ␊ |
243 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 1);␊ |
244 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 2);␊ |
245 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 3);␊ |
246 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 4);␊ |
247 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 5);␊ |
248 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 6);␊ |
249 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 7);␊ |
250 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 8);␊ |
251 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 9);␊ |
252 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 10);␊ |
253 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 11);␊ |
254 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 12);␊ |
255 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 13);␊ |
256 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 14);␊ |
257 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 15);␊ |
258 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 16);␊ |
259 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 17);␊ |
260 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 18);␊ |
261 | OSMetaClassDeclareReservedUnused(IOUSBInterface, 19);␊ |
262 | };␊ |
263 | ␊ |
264 | #endif /* _IOKIT_IOUSBINTERFACE_H */␊ |
265 |