]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/IOKit/pwr_mgt/IOPM.h
xnu-792.17.14.tar.gz
[apple/xnu.git] / iokit / IOKit / pwr_mgt / IOPM.h
index 6809d125b611881ed0e87e53623adec113ed6c2c..bf6902e6b7bc5ae7a6173cb6a57acb3892d83145 100644 (file)
@@ -1,23 +1,29 @@
 /*
  * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 #ifndef _IOKIT_IOPM_H
 #define _IOKIT_IOPM_H
 #define IOPMMaxPowerStates 10
 
 typedef unsigned long IOPMPowerFlags;
+enum {
+                        // following  bits are used in the input and output power fields
+    kIOPMClockNormal           = 0x0004,
+    kIOPMClockRunning          = 0x0008,
+    kIOPMAuxPowerOn            = 0x0020,       // used only between root and root parent
+    kIOPMPagingAvailable       = 0x0020,       // used only between paging plexus and its children
+    kIOPMPassThrough           = 0x0100,
+    kIOPMDoze                  = 0x0400,
+    kIOPMSoftSleep             = 0x0400,       // old usage, replaced by kIOPMDoze
+    kIOPMSleep                 = 0x0001,
+    kIOPMRestart               = 0x0080,
+                        // following  bits are used in the capabilites field and the power fields
+    kIOPMPowerOn               = 0x0002,
+    kIOPMPreventSystemSleep    = 0x0010,
+    kIOPMPreventIdleSleep      = 0x0040,
+                        // following  bits are used in the capabilites field
+    kIOPMNotAttainable         = 0x0001,       // used between a driver and its policy-maker
+    kIOPMChildClamp            = 0x0080,       // used internally in a power domain parent
+    kIOPMChildClamp2           = 0x0200,       // used internally in a power domain parent
+    kIOPMDeviceUsable          = 0x8000,
+    kIOPMMaxPerformance                = 0x4000,
+    kIOPMContextRetained       = 0x2000,
+    kIOPMConfigRetained                = 0x1000,
+    kIOPMSleepCapability       = 0x0004,
+    kIOPMRestartCapability     = 0x0080,
+    kIOPMNotPowerManaged       = 0x0800,       // this is an error return rather than a bit
+    kIOPMStaticPowerValid      = 0x0800,       // therefore this bit safely overloads it
+    
+    kIOPMCapabilitiesMask =     kIOPMPowerOn | kIOPMDeviceUsable | kIOPMMaxPerformance |
+                                kIOPMContextRetained | kIOPMConfigRetained | kIOPMSleepCapability |
+                                kIOPMRestartCapability
+};
+
+
+enum {
+    IOPMNotAttainable  = kIOPMNotAttainable,
+    IOPMPowerOn                = kIOPMPowerOn,
+    IOPMClockNormal    = kIOPMClockNormal,
+    IOPMClockRunning   = kIOPMClockRunning,
+    IOPMAuxPowerOn     = kIOPMAuxPowerOn,
+    IOPMDeviceUsable   = kIOPMDeviceUsable,
+    IOPMMaxPerformance = kIOPMMaxPerformance,
+    IOPMContextRetained        = kIOPMContextRetained,
+    IOPMConfigRetained = kIOPMConfigRetained,
+    IOPMNotPowerManaged        = kIOPMNotPowerManaged,
+    IOPMPagingAvailable        = kIOPMPagingAvailable,
+    IOPMSoftSleep      = kIOPMSoftSleep
+};
+
+
+enum {
+    kIOPMNextHigherState       = 1,
+    kIOPMHighestState          = 2,
+    kIOPMNextLowerState                = 3,
+    kIOPMLowestState           = 4
+};
+
+enum {
+    IOPMNextHigherState                = kIOPMNextHigherState,
+    IOPMHighestState           = kIOPMHighestState,
+    IOPMNextLowerState         = kIOPMNextLowerState,
+    IOPMLowestState            = kIOPMLowestState
+};
 
-#define IOPMNotAttainable      0x0001
-#define IOPMPowerOn            0x0002
-#define IOPMClockNormal        0x0004
-#define IOPMClockRunning       0x0008
-#define IOPMWakeupEnabled      0x0010
-#define IOPMAuxPowerOn         0x0020
-                        // following "capabilites" exist for the convenience
-                        // of the "interested drivers"
-#define IOPMDeviceUsable       0x8000
-#define IOPMMaxPerformance     0x4000
-#define IOPMContextRetained    0x2000
-#define IOPMConfigRetained     0x1000
-#define IOPMNotPowerManaged    0x0800
-#define IOPMSoftSleep          0x0400
-
-#define IOPMNextHigherState    1
-#define IOPMHighestState       2
-#define IOPMNextLowerState     3
-#define IOPMLowestState                4
 
 
 enum {         // commands on power managment command queue
-    kPMbroadcastAggressiveness = 1,
-    kPMunIdleDevice,
-    kPMsleepDemand,
-    kPMwakeSignal,
-    kPMallowSleep,
-    kPMcancelSleep
+    kIOPMBroadcastAggressiveness = 1,
+    kIOPMUnidleDevice
+};
+
+enum {         // special value means "power consumption unknown"
+    kIOPMUnknown = 0xFFFF
 };
 
 // Power events
@@ -73,7 +123,10 @@ enum {
   kIOPMPowerButton              = (1<<3),  // power button was pressed
   kIOPMClamshellClosed          = (1<<4),  // clamshell was closed
   kIOPMPowerEmergency           = (1<<5),  // battery dangerously low
-  kIOPMIgnoreClamshell          = (1<<6)   // take no action on clamshell closure
+  kIOPMDisableClamshell                 = (1<<6),  // do not sleep on clamshell closure
+  kIOPMEnableClamshell          = (1<<7),  // sleep on clamshell closure
+  kIOPMProcessorSpeedChange     = (1<<8),  // change the processor speed
+  kIOPMOverTemp                  = (1<<9)   // system dangerously hot
 };
                                         // Return codes
 
@@ -219,17 +272,32 @@ enum {
     kPMGeneralAggressiveness = 0,
     kPMMinutesToDim,
     kPMMinutesToSpinDown,
-    kPMMinutesToSleep
+    kPMMinutesToSleep,
+    kPMEthernetWakeOnLANSettings,
+    kPMSetProcessorSpeed,
+    kPMPowerSource,
+    kPMMotionSensor,
+    kPMLastAggressivenessType
 };
-#define kMaxType kPMMinutesToSleep
+#define kMaxType (kPMLastAggressivenessType-1)
 
+// SetAggressiveness values for the kPMPowerSource aggressiveness type
+enum {
+    kIOPMInternalPower = 1,
+    kIOPMExternalPower
+};
 
+#define kAppleClamshellStateKey           "AppleClamshellState"
+#define kIOREMSleepEnabledKey             "REMSleepEnabled"
+
+// Strings for deciphering the dictionary returned from IOPMCopyBatteryInfo
 #define kIOBatteryInfoKey              "IOBatteryInfo"
 #define kIOBatteryCurrentChargeKey     "Current"
 #define kIOBatteryCapacityKey          "Capacity"
 #define kIOBatteryFlagsKey             "Flags"
 #define kIOBatteryVoltageKey           "Voltage"
 #define kIOBatteryAmperageKey          "Amperage"
+
 enum {
     kIOBatteryInstalled                = (1 << 2),
     kIOBatteryCharge           = (1 << 1),
@@ -237,6 +305,49 @@ enum {
 };
 
 
+// Private power management message indicating battery data has changed
+// Indicates new data resides in the IORegistry
+#define kIOPMMessageBatteryStatusHasChanged         iokit_family_msg(sub_iokit_pmu, 0x100)
+
+// Apple private Legacy messages for re-routing AutoWake and AutoPower messages to the PMU
+// through newer user space IOPMSchedulePowerEvent API
+#define kIOPMUMessageLegacyAutoWake                 iokit_family_msg(sub_iokit_pmu, 0x200)
+#define kIOPMUMessageLegacyAutoPower                   iokit_family_msg(sub_iokit_pmu, 0x210)
+
+// These flags are deprecated. Use the version with the kIOPM prefix below.
+enum {
+  kACInstalled      = kIOBatteryChargerConnect,
+  kBatteryCharging  = kIOBatteryCharge,
+  kBatteryInstalled = kIOBatteryInstalled,
+  kUPSInstalled     = (1<<3),
+  kBatteryAtWarn    = (1<<4),
+  kBatteryDepleted  = (1<<5),
+  kACnoChargeCapability = (1<<6),     // AC adapter cannot charge battery
+  kRawLowBattery    = (1<<7),         // used only by  Platform Expert
+  kForceLowSpeed    = (1<<8)         // set by Platfm Expert, chk'd by Pwr Plugin};
+};
+
+// For use with IOPMPowerSource bFlags
+#define IOPM_POWER_SOURCE_REV   2
+enum {
+  kIOPMACInstalled      = kIOBatteryChargerConnect,
+  kIOPMBatteryCharging  = kIOBatteryCharge,
+  kIOPMBatteryInstalled = kIOBatteryInstalled,
+  kIOPMUPSInstalled     = (1<<3),
+  kIOPMBatteryAtWarn    = (1<<4),
+  kIOPMBatteryDepleted  = (1<<5),
+  kIOPMACnoChargeCapability = (1<<6),     // AC adapter cannot charge battery
+  kIOPMRawLowBattery    = (1<<7),         // used only by  Platform Expert
+  kIOPMForceLowSpeed    = (1<<8),         // set by Platfm Expert, chk'd by Pwr Plugin
+  kIOPMClosedClamshell  = (1<<9),         // set by PMU - reflects state of the clamshell
+  kIOPMClamshellStateOnWake = (1<<10)     // used only by Platform Expert
+};
+
+
+// **********************************************
+// Internal power management data structures
+// **********************************************
+
 #if KERNEL && __cplusplus
 class IOService;
 
@@ -256,11 +367,14 @@ struct stateChangeNote{
 };
 typedef struct stateChangeNote stateChangeNote;
 
-struct sleepWakeNote{
+struct IOPowerStateChangeNotification {
     void *             powerRef;
     unsigned long      returnValue;
+    unsigned long      stateNumber;
+    IOPMPowerFlags     stateFlags;
 };
-typedef struct sleepWakeNote sleepWakeNote;
+typedef struct IOPowerStateChangeNotification IOPowerStateChangeNotification;
+typedef IOPowerStateChangeNotification sleepWakeNote;
 
 extern void IOPMRegisterDevice(const char *, IOService *);
 #endif /* KERNEL && __cplusplus */