Chameleon

Chameleon Svn Source Tree

Root/branches/Chimera/i386/include/IOKit/usb/IOUSBPipe.h

1/*
2 * Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.2 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
17 * Please see the License for the specific language governing rights and
18 * limitations under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23#ifndef _IOKIT_IOUSBPIPE_H
24#define _IOKIT_IOUSBPIPE_H
25
26#include <IOKit/IOService.h>
27#include <IOKit/IOMemoryDescriptor.h>
28
29#include <IOKit/usb/USB.h>
30#include <IOKit/usb/IOUSBController.h>
31#include <IOKit/usb/IOUSBControllerV2.h>
32
33class IOUSBInterface;
34
35/*!
36 @class IOUSBPipe
37 @abstract The object representing an open pipe for a device.
38*/
39class IOUSBPipe : public OSObject
40{
41 friend class IOUSBInterface;
42 friend class IOUSBDevice;
43
44 OSDeclareDefaultStructors(IOUSBPipe)
45
46protected:
47
48const IOUSBEndpointDescriptor *_descriptor;
49 IOUSBController::Endpoint_endpoint;// tidied up version of descriptor
50 IOUSBController *_controller;
51 USBDeviceAddress_address;
52 UInt8_status;// was previously used for status. Now used to detect whether a property exists or not
53
54 struct ExpansionData
55 {
56 IOReturn_correctStatus;
57IOUSBDevice *_device;// Remember containing device for clearing TTs
58UInt8_speed;
59IOUSBInterface*_interface;
60bool_crossEndianCompatible;
61UInt32_locationID;
62 };
63 ExpansionData * _expansionData;
64
65 virtual void free();
66
67 IOReturn ClosePipe(void);
68
69public:
70
71virtual bool InitToEndpoint(const IOUSBEndpointDescriptor *endpoint, UInt8 speed,
72USBDeviceAddress address, IOUSBController * controller);
73
74 // The following 2 methods are obsolete
75 //
76 static IOUSBPipe *ToEndpoint(const IOUSBEndpointDescriptor *endpoint, UInt8 speed,
77 USBDeviceAddress address, IOUSBController * controller);
78
79 static IOUSBPipe *ToEndpoint(const IOUSBEndpointDescriptor *endpoint,
80 IOUSBDevice * device, IOUSBController * controller);
81
82 static IOUSBPipe *ToEndpoint(const IOUSBEndpointDescriptor *endpoint,
83 IOUSBDevice * device, IOUSBController * controller, IOUSBInterface *interface);
84
85 // Controlling pipe state
86 /*!
87 @function GetStatus
88 This method does NOT work. Do not call it. See GetPipeStatus for the correct method.
89 GetStatus will always return 0.
90 */
91 virtual UInt8 GetStatus(void);
92 /*!
93 @function Abort
94 This method causes all outstanding I/O on a pipe to complete with return code kIOReturnAborted. It clears the halted bit but does NOT clear the
95 toggle bit on the endpoint in the controller. If you wish to clear the toggle bit, see ClearPipeStall
96 */
97 virtual IOReturn Abort(void);
98 /*!
99 @function Reset
100 This method is identical to ClearPipeStall(false). The use of that API is preferred.
101 */
102 virtual IOReturn Reset(void);
103 /*!
104 @function ClearStall
105 This method is equivalent to ClearPipeStall(false). This method is available before version 1.9.
106 */
107 virtual IOReturn ClearStall(void);
108
109 //
110 // Transferring Data
111 //
112
113 // deprecated
114 virtual IOReturn Read(IOMemoryDescriptor *buffer,
115 IOUSBCompletion *completion = 0,
116 IOByteCount *bytesRead = 0);
117
118 // deprecated
119 virtual IOReturn Write(IOMemoryDescriptor *buffer,
120 IOUSBCompletion *completion = 0);
121
122 // Transfer data over Isochronous pipes
123 /*!
124 @function Read
125 Read from an isochronous endpoint
126 @param buffer place to put the transferred data
127 @param frameStart USB frame number of the frame to start transfer
128 @param numFrames Number of frames to transfer
129 @param frameList Bytes to transfer and result for each frame
130 @param completion describes action to take when buffer has been filled
131 */
132 virtual IOReturn Read(IOMemoryDescriptor *buffer,
133 UInt64 frameStart, UInt32 numFrames, IOUSBIsocFrame *frameList,
134 IOUSBIsocCompletion *completion = 0);
135 /*!
136 @function Write
137 Write to an isochronous endpoint
138 @param buffer place to get the transferred data
139 @param frameStart USB frame number of the frame to start transfer
140 @param numFrames Number of frames to transfer
141 @param frameList Bytes to transfer and result for each frame
142 @param completion describes action to take when buffer has been emptied
143 */
144 virtual IOReturn Write(IOMemoryDescriptor *buffer,
145 UInt64 frameStart, UInt32 numFrames, IOUSBIsocFrame *frameList,
146 IOUSBIsocCompletion * completion = 0);
147
148 // Do a control request over a Control pipe, using a memory descriptor
149 /*!
150 @function ControlRequest
151 Make a control request
152 There are two versions of this method, one uses a simple void *
153 to point to the data portion of the transfer, the other uses an
154 IOMemoryDescriptor to point to the data.
155 @param request parameter block for the control request
156 @param completion describes action to take when the request has been executed
157 */
158 virtual IOReturn ControlRequest(IOUSBDevRequestDesc*request,
159 IOUSBCompletion*completion = 0);
160
161 // Do a control request over a Control pipe, using a simple buffer
162 virtual IOReturn ControlRequest(IOUSBDevRequest*request,
163 IOUSBCompletion*completion = 0);
164
165/*
166 * Accessors
167 */
168 /*!
169 @function GetEndpoint
170 returns a pointer to the Endpoint structure for the pipe.
171 */
172 virtual const IOUSBController::Endpoint *GetEndpoint();
173 /*!
174 @function GetEndpointDescriptor
175 returns the endpoint descriptor for the pipe.
176 */
177 virtual const IOUSBEndpointDescriptor *GetEndpointDescriptor();
178 /*!
179 @function GetDirection
180 returns the direction of the pipe:kUSBOut/kUSBIn for a bulk or interrupt pipe,
181 kUSBAnyDirn for a control pipe.
182 */
183 virtual UInt8 GetDirection();
184 /*!
185 @function GetType
186 returns the pipe type: kUSBControl, kUSBBulk or kUSBInterrupt.
187 */
188 virtual UInt8 GetType();
189 /*!
190 @function GetEndpointNumber
191 returns the endpoint number in the device that the pipe is connected to.
192 */
193 virtual UInt8 GetEndpointNumber();
194 virtual USBDeviceAddress GetAddress();
195 virtual UInt16 GetMaxPacketSize();
196 virtual UInt8 GetInterval();
197
198 // Transfer data over Bulk pipes with timeouts.
199 OSMetaClassDeclareReservedUsed(IOUSBPipe, 0);
200
201 // deprecated
202 virtual IOReturn Read(IOMemoryDescriptor *buffer,
203 UInt32noDataTimeout,
204 UInt32completionTimeout,
205 IOUSBCompletion *completion = 0,
206 IOByteCount *bytesRead = 0);
207
208 OSMetaClassDeclareReservedUsed(IOUSBPipe, 1);
209
210 // deprecated
211 virtual IOReturn Write(IOMemoryDescriptor *buffer,
212 UInt32noDataTimeout,
213 UInt32completionTimeout,
214 IOUSBCompletion *completion = 0);
215
216 OSMetaClassDeclareReservedUsed(IOUSBPipe, 2);
217 // Do a control request over a Control pipe, using a memory descriptor
218 /*!
219 @function ControlRequest
220 Make a control request.
221 There are two versions of this method, one uses a simple void *
222 to point to the data portion of the transfer, the other uses an
223 IOMemoryDescriptor to point to the data.
224 @param request parameter block for the control request
225 @param noDataTimeout Specifies an amount of time (in ms) after which the command will be aborted
226 if no data has been transferred on the bus.
227 @param completionTimeout Specifies an amount of time (in ms) after which the command will be aborted if the entire command has
228 not been completed.
229 @param completion describes action to take when the request has been executed
230 */
231 virtual IOReturn ControlRequest(IOUSBDevRequestDesc*request,
232UInt32noDataTimeout,
233UInt32completionTimeout,
234 IOUSBCompletion*completion = 0);
235
236 OSMetaClassDeclareReservedUsed(IOUSBPipe, 3);
237 // Do a control request over a Control pipe, using a simple buffer
238 virtual IOReturn ControlRequest(IOUSBDevRequest*request,
239UInt32noDataTimeout,
240UInt32completionTimeout,
241 IOUSBCompletion*completion = 0);
242
243 OSMetaClassDeclareReservedUsed(IOUSBPipe, 4);
244 /*!
245 @function Read
246 Read from an interrupt or bulk endpoint
247 @param buffer place to put the transferred data
248 @param noDataTimeout number of milliseconds of no bus activity until transaction times out. Note that if a tranasction times out
249 the driver software may have to resynchronize the data toggle. See ClearPipeStall.
250 @param completionTimeout number of milliseconds from the time the transaction is placed on the bus until it times out
251 @param reqCount requested number of bytes to transfer. must be <= buffer->getLength()
252 @param completion describes action to take when buffer has been filled
253 @param bytesRead returns total bytes read for synchronous reads
254 */
255 virtual IOReturn Read(IOMemoryDescriptor *buffer,
256 UInt32noDataTimeout,
257 UInt32completionTimeout,
258 IOByteCountreqCount,
259 IOUSBCompletion *completion = 0,
260 IOByteCount *bytesRead = 0);
261
262 OSMetaClassDeclareReservedUsed(IOUSBPipe, 5);
263 /*!
264 @function Write
265 Write to an interrupt or bulk endpoint
266 @param buffer place to get the transferred data
267 @param noDataTimeout number of milliseconds of no bus activity until transaction times out. Note that if a tranasction times out
268 the driver software may have to resynchronize the data toggle. See ClearPipeStall.
269 @param completionTimeout number of milliseconds from the time the transaction is placed on the bus until it times out
270 @param reqCount requested number of bytes to transfer. must be <= buffer->getLength()
271 @param completion describes action to take when buffer has been emptied
272 */
273 virtual IOReturn Write(IOMemoryDescriptor *buffer,
274 UInt32noDataTimeout,
275 UInt32completionTimeout,
276 IOByteCountreqCount,
277 IOUSBCompletion *completion = 0);
278
279 OSMetaClassDeclareReservedUsed(IOUSBPipe, 6);
280 /*!
281 @function GetPipeStatus
282 Returns the status of the pipe (kIOUSBPipeStalled of the pipe is stalled, else kIOReturnSuccess)
283 */
284 virtual IOReturn GetPipeStatus(void);
285
286 OSMetaClassDeclareReservedUsed(IOUSBPipe, 7);
287 /*!
288@function ClearPipeStall
289 AVAILABLE ONLY IN VERSION 1.9 AND ABOVE
290 This method causes all outstanding I/O on a pipe to complete with return code kIOUSBTransactionReturned. It also clears both the halted bit and the
291 toggle bit on the endpoint in the controller. The driver may need to reset the data toggle within the device to avoid losing any data. If the
292 device correctly handles the ClearFeature(ENDPOINT_HALT) device request, then this API will handle that by sending the correct request to the
293 device.
294 @param withDeviceRequest if true, a ClearFeature(ENDPOINT_HALT) is sent to the appropriate endpoint on the device after the transactions on the
295 controllers endpoint are returned and the toggle bit on the controllers endpoint is cleared. if this parameter is false, then this is equivalent
296 to the pre-1.9 API. This means that the endpoint on the controller is cleared, but no DeviceRequest is sent to the device's endpoint.
297 */
298 virtual IOReturn ClearPipeStall(bool withDeviceRequest);
299
300 OSMetaClassDeclareReservedUsed(IOUSBPipe, 8);
301 /*!
302@function SetPipePolicy
303 AVAILABLE ONLY IN VERSION 1.9 AND ABOVE
304 This method allows a driver to change the maxPacketSize of an Isochronous pipe, or the polling interval for an interrupt pipe. There is a limited
305 amount of bandwidth on any single bus, and isochronous pipes tend to use much of this bandwidth. The driver may know, however, that there
306 will never be as much bandwidth used as is specified in the pipe's endpoint descriptor. Therefore, the driver may return some of this
307 bandwidth to the system by using this method. Additionally, if on an open of an IOUSBInterface any of the Isochronous pipes is unable to be
308 opened because of a lack of bandwidth, the pipe will be created with a bandwidth of zero, and the driver may get some of the limited bandwidth
309 remaining by using this call.
310 This method returns kIOReturnBadArgument if the pipe is a bulk on control pipe, or if the maxPacketSize parameter is larger than the amount specified
311 in the endpoint descriptor. It returns kIOReturnNoBandwidth if the bandwidth requested cannot be allocated. Otherwise it returns kIOReturnSuccess.
312 @param maxPacketSize specifies the maximum number of bytes to be used in any one millisecond frame by this pipe. The value must be less than or
313 equal to the maxPacketSize specified in the endpoint descriptor.
314 @param maxInterval not currently used. reserved for future expansion
315
316 */
317 virtual IOReturn SetPipePolicy(UInt16 maxPacketSize, UInt8 maxInterval);
318
319 OSMetaClassDeclareReservedUsed(IOUSBPipe, 9);
320
321 // Transfer data over Isochronous pipes and process the frame list at hardware interrupt time
322 /*!
323 @function Read
324 AVAILABLE ONLY IN VERSION 1.9.2 AND ABOVE
325 Read from an isochronous endpoint and process the IOUSBLowLatencyIsocFrame fields at
326 hardware interrupt time
327 @param buffer place to put the transferred data
328 @param frameStart USB frame number of the frame to start transfer
329 @param numFrames Number of frames to transfer
330 @param frameList Bytes to transfer, result, and time stamp for each frame
331 @param completion describes action to take when buffer has been filled
332 @param updateFrequency describes how often (in milliseconds) should the frame list be processed
333 */
334 virtual IOReturn Read(IOMemoryDescriptor *buffer,
335 UInt64 frameStart, UInt32 numFrames, IOUSBLowLatencyIsocFrame *frameList,
336 IOUSBLowLatencyIsocCompletion *completion = 0, UInt32 updateFrequency = 0);
337
338 OSMetaClassDeclareReservedUsed(IOUSBPipe, 10);
339 /*!
340 @function Write
341 AVAILABLE ONLY IN VERSION 1.9.2 AND ABOVE
342 Write to an isochronous endpoint
343 @param buffer place to get the data to transfer
344 @param frameStart USB frame number of the frame to start transfer
345 @param numFrames Number of frames to transfer
346 @param frameList Pointer to list of frames indicating bytes to transfer and result for each frame
347 @param completion describes action to take when buffer has been emptied
348 @param updateFrequency describes how often (in milliseconds) should the frame list be processed
349 */
350 virtual IOReturn Write(IOMemoryDescriptor *buffer,
351 UInt64 frameStart, UInt32 numFrames, IOUSBLowLatencyIsocFrame *frameList,
352 IOUSBLowLatencyIsocCompletion * completion = 0, UInt32 updateFrequency = 0);
353
354 OSMetaClassDeclareReservedUsed(IOUSBPipe, 11);
355 /*!
356 @function Read
357 Read from an interrupt or bulk endpoint
358 @param buffer place to put the transferred data
359 @param noDataTimeout number of milliseconds of no bus activity until transaction times out. Note that if a tranasction times out
360 the driver software may have to resynchronize the data toggle. See ClearPipeStall.
361 @param completionTimeout number of milliseconds from the time the transaction is placed on the bus until it times out
362 @param reqCount requested number of bytes to transfer. must be <= buffer->getLength()
363 @param completion describes action to take when buffer has been filled
364 @param bytesRead returns total bytes read for synchronous reads
365 */
366 virtual IOReturn Read(IOMemoryDescriptor *buffer,
367 UInt32noDataTimeout,
368 UInt32completionTimeout,
369 IOByteCountreqCount,
370 IOUSBCompletionWithTimeStamp *completion = 0,
371 IOByteCount *bytesRead = 0);
372
373 OSMetaClassDeclareReservedUsed(IOUSBPipe, 12);
374virtual bool InitToEndpoint(const IOUSBEndpointDescriptor *endpoint, UInt8 speed,
375USBDeviceAddress address, IOUSBController * controller, IOUSBDevice * device, IOUSBInterface * interface);
376
377 OSMetaClassDeclareReservedUnused(IOUSBPipe, 13);
378 OSMetaClassDeclareReservedUnused(IOUSBPipe, 14);
379 OSMetaClassDeclareReservedUnused(IOUSBPipe, 15);
380 OSMetaClassDeclareReservedUnused(IOUSBPipe, 16);
381 OSMetaClassDeclareReservedUnused(IOUSBPipe, 17);
382 OSMetaClassDeclareReservedUnused(IOUSBPipe, 18);
383 OSMetaClassDeclareReservedUnused(IOUSBPipe, 19);
384
385};
386
387#endif /* _IOKIT_IOUSBPIPE_H */
388

Archive Download this file

Revision: 2225