]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/IOKit/pwr_mgt/RootDomain.h
xnu-4570.1.46.tar.gz
[apple/xnu.git] / iokit / IOKit / pwr_mgt / RootDomain.h
index 0de68bbc870f48f6baecd2177e7fa3b6dd86b4c4..1e447d199c222b3fc37cf14805c7be1f4a227b58 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1998-2016 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -44,9 +44,7 @@ class IOPMPowerStateQueue;
 class RootDomainUserClient;
 class PMAssertionsTracker;
 
-#define OBFUSCATE(x) \
-    (((((uintptr_t)(x)) >= VM_MIN_KERNEL_AND_KEXT_ADDRESS) && (((uintptr_t)(x)) < VM_MAX_KERNEL_ADDRESS)) ? \
-        ((void *)(VM_KERNEL_ADDRPERM(x))) : (void *)(x))
+#define OBFUSCATE(x) (void *)VM_KERNEL_UNSLIDE_OR_PERM(x)
 
 #endif
 
@@ -152,26 +150,23 @@ class IOPMrootDomain: public IOService
 public:
     static IOPMrootDomain * construct( void );
 
-    virtual bool        start( IOService * provider );
-    virtual IOReturn    setAggressiveness( unsigned long, unsigned long );
-    virtual IOReturn    getAggressiveness( unsigned long, unsigned long * );
+    virtual bool        start( IOService * provider ) APPLE_KEXT_OVERRIDE;
+    virtual IOReturn    setAggressiveness( unsigned long, unsigned long ) APPLE_KEXT_OVERRIDE;
+    virtual IOReturn    getAggressiveness( unsigned long, unsigned long * ) APPLE_KEXT_OVERRIDE;
 
     virtual IOReturn    sleepSystem( void );
     IOReturn            sleepSystemOptions( OSDictionary *options );
 
-    virtual IOReturn    setProperties( OSObject * );
-    virtual bool        serializeProperties( OSSerialize * s ) const;
-    virtual OSObject *  copyProperty( const char * aKey ) const;
+    virtual IOReturn    setProperties( OSObject * ) APPLE_KEXT_OVERRIDE;
+    virtual bool        serializeProperties( OSSerialize * s ) const APPLE_KEXT_OVERRIDE;
+    virtual OSObject *  copyProperty( const char * aKey ) const APPLE_KEXT_OVERRIDE;
 
 /*! @function systemPowerEventOccurred
     @abstract Other drivers may inform IOPMrootDomain of system PM events
     @discussion systemPowerEventOccurred is a richer alternative to receivePowerNotification()
         Only Apple-owned kexts should have reason to call systemPowerEventOccurred.
     @param event An OSSymbol describing the type of power event.
-    @param value A 32-bit integer value associated with the event.
-    @param shouldUpdate indicates whether the root domain should send a notification
-        to interested parties. Pass false if you're calling systemPowerEventOccurred
-        several times in succession; and pass true only on the last invocatino.
+    @param intValue A 32-bit integer value associated with the event.
     @result kIOReturnSuccess on success */
 
     IOReturn            systemPowerEventOccurred(
@@ -329,17 +324,17 @@ public:
     virtual IONotifier * registerInterest(
                                 const OSSymbol * typeOfInterest,
                                 IOServiceInterestHandler handler,
-                                void * target, void * ref = 0 );
+                                void * target, void * ref = 0 ) APPLE_KEXT_OVERRIDE;
 
     virtual IOReturn    callPlatformFunction(
                                 const OSSymbol *functionName,
                                 bool waitForFunction,
                                 void *param1, void *param2,
-                                void *param3, void *param4 );
+                                void *param3, void *param4 ) APPLE_KEXT_OVERRIDE;
 
 /*! @function createPMAssertion
     @abstract Creates an assertion to influence system power behavior.
-    @param whichAssertionBits A bitfield specify the assertion that the caller requests.
+    @param whichAssertionsBits A bitfield specify the assertion that the caller requests.
     @param assertionLevel An integer detailing the initial assertion level, kIOPMDriverAssertionLevelOn
         or kIOPMDriverAssertionLevelOff.
     @param ownerService A pointer to the caller's IOService class, for tracking.
@@ -392,22 +387,29 @@ public:
     IOReturn restartWithStackshot();
 
 private:
-    virtual IOReturn    changePowerStateTo( unsigned long ordinal );
+    virtual IOReturn    changePowerStateTo( unsigned long ordinal ) APPLE_KEXT_COMPATIBILITY_OVERRIDE;
     virtual IOReturn    changePowerStateToPriv( unsigned long ordinal );
-    virtual IOReturn    requestPowerDomainState( IOPMPowerFlags, IOPowerConnection *, unsigned long );
-    virtual void        powerChangeDone( unsigned long );
-    virtual bool        tellChangeDown( unsigned long );
-    virtual bool        askChangeDown( unsigned long );
-    virtual void        tellChangeUp( unsigned long );
-    virtual void        tellNoChangeDown( unsigned long );
+    virtual IOReturn    requestPowerDomainState( IOPMPowerFlags, IOPowerConnection *, unsigned long ) APPLE_KEXT_OVERRIDE;
+    virtual void        powerChangeDone( unsigned long ) APPLE_KEXT_OVERRIDE;
+    virtual bool        tellChangeDown( unsigned long ) APPLE_KEXT_OVERRIDE;
+    virtual bool        askChangeDown( unsigned long ) APPLE_KEXT_OVERRIDE;
+    virtual void        tellChangeUp( unsigned long ) APPLE_KEXT_OVERRIDE;
+    virtual void        tellNoChangeDown( unsigned long ) APPLE_KEXT_OVERRIDE;
     virtual IOReturn configureReport(IOReportChannelList   *channels,
                                     IOReportConfigureAction action,
                                     void                    *result,
-                                    void                    *destination);
+                                    void                    *destination) APPLE_KEXT_OVERRIDE;
     virtual IOReturn updateReport(IOReportChannelList      *channels,
                                   IOReportUpdateAction     action,
                                   void                     *result,
-                                  void                     *destination);
+                                  void                     *destination) APPLE_KEXT_OVERRIDE;
+
+    void             configureReportGated(uint64_t channel_id,
+                                          uint64_t action,
+                                          void     *result);
+    IOReturn         updateReportGated(uint64_t ch_id, 
+                                       void *result, 
+                                       IOBufferMemoryDescriptor *dest);
 
 #ifdef XNU_KERNEL_PRIVATE
     /* Root Domain internals */
