Root/
Source at commit 1166 created 13 years 10 days ago. By meklort, Fixed recent Makefile changes. Please do not use /Users/evan/SourceCode/tmp/chameleon/trunk or VPATH. the *only* time you should use /Users/evan/SourceCode/tmp/chameleon/trunk is when setting the SRCROOT variable. Also note that very soon make pkg is going to be removed. The pkg build script in trunk is very out of date. Instead please use the package maker at http://forge.voodooprojects.org/p/chameleonApplications/. Once this is ready for trunk it will be merged. | |
---|---|
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␊ |
32 | enum␊ |
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␊ |
39 | ␉kUSBNumberBusPowerStates␉␉= 5␊ |
40 | };␊ |
41 | ␊ |
42 | #define kUSBPowerStateStable␉␉-1␊ |
43 | ␊ |
44 | enum␊ |
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␊ |
53 | typedef struct IOUSBRootHubInterruptTransaction ␊ |
54 | {␊ |
55 | IOMemoryDescriptor *␉␉buf;␊ |
56 | UInt32␉␉␉␉␉␉bufLen;␊ |
57 | IOUSBCompletion␉␉␉␉completion;␊ |
58 | } IOUSBRootHubInterruptTransaction;␊ |
59 | ␊ |
60 | enum ␊ |
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 | ␊ |
75 | class IOUSBControllerV3 : public IOUSBControllerV2␊ |
76 | {␉␊ |
77 | ␉␉OSDeclareAbstractStructors(IOUSBControllerV3)␊ |
78 | ␊ |
79 | ␉protected:␊ |
80 | ␉␉// static variable shared by all instances␊ |
81 | ␉␉static uint32_t *␉␉␉␉_gHibernateState;␊ |
82 | ␊ |
83 | ␉␊ |
84 | ␉␉UInt8␉␉␉␉␉␉␉_myBusState;␉␉␉␉␉// kUSBBusStateReset, kUSBBusStateSuspended, kUSBBusStateRunning␊ |
85 | ␉␉bool␉␉␉␉␉␉␉_wakingFromHibernation;␉␉␉// True while the Hibernation Wake thread is active␊ |
86 | ␉␉bool␉␉␉␉␉␉␉_needToAckPowerDown;␉␉␉// True while we are changing power state due to shutdown/restart␊ |
87 | ␉␉bool␉␉␉␉␉␉␉_onCardBus;␉␉␉␉␉␉// OBSOLETE␊ |
88 | ␉␉bool␉␉␉␉␉␉␉_controllerAvailable;␉␉␉// true if we can talk to the controller␊ |
89 | ␉␉SInt32␉␉␉␉␉␉␉_powerStateChangingTo;␉␉␉// a power state that we are in the process of changing to, or -1 if we are stable␊ |
90 | ␉␉bool␉␉␉␉␉␉␉_poweringDown;␉␉␉␉␉// true is the controller is powering down because of a systemWillPowerDown message␊ |
91 | ␉␉bool␉␉␉␉␉␉␉_restarting;␉␉␉␉␉// true is the controller is restarting because of a systemWillPowerDown message␊ |
92 | ␉␉unsigned long␉␉␉␉␉_myPowerState;␉␉␉␉␉// my current state (since getPowerState doesn't always change in time)␊ |
93 | ␉␉IOUSBControllerV3␉␉␉␉*_ehciController;␉␉␉␉// set if I am a companion controller␊ |
94 | ␉␉unsigned long␉␉␉␉␉_numPowerStates;␉␉␉␉// how many power states do I support (defaults to kUSBNumDefaultPowerStates)␊ |
95 | ␉␉IOPMPowerState␉␉␉␉␉*_myPowerStates;␉␉␉␉// my power state array (allocated on the fly)␊ |
96 | ␉␉IOPCIDevice␉␉␉␉␉␉*_device;␉␉␉␉␉␉// my PCI device␊ |
97 | ␊ |
98 | ␉␉// root hub support␊ |
99 | ␉ IOTimerEventSource␉␉␉␉␉*_rootHubTimer;␉␉␉␉// timer which fires at the rate of the root hub interrupt endpoint␊ |
100 | ␉␉UInt8␉␉␉␉␉␉␉␉_rootHubPollingRate;␉␉// Obsolete -- we need to have it be a uint32_t␊ |
101 | ␉␉UInt8␉␉␉␉␉␉␉␉_rootHubNumPorts;␉␉␉// number of root hub ports - should be 15 or fewer!␊ |
102 | ␉␉UInt16␉␉␉␉␉␉␉␉_rootHubStatusChangedBitmap;␉// support up to 15 ports for status changes␊ |
103 | ␉␉bool␉␉␉␉␉␉␉␉_rootHubTimerActive;␉␉// UNUSED␊ |
104 | ␉␉IOUSBRootHubInterruptTransaction␉_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 | ␊ |
106 | ␉␉struct V3ExpansionData { ␊ |
107 | ␉␉␉uint32_t␉␉␉␉_rootHubPollingRate32;␊ |
108 | ␉␉␉bool␉␉␉␉␉_rootHubTransactionWasAborted;␊ |
109 | ␉␉};␊ |
110 | ␉␉V3ExpansionData *_v3ExpansionData;␊ |
111 | ␊ |
112 | ␉␉// IOKit methods␊ |
113 | ␉␉virtual bool␉␉␉␉␉init( OSDictionary * propTable );␊ |
114 | ␉␉virtual bool␉␉␉␉␉start( IOService * provider );␊ |
115 | ␉␉virtual void␉␉␉␉␉stop( IOService * provider );␊ |
116 | ␉␉virtual unsigned long␉␉␉maxCapabilityForDomainState ( IOPMPowerFlags domainState );␊ |
117 | ␉␉virtual unsigned long␉␉␉initialPowerStateForDomainState ( IOPMPowerFlags domainState );␊ |
118 | ␉␉virtual IOReturn␉␉␉␉powerStateWillChangeTo ( IOPMPowerFlags capabilities, unsigned long stateNumber, IOService* whatDevice);␊ |
119 | ␉␉virtual IOReturn␉␉␉␉setPowerState( unsigned long powerStateOrdinal, IOService* whatDevice );␊ |
120 | ␉␉virtual IOReturn␉␉␉␉powerStateDidChangeTo ( IOPMPowerFlags capabilities, unsigned long stateNumber, IOService* whatDevice);␊ |
121 | ␉␉virtual void␉␉␉␉␉powerChangeDone ( unsigned long fromState);␊ |
122 | ␉␉virtual void␉␉␉␉␉systemWillShutdown( IOOptionBits specifier );␊ |
123 | ␉␉virtual void␉␉␉␉␉free(void);␊ |
124 | ␉␊ |
125 | ␉␉// IOUSBController methods␊ |
126 | ␉␉// we override these to deal with methods attempting to go through the workloop while we are in sleep␊ |
127 | ␉␉virtual IOReturn ␉␉AcquireDeviceZero( void );␊ |
128 | ␉␉virtual void␉␉␉ReleaseDeviceZero( void );␊ |
129 | ␉␉virtual IOReturn ␉␉DeviceRequest(IOUSBDevRequest *request, IOUSBCompletion *completion, USBDeviceAddress address, UInt8 epNum, UInt32 noDataTimeout, UInt32 completionTimeout);␊ |
130 | ␉␉virtual IOReturn ␉␉DeviceRequest(IOUSBDevRequestDesc *request, IOUSBCompletion *completion, USBDeviceAddress address, UInt8 epNum, UInt32 noDataTimeout, UInt32 completionTimeout);␊ |
131 | ␉␉virtual IOReturn ␉␉ClosePipe(USBDeviceAddress address, Endpoint *endpoint);␊ |
132 | ␉␉virtual IOReturn ␉␉AbortPipe(USBDeviceAddress address, Endpoint *endpoint);␊ |
133 | ␉␉virtual IOReturn ␉␉ResetPipe(USBDeviceAddress address, Endpoint *endpoint);␊ |
134 | ␉␉virtual IOReturn ␉␉ClearPipeStall(USBDeviceAddress address, Endpoint *endpoint);␊ |
135 | ␉␉virtual IOReturn ␉␉Read(IOMemoryDescriptor *buffer, USBDeviceAddress address, Endpoint *endpoint, IOUSBCompletion *completion, UInt32 noDataTimeout, UInt32 completionTimeout, IOByteCount reqCount);␊ |
136 | ␉␉virtual IOReturn ␉␉Write(IOMemoryDescriptor *buffer, USBDeviceAddress address, Endpoint *endpoint, IOUSBCompletion *completion, UInt32 noDataTimeout, UInt32 completionTimeout, IOByteCount reqCount);␊ |
137 | ␉␉virtual IOReturn␉␉IsocIO(IOMemoryDescriptor *buffer, UInt64 frameStart, UInt32 numFrames, IOUSBIsocFrame *frameList, USBDeviceAddress address, Endpoint *endpoint, IOUSBIsocCompletion *completion );␊ |
138 | ␉␉virtual IOReturn␉␉IsocIO(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␊ |
142 | ␉␉virtual IOReturn ␉␉OpenPipe(USBDeviceAddress address, UInt8 speed, Endpoint *endpoint);␊ |
143 | ␉␉virtual IOReturn␉␉AddHSHub(USBDeviceAddress highSpeedHub, UInt32 flags);␊ |
144 | ␉␉virtual IOReturn␉␉RemoveHSHub(USBDeviceAddress highSpeedHub);␊ |
145 | ␉␉virtual IOReturn␉␉SetTestMode(UInt32 mode, UInt32 port);␊ |
146 | ␉␉virtual IOReturn␉␉ReadV2(IOMemoryDescriptor *buffer, USBDeviceAddress␉address, Endpoint *endpoint, IOUSBCompletionWithTimeStamp *completion, UInt32 noDataTimeout, UInt32␉completionTimeout, IOByteCount reqCount);␊ |
147 | ␉␊ |
148 | ␉␉// IOUSBControllerV3 methods␊ |
149 | ␉␊ |
150 | ␉␉// these are called through the workloop␊ |
151 | ␉␉static IOReturn␉␉␉␉␉DoEnableAddressEndpoints(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3 );␊ |
152 | ␉␉static IOReturn␉␉␉␉␉DoEnableAllEndpoints(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3 );␊ |
153 | ␉␉static IOReturn␉␉␉␉␉GatedPowerChange(OSObject *owner, void *arg0, void *arg1, void *arg2, void *arg3 );␊ |
154 | ␊ |
155 | ␉␉// also on the workloop␊ |
156 | ␉ static void␉␉␉␉␉␉RootHubTimerFired(OSObject *owner, IOTimerEventSource *sender);␊ |
157 | ␉␊ |
158 | ␉␉// subclassable methods␊ |
159 | ␉␉virtual IOReturn␉␉␉␉CheckForEHCIController(IOService *provider);␊ |
160 | ␉␉virtual␉IOReturn␉␉␉␉AllocatePowerStateArray(void);␊ |
161 | ␉␉virtual␉IOReturn␉␉␉␉InitForPM(void);␊ |
162 | ␉␉virtual IOReturn␉␉␉␉CheckPowerModeBeforeGatedCall(char *fromStr);␊ |
163 | ␉␉virtual IOReturn␉␉␉␉EnableAllEndpoints(bool enable);␊ |
164 | ␉␉virtual IOReturn␉␉␉␉EnableBusMastering(bool enable);␊ |
165 | ␉␉virtual IOReturn␉␉␉␉EnsureUsability(void);␊ |
166 | ␉␉virtual IOReturn␉␉␉␉CheckForRootHubChanges(void);␊ |
167 | ␉␉virtual IOReturn␉␉␉␉RootHubQueueInterruptRead(IOMemoryDescriptor *buf, UInt32 bufLen, IOUSBCompletion completion);␊ |
168 | ␉␉virtual IOReturn␉␉␉␉RootHubAbortInterruptRead(void);␊ |
169 | ␉␉virtual IOReturn␉␉␉␉RootHubStartTimer(UInt8 pollingRate);␉␉␉// Obsolete see RootHubStartTimer32␊ |
170 | ␉␉virtual IOReturn␉␉␉␉RootHubStopTimer(void);␊ |
171 | ␉␊ |
172 | ␉␉// these methods have a default implementation using some of the virtual methods below␊ |
173 | ␉␉virtual␉void␉␉␉␉␉ControllerOff(void);␊ |
174 | ␉␉virtual␉void␉␉␉␉␉ControllerRestart(void);␊ |
175 | ␉␉virtual␉void␉␉␉␉␉ControllerSleep(void);␊ |
176 | ␉␉virtual␉void␉␉␉␉␉ControllerDoze(void);␊ |
177 | ␉␉virtual␉void␉␉␉␉␉ControllerOn(void);␊ |
178 | ␊ |
179 | ␉␉// these methods are pure virtual, and need to be implemented in the subclass driver␊ |
180 | ␉␉virtual␉IOReturn␉␉␉␉ResetControllerState(void) = 0;␊ |
181 | ␉␉virtual IOReturn␉␉␉␉RestartControllerFromReset(void) = 0;␊ |
182 | ␉␉virtual␉IOReturn␉␉␉␉SaveControllerStateForSleep(void) = 0;␊ |
183 | ␉␉virtual␉IOReturn␉␉␉␉RestoreControllerStateFromSleep(void) = 0;␊ |
184 | ␉␉virtual IOReturn␉␉␉␉DozeController(void) = 0;␊ |
185 | ␉␉virtual IOReturn␉␉␉␉WakeControllerFromDoze(void) = 0;␊ |
186 | ␉␉virtual IOReturn␉␉␉␉UIMEnableAddressEndpoints(USBDeviceAddress address, bool enable) = 0;␊ |
187 | ␉␉virtual IOReturn␉␉␉␉UIMEnableAllEndpoints(bool enable) = 0;␊ |
188 | ␉␉virtual IOReturn␉␉␉␉EnableInterruptsFromController(bool enable) = 0;␊ |
189 | ␉␊ |
190 | ␉public:␊ |
191 | ␉␊ |
192 | ␉␉// public methods␊ |
193 | ␉␉virtual IOReturn␉␉␉␉EnableAddressEndpoints(USBDeviceAddress address, bool enable);␊ |
194 | ␉␉virtual bool␉␉␉␉␉IsControllerAvailable(void);␊ |
195 | ␉␉virtual IOReturn␉␉␉␉HandlePowerChange(unsigned long powerStateOrdinal);␊ |
196 | ␉␉virtual␉UInt32␉␉␉␉␉AllocateExtraRootHubPortPower(UInt32 extraPowerRequested);␊ |
197 | ␉␉virtual␉void␉␉␉␉␉ReturnExtraRootHubPortPower(UInt32 extraPowerReturned);␊ |
198 | ␉␊ |
199 | ␉OSMetaClassDeclareReservedUsed(IOUSBControllerV3, 0);␊ |
200 | ␉virtual IOReturn␉␉␉␉RootHubStartTimer32(uint32_t pollingRate);␊ |
201 | ␉␊ |
202 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 1);␊ |
203 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 2);␊ |
204 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 3);␊ |
205 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 4);␊ |
206 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 5);␊ |
207 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 6);␊ |
208 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 7);␊ |
209 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 8);␊ |
210 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 9);␊ |
211 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 10);␊ |
212 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 11);␊ |
213 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 12);␊ |
214 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 13);␊ |
215 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 14);␊ |
216 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 15);␊ |
217 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 16);␊ |
218 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 17);␊ |
219 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 18);␊ |
220 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 19);␊ |
221 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 20);␊ |
222 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 21);␊ |
223 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 22);␊ |
224 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 23);␊ |
225 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 24);␊ |
226 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 25);␊ |
227 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 26);␊ |
228 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 27);␊ |
229 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 28);␊ |
230 | ␉OSMetaClassDeclareReservedUnused(IOUSBControllerV3, 29);␊ |
231 | };␊ |
232 | ␊ |
233 | #endif␉␉// _IOKIT_IOUSBCONTROLLERV3_H |