X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0a7de7458d150b5d4dffc935ba399be265ef0a1a..a991bd8d3e7fe02dbca0644054bab73c5b75324a:/iokit/Kernel/IOServicePMPrivate.h?ds=sidebyside diff --git a/iokit/Kernel/IOServicePMPrivate.h b/iokit/Kernel/IOServicePMPrivate.h index 9c4f3bb7f..31e42e28c 100644 --- a/iokit/Kernel/IOServicePMPrivate.h +++ b/iokit/Kernel/IOServicePMPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Apple Inc. All rights reserved. + * Copyright (c) 2019-2020 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -32,6 +32,8 @@ #include #include +#define USE_SETTLE_TIMER 0 + //****************************************************************************** // PM command types //****************************************************************************** @@ -79,27 +81,27 @@ typedef void void * target, IOService * service, IOPMActions * actions, + const IOPMRequest * request, IOPMPowerStateIndex powerState, - IOPMPowerChangeFlags * changeFlags, - IOPMRequestTag requestTag ); + IOPMPowerChangeFlags * changeFlagsPtr ); typedef void (*IOPMActionPowerChangeDone)( void * target, IOService * service, IOPMActions * actions, + const IOPMRequest * request, IOPMPowerStateIndex powerState, - IOPMPowerChangeFlags changeFlags, - IOPMRequestTag requestTag ); + IOPMPowerChangeFlags changeFlags ); typedef void (*IOPMActionPowerChangeOverride)( void * target, IOService * service, IOPMActions * actions, - IOPMPowerStateIndex * powerState, - IOPMPowerChangeFlags * changeFlags, - IOPMRequestTag requestTag ); + const IOPMRequest * request, + IOPMPowerStateIndex * powerStatePtr, + IOPMPowerChangeFlags * changeFlagsPtr ); typedef void (*IOPMActionActivityTickle)( @@ -114,26 +116,32 @@ typedef void IOPMActions * actions, const OSSymbol * powerClient, IOPMPowerStateIndex oldPowerState, - IOPMPowerStateIndex newPowerState - ); + IOPMPowerStateIndex newPowerState ); struct IOPMActions { void * target; - uint32_t parameter; IOPMActionPowerChangeStart actionPowerChangeStart; IOPMActionPowerChangeDone actionPowerChangeDone; IOPMActionPowerChangeOverride actionPowerChangeOverride; IOPMActionActivityTickle actionActivityTickle; IOPMActionUpdatePowerClient actionUpdatePowerClient; + uint32_t darkWakePowerState; + uint16_t flags; + uint16_t state; +}; + +// IOPMActions flags +enum { + kPMActionsPCIBitNumberMask = 0x00ff, + kPMActionsFlagIsDisplayWrangler = 0x0100, + kPMActionsFlagIsGraphicsDriver = 0x0200, + kPMActionsFlagIsAudioDriver = 0x0400, + kPMActionsFlagHasDarkWakePowerState = 0x0800 }; -// IOPMActions parameter flags +// IOPMActions state enum { - kPMActionsFlagIsDisplayWrangler = 0x00000100, - kPMActionsFlagIsGraphicsDevice = 0x00000200, - kPMActionsFlagIsAudioDevice = 0x00000400, - kPMActionsFlagLimitPower = 0x00000800, - kPMActionsPCIBitNumberMask = 0x000000ff + kPMActionsStatePowerClamped = 0x0001 }; //****************************************************************************** @@ -142,9 +150,11 @@ struct IOPMPSEntry { IOPMPowerFlags capabilityFlags; IOPMPowerFlags outputPowerFlags; IOPMPowerFlags inputPowerFlags; - uint32_t staticPower; + unsigned long staticPower; +#if USE_SETTLE_TIMER uint32_t settleUpTime; uint32_t settleDownTime; +#endif IOPMPowerStateIndex stateOrder; IOPMPowerStateIndex stateOrderToIndex; }; @@ -158,7 +168,7 @@ class IOServicePM : public OSObject friend class IOService; friend class IOPMWorkQueue; - OSDeclareDefaultStructors( IOServicePM ) + OSDeclareDefaultStructors( IOServicePM ); private: // Link IOServicePM objects on IOPMWorkQueue. @@ -180,7 +190,9 @@ private: uint32_t MachineState; thread_call_t AckTimer; +#if USE_SETTLE_TIMER thread_call_t SettleTimer; +#endif thread_call_t IdleTimer; thread_call_t WatchdogTimer; thread_call_t SpinDumpTimer; @@ -191,8 +203,10 @@ private: uint64_t WatchdogDeadline; // Settle time after changing power state. +#if USE_SETTLE_TIMER uint32_t SettleTimeUS; - uint32_t IdleTimerGeneration; +#endif + IOPMPowerStateIndex IdleTimerGeneration; // The flags describing current change note. IOPMPowerChangeFlags HeadNoteChangeFlags; @@ -247,9 +261,9 @@ private: IOLock * ActivityLock; // Idle timer's period in seconds. - unsigned long IdleTimerPeriod; - unsigned long IdleTimerMinPowerState; - unsigned long NextIdleTimerPeriod; + int IdleTimerPeriod; + int NextIdleTimerPeriod; + IOPMPowerStateIndex IdleTimerMinPowerState; AbsoluteTime IdleTimerStartTime; // Power state desired by a subclassed device object. @@ -293,7 +307,7 @@ private: OSArray * NotifyClientArray; // Used to uniquely identify power management notification to apps and clients. - UInt16 SerialNumber; + uint16_t SerialNumber; // Used to communicate desired function to tellClientsWithResponse(). // This is used because it avoids changing the signatures of the affected virtual methods. @@ -312,8 +326,8 @@ private: uint32_t DriverCallReason; uint32_t OutOfBandMessage; uint32_t TempClampCount; - uint32_t OverrideMaxPowerState; - uint32_t DeviceUsablePowerState; + IOPMPowerStateIndex OverrideMaxPowerState; + IOPMPowerStateIndex DeviceUsablePowerState; // Protected by ActivityLock - BEGIN IOPMPowerStateIndex ActivityTicklePowerState; @@ -368,7 +382,6 @@ private: #define fWatchdogLock pwrMgt->WatchdogLock #define fBlockedArray pwrMgt->BlockedArray #define fPendingResponseDeadline pwrMgt->PendingResponseDeadline -#define fSpinDumpTimer pwrMgt->SpinDumpTimer #define fSettleTimeUS pwrMgt->SettleTimeUS #define fIdleTimerGeneration pwrMgt->IdleTimerGeneration #define fHeadNoteChangeFlags pwrMgt->HeadNoteChangeFlags @@ -470,8 +483,8 @@ private: #define WATCHDOG_SLEEP_TIMEOUT (180) // 180 secs #define WATCHDOG_WAKE_TIMEOUT (180) // 180 secs #else -#define WATCHDOG_SLEEP_TIMEOUT (180) // 180 secs -#define WATCHDOG_WAKE_TIMEOUT (180) // 180 secs +#define WATCHDOG_SLEEP_TIMEOUT (35) // 35 secs (kMaxTimeRequested + 5s) +#define WATCHDOG_WAKE_TIMEOUT (35) // 35 secs (kMaxTimeRequested + 5s) #endif // Max wait time in microseconds for kernel priority and capability clients @@ -542,6 +555,8 @@ struct IOPMInterestContext { uint32_t maxTimeRequested; uint32_t messageType; uint32_t notifyType; + uint32_t skippedInDark; + uint32_t notSkippedInDark; IOService * us; IOPMPowerStateIndex stateNumber; IOPMPowerFlags stateFlags; @@ -552,18 +567,28 @@ struct IOPMInterestContext { // assertPMDriverCall() options enum { - kIOPMADC_NoInactiveCheck = 1 + kIOPMDriverCallNoInactiveCheck = 1 +}; + +// assertPMDriverCall() method +enum { + kIOPMDriverCallMethodUnknown = 0, + kIOPMDriverCallMethodSetPowerState = 1, + kIOPMDriverCallMethodWillChange = 2, + kIOPMDriverCallMethodDidChange = 3, + kIOPMDriverCallMethodChangeDone = 4, + kIOPMDriverCallMethodSetAggressive = 5 }; //****************************************************************************** // PM Statistics & Diagnostics //****************************************************************************** -extern const OSSymbol *gIOPMStatsResponseTimedOut; -extern const OSSymbol *gIOPMStatsResponseCancel; -extern const OSSymbol *gIOPMStatsResponseSlow; -extern const OSSymbol *gIOPMStatsResponsePrompt; -extern const OSSymbol *gIOPMStatsDriverPSChangeSlow; +extern OSPtr gIOPMStatsResponseTimedOut; +extern OSPtr gIOPMStatsResponseCancel; +extern OSPtr gIOPMStatsResponseSlow; +extern OSPtr gIOPMStatsResponsePrompt; +extern OSPtr gIOPMStatsDriverPSChangeSlow; //****************************************************************************** // IOPMRequest @@ -571,15 +596,16 @@ extern const OSSymbol *gIOPMStatsDriverPSChangeSlow; class IOPMRequest : public IOCommand { - OSDeclareDefaultStructors( IOPMRequest ) + OSDeclareDefaultStructors( IOPMRequest ); protected: - IOService * fTarget; // request target - IOPMRequest * fRequestNext; // the next request in the chain - IOPMRequest * fRequestRoot; // the root request in the call tree - IOItemCount fWorkWaitCount;// execution blocked if non-zero - IOItemCount fFreeWaitCount;// completion blocked if non-zero - uint32_t fRequestType; // request type + IOService * fTarget; // request target + IOPMRequest * fRequestNext; // the next request in the chain + IOPMRequest * fRequestRoot; // the root request in the call tree + uint32_t fWorkWaitCount; // execution blocked if non-zero + uint32_t fFreeWaitCount; // completion blocked if non-zero + uint64_t fTimestamp; // MCTU + uint32_t fRequestType; // request type bool fIsQuiesceBlocker; IOPMCompletionAction fCompletionAction; @@ -587,7 +613,7 @@ protected: void * fCompletionParam; public: - uint32_t fRequestTag; + uint32_t fTag; void * fArg0; void * fArg1; void * fArg2; @@ -621,7 +647,7 @@ public: return (IOPMRequest *) this; } #endif - return 0; + return NULL; } inline uint32_t @@ -630,6 +656,12 @@ public: return fRequestType; } + inline uint32_t + getTag( void ) const + { + return fTag; + } + inline bool isReplyType( void ) const { @@ -652,7 +684,7 @@ public: isQuiesceType( void ) const { return (kIOPMRequestTypeQuiescePowerTree == fRequestType) && - (fCompletionAction != 0) && (fCompletionTarget != 0); + (fCompletionAction != NULL) && (fCompletionTarget != NULL); } inline void @@ -666,6 +698,18 @@ public: fCompletionParam = param; } + inline void + setTimestamp( uint64_t time ) + { + fTimestamp = time; + } + + inline uint64_t + getTimestamp( void ) const + { + return fTimestamp; + } + static IOPMRequest * create( void ); bool init( IOService * owner, IOOptionBits type ); void reset( void ); @@ -681,7 +725,7 @@ public: class IOPMRequestQueue : public IOEventSource { - OSDeclareDefaultStructors( IOPMRequestQueue ) + OSDeclareDefaultStructors( IOPMRequestQueue ); public: typedef bool (*Action)( IOService *, IOPMRequest *, IOPMRequestQueue * ); @@ -698,7 +742,7 @@ protected: public: static IOPMRequestQueue * create( IOService * inOwner, Action inAction ); - void queuePMRequest( IOPMRequest * request ); + void queuePMRequest( LIBKERN_CONSUMED IOPMRequest * request ); void queuePMRequestChain( IOPMRequest ** requests, IOItemCount count ); }; @@ -710,7 +754,7 @@ public: class IOPMWorkQueue : public IOEventSource { - OSDeclareDefaultStructors( IOPMWorkQueue ) + OSDeclareDefaultStructors( IOPMWorkQueue ); public: typedef bool (*Action)( IOService *, IOPMRequest *, IOPMWorkQueue * ); @@ -752,7 +796,7 @@ public: class IOPMCompletionQueue : public IOEventSource { - OSDeclareDefaultStructors( IOPMCompletionQueue ) + OSDeclareDefaultStructors( IOPMCompletionQueue ); public: typedef bool (*Action)( IOService *, IOPMRequest *, IOPMCompletionQueue * );