@@ -479,12 +481,14 @@ public:
     void        handleQueueSleepWakeUUID(
                     OSObject *obj);
 
+    void        handleDisplayPowerOn( );
+
     void        willNotifyPowerChildren( IOPMPowerStateIndex newPowerState );
 
     IOReturn    setMaintenanceWakeCalendar(
                     const IOPMCalendarStruct * calendar );
 
-    IOReturn    getSystemSleepType( uint32_t * sleepType );
+    IOReturn    getSystemSleepType(uint32_t * sleepType, uint32_t * standbyTimer);
 
     // Handle callbacks from IOService::systemWillShutdown()
     void        acknowledgeSystemWillShutdown( IOService * from );
@@ -498,13 +502,19 @@ public:
 
     bool        activitySinceSleep(void);
     bool        abortHibernation(void);
+    void        updateConsoleUsers(void);
 
     IOReturn    joinAggressiveness( IOService * service );
     void        handleAggressivesRequests( void );
 
-    void        tracePoint( uint8_t point );
-    void        tracePoint( uint8_t point, uint8_t data );
-    void        traceDetail( uint32_t data32 );
+    void        kdebugTrace(uint32_t event, uint64_t regId,
+                            uintptr_t param1, uintptr_t param2, uintptr_t param3 = 0);
+    void        tracePoint(uint8_t point);
+    void        traceDetail(uint32_t msgType, uint32_t msgIndex, uint32_t delay);
+    void        traceDetail(OSObject *notifier);
+    void        traceAckDelay(OSObject *notifier, uint32_t response, uint32_t delay_ms);
+
+    void        startSpinDump(uint32_t spindumpKind);
 
     bool        systemMessageFilter(
                     void * object, void * arg1, void * arg2, void * arg3 );
@@ -526,7 +536,7 @@ public:
                                 const char          *name,
                                 int                 messageType,
                                 uint32_t            delay_ms,
-                                int                 app_pid,
+                                uint64_t            id,
                                 OSObject            *object,
                                 IOPMPowerStateIndex ps=0);
 
@@ -537,12 +547,16 @@ public:
                     uint32_t *  hibernateMode,
                     uint32_t *  hibernateFreeRatio,
                     uint32_t *  hibernateFreeTime );
+    bool        mustHibernate( void );
 #endif
-    void        takeStackshot(bool restart, bool isOSXWatchdog);
+    void        takeStackshot(bool restart, bool isOSXWatchdog, bool isSpinDump);
     void        sleepWakeDebugTrig(bool restart);
     void        sleepWakeDebugEnableWdog();
     bool        sleepWakeDebugIsWdogEnabled();
     static void saveTimeoutAppStackShot(void *p0, void *p1);
+    void        sleepWakeDebugSaveSpinDumpFile();
+    void        swdDebugSetup();
+    void        swdDebugTeardown();
 
 private:
     friend class PMSettingObject;
@@ -612,9 +626,20 @@ private:
     OSArray                 *pmStatsAppResponses;
     IOLock                  *pmStatsLock;   // guards pmStatsAppResponses
 
