|
|
1.1 root 1: /*
2: * Copyright (c) 1998-2000 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.1 (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 OR NON-INFRINGEMENT. Please see the
17: * License for the specific language governing rights and limitations
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: #include <libkern/c++/OSObject.h>
23: #include <IOKit/IOLocks.h>
24: class IOPMinformee;
25: class IOPMinformeeList;
26: class IOPMchangeNoteList;
27: class IOPMpmChild;
28: class IOWorkLoop;
29: class IOCommandQueue;
30: class IOTimerEventSource;
31: class IOPlatformExpert;
32:
33: #include <IOKit/pwr_mgt/IOPM.h>
34:
35:
36: /*!
37: @defined ACK_TIMER_PERIOD
38: @discussion When an IOService is waiting for acknowledgement to a power state change
39: notification from an interested driver or the controlling driver its ack timer is ticking every tenth of a second.
40: (100000000 nanoseconds are one tenth of a second).
41: */
42: #define ACK_TIMER_PERIOD 100000000
43:
44:
45: /*!
46: @defined State machine states
47: @discussion The current change note is processed by a state machine.
48: Inputs are acks from interested parties, ack from the controlling driver,
49: ack timeouts, settle timeout, and powerStateDidChange from the parent.
50: */
51: #define IOPMour_prechange_1 1
52: #define IOPMour_prechange_2 2
53: #define IOPMour_prechange_3 3
54: #define IOPMour_prechange_4 4
55: #define IOPMparent_prechange_down_3 5
56: #define IOPMparent_prechange_down_4 6
57: #define IOPMparent_prechange_down_5 7
58: #define IOPMparent_postchange_down_1 8
59: #define IOPMparent_postchange_down_2 9
60: #define IOPMparent_prechange_up_1 10
61: #define IOPMparent_postchange_up_1 11
62: #define IOPMparent_postchange_up_4 12
63: #define IOPMparent_postchange_up_5 13
64: #define IOPMparent_postchange_up_6 14
65: #define IOPMparent_postchange_null 15
66: #define IOPMfinished 16
67:
68: /*!
69: @class IOPMpriv : public OSObject
70: @abstract Private power management private instance variables for IOService objects.
71: */
72: class IOPMpriv : public OSObject
73: {
74: friend class IOService;
75:
76: OSDeclareDefaultStructors(IOPMpriv)
77:
78: public:
79:
80: /*! @field we_are_root TRUE if this device is the root power domain */
81: bool we_are_root;
82:
83: /*! @field interestedDrivers list of interested drivers */
84: IOPMinformeeList * interestedDrivers;
85:
86: /*! @field children list of power domain children */
87: IOPMinformeeList * children;
88:
89: /*! @field numberOfInformees sum of lengths of driver list and children list */
90: unsigned long numberOfInformees;
91:
92: /*! @field changeList list of pending power state changes */
93: IOPMchangeNoteList * changeList;
94:
95: /*! @field driver_timer timeout on waiting for controlling driver to acknowledgeSetPowerState */
96: IOReturn driver_timer;
97:
98: /*! @field machine_state state number of state machine processing current change note */
99: unsigned long machine_state;
100:
101: /*! @field settle_time settle timer after changing power state */
102: unsigned long settle_time;
103:
104: /*! @field head_note ordinal of change note currently being processed */
105: long head_note;
106:
107: /*! @field head_note_flags copy of flags field in change note currently being processed*/
108: unsigned long head_note_flags;
109:
110: /*! @field head_note_state copy of newStateNumberfield in change note currently being processed */
111: unsigned long head_note_state;
112:
113: /*! @field head_note_outputFlags outputPowerCharacter field from change note currently being processed */
114: unsigned long head_note_outputFlags;
115:
116: /*! @field head_note_inputFlags power domain flags from parent... (only on parent change) */
117: unsigned long head_note_domainState;
118:
119: /*! @field head_note_capabilityFlags copy of capabilityFlags field in change note currently being processed */
120: unsigned long head_note_capabilityFlags;
121:
122: /*! @field head_note_pendingAcks number of acks we are waiting for during notification */
123: unsigned long head_note_pendingAcks;
124:
125: /*! @field our_lock used to control access to head_note_pendingAcks and driver_timer */
126: IOLock * our_lock;
127:
128: /*! @field initial_change true forces first state to be broadcast even if it isn't a change */
129: bool initial_change;
130:
131: /*! @field need_to_become_usable someone called makeUsable before we had a controlling driver */
132: bool need_to_become_usable;
133:
134: /*! @field device_overrides state changes are made based only on subclass's desire */
135: bool device_overrides;
136:
137: /*! @field owner points to object which made this struct. Used for debug output only */
138: IOService * owner;
139:
140: /*! @field activityLock used to protect activity flag */
141: IOLock * activityLock;
142:
143: /*! @field timerEventSrc an idle timer */
144: IOTimerEventSource * timerEventSrc;
145:
146: /*! @field idle_timer_period its period in seconds */
147: unsigned long idle_timer_period;
148:
149: /*! @field device_active true: there has been device activity since last idle timer expiration */
150: bool device_active;
151:
152: /*! @field driverDesire
153: This is the power state desired by our controlling driver. It is initialized to myCurrentState and is changed
154: when the controlling driver calls changeStateTo. A change in driverDesire may cause a change in ourDesiredPowerState.
155: */
156: unsigned long driverDesire;
157:
158:
159:
160: /*! @field deviceDesire
161: This is the power state desired by a subclassed device object. It is initialized to myCurrentState and is changed
162: when the subclassed object calls changeStateToPriv. A change in deviceDesire may cause a change in ourDesiredPowerState.
163: */
164: unsigned long deviceDesire;
165:
166:
167:
168: /*! @field ourDesiredPowerState
169: This is the power state we desire currently. If equal to myCurrentState, we're happy.
170: Otherwise, we're waiting for the parent to raise the power domain to at least this level.
171:
172: If this is a power domain, this is the maximum of all our children's desires, driverDesire, and deviceDesire.
173: It increases when:
174: a child asks for more power via requestDomainState,
175: the controlling driver asks for more power via changeStateTo
176:
177: It decreases when:
178: we lose a child and the child had the highest power need of all our children,
179: the child with the highest power need suggests a lower power domain state,
180: the controlling driver asks for lower power for some reason via changeStateTo
181:
182: If this is not a power domain, ourDesiredPowerState represents the greater of driverDesire and deviceDesire.
183: It increases when:
184: the controlling driver asks for more power via changeStateTo
185: some driver calls makeUsable
186: a subclassed object asks for more power via changeStateToPriv
187:
188: It decreases when:
189: the controlling driver asks for lower power for some reason via changeStateTo
190: a subclassed object asks for lower power for some reason via changeStateToPriv
191: */
192: unsigned long ourDesiredPowerState;
193:
194:
195: /*! @field previousRequest
196: This is a reminder of what our parent thinks our need is. Whenever it changes,
197: we call requestDomainState in the parent to keep it current. It is usually equal to ourDesiredPowerState
198: except while a power change is in progress.
199: */
200: unsigned long previousRequest;
201:
202:
203: /*! @field askingFor
204: Used by activityTickle so it doesn't try to raise the device to a lower state than
205: what it may have previously requested.
206: */
207: unsigned long askingFor;
208:
209:
210: /*! @field imminentState
211: Usually the same as myCurrentState, except right after calling powerStateWillChangeTo.
212: */
213: unsigned long imminentState;
214:
215: /*! @function serialize
216: Serialize private instance variables for debug output (IORegistryDumper).
217: */
218: virtual bool serialize(OSSerialize *s) const;
219:
220: };
221:
222:
223:
224:
225: /*!
226: @class IOPMprot : public OSObject
227: @abstract Protected power management instance variables for IOService objects.
228: */
229: class IOPMprot : public OSObject //management
230: {
231: friend class IOService;
232:
233: OSDeclareDefaultStructors(IOPMprot)
234:
235: public:
236:
237: /*! @field ourName from getName(), used in logging */
238: const char * ourName;
239:
240: /*! @field thePlatform from getPlatform, used in logging and registering */
241: IOPlatformExpert * thePlatform;
242:
243: /*! @field theNumberOfPowerStates the number of states in the array */
244: unsigned long theNumberOfPowerStates; // the number of states in the array
245:
246: /*! @field thePowerStates the array */
247: IOPMPowerState thePowerStates[IOPMMaxPowerStates];
248:
249: /*! @field myParent power domain parent */
250: IOService * myParent;
251:
252: /*! @field theControllingDriver points to the controlling driver */
253: IOService * theControllingDriver;
254:
255: /*! @field aggressiveness current value of power management aggressiveness */
256: unsigned long aggressiveness;
257:
258: /*! @field myCurrentState the ordinal of our current power state */
259: unsigned long myCurrentState;
260:
261: /*! @field parentCurrentPowerFlags the power flags of the current state of the power domain (our parent) */
262: IOPMPowerFlags parentCurrentPowerFlags;
263:
264: /*! @field maxCapability ordinal of highest state we can achieve in current power domain state */
265: unsigned long maxCapability;
266:
267: /*! @field PMworkloop points to the single power management workloop */
268: IOWorkLoop * PMworkloop;
269:
270: /*! @field commandQueue used to serialize idle-power-down and busy-power-up */
271: IOCommandQueue * commandQueue;
272:
273: /*! @function serialize
274: Serialize protected instance variables for debug output (IORegistryDumper).
275: */
276: virtual bool serialize(OSSerialize *s) const;
277:
278: };
279:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.