]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/IOKit/pwr_mgt/IOPM.h
xnu-1699.32.7.tar.gz
[apple/xnu.git] / iokit / IOKit / pwr_mgt / IOPM.h
index 1d3953308de3df4e1030d6d6eaf3988837a939ec..4bdddb751ebe3b03c48ac49f7e3d464757bbdf83 100644 (file)
 #include <IOKit/IOMessage.h>
 #include <IOKit/IOReturn.h>
 
-#ifdef __ppc__
-#include <IOKit/pwr_mgt/IOPMDeprecated.h>
-#endif
-
 /*! @header IOPM.h
     @abstract Defines power management constants and keys used by both in-kernel and user space power management.
     @discussion IOPM.h defines a range of power management constants used in several in-kernel and user space APIs. Most significantly, the IOPMPowerFlags used to specify the fields of an IOPMPowerState struct are defined here.
@@ -80,7 +76,7 @@ enum {
 
     Useful only as a Capability.
     
-    @constant kIOPMSleepCapability 
+    @constant kIOPMSleepCapability
     Used only by certain IOKit Families (USB). Not defined or used by generic Power Management. Read your family documentation to see if you should define a powerstate using these capabilities.
     
     @constant kIOPMRestartCapability
@@ -91,6 +87,9 @@ enum {
 
     @constant kIOPMRestart
     Used only by certain IOKit Families (USB). Not defined or used by generic Power Management. Read your family documentation to see if you should define a powerstate using these capabilities.
+
+    @constant kIOPMInitialDeviceState
+    Indicates the initial power state for the device. If <code>initialPowerStateForDomainState()</code> returns a power state with this flag set in the capability field, then the initial power change is performed without calling the driver's <code>setPowerState()</code>.
 */
 typedef unsigned long IOPMPowerFlags;
 enum {
@@ -101,7 +100,8 @@ enum {
     kIOPMSleepCapability            = 0x00000004,
     kIOPMRestartCapability          = 0x00000080,
     kIOPMSleep                      = 0x00000001,
-    kIOPMRestart                    = 0x00000080
+    kIOPMRestart                    = 0x00000080,
+    kIOPMInitialDeviceState         = 0x00000100
 };
 
 /*
@@ -121,7 +121,6 @@ enum {
     kIOPMNotPowerManaged            = 0x0800
 };
 
-
 /*
  * Deprecated IOPMPowerFlags
  * Their behavior is undefined when used in IOPMPowerState
@@ -210,10 +209,137 @@ enum {
  */
 #define kAppleClamshellCausesSleepKey       "AppleClamshellCausesSleep"
 
+/* kIOPMSleepWakeUUIDKey
+ * Key refers to a CFStringRef that will uniquely identify
+ * a sleep/wake cycle for logging & tracking.
+ * The key becomes valid at the beginning of a sleep cycle - before we
+ * initiate any sleep/wake notifications.
+ * The key becomes invalid at the completion of a system wakeup. The
+ * property will not be present in the IOPMrootDomain's registry entry
+ * when it is invalid.
+ * 
+ * See IOPMrootDomain notification kIOPMMessageSleepWakeUUIDChange
+ */
+ #define kIOPMSleepWakeUUIDKey              "SleepWakeUUID"
+
+/* kIOPMDeepSleepEnabledKey
+ * Indicates the Deep Sleep enable state.
+ * It has a boolean value.
+ *  true        == Deep Sleep is enabled
+ *  false       == Deep Sleep is disabled
+ *  not present == Deep Sleep is not supported on this hardware
+ */
+#define kIOPMDeepSleepEnabledKey            "Standby Enabled"
+
+/* kIOPMDeepSleepDelayKey
+ * Key refers to a CFNumberRef that represents the delay in seconds before
+ * entering Deep Sleep state. The property is not present if Deep Sleep is
+ * unsupported.
+ */
+#define kIOPMDeepSleepDelayKey              "Standby Delay"
+
+/* kIOPMDestroyFVKeyOnStandbyKey
+ * Specifies if FileVault key can be stored when going to standby mode
+ * It has a boolean value,
+ *  true        == Destroy FV key when going to standby mode
+ *  false       == Retain FV key when going to standby mode
+ *  not present == Retain FV key when going to standby mode
+ */
+#define kIOPMDestroyFVKeyOnStandbyKey       "DestroyFVKeyOnStandby"
+
+/*******************************************************************************
+ *
+ * Driver PM Assertions
+ *
+ ******************************************************************************/
+
+/* Driver Assertion bitfield description
+ * Driver PM assertions are defined by these bits.
+ */
+enum {
+    /*! kIOPMDriverAssertionCPUBit
+     * When set, PM kernel will prefer to leave the CPU and core hardware
+     * running in "Dark Wake" state, instead of sleeping.
+     */
+    kIOPMDriverAssertionCPUBit                      = 0x01,
+
+    /*! kIOPMDriverAssertionUSBExternalDeviceBit
+     * When set, driver is informing PM that an external USB device is attached.
+     */
+    kIOPMDriverAssertionUSBExternalDeviceBit        = 0x04,
+
+    /*! kIOPMDriverAssertionBluetoothHIDDevicePairedBit
+     * When set, driver is informing PM that a Bluetooth HID device is paired.
+     */
+    kIOPMDriverAssertionBluetoothHIDDevicePairedBit = 0x08,
+
+    /*! kIOPMDriverAssertionExternalMediaMountedBit
+     * When set, driver is informing PM that an external media is mounted.
+     */
+    kIOPMDriverAssertionExternalMediaMountedBit     = 0x10,
+
+    /*! kIOPMDriverAssertionReservedBit5
+     * Reserved for Thunderbolt.
+     */
+    kIOPMDriverAssertionReservedBit5                = 0x20,
+
+    /*! kIOPMDriverAssertionPreventDisplaySleepBit
+     * When set, the display should remain powered on while the system's awake.
+     */
+    kIOPMDriverAssertionPreventDisplaySleepBit      = 0x40,
+
+    /*! kIOPMDriverAssertionReservedBit7
+     * Reserved for storage family.
+     */
+    kIOPMDriverAssertionReservedBit7                = 0x80,
+
+    /*! kIOPMDriverAssertionReservedBit8
+     * Reserved for networking family.
+     */
+    kIOPMDriverAssertionReservedBit8                = 0x100
+};
+
+ /* kIOPMAssertionsDriverKey
+  * This kIOPMrootDomain key refers to a CFNumberRef property, containing
+  * a bitfield describing the aggregate PM assertion levels.
+  * Example: A value of 0 indicates that no driver has asserted anything.
+  * Or, a value of <link>kIOPMDriverAssertionCPUBit</link>
+  *   indicates that a driver (or drivers) have asserted a need fro CPU and video.
+  */
+#define kIOPMAssertionsDriverKey            "DriverPMAssertions"
+
+ /* kIOPMAssertionsDriverKey
+  * This kIOPMrootDomain key refers to a CFNumberRef property, containing
+  * a bitfield describing the aggregate PM assertion levels.
+  * Example: A value of 0 indicates that no driver has asserted anything.
+  * Or, a value of <link>kIOPMDriverAssertionCPUBit</link>
+  *   indicates that a driver (or drivers) have asserted a need fro CPU and video.
+  */
+#define kIOPMAssertionsDriverDetailedKey    "DriverPMAssertionsDetailed"
+
+/*******************************************************************************
+ *
+ * Kernel Driver assertion detailed dictionary keys
+ *
+ * Keys decode the Array & dictionary data structure under IOPMrootDomain property 
+ *  kIOPMAssertionsDriverKey.
+ *
+ */
+#define kIOPMDriverAssertionIDKey               "ID"
+#define kIOPMDriverAssertionCreatedTimeKey      "CreatedTime"
+#define kIOPMDriverAssertionModifiedTimeKey     "ModifiedTime"
+#define kIOPMDriverAssertionOwnerStringKey      "Owner"
+#define kIOPMDriverAssertionOwnerServiceKey     "ServicePtr"
+#define kIOPMDriverAssertionLevelKey            "Level"
+#define kIOPMDriverAssertionAssertedKey         "Assertions"
+
 /*******************************************************************************
  *
  * Root Domain general interest messages
  *
+ * Available by registering for interest type 'gIOGeneralInterest' 
+ * on IOPMrootDomain. 
+ *
  ******************************************************************************/
 
 /* kIOPMMessageClamshellStateChange
@@ -265,6 +391,30 @@ enum {
 #define kIOPMMessageSystemPowerEventOccurred  \
                 iokit_family_msg(sub_iokit_powermanagement, 0x130)
 
+/* kIOPMMessageSleepWakeUUIDChange
+ * Either a new SleepWakeUUID has been specified at the beginning of a sleep,
+ * or we're removing the existing property upon completion of a wakeup.
+ */
+#define kIOPMMessageSleepWakeUUIDChange  \
+                iokit_family_msg(sub_iokit_powermanagement, 0x140)
+                
+/* kIOPMMessageSleepWakeUUIDSet
+ * Argument accompanying the kIOPMMessageSleepWakeUUIDChange notification when 
+ * a new UUID has been specified.
+ */
+#define kIOPMMessageSleepWakeUUIDSet                    ((void *)1)
+
+/* kIOPMMessageSleepWakeUUIDCleared
+ * Argument accompanying the kIOPMMessageSleepWakeUUIDChange notification when 
+ * the current UUID has been removed.
+ */
+#define kIOPMMessageSleepWakeUUIDCleared                ((void *)0)
+
+/*! kIOPMMessageDriverAssertionsChanged
+ *  Sent when kernel PM driver assertions have changed.
+ */
+#define kIOPMMessageDriverAssertionsChanged  \
+                iokit_family_msg(sub_iokit_powermanagement, 0x150)
 
 /*******************************************************************************
  *
@@ -274,6 +424,7 @@ enum {
  * These commands are issued from system drivers only:
  *      ApplePMU, AppleSMU, IOGraphics, AppleACPIFamily
  *
+ * TODO: deprecate kIOPMAllowSleep and kIOPMPreventSleep
  ******************************************************************************/
 enum {
   kIOPMSleepNow                 = (1<<0),  // put machine to sleep now
@@ -297,25 +448,31 @@ enum {
  ******************************************************************************/
 enum {
     kIOPMNoErr                  = 0,
-    // Returned by powerStateWillChange and powerStateDidChange:
-    // Immediate acknowledgement of power state change
+
+    // Returned by driver's setPowerState(), powerStateWillChangeTo(),
+    // powerStateDidChangeTo(), or acknowledgeSetPowerState() to
+    // implicitly acknowledge power change upon function return.
     kIOPMAckImplied             = 0,
-    // Acknowledgement of power state change will come later 
+
+    // Deprecated
     kIOPMWillAckLater           = 1,
-    
-    // Returned by requestDomainState:
-    // Unrecognized specification parameter
+
+    // Returned by requestPowerDomainState() to indicate
+    // unrecognized specification parameter.
     kIOPMBadSpecification       = 4,
-    // No power state matches search specification
+
+    // Returned by requestPowerDomainState() to indicate
+    // no power state matches search specification.
     kIOPMNoSuchState            = 5,
-    
-    // Device cannot change its power for some reason
+
+    // Deprecated
     kIOPMCannotRaisePower       = 6,
-    
-  // Returned by changeStateTo:
-    // Requested state doesn't exist
+
+    // Deprecated
     kIOPMParameterError         = 7,
-    // Device not yet fully hooked into power management
+
+    // Returned when power management state is accessed
+    // before driver has called PMinit().
     kIOPMNotYetInitialized      = 8,
 
     // And the old constants; deprecated
@@ -361,13 +518,17 @@ enum {
 #define kIOPMPSHealthConfidenceKey                  "HealthConfidence"
 #define kIOPMPSCapacityEstimatedKey                    "CapacityEstimated"
 #define kIOPMPSBatteryChargeStatusKey               "ChargeStatus"
+#define kIOPMPSBatteryTemperatureKey                "Temperature"
+#define kIOPMPSAdapterDetailsKey                   "AdapterDetails"
+#define kIOPMPSChargerConfigurationKey             "ChargerConfiguration"
 
-// kIOPMBatteryChargeStatusKey may have one of the following values, or may have
+// kIOPMPSBatteryChargeStatusKey may have one of the following values, or may have
 // no value. If kIOPMBatteryChargeStatusKey has a NULL value (or no value) associated with it
 // then charge is proceeding normally. If one of these battery charge status reasons is listed,
 // then the charge may have been interrupted.
 #define kIOPMBatteryChargeStatusTooHot              "HighTemperature"
 #define kIOPMBatteryChargeStatusTooCold             "LowTemperature"
+#define kIOPMBatteryChargeStatusTooHotOrCold       "HighOrLowTemperature"
 #define kIOPMBatteryChargeStatusGradient            "BatteryTemperatureGradient"
 
 // Definitions for battery location, in case of multiple batteries.
@@ -387,6 +548,16 @@ enum {
     kIOPMGoodValue      = 3
 };
 
+// Keys for kIOPMPSAdapterDetailsKey dictionary
+#define kIOPMPSAdapterDetailsIDKey                 "AdapterID"
+#define kIOPMPSAdapterDetailsWattsKey              "Watts"
+#define kIOPMPSAdapterDetailsRevisionKey           "AdapterRevision"
+#define kIOPMPSAdapterDetailsSerialNumberKey       "SerialNumber"
+#define kIOPMPSAdapterDetailsFamilyKey             "FamilyCode"
+#define kIOPMPSAdapterDetailsAmperageKey           "Amperage"
+#define kIOPMPSAdapterDetailsDescriptionKey        "Description"
+#define kIOPMPSAdapterDetailsPMUConfigurationKey    "PMUConfiguration"
+
 // Battery's time remaining estimate is invalid this long (seconds) after a wake
 #define kIOPMPSInvalidWakeSecondsKey           "BatteryInvalidWakeSeconds"
 
@@ -484,6 +655,7 @@ enum {
 #define kIOPMSettingDisplaySleepUsesDimKey          "Display Sleep Uses Dim"
 #define kIOPMSettingTimeZoneOffsetKey               "TimeZoneOffsetSeconds"
 #define kIOPMSettingMobileMotionModuleKey           "MobileMotionModule"
+#define kIOPMSettingGraphicsSwitchKey               "GPUSwitch"
 
 // Setting controlling drivers can register to receive scheduled wake data
 // Either in "CF seconds" type, or structured calendar data in a formatted
@@ -498,6 +670,10 @@ enum {
 #define kIOPMSettingDebugWakeRelativeKey            "WakeRelativeToSleep"
 #define kIOPMSettingDebugPowerRelativeKey           "PowerRelativeToShutdown"
 
+// Maintenance wake calendar.
+#define kIOPMSettingMaintenanceWakeCalendarKey      "MaintenanceWakeCalendarDate"
+
+
 struct IOPMCalendarStruct {
     UInt32      year;
     UInt8       month;
@@ -505,6 +681,7 @@ struct IOPMCalendarStruct {
     UInt8       hour;
     UInt8       minute;
     UInt8       second;
+    UInt8       selector;
 };
 typedef struct IOPMCalendarStruct IOPMCalendarStruct;
 
@@ -545,7 +722,6 @@ enum {
     kIOBatteryChargerConnect    = (1 << 0)
 };
 
-
 // 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)
@@ -571,7 +747,6 @@ enum {
   kIOPMClamshellStateOnWake = (1<<10)     // used only by Platform Expert
 };
 
-
 // **********************************************
 // Internal power management data structures
 // **********************************************
@@ -588,13 +763,14 @@ enum {
     kIOPMSuperclassPolicy1
 };
 
-struct stateChangeNote{
+struct stateChangeNote {
     IOPMPowerFlags    stateFlags;
     unsigned long    stateNum;
     void *         powerRef;
 };
 typedef struct stateChangeNote stateChangeNote;
 
+#endif /* KERNEL && __cplusplus */
 struct IOPowerStateChangeNotification {
     void *        powerRef;
     unsigned long    returnValue;
@@ -604,8 +780,54 @@ struct IOPowerStateChangeNotification {
 typedef struct IOPowerStateChangeNotification IOPowerStateChangeNotification;
 typedef IOPowerStateChangeNotification sleepWakeNote;
 
-extern void IOPMRegisterDevice(const char *, IOService *);
-#endif /* KERNEL && __cplusplus */
+/*! @struct IOPMSystemCapabilityChangeParameters
+    @abstract A structure describing a system capability change.
+    @discussion A system capability change is a system level transition from a set
+        of system capabilities to a new set of system capabilities. Power management
+        sends a <code>kIOMessageSystemCapabilityChange</code> message and provides
+        this structure as the message data (by reference) to
+        <code>gIOPriorityPowerStateInterest</code> clients when system capability
+        changes.
+    @field notifyRef An identifier for this message notification. Clients with pending
+        I/O can signal completion by calling <code>allowPowerChange()</code> with this
+        value as the argument. Clients that are able to process the notification
+        synchronously should ignore this field.
+    @field maxWaitForReply A return value to the caller indicating the maximum time in
+        microseconds to wait for the <code>allowPowerChange()</code> call. The default
+        value is zero, which indicates the client processing has finished, and power
+        management should not wait for an <code>allowPowerChange()</code> call.
+    @field changeFlags Flags will be set to indicate whether the notification precedes
+        the capability change (<code>kIOPMSystemCapabilityWillChange</code>), or after
+        the capability change has occurred (<code>kIOPMSystemCapabilityDidChange</code>).
+    @field __reserved1 Set to zero.
+    @field fromCapabilities The system capabilities at the start of the transition.
+    @field toCapabilities The system capabilities at the end of the transition.
+    @field __reserved2 Set to zero.
+ */
+struct IOPMSystemCapabilityChangeParameters {
+    uint32_t    notifyRef;
+    uint32_t    maxWaitForReply;
+    uint32_t    changeFlags;
+    uint32_t    __reserved1;
+    uint32_t    fromCapabilities;
+    uint32_t    toCapabilities;
+    uint32_t    __reserved2[4];
+};
 
-#endif /* ! _IOKIT_IOPM_H */
+/*! @enum IOPMSystemCapabilityChangeFlags
+    @constant kIOPMSystemCapabilityWillChange Indicates the system capability will change.
+    @constant kIOPMSystemCapabilityDidChange Indicates the system capability has changed.
+*/
+enum {
+    kIOPMSystemCapabilityWillChange = 0x01,
+    kIOPMSystemCapabilityDidChange  = 0x02
+};
 
+enum {
+    kIOPMSystemCapabilityCPU        = 0x01,
+    kIOPMSystemCapabilityGraphics   = 0x02,
+    kIOPMSystemCapabilityAudio      = 0x04,
+    kIOPMSystemCapabilityNetwork    = 0x08
+};
+
+#endif /* ! _IOKIT_IOPM_H */