Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Modules/i386/include/IOKit/usb/IOUSBControllerV3.h

1/*
2* Copyright (c) 2007-2008 Apple 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_IOUSBCONTROLLERV3_H
24#define _IOKIT_IOUSBCONTROLLERV3_H
25
26#include <IOKit/pci/IOPCIDevice.h>
27
28#include <IOKit/usb/IOUSBControllerV2.h>
29#include <IOKit/usb/IOUSBHubDevice.h>
30
31// Constants that define the different power states in the setPowerState call
32enum
33{
34 kUSBPowerStateOff= 0,// controller is reset, nothing is attached
35 kUSBPowerStateRestart= 1,// same as OFF
36 kUSBPowerStateSleep= 2,// controller is suspended, preparing to lose main power
37 kUSBPowerStateLowPower= 3,// controller is suspended, power remains on
38 kUSBPowerStateOn= 4,// up and running
39kUSBNumberBusPowerStates= 5
40};
41
42#define kUSBPowerStateStable-1
43
44enum
45{
46 kUSBBusStateReset= 0,// bus is in RESET
47 kUSBBusStateSuspended= 1,// bus is in SUSPEND mode
48 kUSBBusStateRunning= 2// bus is operational
49};
50
51
52// Root Hub things
53typedef struct IOUSBRootHubInterruptTransaction
54{
55 IOMemoryDescriptor *buf;
56 UInt32bufLen;
57 IOUSBCompletioncompletion;
58} IOUSBRootHubInterruptTransaction;
59
60enum
61{
62 kIOUSBMaxRootHubTransactions = 2
63};
64
65
66
67/*!
68 @class IOUSBControllerV3
69 @abstract subclass of the IOUSBControllerV2 to provide support for new USB Power Management techniques.
70 @discussion With Leopard, we are providing more information to USB Device Drivers in the IOPower
71 tree to allow for more efficient Power Management. This controller class encapulates many of the changes
72 needed for that, without disturbing third party subclasses of IOUSBController or IOUSBControllerV2
73 */
74
75class IOUSBControllerV3 : public IOUSBControllerV2
76{
77OSDeclareAbstractStructors(IOUSBControllerV3)
78
79protected:
80// static variable shared by all instances
81static uint32_t *_gHibernateState;
82
83
84UInt8_myBusState;// kUSBBusStateReset, kUSBBusStateSuspended, kUSBBusStateRunning
85bool_wakingFromHibernation;// True while the Hibernation Wake thread is active
86bool_needToAckPowerDown;// True while we are changing power state due to shutdown/restart
87bool_onCardBus;// OBSOLETE
88bool_controllerAvailable;// true if we can talk to the controller
89SInt32_powerStateChangingTo;// a power state that we are in the process of changing to, or -1 if we are stable
90bool_poweringDown;// true is the controller is powering down because of a systemWillPowerDown message
91bool_restarting;// true is the controller is restarting because of a systemWillPowerDown message
92unsigned long_myPowerState;// my current state (since getPowerState doesn't always change in time)
93IOUSBControllerV3*_ehciController;// set if I am a companion controller
94unsigned long_numPowerStates;// how many power states do I support (defaults to kUSBNumDefaultPowerStates)
95IOPMPowerState*_myPowerStates;// my power state array (allocated on the fly)
96IOPCIDevice*_device;// my PCI device
97
98// root hub support
99 IOTimerEventSource*_rootHubTimer;// timer which fires at the rate of the root hub interrupt endpoint
100UInt8_rootHubPollingRate;// Obsolete -- we need to have it be a uint32_t
101UInt8_rootHubNumPorts;// number of root hub ports - should be 15 or fewer!
102UInt16_rootHubStatusChangedBitmap;// support up to 15 ports for status changes
103bool_rootHubTimerActive;// UNUSED
104IOUSBRootHubInterruptTransaction_outstandingRHTrans[4];// Transactions for the Root Hub. We need 2, one for the current transaction and one for the next. This is declared as 4 for binary compatibility
105
106struct V3ExpansionData {
107uint32_t_rootHubPollingRate32;
108bool_rootHubTransactionWasAborted;
109};
110V3ExpansionData *_v3ExpansionData;
111
112// IOKit methods
113virtual boolinit( OSDictionary * propTable );
114virtual boolstart( IOService * provider );
115virtual voidstop( IOService * provider );
116virtual unsigned longmaxCapabilityForDomainState ( IOPMPowerFlags domainState );
117virtual unsigned longinitialPowerStateForDomainState ( IOPMPowerFlags domainState );
118virtual IOReturnpowerStateWillChangeTo ( IOPMPowerFlags capabilities, unsigned long stateNumber, IOService* whatDevice);
119virtual IOReturnsetPowerState( unsigned long powerStateOrdinal, IOService* whatDevice );
120virtual IOReturnpowerStateDidChangeTo ( IOPMPowerFlags capabilities, unsigned long stateNumber, IOService* whatDevice);
121virtual voidpowerChangeDone ( unsigned long fromState);
122virtual voidsystemWillShutdown( IOOptionBits specifier );
123virtual voidfree(void);
124
125// IOUSBController methods
126// we override these to deal with methods attempting to go through the workloop while we are in sleep
127virtual IOReturn AcquireDeviceZero( void );
128virtual voidReleaseDeviceZero( void );
129virtual IOReturn DeviceRequest(IOUSBDevRequest *request, IOUSBCompletion *completion, USBDeviceAddress address, UInt8 epNum, UInt32 noDataTimeout, UInt32 completionTimeout);
130virtual IOReturn DeviceRequest(IOUSBDevRequestDesc *request, IOUSBCompletion *completion, USBDeviceAddress address, UInt8 epNum, UInt32 noDataTimeout, UInt32 completionTimeout);
131virtual IOReturn ClosePipe(USBDeviceAddress address, Endpoint *endpoint);
132virtual IOReturn AbortPipe(USBDeviceAddress address, Endpoint *endpoint);
133virtual IOReturn ResetPipe(USBDeviceAddress address, Endpoint *endpoint);
134virtual IOReturn ClearPipeStall(USBDeviceAddress address, Endpoint *endpoint);
135virtual IOReturn Read(IOMemoryDescriptor *buffer, USBDeviceAddress address, Endpoint *endpoint, IOUSBCompletion *completion, UInt32 noDataTimeout, UInt32 completionTimeout, IOByteCount reqCount);
136virtual IOReturn Write(IOMemoryDescriptor *buffer, USBDeviceAddress address, Endpoint *endpoint, IOUSBCompletion *completion, UInt32 noDataTimeout, UInt32 completionTimeout, IOByteCount reqCount);
137virtual IOReturnIsocIO(IOMemoryDescriptor *buffer, UInt64 frameStart, UInt32 numFrames, IOUSBIsocFrame *frameList, USBDeviceAddress address, Endpoint *endpoint, IOUSBIsocCompletion *completion );
138virtual IOReturnIsocIO(IOMemoryDescriptor *buffer, UInt64 frameStart, UInt32 numFrames, IOUSBLowLatencyIsocFrame *frameList, USBDeviceAddress address, Endpoint *endpoint, IOUSBLowLatencyIsocCompletion *completion, UInt32 updateFrequency );
139
140// IOUSBControllerV2 methods
141// we override these to deal with methods attempting to go through the workloop while we are in sleep
142virtual IOReturn OpenPipe(USBDeviceAddress address, UInt8 speed, Endpoint *endpoint);
143virtual IOReturnAddHSHub(USBDeviceAddress highSpeedHub, UInt32 flags);
144virtual IOReturnRemoveHSHub(USBDeviceAddress highSpeedHub);
145virtual IOReturnSetTestMode(UInt32 mode, UInt32 port);
146virtual IOReturnReadV2(IOMemoryDescriptor *buffer, USBDeviceAddressaddress, Endpoint *endpoint, IOUSBCompletionWithTimeStamp *completion, UInt32 noDataTimeout, UInt32completionTimeout, IOByteCount reqCount);
147
148// IOUSBControllerV3 methods
149
150// these are called through the workloop
151static IOReturnDoEnableAddressEndpoints(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3 );
152static IOReturnDoEnableAllEndpoints(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3 );
153static IOReturnGatedPowerChange(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3 );
154
155// also on the workloop
156 static voidRootHubTimerFired(OSObject *owner, IOTimerEventSource *sender);
157
158// subclassable methods
159virtual IOReturnCheckForEHCIController(IOService *provider);
160virtualIOReturnAllocatePowerStateArray(void);
161virtualIOReturnInitForPM(void);
162virtual IOReturnCheckPowerModeBeforeGatedCall(char *fromStr);
163virtual IOReturnEnableAllEndpoints(bool enable);
164virtual IOReturnEnableBusMastering(bool enable);
165virtual IOReturnEnsureUsability(void);
166virtual IOReturnCheckForRootHubChanges(void);
167virtual IOReturnRootHubQueueInterruptRead(IOMemoryDescriptor *buf, UInt32 bufLen, IOUSBCompletion completion);
168virtual IOReturnRootHubAbortInterruptRead(void);
169virtual IOReturnRootHubStartTimer(UInt8 pollingRate);// Obsolete see RootHubStartTimer32
170virtual IOReturnRootHubStopTimer(void);
171
172// these methods have a default implementation using some of the virtual methods below
173virtualvoidControllerOff(void);
174virtualvoidControllerRestart(void);
175virtualvoidControllerSleep(void);
176virtualvoidControllerDoze(void);
177virtualvoidControllerOn(void);
178
179// these methods are pure virtual, and need to be implemented in the subclass driver
180virtualIOReturnResetControllerState(void) = 0;
181virtual IOReturnRestartControllerFromReset(void) = 0;
182virtualIOReturnSaveControllerStateForSleep(void) = 0;
183virtualIOReturnRestoreControllerStateFromSleep(void) = 0;
184virtual IOReturnDozeController(void) = 0;
185virtual IOReturnWakeControllerFromDoze(void) = 0;
186virtual IOReturnUIMEnableAddressEndpoints(USBDeviceAddress address, bool enable) = 0;
187virtual IOReturnUIMEnableAllEndpoints(bool enable) = 0;
188virtual IOReturnEnableInterruptsFromController(bool enable) = 0;
189
190public:
191
192// public methods
193virtual IOReturnEnableAddressEndpoints(USBDeviceAddress address, bool enable);
194virtual boolIsControllerAvailable(void);
195virtual IOReturnHandlePowerChange(unsigned long powerStateOrdinal);
196virtualUInt32AllocateExtraRootHubPortPower(UInt32 extraPowerRequested);
197virtualvoidReturnExtraRootHubPortPower(UInt32 extraPowerReturned);
198
199OSMetaClassDeclareReservedUsed(IOUSBControllerV3, 0);
200virtual IOReturnRootHubStartTimer32(uint32_t pollingRate);
201
202OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 1);
203OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 2);
204OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 3);
205OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 4);
206OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 5);
207OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 6);
208OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 7);
209OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 8);
210OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 9);
211OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 10);
212OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 11);
213OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 12);
214OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 13);
215OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 14);
216OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 15);
217OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 16);
218OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 17);
219OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 18);
220OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 19);
221OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 20);
222OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 21);
223OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 22);
224OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 23);
225OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 24);
226OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 25);
227OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 26);
228OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 27);
229OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 28);
230OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 29);
231};
232
233#endif// _IOKIT_IOUSBCONTROLLERV3_H

Archive Download this file

Revision: 1621