Chameleon

Chameleon Svn Source Tree

Root/branches/mozodojo/i386/include/IOKit/usb/IOUSBController.h

1/*
2 * Copyright (c) 1998-2010 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_IOUSBCONTROLLER_H
24#define _IOKIT_IOUSBCONTROLLER_H
25
26//================================================================================================
27//
28// Headers
29//
30//================================================================================================
31//
32#include <libkern/c++/OSArray.h>
33
34#include <IOKit/IOService.h>
35#include <IOKit/IOMemoryDescriptor.h>
36#include <IOKit/IODeviceMemory.h>
37#include <IOKit/IOWorkLoop.h>
38#include <IOKit/IOCommandGate.h>
39#include <IOKit/IOCommandPool.h>
40
41#include <IOKit/usb/USB.h>
42#include <IOKit/usb/USBHub.h>
43#include <IOKit/usb/IOUSBBus.h>
44#include <IOKit/usb/IOUSBNub.h>
45#include <IOKit/usb/IOUSBCommand.h>
46#include <IOKit/usb/IOUSBWorkLoop.h>
47
48
49//================================================================================================
50//
51// Types and Constants
52//
53//================================================================================================
54//
55enum
56{
57 kErrataCMDDisableTestMode= (1 << 0),// turn off UHCI test mode
58 kErrataOnlySinglePageTransfers= (1 << 1),// Don't cross page boundaries in a single transfer
59 kErrataRetryBufferUnderruns= (1 << 2),// Don't cross page boundaries in a single transfer
60 kErrataLSHSOpti= (1 << 3),// Don't cross page boundaries in a single transfer
61 kErrataDisableOvercurrent= (1 << 4),// Always set the NOCP bit in rhDescriptorA register
62 kErrataLucentSuspendResume= (1 << 5),// Don't allow port suspend at the root hub
63 kErrataNeedsWatchdogTimer= (1 << 6),// Use Watchdog timer to reset confused controllers
64 kErrataNeedsPortPowerOff= (1 << 7),// Power off the ports and back on again to clear weird status.
65 kErrataAgereEHCIAsyncSched= (1 << 8),// needs workaround for Async Sched bug
66 kErrataNECOHCIIsochWraparound= (1 << 9),// needs workaround for NEC isoch buffer wraparound problem
67kErrataNECIncompleteWrite= (1 << 10),// needs workaround for NEC bits not sticking (errata IBB-2UE-00030 Jun 23 2005)
68kErrataICH6PowerSequencing= (1 << 11),// needs special power sequencing for early Transition machines
69kErrataICH7ISTBuffer= (1 << 12),// buffer for Isochronous Scheduling Threshold
70kErrataUHCISupportsOvercurrent= (1 << 13),// UHCI controller supports overcurrent detection
71kErrataNeedsOvercurrentDebounce= (1 << 14),// The overcurrent indicator should be debounced by 10ms
72kErrataSupportsPortResumeEnable= (1 << 15),// UHCI has resume enable bits at config address 0xC4
73kErrataNoCSonSplitIsoch= (1 << 16),// MCP79 - split iscoh is a little different
74kErrataOHCINoGlobalSuspendOnSleep= (1 << 17),// when sleeping, do not put the OHCI controller in SUSPEND state. just leave it Operational with suspended downstream ports
75kErrataMissingPortChangeInt= (1 << 18),// sometimes the port change interrupt may be missing
76kErrataMCP79IgnoreDisconnect= (1 << 19),// MCP79 - need to ignore a connect/disconnect on wake
77kErrataUse32bitEHCI= (1 << 20),// MCP79 - EHCI should only run with 32 bit DMA addresses
78kErrataUHCISupportsResumeDetectOnConnect= (1 << 21),// UHCI controller will generate a ResumeDetect interrupt while in Global Suspend if a device is plugged in
79kErrataDontUseCompanionController= (1 << 22)// For systems which will end up being EHCI only
80};
81
82enum
83{
84 kUSBWatchdogTimeoutMS = 1000
85};
86
87
88/*!
89 @struct
90 @discussion This table contains the list of errata that are necessary for known problems with particular devices.
91 The format is vendorID, product ID, lowest revisionID needing errata, highest rev needing errata, errataBits.
92 The result of all matches is ORed together, so more than one entry may match.
93 Typically for a given errata a list of revisions that this applies to is supplied.
94 @field vendID The Vendor ID of the device
95 @field deviceID Product ID of device
96 @field revisionLo Lowest product revsion to apply errata to
97 @field revisionHi Highest product revision to apply errata to
98 @field errata Bit field flagging which errata to apply to device.
99*/
100
101struct ErrataListEntryStruct
102{
103 UInt16 vendID;
104 UInt16 deviceID;
105 UInt16 revisionLo;
106 UInt16 revisionHi;
107 UInt32 errata;
108};
109
110typedef struct ErrataListEntryStruct ErrataListEntry, *ErrataListEntryPtr;
111
112
113//================================================================================================
114//
115// Routines used to implement synchronous I/O
116//
117//================================================================================================
118//
119void IOUSBSyncCompletion(void *target, void * parameter, IOReturn status, UInt32 bufferSizeRemaining);
120
121void IOUSBSyncIsoCompletion(void *target, void * parameter, IOReturn status, IOUSBIsocFrame *pFrames);
122
123
124//================================================================================================
125//
126// Forward Declarations
127//
128//================================================================================================
129//
130class IOUSBDevice;
131class IOUSBLog;
132class IOUSBHubDevice;
133class IOUSBRootHubDevice;
134class IOMemoryDescriptor;
135
136
137//================================================================================================
138//
139// IOUSBController Class
140//
141//================================================================================================
142//
143/*!
144 @class IOUSBController
145 @abstract Base class for USB hardware driver
146 @discussion Not many directly useful methods for USB device driver writers,
147 IOUSBDevice, IOUSBInterface and IOUSBPipe provide more useful abstractions.
148 The bulk of this class interfaces between IOKit and the low-level UIM, which is
149 based on the MacOS9 UIM. To impliment a new controller type, subclass
150 IOUSBController and impiment all the "UIM functions". AppleUSBOHCI
151 is an example of this implementing all the functions necessary to drive an
152 OHCI controller.
153*/
154class IOUSBController : public IOUSBBus
155{
156 OSDeclareAbstractStructors(IOUSBController)
157 friend class IOUSBControllerV2;
158 friend class IOUSBControllerV3;
159
160protected:
161
162 IOUSBWorkLoop *_workLoop;
163 IOCommandGate *_commandGate;
164 IOUSBRootHubDevice *_rootHubDevice;
165 UInt32_devZeroLock;
166 static UInt32_busCount;
167 static boolgUsedBusIDs[256];
168
169 struct ExpansionData
170 {
171IOCommandPool*freeUSBCommandPool;
172IOCommandPool*freeUSBIsocCommandPool;
173 IOTimerEventSource*watchdogUSBTimer;
174 bool_terminating;
175 bool_watchdogTimerActive;
176 bool_pcCardEjected;// Obsolete
177 UInt32_busNumber;
178 UInt32_currentSizeOfCommandPool;
179 UInt32_currentSizeOfIsocCommandPool;
180 UInt8_controllerSpeed;// Controller speed, passed down for splits
181 thread_call_t_terminatePCCardThread;// Obsolete
182 bool_addressPending[128];
183SInt32_activeIsochTransfers;// isochronous transfers in the queue
184IOService*_provider;// common name for our provider
185bool_controllerCanSleep;// true iff the controller is able to support sleep/wake
186bool_needToClose;
187UInt32_isochMaxBusStall;// value (in ns) of the maximum PCI bus stall allowed for Isoch..
188 };
189 ExpansionData *_expansionData;
190
191 // The following methods do not use and upper case initial letter because they are part of IOKit
192 //
193
194public:
195 virtual bool init( OSDictionary * propTable );
196 virtual bool start( IOService * provider );
197 virtual void stop( IOService * provider );
198 virtual bool finalize(IOOptionBits options);
199 virtual IOReturn message( UInt32 type, IOService * provider, void * argument = 0 );
200 virtual booldidTerminate( IOService * provider, IOOptionBits options, bool * defer );
201
202protected:
203
204 IOReturngetNubResources( IOService * regEntry );
205
206 virtual UInt32 GetErrataBits(
207 UInt16 vendorID,
208 UInt16 deviceID,
209 UInt16 revisionID );
210
211
212 static IOReturn DoDeleteEP(
213 OSObject *owner,
214 void *arg0,
215 void *arg1,
216 void *arg2,
217 void *arg3 );
218
219 static IOReturn DoAbortEP(
220 OSObject *owner,
221 void *arg0,
222 void *arg1,
223 void *arg2,
224 void *arg3 );
225
226 static IOReturn DoClearEPStall(
227 OSObject *owner,
228 void *arg0,
229 void *arg1,
230 void *arg2,
231 void *arg3 );
232
233 static IOReturn DoCreateEP(
234 OSObject *owner,
235 void *arg0,
236 void *arg1,
237 void *arg2,
238 void *arg3 );
239 static IOReturn DoControlTransfer(
240 OSObject *owner,
241 void *arg0,
242 void *arg1,
243 void *arg2,
244 void *arg3 );
245
246 static IOReturn DoIOTransfer(
247 OSObject *owner,
248 void *arg0,
249 void *arg1,
250 void *arg2,
251 void *arg3 );
252
253 static IOReturn DoIsocTransfer(
254 OSObject *owner,
255 void *arg0,
256 void *arg1,
257 void *arg2,
258 void *arg3 );
259
260 static IOReturn DoLowLatencyIsocTransfer(
261 OSObject *owner,
262 void *arg0,
263 void *arg1,
264 void *arg2,
265 void *arg3 );
266
267 static voidControlPacketHandler(
268 OSObject *target,
269 void *parameter,
270 IOReturnstatus,
271 UInt32bufferSizeRemaining );
272
273 static voidInterruptPacketHandler(
274 OSObject *target,
275 void * parameter,
276 IOReturnstatus,
277 UInt32bufferSizeRemaining );
278
279 static voidBulkPacketHandler(
280 OSObject *target,
281 void * parameter,
282 IOReturnstatus,
283 UInt32bufferSizeRemaining );
284
285 static voidIsocCompletionHandler(
286 OSObject *target,
287 void * parameter,
288 IOReturnstatus,
289 IOUSBIsocFrame*pFrames );
290
291 static voidLowLatencyIsocCompletionHandler(
292 OSObject *target,
293 void * parameter,
294 IOReturnstatus,
295 IOUSBLowLatencyIsocFrame*pFrames );
296
297 static voidWatchdogTimer(OSObject *target, IOTimerEventSource *sender);
298
299// Obsolete
300 static void TerminatePCCard(OSObject *target);
301
302 static IOReturnProtectedDevZeroLock(OSObject *target, void* lock, void *, void *, void*);
303
304
305 USBDeviceAddressGetNewAddress( void );
306
307 IOReturn ControlTransaction( IOUSBCommand * command );
308
309 IOReturn InterruptTransaction( IOUSBCommand * command );
310
311 IOReturn BulkTransaction( IOUSBCommand *command );
312
313 IOReturn IsocTransaction( IOUSBIsocCommand * command );
314
315 IOReturn LowLatencyIsocTransaction( IOUSBIsocCommand * command );
316
317 void FreeCommand( IOUSBCommand * command );
318
319 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
320 // Invokes the specified completion action of the request. If
321 // the completion action is unspecified, no action is taken.
322 void Complete(
323 IOUSBCompletioncompletion,
324 IOReturnstatus,
325 UInt32actualByteCount = 0 );
326
327 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
328 // Invokes the specified completion action of the request. If
329 // the completion action is unspecified, no action is taken.
330 voidCompleteWithTimeStamp (
331 IOUSBCompletionWithTimeStampcompletion,
332 IOReturnstatus,
333 UInt32actualByteCount,
334 AbsoluteTimetimeStamp);
335
336
337
338 //
339 // UIM methods
340 //
341
342/*!
343 @function UIMInitialize
344 @abstract UIM function, initialise the controller and UIM data structures.
345*/
346 virtual IOReturn UIMInitialize( IOService * provider ) = 0;
347
348/*!
349 @function UIMFinalize
350 @abstract UIM function, finalise the controller and UIM data structures prior to removal.
351*/
352 virtual IOReturn UIMFinalize() = 0;
353
354 // Control
355/*!
356 @function UIMCreateControlEndpoint
357 @abstract UIM function, create a control endpoint for the controller.
358 @param functionNumber The USB device ID of the device for this endpoint
359 @param endpointNumber The endpoint number for this endpoint
360 @param maxPacketSize Maximum packet size of this endpoint
361 @param speed speed of the device: kUSBDeviceSpeedLow or kUSBDeviceSpeedFull
362*/
363 virtual IOReturn UIMCreateControlEndpoint(
364 UInt8functionNumber,
365 UInt8endpointNumber,
366 UInt16maxPacketSize,
367 UInt8speed) = 0;
368
369/* Note: this function has been superceded. */
370 virtual IOReturn UIMCreateControlTransfer( shortfunctionNumber,
371 shortendpointNumber,
372 IOUSBCompletioncompletion,
373 void *CBP,
374 boolbufferRounding,
375 UInt32bufferSize,
376 shortdirection) = 0;
377
378/*!
379 @function UIMCreateControlTransfer
380 @abstract UIM function, Do a transfer on a control endpoint.
381 This method supercedes the method which takes a void * parameter.
382 @param functionNumber The USB device ID of the device to perform the transaction with
383 @param endpointNumber The endpoint number for the transaction
384 @param completion Action to perform when I/O completes
385 @param CBP Memory descriptor describing the buffer to transfer. Will never describe
386 memory which has disjoint packets.
387 @param bufferRounding If true, short packets are OK and do not cause an error
388 @param bufferSize Size of the data to transfer in the data phase. (C
389 @param direction Specifies direction and PID for transaction. kUSBIn, KUSBOut (DATA PID) or kUSBSetup (SETUP PID).
390*/
391 virtual IOReturn UIMCreateControlTransfer( shortfunctionNumber,
392 shortendpointNumber,
393 IOUSBCompletioncompletion,
394 IOMemoryDescriptor *CBP,
395 boolbufferRounding,
396 UInt32bufferSize,
397 shortdirection) = 0;
398
399 // Bulk
400/*!
401 @function UIMCreateBulkEndpoint
402 @abstract UIM function, create a bulk endpoint for the controller.
403 @param functionNumber The USB device ID of the device for this endpoint
404 @param endpointNumber The endpoint number for this endpoint
405 @param direction Specifies direction for the endpoint. kUSBIn or KUSBOut.
406 @param speed speed of the device: kUSBDeviceSpeedLow or kUSBDeviceSpeedFull
407 @param maxPacketSize Maximum packet size of this endpoint
408*/
409 virtual IOReturn UIMCreateBulkEndpoint(
410 UInt8functionNumber,
411 UInt8endpointNumber,
412 UInt8direction,
413 UInt8speed,
414 UInt8maxPacketSize) = 0;
415
416/* Note: this function has been superceded. */
417 virtual IOReturn UIMCreateBulkTransfer( shortfunctionNumber,
418 shortendpointNumber,
419 IOUSBCompletioncompletion,
420 IOMemoryDescriptor *CBP,
421 boolbufferRounding,
422 UInt32bufferSize,
423 shortdirection) = 0;
424
425 // Interrupt
426/*!
427 @function UIMCreateInterruptEndpoint
428 @abstract UIM function, create an interrupt endpoint for the controller.
429 @param functionNumber The USB device ID of the device for this endpoint
430 @param endpointNumber The endpoint number for this endpoint
431 @param direction Specifies direction for the endpoint. kUSBIn or KUSBOut.
432 @param speed speed of the device: kUSBDeviceSpeedLow or kUSBDeviceSpeedFull
433 @param maxPacketSize Maximum packet size of this endpoint
434 @param pollingRate The maximum polling interval from the endpoint descriptor.
435*/
436 virtual IOReturnUIMCreateInterruptEndpoint(
437 shortfunctionAddress,
438 shortendpointNumber,
439 UInt8direction,
440 shortspeed,
441 UInt16maxPacketSize,
442 shortpollingRate) = 0;
443
444/* Note: this function has been superceded. */
445 virtual IOReturn UIMCreateInterruptTransfer( shortfunctionNumber,
446 shortendpointNumber,
447 IOUSBCompletioncompletion,
448 IOMemoryDescriptor *CBP,
449 boolbufferRounding,
450 UInt32bufferSize,
451 shortdirection) = 0;
452
453 // Isoch
454/*!
455@function UIMCreateIsochEndpoint
456 @abstract Create an Isochronous endpoint in the controller.
457 @param functionNumber The USB device ID of the device for this endpoint
458 @param endpointNumber The endpoint number for this endpoint
459 @param maxPacketSize Maximum packet size of this endpoint
460 @param direction Specifies direction for the endpoint. kUSBIn or KUSBOut.
461*/
462 virtual IOReturn UIMCreateIsochEndpoint(
463 shortfunctionAddress,
464 shortendpointNumber,
465 UInt32maxPacketSize,
466 UInt8direction) = 0;
467
468/*!
469 @function UIMCreateIsochTransfer
470 @abstract UIM function, Do a transfer on an Isocchronous endpoint.
471 @param functionNumber The USB device ID of the device to perform the transaction with
472 @param endpointNumber The endpoint number for the transaction
473 @param completion Action to perform when I/O completes
474 @param direction Specifies direction for transfer. kUSBIn or KUSBOut.
475 @param frameStart The frame number in which to start the transactions
476 @param pBuffer describes memory buffer.
477 @param frameCount number of frames to do transactions in
478 @param pFrames Describes transactions in individual frames, gives sizes and reults for transactions.
479*/
480 virtual IOReturn UIMCreateIsochTransfer(
481 shortfunctionAddress,
482 shortendpointNumber,
483 IOUSBIsocCompletioncompletion,
484 UInt8direction,
485 UInt64frameStart,
486 IOMemoryDescriptor *pBuffer,
487 UInt32frameCount,
488 IOUSBIsocFrame*pFrames) = 0;
489
490/*!
491 @function UIMAbortEndpoint
492 @abstract UIM function Abort the specified endpoint, return all transactions queued on it.
493 @param functionNumber The USB device ID of the device to Abort
494 @param endpointNumber The endpoint number to Abort
495 @param direction Specifies direction of the endpoint for uniqueness. kUSBIn or KUSBOut.
496*/
497 virtual IOReturn UIMAbortEndpoint(
498 shortfunctionNumber,
499 shortendpointNumber,
500 shortdirection) = 0;
501
502/*!
503 @function UIMDeleteEndpoint
504 @abstract UIM function Delete the specified endpoint, returning all transactions queued on it.
505 @param functionNumber The USB device ID of the device to Delete
506 @param endpointNumber The endpoint number to Delete
507 @param direction Specifies direction of the endpoint for uniqueness. kUSBIn or KUSBOut.
508*/
509 virtual IOReturn UIMDeleteEndpoint(
510 shortfunctionNumber,
511 shortendpointNumber,
512 shortdirection) = 0;
513
514/*!
515 @function UIMClearEndpointStall
516 @abstract UIM function Clear stall on the specified endpoint, set data toggle to zero,
517 return all transactions queued on it.
518 @param functionNumber The USB device ID of the device to Clear
519 @param endpointNumber The endpoint number to Clear
520 @param direction Specifies direction of the endpoint for uniqueness. kUSBIn or KUSBOut.
521*/
522 virtual IOReturn UIMClearEndpointStall(
523 shortfunctionNumber,
524 shortendpointNumber,
525 shortdirection) = 0;
526
527/*!
528 @function UIMRootHubStatusChange
529 @abstract UIM function UIMRootHubStatusChange - This method was internal to the UIM (never called by the superclass) until
530IOUSBControllerV3. For UIMs which are a subclass of IOUSBController or IOUSBControllerV2, it can
531still be used internally only. For subclasses of IOUSBControllerV3, however, the meaning has changed
532slightly. Now, it is used to determine if there is a status change on the root hub, and if so, it
533needs to update the IOUSBControllerV3 instance variable _rootHubStatusChangedBitmap
534*/
535 virtual void UIMRootHubStatusChange(void) = 0;
536
537 static const IORegistryPlane*gIOUSBPlane;
538
539public:
540
541 static IOUSBLog*_log;
542
543 IOCommandGate *GetCommandGate(void);
544
545 /*!
546@struct Endpoint
547 Describes an endpoint of a device.
548Simply an easier to use version of the endpoint descriptor.
549 @field descriptor The raw endpoint descriptor.
550 @field number Endpoint number
551@field direction Endpoint direction: kUSBOut, kUSBIn, kUSBAnyDirn
552@field transferType Type of endpoint: kUSBControl, kUSBIsoc, kUSBBulk, kUSBInterrupt
553@field maxPacketSize Maximum packet size for endpoint
554@field interval Polling interval in milliseconds (only relevent for Interrupt endpoints)
555 */
556 struct Endpoint {
557 IOUSBEndpointDescriptor*descriptor;
558 UInt8 number;
559 UInt8direction;// in, out
560 UInt8transferType;// cntrl, bulk, isoc, int
561 UInt16maxPacketSize;
562 UInt8interval;
563 };
564
565 // Implements IOService::getWorkLoop const member function
566 virtual IOWorkLoop *getWorkLoop() const;
567
568 /*
569 * Root hub methods
570 * Only of interest to the IOUSBRootHubDevice object
571 */
572/*!
573 @function GetRootHubDeviceDescriptor
574 @abstract UIM function, return the device descriptor of the simulated root hub device
575 As GET_DESCRIPTOR control request for device descrptor
576 @param desc Descriptor structure to return data in
577*/
578 virtual IOReturn GetRootHubDeviceDescriptor( IOUSBDeviceDescriptor *desc ) = 0;
579
580/*!
581 @function GetRootHubDescriptor
582 @abstract UIM function, return the hub descriptor of the simulated root hub device
583 As GET_DESCRIPTOR control request for hub descrptor
584 @param desc Descriptor structure to return data in
585*/
586 virtual IOReturn GetRootHubDescriptor( IOUSBHubDescriptor *desc ) = 0;
587
588/*!
589 @function SetRootHubDescriptor
590 @abstract UIM function, optional. Set the hub descriptor data.
591 As SET_DESCRIPTOR control request for hub descrptor
592 @param buffer Descriptor data
593*/
594 virtual IOReturn SetRootHubDescriptor( OSData *buffer ) = 0;
595
596/*!
597 @function GetRootHubConfDescriptor
598 @abstract UIM function, retrun the configuration descriptor of the simulated root hub device
599 As GET_DESCRIPTOR control request for configuration descrptor
600 @param desc Descriptor structure to return data in
601*/
602 virtual IOReturn GetRootHubConfDescriptor( OSData *desc ) = 0;
603
604/*!
605 @function GetRootHubStatus
606 @abstract UIM function, get the status of the root hub. As GET_STATUS control request to device.
607 @param status Status structure to return
608*/
609 virtual IOReturn GetRootHubStatus( IOUSBHubStatus *status ) = 0;
610
611/*!
612 @function SetRootHubFeature
613 @abstract UIM function, set feature of root hub, As SET_FEATURE control request.
614 @param wValue The feature to set, as would be transferred in wValue field of SETUP packet.
615*/
616 virtual IOReturn SetRootHubFeature( UInt16 wValue ) = 0;
617
618/*!
619 @function ClearRootHubFeature
620 @abstract UIM function, set feature of root hub, As CLEAR_FEATURE control request.
621 @param wValue The feature to clear, as would be transferred in wValue field of SETUP packet.
622*/
623 virtual IOReturnClearRootHubFeature( UInt16 wValue ) = 0;
624
625/*!
626 @function GetRootHubPortStatus
627 @abstract UIM function, get the status of a root hub port. As GET_STATUS control request to the port.
628 @param status Status structure to return
629 @param port Port to get status for.
630*/
631 virtual IOReturn GetRootHubPortStatus( IOUSBHubPortStatus *status, UInt16 port ) = 0;
632
633/*!
634 @function SetRootHubPortFeature
635 @abstract UIM function, set feature of a root hub port, As SET_FEATURE control request to a port.
636 @param wValue The feature to set, as would be transferred in wValue field of SETUP packet.
637 @param port Port to set feature for
638*/
639 virtual IOReturn SetRootHubPortFeature( UInt16 wValue, UInt16 port ) = 0;
640
641/*!
642 @function ClearRootHubPortFeature
643 @abstract UIM function, clear feature of a root hub port, As CLEAR_FEATURE control request to a port.
644 @param wValue The feature to clear, as would be transferred in wValue field of SETUP packet.
645 @param port Port to clear feature for
646*/
647 virtual IOReturn ClearRootHubPortFeature( UInt16 wValue, UInt16 port ) = 0;
648
649/*!
650 @function ClearRootHubPortFeature
651 @abstract UIM function, Impliments GET_BUS_STATE control request, now obsolete.
652*/
653 virtual IOReturn GetRootHubPortState( UInt8 *state, UInt16 port ) = 0;
654
655/*!
656 @function SetHubAddress
657 @abstract UIM function, set the address of the simulated root hub device, as SET_ADDRESS
658 @param wValue New address for root hub.
659*/
660 virtual IOReturn SetHubAddress( UInt16 wValue ) = 0;
661
662
663 /*!
664@function openPipe
665 Open a pipe to the specified device endpoint
666 @param address Address of the device on the USB bus
667@param speed of the device: kUSBHighSpeed or kUSBLowSpeed
668 @param endpoint description of endpoint to connect to
669 */
670 virtual IOReturn OpenPipe( USBDeviceAddress address,
671UInt8speed,
672 Endpoint *endpoint );
673 /*!
674 @function closePipe
675 Close a pipe to the specified device endpoint
676 @param address Address of the device on the USB bus
677@param endpoint description of endpoint
678 */
679 virtual IOReturn ClosePipe(USBDeviceAddress address,
680 Endpoint *endpoint );
681
682 // Controlling pipe state
683 /*!
684 @function abortPipe
685 Abort pending I/O to/from the specified endpoint, causing them to complete with return code kIOReturnAborted
686 @param address Address of the device on the USB bus
687 @param endpoint description of endpoint
688 */
689 virtual IOReturn AbortPipe(
690 USBDeviceAddress address,
691 Endpoint *endpoint );
692 /*!
693 @function resetPipe
694 Abort pending I/O and clear stalled state - this method is a combination of abortPipe and clearPipeStall
695 @param address Address of the device on the USB bus
696 @param endpoint description of endpoint
697 */
698 virtual IOReturn ResetPipe(USBDeviceAddress address,
699 Endpoint *endpoint );
700 /*!
701 @function clearPipeStall
702 Clear a pipe stall.
703 @param address Address of the device on the USB bus
704 @param endpoint description of endpoint
705 */
706 virtual IOReturn ClearPipeStall(USBDeviceAddress address,
707Endpoint *endpoint );
708
709 // Transferring Data
710 /*!
711 @function read
712 Read from an interrupt or bulk endpoint
713@param buffer place to put the transferred data
714 @param address Address of the device on the USB bus
715 @param endpoint description of endpoint
716@param completion describes action to take when buffer has been filled
717 */
718 virtual IOReturn Read(IOMemoryDescriptor * buffer,
719USBDeviceAddressaddress,
720Endpoint *endpoint,
721IOUSBCompletion *completion );
722 /*!
723 @function write
724 Write to an interrupt or bulk endpoint
725 @param buffer place to get the transferred data
726 @param address Address of the device on the USB bus
727 @param endpoint description of endpoint
728 @param completion describes action to take when buffer has been emptied
729 */
730 virtual IOReturn Write(IOMemoryDescriptor *buffer,
731USBDeviceAddress address,
732Endpoint *endpoint,
733IOUSBCompletion *completion );
734
735 /*!
736 @function isocIO
737 Read from or write to an isochronous endpoint
738 @param buffer place to put the transferred data
739 @param frameStart USB frame number of the frame to start transfer
740 @param numFrames Number of frames to transfer
741 @param frameList Bytes to transfer and result for each frame
742 @param address Address of the device on the USB bus
743 @param endpoint description of endpoint
744 @param completion describes action to take when buffer has been filled
745 */
746 virtual IOReturn IsocIO(IOMemoryDescriptor * buffer,
747UInt64frameStart,
748UInt32numFrames,
749IOUSBIsocFrame *frameList,
750USBDeviceAddressaddress,
751Endpoint *endpoint,
752IOUSBIsocCompletion *completion );
753 /*!
754 @function deviceRequest
755 Make a control request to the specified endpoint
756There are two versions of this method, one uses a simple void *
757 to point to the data portion of the transfer, the other uses an
758IOMemoryDescriptor to point to the data.
759@param request parameter block for the control request
760@param completion describes action to take when the request has been executed
761 @param address Address of the device on the USB bus
762@param epNum endpoint number
763 */
764 virtual IOReturn DeviceRequest(IOUSBDevRequest *request,
765IOUSBCompletion *completion,
766USBDeviceAddress address,
767UInt8epNum );
768
769 virtual IOReturn DeviceRequest(IOUSBDevRequestDesc *request,
770IOUSBCompletion *completion,
771USBDeviceAddressaddress,
772UInt8epNum );
773
774 /*
775 * Methods used by the hub driver to initialize a device
776 */
777 /*!
778@function AcquireDeviceZero
779Get the device zero lock - call this before resetting a device, to ensure there's
780only one device with address 0
781 */
782 virtual IOReturn AcquireDeviceZero( void );
783 /*!
784 @function ReleaseDeviceZero
785 Release the device zero lock - call this to release the device zero lock,
786when there is no longer a device at address 0
787 */
788 virtual voidReleaseDeviceZero( void );
789
790// non-virtual methods
791 voidWaitForReleaseDeviceZero( void );
792 IOReturnConfigureDeviceZero( UInt8 maxPacketSize, UInt8 speed );
793 IOReturnGetDeviceZeroDescriptor( IOUSBDeviceDescriptor * desc, UInt16 size );
794 IOReturnSetDeviceZeroAddress(USBDeviceAddress address);
795 IOUSBDevice *MakeDevice(USBDeviceAddress *address);
796 IOUSBHubDevice *MakeHubDevice(USBDeviceAddress *address);
797IOReturnCreateDevice(IOUSBDevice *device,
798USBDeviceAddressdeviceAddress,
799UInt8maxPacketSize,
800UInt8speed,
801UInt32powerAvailable );
802
803 /*!
804@function GetBandwidthAvailable
805 Returns the available bandwidth (in bytes) per frame or microframe for
806isochronous transfers.
807@result maximum number of bytes that a new iso pipe could transfer
808per frame given current allocations.
809 */
810 virtual UInt32 GetBandwidthAvailable( void ) = 0;
811
812 /*!
813 @function GetFrameNumber
814 Returns the full current frame number.
815 @result The frame number.
816 */
817 virtual UInt64 GetFrameNumber( void ) = 0;
818
819 /*!
820 @function GetFrameNumber32
821 Returns the least significant 32 bits of the frame number.
822 @result The lsb 32 bits of the frame number.
823 */
824 virtual UInt32 GetFrameNumber32( void ) = 0;
825
826 // Debugger polled mode
827 virtual void PollInterrupts( IOUSBCompletionAction safeAction = 0 ) = 0;
828
829 virtual IOReturn PolledRead(
830 shortfunctionNumber,
831 shortendpointNumber,
832 IOUSBCompletioncompletion,
833 IOMemoryDescriptor *CBP,
834 boolbufferRounding,
835 UInt32bufferSize);
836
837 OSMetaClassDeclareReservedUsed(IOUSBController, 0);
838 virtual void UIMCheckForTimeouts(void);
839
840 OSMetaClassDeclareReservedUsed(IOUSBController, 1);
841 virtual IOReturn UIMCreateControlTransfer( shortfunctionNumber,
842 shortendpointNumber,
843 IOUSBCommand*command,
844 void*CBP,
845 boolbufferRounding,
846 UInt32bufferSize,
847 shortdirection);
848
849 OSMetaClassDeclareReservedUsed(IOUSBController, 2);
850 virtual IOReturn UIMCreateControlTransfer( shortfunctionNumber,
851 shortendpointNumber,
852 IOUSBCommand*command,
853 IOMemoryDescriptor*CBP,
854 boolbufferRounding,
855 UInt32bufferSize,
856 shortdirection);
857
858 OSMetaClassDeclareReservedUsed(IOUSBController, 3);
859/*!
860 @function UIMCreateBulkTransfer
861 @abstract UIM function, Do a transfer on a bulk endpoint.
862 This method supercedes the method which takes multiple parameters.
863 @param command paramters for transfer.
864*/
865 virtual IOReturn UIMCreateBulkTransfer(IOUSBCommand* command);
866
867 OSMetaClassDeclareReservedUsed(IOUSBController, 4);
868/*!
869 @function UIMCreateInterruptTransfer
870 @abstract UIM function, Do a transfer on an interrupt endpoint.
871 This method supercedes the method which takes multiple parameters.
872 @param command paramters for transfer.
873*/
874 virtual IOReturn UIMCreateInterruptTransfer(IOUSBCommand* command);
875
876 /*!
877 @function deviceRequest
878 Make a control request to the specified endpoint
879There are two versions of this method, one uses a simple void *
880 to point to the data portion of the transfer, the other uses an
881IOMemoryDescriptor to point to the data.
882@param request parameter block for the control request
883@param completion describes action to take when the request has been executed
884 @param address Address of the device on the USB bus
885@param epNum endpoint number
886 */
887 OSMetaClassDeclareReservedUsed(IOUSBController, 5);
888 virtual IOReturn DeviceRequest( IOUSBDevRequest *request,
889 IOUSBCompletion *completion,
890 USBDeviceAddress address,
891 UInt8 epNum,
892UInt32noDataTimeout,
893UInt32completionTimeout );
894
895 OSMetaClassDeclareReservedUsed(IOUSBController, 6);
896 virtual IOReturn DeviceRequest( IOUSBDevRequestDesc *request,
897 IOUSBCompletion *completion,
898 USBDeviceAddress address,
899 UInt8 epNum,
900UInt32noDataTimeout,
901UInt32completionTimeout );
902
903
904
905 OSMetaClassDeclareReservedUsed(IOUSBController, 7);
906 /*!
907 @function read
908 Read from an interrupt or bulk endpoint
909@param buffer place to put the transferred data
910 @param address Address of the device on the USB bus
911 @param endpoint description of endpoint
912@param completion describes action to take when buffer has been filled
913 */
914 virtual IOReturn Read( IOMemoryDescriptor * buffer,
915 USBDeviceAddress address,
916 Endpoint *endpoint,
917 IOUSBCompletion *completion,
918UInt32noDataTimeout,
919UInt32completionTimeout );
920
921 OSMetaClassDeclareReservedUsed(IOUSBController, 8);
922 /*!
923 @function write
924 Write to an interrupt or bulk endpoint
925 @param buffer place to get the transferred data
926 @param address Address of the device on the USB bus
927 @param endpoint description of endpoint
928 @param completion describes action to take when buffer has been emptied
929 */
930 virtual IOReturn Write( IOMemoryDescriptor *buffer,
931 USBDeviceAddress address,
932 Endpoint *endpoint,
933 IOUSBCompletion *completion,
934UInt32noDataTimeout,
935UInt32completionTimeout );
936
937 // this should really not be using a padding slot, since free is in our superclas, but we shipped this way so now we need to leave it.
938 OSMetaClassDeclareReservedUsed(IOUSBController, 9);
939 virtual void free();
940
941protected:
942
943/*!
944 @function UIMRootHubStatusChange(bool)
945 @abstract UIM function UIMRootHubStatusChange(bool) - This method was internal to the UIM (never called by the superclass) until
946IOUSBControllerV3. For UIMs which are a subclass of IOUSBController or IOUSBControllerV2, it can
947still be used internally only. For subclasses of IOUSBControllerV3, however, it has become obsolete
948(it still needs to be implemented since it is pure virtual)
949*/
950 OSMetaClassDeclareReservedUsed(IOUSBController, 10);
951 virtual void UIMRootHubStatusChange( bool abort ) = 0;
952
953public:
954
955 OSMetaClassDeclareReservedUsed(IOUSBController, 11);
956 virtual IOReturn CreateRootHubDevice( IOService * provider, IOUSBRootHubDevice ** rootHubDevice);
957
958 OSMetaClassDeclareReservedUsed(IOUSBController, 12);
959 /*!
960 @function Read
961 Read from an interrupt or bulk endpoint
962@param buffer place to put the transferred data
963 @param address Address of the device on the USB bus
964 @param endpoint description of endpoint
965@param completion describes action to take when buffer has been filled
966@param noDataTimeout number of milliseconds of no data movement before the request is aborted
967@param completionTimeout number of milliseonds after the command is on the bus in which it must complete
968@param reqCount number of bytes requested for the transfer (must not be greater than the length of the buffer)
969 */
970 virtual IOReturn Read( IOMemoryDescriptor * buffer,
971 USBDeviceAddress address,
972 Endpoint *endpoint,
973 IOUSBCompletion *completion,
974UInt32noDataTimeout,
975UInt32completionTimeout,
976IOByteCountreqCount );
977
978 OSMetaClassDeclareReservedUsed(IOUSBController, 13);
979 /*!
980 @function Write
981 Write to an interrupt or bulk endpoint
982 @param buffer place to get the transferred data
983 @param address Address of the device on the USB bus
984 @param endpoint description of endpoint
985 @param completion describes action to take when buffer has been emptied
986@param noDataTimeout number of milliseconds of no data movement before the request is aborted
987@param completionTimeout number of milliseonds after the command is on the bus in which it must complete
988@param reqCount number of bytes requested for the transfer (must not be greater than the length of the buffer)
989 */
990 virtual IOReturn Write( IOMemoryDescriptor *buffer,
991 USBDeviceAddress address,
992 Endpoint *endpoint,
993 IOUSBCompletion *completion,
994UInt32noDataTimeout,
995UInt32completionTimeout,
996IOByteCountreqCount );
997
998 OSMetaClassDeclareReservedUsed(IOUSBController, 14);
999
1000 virtual IOReturn GetRootHubStringDescriptor(UInt8index, OSData *desc) = 0;
1001
1002 OSMetaClassDeclareReservedUsed(IOUSBController, 15);
1003 /*!
1004 @function IsocIO
1005 Read from or write to an isochronous endpoint
1006 @param buffer place to put the transferred data
1007 @param frameStart USB frame number of the frame to start transfer
1008 @param numFrames Number of frames to transfer
1009 @param frameList Bytes to transfer and result for each frame
1010 @param address Address of the device on the USB bus
1011 @param endpoint description of endpoint
1012 @param completion describes action to take when buffer has been filled
1013 @param updateFrequency describes how often to update the framelist once the transfer has completed (in ms)
1014 */
1015 virtual IOReturn IsocIO( IOMemoryDescriptor * buffer,
1016 UInt64 frameStart,
1017 UInt32 numFrames,
1018 IOUSBLowLatencyIsocFrame *frameList,
1019 USBDeviceAddress address,
1020 Endpoint *endpoint,
1021 IOUSBLowLatencyIsocCompletion *completion,
1022 UInt32updateFrequency );
1023
1024 OSMetaClassDeclareReservedUsed(IOUSBController, 16);
1025
1026 /*!
1027@function UIMCreateIsochTransfer
1028@abstract UIM function, Do a transfer on an Isocchronous endpoint.
1029@param functionNumber The USB device ID of the device to perform the transaction with
1030@param endpointNumber The endpoint number for the transaction
1031@param completion Action to perform when I/O completes
1032@param direction Specifies direction for transfer. kUSBIn or KUSBOut.
1033@param frameStart The frame number in which to start the transactions
1034@param pBuffer describes memory buffer.
1035@param frameCount number of frames to do transactions in
1036@param pFrames Describes transactions in individual frames, gives sizes and reults for transactions.
1037@param updateFrequency Describes how often we update the frameList parameters (in ms)
1038*/
1039 virtual IOReturn UIMCreateIsochTransfer(
1040 shortfunctionAddress,
1041 shortendpointNumber,
1042 IOUSBIsocCompletioncompletion,
1043 UInt8direction,
1044 UInt64frameStart,
1045 IOMemoryDescriptor *pBuffer,
1046 UInt32frameCount,
1047 IOUSBLowLatencyIsocFrame *pFrames,
1048 UInt32updateFrequency);
1049
1050
1051 OSMetaClassDeclareReservedUsed(IOUSBController, 17);
1052 virtual IOReturn CheckForDisjointDescriptor(IOUSBCommand *command, UInt16 maxPacketSize);
1053
1054 /*!
1055@function UIMCreateIsochTransfer
1056@abstract UIM function, Do a transfer on an Isocchronous endpoint.
1057@param command an IOUSBIsocCommand object with all the necessary information
1058 */
1059 OSMetaClassDeclareReservedUsed(IOUSBController, 18);
1060virtual IOReturn UIMCreateIsochTransfer(IOUSBIsocCommand *command);
1061
1062// do not use this slot without first checking bug rdar://6022420
1063 OSMetaClassDeclareReservedUnused(IOUSBController, 19);
1064
1065protected:
1066 voidIncreaseIsocCommandPool();
1067 void IncreaseCommandPool();
1068 voidParsePCILocation(const char *str, int *deviceNum, int *functionNum);
1069 intValueOfHexDigit(char c);
1070};
1071
1072#endif /* ! _IOKIT_IOUSBCONTROLLER_H */
1073
1074

Archive Download this file

Revision: 1232