Chameleon

Chameleon Svn Source Tree

Root/branches/rewrite/i386/include/IOKit/pwr_mgt/RootDomain.h

Source at commit 1129 created 12 years 11 months ago.
By meklort, Change options.o so that it reloads the system config as well. Also change it so that it uses that config for variables (NOTE: if the calue exists in chameleonConfig, it's used instead.
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28#ifndef _IOKIT_ROOTDOMAIN_H
29#define _IOKIT_ROOTDOMAIN_H
30
31#include <IOKit/IOService.h>
32#include <IOKit/pwr_mgt/IOPM.h>
33#include "IOKit/pwr_mgt/IOPMPrivate.h"
34
35
36class IOPMPowerStateQueue;
37class RootDomainUserClient;
38class PMTraceWorker;
39
40/*
41 * Flags for get/setSleepSupported()
42 */
43enum {
44 kRootDomainSleepNotSupported= 0x00000000,
45 kRootDomainSleepSupported = 0x00000001,
46 kFrameBufferDeepSleepSupported= 0x00000002,
47 kPCICantSleep = 0x00000004
48};
49
50/*
51 *IOPMrootDomain registry property keys
52 */
53#define kRootDomainSupportedFeatures "Supported Features"
54#define kRootDomainSleepReasonKey "Last Sleep Reason"
55#define kRootDomainSleepOptionsKey "Last Sleep Options"
56#define kIOPMRootDomainWakeReasonKey "Wake Reason"
57#define kIOPMRootDomainWakeTypeKey "Wake Type"
58#define kIOPMRootDomainPowerStatusKey "Power Status"
59
60/*
61 * Possible sleep reasons found under kRootDomainSleepReasonsKey
62 */
63#define kIOPMClamshellSleepKey "Clamshell Sleep"
64#define kIOPMPowerButtonSleepKey "Power Button Sleep"
65#define kIOPMSoftwareSleepKey "Software Sleep"
66#define kIOPMOSSwitchHibernationKey "OS Switch Sleep"
67#define kIOPMIdleSleepKey "Idle Sleep"
68#define kIOPMLowPowerSleepKey "Low Power Sleep"
69#define kIOPMThermalEmergencySleepKey "Thermal Emergency Sleep"
70#define kIOPMMaintenanceSleepKey "Maintenance Sleep"
71
72/*
73 * String constants for communication with PM CPU
74 */
75#define kIOPMRootDomainLidCloseCString "LidClose"
76#define kIOPMRootDomainBatPowerCString "BatPower"
77
78/*
79 * Supported Feature bitfields for IOPMrootDomain::publishFeature()
80 */
81enum {
82 kIOPMSupportedOnAC = (1<<0),
83 kIOPMSupportedOnBatt = (1<<1),
84 kIOPMSupportedOnUPS = (1<<2)
85};
86
87typedef IOReturn (*IOPMSettingControllerCallback)
88 (OSObject *target, const OSSymbol *type,
89 OSObject *val, uintptr_t refcon);
90
91__BEGIN_DECLS
92IONotifier * registerSleepWakeInterest(
93 IOServiceInterestHandler, void *, void * = 0);
94
95IONotifier * registerPrioritySleepWakeInterest(
96 IOServiceInterestHandler handler,
97 void * self, void * ref = 0);
98
99IOReturn acknowledgeSleepWakeNotification(void * );
100
101IOReturn vetoSleepWakeNotification(void * PMrefcon);
102__END_DECLS
103
104#define IOPM_ROOTDOMAIN_REV2
105
106class IOPMrootDomain: public IOService
107{
108 OSDeclareFinalStructors(IOPMrootDomain)
109
110public:
111 static IOPMrootDomain * construct( void );
112
113 virtual bool start( IOService * provider );
114 virtual IOReturn setAggressiveness( unsigned long, unsigned long );
115 virtual IOReturn getAggressiveness( unsigned long, unsigned long * );
116
117 virtual IOReturn sleepSystem( void );
118 IOReturn sleepSystemOptions( OSDictionary *options );
119
120 virtual IOReturn setProperties( OSObject * );
121
122/*! @function systemPowerEventOccurred
123 @abstract Other drivers may inform IOPMrootDomain of system PM events
124 @discussion systemPowerEventOccurred is a richer alternative to receivePowerNotification()
125 Only Apple-owned kexts should have reason to call systemPowerEventOccurred.
126 @param event An OSSymbol describing the type of power event.
127 @param value A 32-bit integer value associated with the event.
128 @param shouldUpdate indicates whether the root domain should send a notification
129 to interested parties. Pass false if you're calling systemPowerEventOccurred
130 several times in succession; and pass true only on the last invocatino.
131 @result kIOReturnSuccess on success */
132
133 IOReturn systemPowerEventOccurred(
134 const OSSymbol *event,
135 uint32_t intValue );
136
137 IOReturn systemPowerEventOccurred(
138 const OSSymbol *event,
139 OSObject *value );
140
141 virtual IOReturn receivePowerNotification( UInt32 msg );
142
143 virtual void setSleepSupported( IOOptionBits flags );
144
145 virtual IOOptionBits getSleepSupported( void );
146
147 void wakeFromDoze( void );
148
149 // KEXT driver announces support of power management feature
150
151 void publishFeature( const char *feature );
152
153 // KEXT driver announces support of power management feature
154 // And specifies power sources with kIOPMSupportedOn{AC/Batt/UPS} bitfield.
155 // Returns a unique uint32_t identifier for later removing support for this
156 // feature.
157 // NULL is acceptable for uniqueFeatureID for kexts without plans to unload.
158
159 void publishFeature( const char *feature,
160 uint32_t supportedWhere,
161 uint32_t *uniqueFeatureID);
162
163 // KEXT driver announces removal of a previously published power management
164 // feature. Pass 'uniqueFeatureID' returned from publishFeature()
165
166 IOReturn removePublishedFeature( uint32_t removeFeatureID );
167
168/*! @function copyPMSetting
169 @abstract Copy the current value for a PM setting. Returns an OSNumber or
170 OSData depending on the setting.
171 @param whichSetting Name of the desired setting.
172 @result OSObject value if valid, NULL otherwise. */
173
174 OSObject * copyPMSetting( OSSymbol *whichSetting );
175
176/*! @function registerPMSettingController
177 @abstract Register for callbacks on changes to certain PM settings.
178 @param settings NULL terminated array of C strings, each string for a PM
179 setting that the caller is interested in and wants to get callbacks for.
180 @param callout C function ptr or member function cast as such.
181 @param target The target of the callback, usually 'this'
182 @param refcon Will be passed to caller in callback; for caller's use.
183 @param handle Caller should keep the OSObject * returned here. If non-NULL,
184 handle will have a retain count of 1 on return. To deregister, pass to
185 unregisterPMSettingController()
186 @result kIOReturnSuccess on success. */
187
188 IOReturn registerPMSettingController(
189 const OSSymbol *settings[],
190 IOPMSettingControllerCallback callout,
191 OSObject *target,
192 uintptr_t refcon,
193 OSObject **handle); // out param
194
195/*! @function registerPMSettingController
196 @abstract Register for callbacks on changes to certain PM settings.
197 @param settings NULL terminated array of C strings, each string for a PM
198 setting that the caller is interested in and wants to get callbacks for.
199 @param supportedPowerSources bitfield indicating which power sources these
200 settings are supported for (kIOPMSupportedOnAC, etc.)
201 @param callout C function ptr or member function cast as such.
202 @param target The target of the callback, usually 'this'
203 @param refcon Will be passed to caller in callback; for caller's use.
204 @param handle Caller should keep the OSObject * returned here. If non-NULL,
205 handle will have a retain count of 1 on return. To deregister, pass to
206 unregisterPMSettingController()
207 @result kIOReturnSuccess on success. */
208
209 IOReturn registerPMSettingController(
210 const OSSymbol *settings[],
211 uint32_t supportedPowerSources,
212 IOPMSettingControllerCallback callout,
213 OSObject *target,
214 uintptr_t refcon,
215 OSObject **handle); // out param
216
217 virtual IONotifier * registerInterest(
218 const OSSymbol * typeOfInterest,
219 IOServiceInterestHandler handler,
220 void * target, void * ref = 0 );
221
222 void pmStatsRecordEvent(
223 int eventIndex,
224 AbsoluteTime timestamp);
225
226 void pmStatsRecordApplicationResponse(
227 const OSSymbol*response,
228 const char *name,
229 int messageType,
230 uint32_tdelay_ms,
231 int app_pid);
232
233 virtual IOReturn callPlatformFunction(
234 const OSSymbol *functionName,
235 bool waitForFunction,
236 void *param1, void *param2,
237 void *param3, void *param4 );
238
239private:
240 virtual IOReturn changePowerStateTo( unsigned long ordinal );
241 virtual IOReturn changePowerStateToPriv( unsigned long ordinal );
242 virtual IOReturn requestPowerDomainState( IOPMPowerFlags, IOPowerConnection *, unsigned long );
243 virtual void powerChangeDone( unsigned long );
244 virtual bool tellChangeDown( unsigned long );
245 virtual bool askChangeDown( unsigned long );
246 virtual void tellChangeUp( unsigned long );
247 virtual void tellNoChangeDown( unsigned long );
248};
249
250
251#endif /* _IOKIT_ROOTDOMAIN_H */
252

Archive Download this file

Revision: 1129