Chameleon

Chameleon Svn Source Tree

Root/branches/slice/trunkM/i386/include/IOKit/usb/IOUSBControllerV2.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_IOUSBCONTROLLERV2_H
24#define _IOKIT_IOUSBCONTROLLERV2_H
25
26#include <IOKit/IODMACommand.h>
27
28#include <IOKit/usb/IOUSBControllerListElement.h>
29#include <IOKit/usb/IOUSBController.h>
30
31enum
32{
33 kUSBHSHubCommandAddHub= 1,
34 kUSBHSHubCommandRemoveHub= 2,
35
36 kUSBHSHubFlagsMultiTT= 1
37};
38
39
40/*!
41 @class IOUSBControllerV2
42 @abstract subclass of the IOUSBController to provide support for high speed
43 devices and split transactions.
44 @discussion The IOUSBController class provide sufficient functionality to
45 work with full (12Mb/s) and low (1.5Mb/s) devices. IOUSBControllerV2
46 introduces the support for high (480Mb/s) speed devices from the
47 USB 2.0 spec. In particular IOUSBControllerV2 indicates the high
48 speed hub a full or low speed device is attached to so that split
49 transactions can be directed to the hub at high speed to be forwarded
50 to the full or low speed device by the hub.
51 It also gives support for bulk endoints of greater than 256 bytes.
52*/
53
54class IOUSBControllerV2 : public IOUSBController
55{
56 OSDeclareAbstractStructors(IOUSBControllerV2)
57
58protected:
59
60 // These for keeping track of high speed ancestor to allow controller to do splits.
61 //
62 UInt8 _highSpeedHub[128];
63 UInt8 _highSpeedPort[128];
64
65 struct V2ExpansionData {
66UInt8_multiTT[128];
67IOUSBCommand*ClearTTCommand;
68IOUSBControllerIsochEndpoint*_isochEPList;// linked list of active Isoch "endpoints"
69IOUSBControllerIsochEndpoint*_freeIsochEPList;// linked list of freed Isoch EP data structures
70thread_call_t_returnIsochDoneQueueThread;
71};
72 V2ExpansionData *_v2ExpansionData;
73
74 // Super's expansion data
75 #define _freeUSBCommandPool_expansionData->freeUSBCommandPool
76 #define _freeUSBIsocCommandPool_expansionData->freeUSBIsocCommandPool
77 #define _watchdogUSBTimer_expansionData->watchdogUSBTimer
78 #define _controllerTerminating_expansionData->_terminating
79 #define _watchdogTimerActive_expansionData->_watchdogTimerActive
80 #define _busNumber_expansionData->_busNumber
81 #define _currentSizeOfCommandPool_expansionData->_currentSizeOfCommandPool
82 #define _currentSizeOfIsocCommandPool_expansionData->_currentSizeOfIsocCommandPool
83 #define _controllerSpeed_expansionData->_controllerSpeed
84#define _activeIsochTransfers_expansionData->_activeIsochTransfers
85
86// this class's expansion data
87#define _isochEPList_v2ExpansionData->_isochEPList
88#define _freeIsochEPList_v2ExpansionData->_freeIsochEPList
89#define _returnIsochDoneQueueThread_v2ExpansionData->_returnIsochDoneQueueThread
90
91 virtual bool init( OSDictionary * propTable );
92 virtual bool start( IOService * provider );
93 virtual voidfree();
94
95 static IOReturn DoCreateEP(OSObject *owner,
96 void *arg0, void *arg1,
97 void *arg2, void *arg3);
98
99 static voidclearTTHandler(
100OSObject *target,
101 void *parameter,
102 IOReturnstatus,
103 UInt32bufferSizeRemaining );
104
105public:
106
107 /*!
108 @function openPipe
109 Open a pipe to the specified device endpoint
110 @param address Address of the device on the USB bus
111 @param speed of the device: kUSBDeviceSpeedLow, kUSBDeviceSpeedFull or kUSBDeviceSpeedHigh
112 @param endpoint description of endpoint to connect to
113 */
114 virtual IOReturn OpenPipe( USBDeviceAddress address,
115 UInt8 speed,
116 Endpoint *endpoint );
117
118 /*!
119 @function CreateDevice
120 @abstract Create a new device as IOUSBController, making a note of the
121 high speed hub device ID and port number the full/low speed
122 device is attached to.
123 @param newDevice new device object to work with
124 @param deviceAddress USB device ID
125 @param maxPacketSize max packet size of endpoint zero
126 @param speed speed of the device kUSBDeviceSpeedLow, kUSBDeviceSpeedFull, kUSBDeviceSpeedHigh
127 @param powerAvailable power available to the device
128 @param hub USB ID of hub the device is immediatly attached to. (Not necessarily high speed)
129 @param port port number of port the device is attached to.
130*/
131 virtual IOReturn CreateDevice(IOUSBDevice *newDevice,
132 USBDeviceAddressdeviceAddress,
133 UInt8 maxPacketSize,
134 UInt8speed,
135 UInt32powerAvailable,
136 USBDeviceAddresshub,
137 int port);
138
139/*!
140@function ConfigureDeviceZero
141 @abstract configure pipe zero of device zero, as IOUSBController, but also keeping
142 note of high speed hub device is attached to.
143 @param maxPacketSize max packet size for the pipe
144 @param speed speed of the device kUSBDeviceSpeedLow, kUSBDeviceSpeedFull, kUSBDeviceSpeedHigh
145 @param hub USB ID of hub the device is immediatly attached to. (Not necessarily high speed)
146 @param port port number of port the device is attached to.
147*/
148 virtual IOReturn ConfigureDeviceZero(UInt8 maxPacketSize, UInt8 speed, USBDeviceAddress hub, int port);
149
150/*!
151@function UIMCreateControlEndpoint
152 @abstract Create an endpoint in the controller to do control transactions.
153 @param functionNumber USB device ID of device
154 @param endpointNumber endpoint address of the endpoint in the device
155 @param maxPacketSize maximum packet size of this endpoint
156 @param speed speed of the device kUSBDeviceSpeedLow, kUSBDeviceSpeedFull, kUSBDeviceSpeedHigh
157 @param highSpeedHub If speed is not kUSBDeviceSpeedHigh, the address of the high speed hub to
158 address split transactions to.
159 @param highSpeedPort If speed is not kUSBDeviceSpeedHigh, the hub port to address split transactions to
160*/
161 virtual IOReturn UIMCreateControlEndpoint(
162 UInt8functionNumber,
163 UInt8endpointNumber,
164 UInt16maxPacketSize,
165 UInt8speed,
166 USBDeviceAddress highSpeedHub,
167 int highSpeedPort) = 0;
168
169/*!
170@function UIMCreateBulkEndpoint
171 @abstract Create an endpoint in the controller to do bulk transactions.
172 @param functionNumber USB device ID of device
173 @param endpointNumber endpoint address of the endpoint in the device
174 @param direction Direction of data flow. kUSBIn or kUSBOut
175 @param maxPacketSize maximum packet size of this endpoint
176 @param speed speed of the device kUSBDeviceSpeedFull, kUSBDeviceSpeedHigh
177 @param highSpeedHub If speed is not kUSBDeviceSpeedHigh, the address of the high speed hub to
178 address split transactions to.
179 @param highSpeedPort If speed is not kUSBDeviceSpeedHigh, the hub port to address split transactions to
180*/
181 virtual IOReturn UIMCreateBulkEndpoint(
182 UInt8functionNumber,
183 UInt8endpointNumber,
184 UInt8direction,
185 UInt8speed,
186 UInt16maxPacketSize,
187 USBDeviceAddress highSpeedHub,
188 int highSpeedPort) = 0;
189
190/*!
191@function UIMCreateInterruptEndpoint
192 @abstract Create an endpoint in the controller to do interrupt transactions.
193 @param functionAddress USB device ID of device
194 @param endpointNumber endpoint address of the endpoint in the device
195 @param direction Direction of data flow. kUSBIn or kUSBOut
196 @param speed speed of the device kUSBDeviceSpeedLow, kUSBDeviceSpeedFull, kUSBDeviceSpeedHigh
197 @param maxPacketSize maximum packet size of this endpoint
198 @param pollingRate The maximum polling interval from the endpoint descriptor.
199 @param highSpeedHub If speed is not kUSBDeviceSpeedHigh, the address of the high speed hub to
200 address split transactions to.
201 @param highSpeedPort If speed is not kUSBDeviceSpeedHigh, the hub port to address split transactions to
202*/
203 virtual IOReturnUIMCreateInterruptEndpoint(
204 shortfunctionAddress,
205 shortendpointNumber,
206 UInt8direction,
207 shortspeed,
208 UInt16maxPacketSize,
209 shortpollingRate,
210 USBDeviceAddress highSpeedHub,
211 int highSpeedPort) = 0;
212
213/*!
214@function UIMCreateIsochEndpoint
215 @abstract Create an endpoint in the controller to do Isochronous transactions.
216 @param functionAddress USB device ID of device
217 @param endpointNumber endpoint address of the endpoint in the device
218 @param maxPacketSize maximum packet size of this endpoint
219 @param direction Specifies direction for the endpoint. kUSBIn or KUSBOut.
220 @param highSpeedHub If non zero, this is a full speed device, the address of the high speed hub to
221 address split transactions to.
222 @param highSpeedPort If highSpeedHub is non zero, the hub port to address split transactions to
223*/
224 virtual IOReturn UIMCreateIsochEndpoint(
225 shortfunctionAddress,
226 shortendpointNumber,
227 UInt32maxPacketSize,
228 UInt8direction,
229 USBDeviceAddresshighSpeedHub,
230 inthighSpeedPort) = 0;
231
232
233static void ReturnIsochDoneQueueEntry(OSObject *target, thread_call_param_t endpointPtr);
234
235
236OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 0);
237 virtual IOReturnAddHSHub(USBDeviceAddress highSpeedHub, UInt32 flags);
238
239 static IOReturn DOHSHubMaintenance(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3);
240
241 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 1);
242 virtual IOReturn UIMHubMaintenance(USBDeviceAddress highSpeedHub, UInt32 highSpeedPort, UInt32 command, UInt32 flags);
243
244 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 2);
245 virtual IOReturnRemoveHSHub(USBDeviceAddress highSpeedHub);
246
247 static IOReturn DOSetTestMode(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3);
248
249 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 3);
250 virtual IOReturnSetTestMode(UInt32 mode, UInt32 port);
251
252 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 4);
253 virtual IOReturnUIMSetTestMode(UInt32 mode, UInt32 port);
254
255 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 5);
256 virtual UInt64GetMicroFrameNumber( void );
257
258 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 6);
259 virtual void ClearTT(USBDeviceAddress addr, UInt8 endpt, Boolean IN);
260
261 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 7);
262 /*!
263 @function Read
264 Read from an interrupt or bulk endpoint
265 @param buffer place to put the transferred data
266 @param address Address of the device on the USB bus
267 @param endpoint description of endpoint
268 @param completion describes action to take when buffer has been filled
269 @param noDataTimeout number of milliseconds of no data movement before the request is aborted
270 @param completionTimeout number of milliseonds after the command is on the bus in which it must complete
271 @param reqCount number of bytes requested for the transfer (must not be greater than the length of the buffer)
272 */
273 virtual IOReturn ReadV2( IOMemoryDescriptor *buffer,
274 USBDeviceAddressaddress,
275 Endpoint *endpoint,
276 IOUSBCompletionWithTimeStamp *completion,
277 UInt32noDataTimeout,
278 UInt32completionTimeout,
279 IOByteCountreqCount );
280
281 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 8);
282/*!
283@function UIMCreateIsochEndpoint
284 @abstract Create an endpoint in the controller to do Isochronous transactions.
285 @param functionAddress USB device ID of device
286 @param endpointNumber endpoint address of the endpoint in the device
287 @param maxPacketSize maximum packet size of this endpoint
288 @param direction Specifies direction for the endpoint. kUSBIn or KUSBOut.
289 @param highSpeedHub If non zero, this is a full speed device, the address of the high speed hub to
290 address split transactions to.
291 @param highSpeedPort If highSpeedHub is non zero, the hub port to address split transactions to
292@param interval The encoded interval value from the endpoint descriptor
293*/
294 virtual IOReturn UIMCreateIsochEndpoint(shortfunctionAddress,
295 shortendpointNumber,
296 UInt32maxPacketSize,
297 UInt8direction,
298 USBDeviceAddresshighSpeedHub,
299 inthighSpeedPort,
300UInt8interval);
301
302
303 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 9);
304virtual IOUSBControllerIsochEndpoint*AllocateIsochEP(void);
305
306 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 10);
307virtual IOReturnDeallocateIsochEP(IOUSBControllerIsochEndpoint *pEP);
308
309OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 11);
310 virtual IOUSBControllerIsochEndpoint* FindIsochronousEndpoint(short functionNumber, short endpointNumber, short direction, IOUSBControllerIsochEndpoint* *pEDBack);
311
312 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 12);
313 virtual IOUSBControllerIsochEndpoint*CreateIsochronousEndpoint(short functionNumber, short endpointNumber, short direction);
314
315 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 13);
316 virtual voidPutTDonToDoList(IOUSBControllerIsochEndpoint* pED, IOUSBControllerIsochListElement *pTD);
317
318 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 14);
319 virtual IOUSBControllerIsochListElement*GetTDfromToDoList(IOUSBControllerIsochEndpoint* pED);
320
321 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 15);
322 virtual voidPutTDonDeferredQueue(IOUSBControllerIsochEndpoint* pED, IOUSBControllerIsochListElement *pTD);
323
324 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 16);
325virtual IOUSBControllerIsochListElement*GetTDfromDeferredQueue(IOUSBControllerIsochEndpoint* pED);
326
327 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 17);
328 virtual voidPutTDonDoneQueue(IOUSBControllerIsochEndpoint* pED, IOUSBControllerIsochListElement *pTD, bool checkDeferred);
329
330 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 18);
331 virtual IOUSBControllerIsochListElement*GetTDfromDoneQueue(IOUSBControllerIsochEndpoint* pED);
332
333// 7185026 - this is to make this call from behind the gate
334 static IOReturnGatedGetTDfromDoneQueue(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);
335
336 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 19);
337 virtual voidReturnIsochDoneQueue(IOUSBControllerIsochEndpoint*);
338
339 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 20);
340virtual IODMACommand*GetNewDMACommand();
341
342 OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 21);
343/*!
344 @function GetLowLatencyOptionsAndPhysicalMask
345 @abstract Low Latency transfers require that the client have access to the memory after the Isochronous I/O request has already been scheduled. This might be used, for example to fill in outgoing data "just in time." Some controllers, however, may have requirements which need to be followed in order to make sure that the memory buffer isn't moved after the call is made. This call will return an IOOptionBits and mach_vm_address_t which can be used in a call to IOBufferMemoryDescriptor::inTaskWithPhysicalMask which will help meet these requirements.
346 @param optionBits Pointer to an an IOOptionBits. The only bit which may be returned is kIOMemoryPhysicallyContiguous. Other bits, e.g. direction bits, must be ORd in by the client as needed. This call replaces the old property based method of obtaining this information.
347 @param physicalMask Pointer to a mach_vm_address_t which should be used in the call to IOBufferMemoryDescriptor::inTaskWithPhysicalMask and will guarantee that when the memory is wired down it will be accessible by both the client and the USB controller at the same time.
348 @result returns kIOReturnSuccess if the method is implemented by the controller, otherwise kIOReturnUnsupported
349 */
350 virtual IOReturn GetLowLatencyOptionsAndPhysicalMask(IOOptionBits *optionBits, mach_vm_address_t *physicalMask);
351
352OSMetaClassDeclareReservedUsed(IOUSBControllerV2, 22);
353/*!
354 @function GetFrameNumberWithTime
355 @abstract Real Time A/V applications send and receive Iscohronous data scheduled on certain USB frame numbers. The clock for these frame numbers is independent of the system clock, and drivers need to synchronize these two clocks. This routine will return a system time which corresponds to the beginning of a USB frame number. It is not necessarily the currrent frame, but it will be a frame in the recent past (within the past minute). The jitter between the start of the USB frame and the system time will be as low as possible, but due to hardware interrupt latencies could be as high as 200 microseconds.
356 @param frameNumber A pointer to a UInt64 in which to hold the USB frame number corresponding to the given system time.
357 @param theTime A pointer to an AbsoluteTime corresponding to the system time at the beginning of the given USB frame number.
358 @result returns kIOReturnSuccess if the method is implemented by the controller, otherwise kIOReturnUnsupported
359 */
360virtual IOReturnGetFrameNumberWithTime(UInt64* frameNumber, AbsoluteTime *theTime);
361
362
363OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 23);
364 OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 24);
365 OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 25);
366 OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 26);
367 OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 27);
368 OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 28);
369 OSMetaClassDeclareReservedUnused(IOUSBControllerV2, 29);
370
371};
372
373
374#endif /* ! _IOKIT_IOUSBCONTROLLERV2_H */
375

Archive Download this file

Revision: 1171