]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/IOKit/pwr_mgt/IOPMPrivate.h
xnu-7195.50.7.100.1.tar.gz
[apple/xnu.git] / iokit / IOKit / pwr_mgt / IOPMPrivate.h
index 25226da746b218b28690b561482e99625b0aa971..4c1eb9eecf4a136655e68afce3ea626fc1180053 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2002-2020 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -103,6 +103,18 @@ enum {
 #define kIOPMMessageSystemSleepPreventers \
                 iokit_family_msg(sub_iokit_powermanagement, 0x430)
 
+#define kIOPMMessageLaunchBootSpinDump \
+                iokit_family_msg(sub_iokit_powermanagement, 0x440)
+
+#define kIOPMMessageProModeStateChange \
+                iokit_family_msg(sub_iokit_powermanagement, 0x450)
+
+#define kIOPMMessageRequestUserActive \
+                iokit_family_msg(sub_iokit_powermanagement, 0x460)
+
+#define kIOPMMessageRequestSystemShutdown \
+                iokit_family_msg(sub_iokit_powermanagement, 0x470)
+
 /* @enum SystemSleepReasons
  * @abstract The potential causes for system sleep as logged in the system event record.
  */
@@ -116,7 +128,8 @@ enum {
     kIOPMSleepReasonThermalEmergency            = 107,
     kIOPMSleepReasonMaintenance                 = 108,
     kIOPMSleepReasonSleepServiceExit            = 109,
-    kIOPMSleepReasonDarkWakeThermalEmergency    = 110
+    kIOPMSleepReasonDarkWakeThermalEmergency    = 110,
+    kIOPMSleepReasonNotificationWakeExit        = 111
 };
 
 /*
@@ -131,6 +144,7 @@ enum {
 #define kIOPMThermalEmergencySleepKey               "Thermal Emergency Sleep"
 #define kIOPMSleepServiceExitKey                    "Sleep Service Back to Sleep"
 #define kIOPMDarkWakeThermalEmergencyKey            "Dark Wake Thermal Emergency"
+#define kIOPMNotificationWakeExitKey                "Notification Wake Back to Sleep"
 
 /*! kIOPMPSRestrictedModeKey
  *  An IOPMPowerSource property key
@@ -141,6 +155,9 @@ enum {
 */
 #define kIOPMPSRestrictedModeKey                    "RestrictedMode"
 
+// Private keys for kIOPMPSAdapterDetailsKey dictionary
+#define kIOPMPSAdapterDetailsIsWirelessKey          "IsWireless"
+
 #pragma mark Stray Bitfields
 // Private power commands issued to root domain
 // bits 0-7 in IOPM.h
@@ -180,6 +197,7 @@ enum {
  * These are valid values for IOPM.h:IOPMCalendarStruct->selector
  */
 enum {
+    kPMCalendarTypeInvalid = 0,
     kPMCalendarTypeMaintenance = 1,
     kPMCalendarTypeSleepService = 2
 };
@@ -239,6 +257,13 @@ enum {
     kIOPMSilentRunningModeOn = 0x00000001
 };
 
+/* @constant kIOPMSettingLowLatencyAudioModeKey
+ * @abstract Notification about low latency activity in the system available to kexts.
+ * @discussion This type can be passed as arguments to registerPMSettingController()
+ * to receive callbacks.
+ */
+#define kIOPMSettingLowLatencyAudioModeKey          "LowLatencyAudioMode"
+
 /*****************************************************************************/
 /*****************************************************************************/
 
@@ -266,6 +291,8 @@ enum {
 #define kIOPMSleepStatisticsAppsKey             "AppStatistics"
 #define kIOPMIdleSleepPreventersKey             "IdleSleepPreventers"
 #define kIOPMSystemSleepPreventersKey           "SystemSleepPreventers"
+#define kIOPMIdleSleepPreventersWithIDKey       "IdleSleepPreventersWithID"
+#define kIOPMSystemSleepPreventersWithIDKey     "SystemSleepPreventersWithID"
 
 // Application response statistics
 #define kIOPMStatsNameKey                       "Name"
@@ -531,10 +558,49 @@ enum {
 /*****************************************************************************/
 
 /*
-Ê* kIOPMLoginWindowSecurityDebugKey - identifies PM debug data specific to LoginWindow
- *  for use with IOPMrootDomain.
-Ê*/
-#define kIOPMLoginWindowSecurityDebugKey        "LoginWindowSecurity"
+ * Component wake progress keys
+ *
+ * Certain components have the ability to log their wake progress with
+ * root domain using the keys provided below.
+ *
+ * LoginWindow - 4 bits
+ * CoreDisplay - 8 bits
+ * CoreGraphics - 8 bits
+ *
+ * These bits are stored with the trace phase that gets logged to
+ * the RTC register.
+ */
+
+// Values that should be passed in to IOPMLogWakeProgress
+enum {
+    kIOPMLoginWindowProgress    = 1,
+    kIOPMCoreDisplayProgress    = 2,
+    kIOPMCoreGraphicsProgress   = 3
+};
+
+enum {
+    kIOPMLoginWindowProgressMask    = 0x0f,
+    kIOPMCoreDisplayProgressMask    = 0xff,
+    kIOPMCoreGraphicsProgressMask   = 0xff
+};
+
+/*
+ * kIOPMLoginWindowProgressKey - identifies PM debug data specific to LoginWindow
+ *  for use with IOPMrootDomain. Only 4 bits of data are allotted.
+ */
+#define kIOPMLoginWindowProgressKey             "LoginWindowProgress"
+
+/*
+ * kIOPMCoreDisplayProgressKey - identifies PM debug data specific to CoreDisplay
+ *  for use with IOPMrootDomain. Only 8 bits of data are allotted.
+ */
+#define kIOPMCoreDisplayProgressKey             "CoreDisplayProgress"
+
+/*
+ * kIOPMCoreGraphicsProgressKey - identifies PM debug data specific to CoreGraphics
+ *  for use with IOPMrootDomain. Only 8 bits of data are allotted.
+ */
+#define kIOPMCoreGraphicsProgressKey            "CoreGraphicsProgress"
 
 // For PM internal use only - key to locate sleep failure results within SCDynamicStore.
 #define kIOPMDynamicStoreSleepFailureKey        "SleepFailure"
@@ -584,6 +650,13 @@ enum {
  */
 #define kIOPMAutoPowerOffTimerKey           "AutoPowerOff Timer"
 
+/* kIOPMDeepSleepTimerKey
+ * Key refers to a CFNumberRef that indicates the time in seconds until the
+ * expiration of the Standby delay period. This value should be used
+ * to program a wake alarm before system sleep.
+ */
+#define kIOPMDeepSleepTimerKey                "Standby Timer"
+
 /* kIOPMUserWakeAlarmScheduledKey
  * Key refers to a boolean value that indicates if an user alarm was scheduled
  * or pending.
@@ -625,6 +698,11 @@ enum {
 #define kIOPMWakeEventReasonKey             "Reason"
 #define kIOPMWakeEventDetailsKey            "Details"
 
+/* kIOPMFeatureProModeKey
+ * Feature published if ProMode is supported
+ */
+#define kIOPMFeatureProModeKey              "ProMode"
+
 /*****************************************************************************
  *
  * Wake event flags reported to IOPMrootDomain::claimSystemWakeEvent()
@@ -633,6 +711,94 @@ enum {
 
 #define kIOPMWakeEventSource                0x00000001
 
+/*****************************************************************************
+ *
+ * AOT defs
+ *
+ *****************************************************************************/
+
+// signals the device should wake up to user space running
+#define kIOPMWakeEventAOTExit                   0x00000002
+
+// will start a 400 ms timer before sleeping
+#define kIOPMWakeEventAOTPossibleExit           0x00000004
+
+// signals the device should wake up to user space running
+#define kIOPMWakeEventAOTConfirmedPossibleExit  0x00000008
+
+// signals the device should go back to AOT
+#define kIOPMWakeEventAOTRejectedPossibleExit   0x00000010
+
+// signals the device should go back to AOT
+#define kIOPMWakeEventAOTExpiredPossibleExit    0x00000020
+
+#define kIOPMWakeEventAOTFlags \
+                                 (kIOPMWakeEventAOTExit \
+                                | kIOPMWakeEventAOTPossibleExit \
+                                | kIOPMWakeEventAOTConfirmedPossibleExit \
+                                | kIOPMWakeEventAOTRejectedPossibleExit \
+                                | kIOPMWakeEventAOTExpiredPossibleExit)
+
+#define kIOPMWakeEventAOTPossibleFlags \
+                                 (kIOPMWakeEventAOTPossibleExit \
+                                | kIOPMWakeEventAOTConfirmedPossibleExit \
+                                | kIOPMWakeEventAOTRejectedPossibleExit \
+                                | kIOPMWakeEventAOTExpiredPossibleExit)
+
+#define kIOPMWakeEventAOTPerCycleFlags \
+                                 (kIOPMWakeEventAOTPossibleExit \
+                                | kIOPMWakeEventAOTRejectedPossibleExit \
+                                | kIOPMWakeEventAOTExpiredPossibleExit)
+
+#define kIOPMWakeEventAOTExitFlags \
+                                 (kIOPMWakeEventAOTExit \
+                                | kIOPMWakeEventAOTConfirmedPossibleExit)
+
+enum {
+       kIOPMAOTModeMask          = 0x000000ff,
+    kIOPMAOTModeEnable        = 0x00000001,
+    kIOPMAOTModeCycle         = 0x00000002,
+    kIOPMAOTModeAddEventFlags = 0x00000004,
+    kIOPMAOTModeRespectTimers = 0x00000008,
+    kIOPMAOTModeDefault       = (kIOPMAOTModeEnable | kIOPMAOTModeAddEventFlags | kIOPMAOTModeRespectTimers)
+};
+
+enum {
+    kIOPMAOTMetricsKernelWakeCountMax = 24
+};
+
+struct IOPMAOTMetrics
+{
+    uint32_t sleepCount;
+    uint32_t possibleCount;
+    uint32_t confirmedPossibleCount;
+    uint32_t rejectedPossibleCount;
+    uint32_t expiredPossibleCount;
+    uint32_t noTimeSetCount;
+    uint32_t rtcAlarmsCount;
+    uint32_t softwareRequestCount;
+    uint64_t totalTime;
+
+       char     kernelWakeReason[kIOPMAOTMetricsKernelWakeCountMax][64];
+       // 54:10 secs:ms calendar time
+    uint64_t kernelSleepTime[kIOPMAOTMetricsKernelWakeCountMax];
+    uint64_t kernelWakeTime[kIOPMAOTMetricsKernelWakeCountMax];
+};
+
+#define kIOPMAOTPowerKey    "aot-power"
+
+/*****************************************************************************
+ *
+ * Dark Wake
+ *
+ *****************************************************************************/
+
+/* An OSNumber property set on a power managed driver that the root domain
+ * will use as the driver's max power state while system is in dark wake.
+ * This property should be set prior to the driver joining the PM tree.
+ */
+#define kIOPMDarkWakeMaxPowerStateKey       "IOPMDarkWakeMaxPowerState"
+
 /*****************************************************************************
  *
  * System Sleep Policy
@@ -667,6 +833,7 @@ struct IOPMSystemSleepPolicyVariables
     uint32_t    hibernateMode;              // current hibernate mode
 
     uint32_t    standbyDelay;               // standby delay in seconds
+    uint32_t    standbyTimer;               // standby timer in seconds
     uint32_t    poweroffDelay;              // auto-poweroff delay in seconds
     uint32_t    scheduledAlarms;            // bitmask of scheduled alarm types
     uint32_t    poweroffTimer;              // auto-poweroff timer in seconds
@@ -749,7 +916,18 @@ enum {
     kIOPMWakeEventUserPME                   = 0x00000400,
     kIOPMWakeEventSleepTimer                = 0x00000800,
     kIOPMWakeEventBatteryLow                = 0x00001000,
-    kIOPMWakeEventDarkPME                   = 0x00002000
+    kIOPMWakeEventDarkPME                   = 0x00002000,
+    kIOPMWakeEventWifi                      = 0x00004000,
+    kIOPMWakeEventRTCSystem                 = 0x00008000,  // Maintenance RTC wake
+    kIOPMWakeEventUSBCPlugin                = 0x00010000,  // USB-C Plugin
+    kIOPMWakeEventHID                       = 0x00020000,
+    kIOPMWakeEventBluetooth                 = 0x00040000,
+    kIOPMWakeEventDFR                       = 0x00080000,
+    kIOPMWakeEventSD                        = 0x00100000,  // SD card
+    kIOPMWakeEventLANWake                   = 0x00200000,  // Wake on Lan
+    kIOPMWakeEventLANPlugin                 = 0x00400000,  // Ethernet media sense
+    kIOPMWakeEventThunderbolt               = 0x00800000,
+    kIOPMWakeEventRTCUser                   = 0x01000000,  // User requested RTC wake
 };
 
 /*!
@@ -788,28 +966,22 @@ typedef struct {
 
    /* All members from UUID onwards are saved into log file */
    char             UUID[44];
-   char             cps[9];          /* Current power state */
+   char             spindump_status[24];   /* stackshot status*/
    char             PMStatusCode[32];
    char             reason[32];
 } swd_hdr;
 
-/*
- * Structure between stackshot samples, expected by spindump
- */
-typedef struct {
-    uint32_t magic;      // 0xbad51ee4
-    uint32_t size;       // Size of the stackshot buffer following this struct
-} swd_stackshot_hdr;
-
 
 #define SWD_HDR_SIGNATURE       0xdeb8da2a
-#define SWD_STACKSHOTHDR_MAGIC  0xbad51ee4  // expected by spindump
 
-#define SWD_BUF_SIZE            (40*PAGE_SIZE)
-#define SWD_INITIAL_STACK_SIZE  ((SWD_BUF_SIZE/2)-sizeof(swd_hdr))
+#define SWD_STACKSHOT_SIZE      (40*PAGE_SIZE)
+#define SWD_COMPRESSED_BUFSIZE  (5*PAGE_SIZE)
+#define SWD_ZLIB_BUFSIZE        (10*PAGE_SIZE)
+#define SWD_STACKSHOT_VAR_PREFIX    "sleepwake_diags"
 
 #define SWD_SPINDUMP_SIZE          (256*1024)
 #define SWD_INITIAL_SPINDUMP_SIZE  ((SWD_SPINDUMP_SIZE/2)-sizeof(swd_hdr))
+#define SWD_MAX_STACKSHOTS          (10)
 
 /* Bits in swd_flags */
 #define SWD_WDOG_ENABLED        0x01
@@ -818,27 +990,22 @@ typedef struct {
 #define SWD_VALID_LOGS          0x08
 #define SWD_LOGS_IN_FILE        0x10
 #define SWD_LOGS_IN_MEM         0x20
+#define SWD_PWR_BTN_STACKSHOT   0x30
 
-/* Filenames associated with the stackshots/logs generated by the SWD */
-#define kSleepWakeStackBinFilename          "/var/log/SleepWakeStacks.bin"
-#define kSleepWakeStackFilename             "/var/log/SleepWakeStacks.dump"
-#define kSleepWakeLogFilename               "/var/log/SleepWakeLog.dump"
-#define kAppleOSXWatchdogStackFilename      "/var/log/AppleOSXWatchdogStacks.dump"
-#define kAppleOSXWatchdogLogFilename        "/var/log/AppleOSXWatchdogLog.dump"
+#define SWD_DATA_CRC_ERROR      0x010000
+#define SWD_BUF_SIZE_ERROR      0x020000
+#define SWD_HDR_SIZE_ERROR      0x040000
+#define SWD_FILEOP_ERROR        0x080000
+#define SWD_HDR_SIGNATURE_ERROR 0x100000
+#define SWD_INTERNAL_FAILURE    0x200000
 
-inline char const* getDumpStackFilename(swd_hdr *hdr)
-{
-    if (hdr && hdr->is_osx_watchdog)
-        return kAppleOSXWatchdogStackFilename;
-    return kSleepWakeStackFilename;
-}
 
-inline char const* getDumpLogFilename(swd_hdr *hdr)
-{
-    if (hdr && hdr->is_osx_watchdog)
-        return kAppleOSXWatchdogLogFilename;
-    return kSleepWakeLogFilename;
-}
+/* Filenames associated with the stackshots/logs generated by the SWD */
+#define kOSWatchdogStacksFilename           "/var/log/OSXWatchdogStacks.gz"
+#define kOSWatchdogFailureStringFile        "/var/log/OSWatchdogFailureString.txt"
+#define kSleepWakeStacksFilename            "/var/log/SleepWakeStacks.gz"
+#define kSleepWakeFailureStringFile         "/var/log/SleepWakeFailureString.txt"
+
 
 /* RootDomain IOReporting channels */
 #define kSleepCntChID IOREPORT_MAKEID('S','l','e','e','p','C','n','t')