+    void                    *sleepDelaysReport;     // report to track time taken to go to sleep
+    uint32_t                sleepDelaysClientCnt;   // Number of interested clients in sleepDelaysReport
+    uint64_t                ts_sleepStart;
+    uint64_t                wake2DarkwakeDelay;      // Time taken to change from full wake -> Dark wake
+
+
+    void                    *assertOnWakeReport;    // report to track time spent without any assertions held after wake
+    uint32_t                assertOnWakeClientCnt;  // Number of clients interested in assertOnWakeReport
+    clock_sec_t             assertOnWakeSecs;       // Num of secs after wake for first assertion
+
     bool                    uuidPublished;
 
     // Pref: idle time before idle sleep
+    bool                    idleSleepEnabled;
     unsigned long           sleepSlider;
     unsigned long           idleSeconds;
     uint64_t                autoWakeStart;
@@ -627,7 +652,9 @@ private:
     thread_call_t           extraSleepTimer;
     thread_call_t           diskSyncCalloutEntry;
     thread_call_t           fullWakeThreadCall;
-    thread_call_t           hibDebugSetupEntry;
+    thread_call_t           swdDebugSetupEntry;
+    thread_call_t           swdDebugTearDownEntry;
+    thread_call_t           updateConsoleUsersEntry;
 
     // Track system capabilities.
     uint32_t                _desiredCapability;
@@ -693,7 +720,11 @@ private:
 
     unsigned int            displayIdleForDemandSleep :1;
     unsigned int            darkWakeHibernateError  :1;
+    unsigned int            thermalWarningState:1;
+    unsigned int            toldPowerdCapWillChange :1;
+    unsigned int            displayPowerOnRequested:1;
 
+    uint8_t                 tasksSuspended;
     uint32_t                hibernateMode;
     AbsoluteTime            userActivityTime;
     AbsoluteTime            userActivityTime_prev;
@@ -702,6 +733,8 @@ private:
     uint32_t                lastSleepReason;
     uint32_t                fullToDarkReason;
     uint32_t                hibernateAborted;
+    uint8_t                 standbyNixed;
+    uint8_t                 resetTimers;
 
     enum FullWakeReason {
         kFullWakeReasonNone = 0,
@@ -724,7 +757,6 @@ private:
     OSData *                aggressivesData;
 
     AbsoluteTime            userBecameInactiveTime;
-    AbsoluteTime            systemWakeTime;
 
     // PCI top-level PM trace
     IOService *             pciHostBridgeDevice;
@@ -752,7 +784,11 @@ private:
 #endif
     volatile uint32_t   swd_lock;    /* Lock to access swd_buffer & and its header */
     void  *             swd_buffer;  /* Memory allocated for dumping sleep/wake logs */
-    uint8_t             swd_flags;   /* Flags defined in IOPMPrivate.h */
+    uint32_t            swd_flags;   /* Flags defined in IOPMPrivate.h */
+    uint8_t             swd_DebugImageSetup;
+    void  *             swd_spindump_buffer;
+
+    IOBufferMemoryDescriptor    *swd_memDesc;
 
     IOMemoryMap  *      swd_logBufMap; /* Memory with sleep/wake logs from previous boot */
 
@@ -818,12 +854,15 @@ private:
 
     void        deregisterPMSettingObject( PMSettingObject * pmso );
 
+    uint32_t    checkForValidDebugData(const char *fname, vfs_context_t *ctx, 
+                                            void *tmpBuf, struct vnode **vp);
     void        sleepWakeDebugMemAlloc( );
+    void        sleepWakeDebugSpinDumpMemAlloc( );
     void        sleepWakeDebugDumpFromMem(IOMemoryMap *logBufMap);
     void        sleepWakeDebugDumpFromFile( );
     IOMemoryMap *sleepWakeDebugRetrieve();
     errno_t     sleepWakeDebugSaveFile(const char *name, char *buf, int len);
-    errno_t sleepWakeDebugCopyFile( struct vnode *srcVp, 
+    errno_t     sleepWakeDebugCopyFile( struct vnode *srcVp,
                                vfs_context_t srcCtx,
                                char *tmpBuf, uint64_t tmpBufSize,
                                uint64_t srcOffset, 
@@ -846,6 +885,8 @@ private:
     void        acceptSystemWakeEvents( bool accept );
     void        systemDidNotSleep( void );
     void        preventTransitionToUserActive( bool prevent );
+    void        setThermalState(OSObject *value);
+    void        copySleepPreventersList(OSArray  **idleSleepList, OSArray  **systemSleepList);
 #endif /* XNU_KERNEL_PRIVATE */
 };
 
@@ -856,8 +897,8 @@ class IORootParent: public IOService
 
 public:
     static void initialize( void );
-    virtual OSObject * copyProperty( const char * aKey ) const;
-    bool start( IOService * nub );
+    virtual OSObject * copyProperty( const char * aKey ) const APPLE_KEXT_OVERRIDE;
+    bool start( IOService * nub ) APPLE_KEXT_OVERRIDE;
     void shutDownSystem( void );
     void restartSystem( void );
     void sleepSystem( void );