ReactOS  0.4.15-dev-3442-gc05a45e
FxPowerIdleMachine Class Reference

#include <fxpoweridlestatemachine.hpp>

Inheritance diagram for FxPowerIdleMachine:
Collaboration diagram for FxPowerIdleMachine:

Public Member Functions

 FxPowerIdleMachine (VOID)
 
 ~FxPowerIdleMachine (VOID)
 
_Must_inspect_result_ NTSTATUS Init (VOID)
 
VOID EnableTimer (VOID)
 
BOOLEAN DisableTimer (VOID)
 
VOID Start (VOID)
 
VOID Stop (VOID)
 
VOID Reset (VOID)
 
_Must_inspect_result_ NTSTATUS IoIncrement (VOID)
 
_Must_inspect_result_ NTSTATUS IoIncrementWithFlags (__in FxPowerReferenceFlags Flags, __out_opt PULONG Count=NULL)
 
VOID IoDecrement (__in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
 
BOOLEAN QueryReturnToIdle (VOID)
 
VOID WaitForD0 (VOID)
 
_Must_inspect_result_ NTSTATUS PowerReference (__in BOOLEAN WaitForD0, __in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
 
_Must_inspect_result_ NTSTATUS PowerReferenceWithFlags (__in FxPowerReferenceFlags Flags)
 
VOID ProcessPowerEvent (__in FxPowerIdleEvents Event)
 
- Public Member Functions inherited from FxStump
PVOID operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
PVOID operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in POOL_TYPE PoolType)
 
VOID operator delete (__in PVOID pointer)
 
PVOID operator new[] (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
VOID operator delete[] (__in PVOID pointer)
 

Public Attributes

LARGE_INTEGER m_PowerTimeout
 
UCHAR m_Flags
 
UCHAR TimerEnabled: 1
 
UCHAR InDx: 1
 
UCHAR TimerCanceled: 1
 
UCHAR TimerStarted: 1
 
UCHAR TimerPowerFailed: 1
 
UCHAR IsStarted: 1
 
UCHAR IoPresentSent: 1
 
UCHAR SendPnpPowerUpEvent: 1
 
struct {
   UCHAR   TimerEnabled: 1
 
   UCHAR   InDx: 1
 
   UCHAR   TimerCanceled: 1
 
   UCHAR   TimerStarted: 1
 
   UCHAR   TimerPowerFailed: 1
 
   UCHAR   IsStarted: 1
 
   UCHAR   IoPresentSent: 1
 
   UCHAR   SendPnpPowerUpEvent: 1
 
m_FlagsByName
 

Protected Member Functions

VOID ProcessEventLocked (__in FxPowerIdleEvents Event)
 
BOOLEAN IsTransitioning (VOID)
 
BOOLEAN CancelIdleTimer (VOID)
 
BOOLEAN InD0Locked (VOID)
 
VOID SendD0Notification (VOID)
 
_Must_inspect_result_ NTSTATUS PowerReferenceWorker (__in BOOLEAN WaitForD0, __in FxPowerReferenceFlags Flags, __in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
 
- Protected Member Functions inherited from FxStump
 FxStump (VOID)
 

Static Protected Member Functions

static FxPowerIdleStates Stopped (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates Started (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates StartedPowerUp (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates StartedPowerFailed (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates Disabled (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates CheckIoCount (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates DecrementIo (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates StartTimer (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates TimingOut (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates TimedOutIoIncrement (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates TimedOutPowerDown (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates TimedOutPowerDownFailed (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates GoingToDx (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates InDx (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates InDxIoIncrement (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates InDxPowerUpFailure (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates InDxStopped (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates InDxDisabled (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates InDxEnabled (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates PowerUp (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates PowerUpComplete (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates TimedOutDisabled (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates TimedOutEnabled (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates CancelTimer (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates TimerExpired (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates Disabling (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates DisablingTimerExpired (__inout FxPowerIdleMachine *This)
 
static FxPowerIdleStates PowerFailed (__inout FxPowerIdleMachine *This)
 

Protected Attributes

MxLock m_Lock
 
ULONG m_IoCount
 
FxTagTrackerm_TagTracker
 
MxTimer m_PowerTimeoutTimer
 
FxCREvent m_D0NotificationEvent
 
union {
   UCHAR   m_Flags
 
   struct {
      UCHAR   TimerEnabled: 1
 
      UCHAR   InDx: 1
 
      UCHAR   TimerCanceled: 1
 
      UCHAR   TimerStarted: 1
 
      UCHAR   TimerPowerFailed: 1
 
      UCHAR   IsStarted: 1
 
      UCHAR   IoPresentSent: 1
 
      UCHAR   SendPnpPowerUpEvent: 1
 
   }   m_FlagsByName
 
}; 
 
UCHAR m_EventHistoryIndex
 
UCHAR m_StateHistoryIndex
 
FxPowerIdleStates m_CurrentIdleState
 
FxPowerIdleEvents m_EventHistory [FxPowerIdleEventQueueDepth]
 
FxPowerIdleStates m_StateHistory [FxPowerIdleEventQueueDepth]
 

Static Protected Attributes

static MdDeferredRoutineType _PowerTimeoutDpcRoutine
 
static const FxPowerIdleTargetState m_StoppedStates []
 
static const FxPowerIdleTargetState m_StartedStates []
 
static const FxPowerIdleTargetState m_DisabledStates []
 
static const FxPowerIdleTargetState m_BusyStates []
 
static const FxPowerIdleTargetState m_TimerRunningStates []
 
static const FxPowerIdleTargetState m_TimedOutStates []
 
static const FxPowerIdleTargetState m_InDxStates []
 
static const FxPowerIdleTargetState m_WaitForTimeoutStates []
 
static const FxPowerIdleTargetState m_DisablingWaitForTimeoutStates []
 
static const FxPowerIdleTargetState m_PowerFailedWaitForTimeoutStates []
 
static const FxIdleStateTable m_StateTable []
 
static const ULONG m_IdleTimerTolerableDelayMS = 100
 

Private Member Functions

VOID CheckAssumptions (VOID)
 

Detailed Description

Definition at line 116 of file fxpoweridlestatemachine.hpp.

Constructor & Destructor Documentation

◆ FxPowerIdleMachine()

FxPowerIdleMachine::FxPowerIdleMachine ( VOID  )

Definition at line 332 of file poweridlestatemachine.cpp.

347 {
348  //
349  // m_Lock and m_PowerTimeoutTimer are now being initialized in Init method
350  // since they may fail for UM.
351  //
352 
355 
358 
361 
362  m_TagTracker = NULL;
363 }
FxPowerIdleEvents m_EventHistory[FxPowerIdleEventQueueDepth]
FxPowerIdleStates m_StateHistory[FxPowerIdleEventQueueDepth]
FxPowerIdleStates m_CurrentIdleState
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
LONGLONG QuadPart
Definition: typedefs.h:114

◆ ~FxPowerIdleMachine()

FxPowerIdleMachine::~FxPowerIdleMachine ( VOID  )

Definition at line 365 of file poweridlestatemachine.cpp.

368 {
369  if (m_TagTracker != NULL) {
370  delete m_TagTracker;
371  m_TagTracker = NULL;
372  }
373 }
#define NULL
Definition: types.h:112

Member Function Documentation

◆ CancelIdleTimer()

BOOLEAN FxPowerIdleMachine::CancelIdleTimer ( VOID  )
inlineprotected

Definition at line 234 of file fxpoweridlestatemachine.hpp.

237  {
238  //
239  // If we are canceling the timer, be well sure it is started
240  //
242 
243  if (m_PowerTimeoutTimer.Stop()) {
245  return TRUE;
246  }
247  else {
248  return FALSE;
249  }
250  }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:44
_Must_inspect_result_ __inline BOOLEAN Stop(VOID)
Definition: mxtimerkm.h:273

◆ CancelTimer()

FxPowerIdleStates FxPowerIdleMachine::CancelTimer ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 1112 of file poweridlestatemachine.cpp.

1128 {
1129  if (This->CancelIdleTimer()) {
1130  return FxIdleCheckIoCount;
1131  }
1132  else {
1133  return FxIdleWaitForTimeout;
1134  }
1135 }

◆ CheckAssumptions()

VOID FxPowerIdleMachine::CheckAssumptions ( VOID  )
private

Definition at line 405 of file poweridlestatemachine.cpp.

424 {
425  WDFCASSERT((sizeof(m_StateTable)/sizeof(m_StateTable[0]))
426  ==
428 }
WDFCASSERT(sizeof(WDF_DRIVER_CONFIG_V1_0)==sizeof(WDF_DRIVER_CONFIG_V1_1))
static const FxIdleStateTable m_StateTable[]

◆ CheckIoCount()

FxPowerIdleStates FxPowerIdleMachine::CheckIoCount ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 560 of file poweridlestatemachine.cpp.

577 {
578  This->m_Flags |= FxPowerIdleTimerEnabled;
579 
580  if (This->m_IoCount == 0) {
581  return FxIdleStartTimer;
582  }
583  else {
584  return FxIdleBusy;
585  }
586 }

◆ DecrementIo()

FxPowerIdleStates FxPowerIdleMachine::DecrementIo ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 589 of file poweridlestatemachine.cpp.

604 {
605  if (This->m_IoCount == 0) {
606  return FxIdleStartTimer;
607  }
608  else {
609  return FxIdleBusy;
610  }
611 }

◆ Disabled()

FxPowerIdleStates FxPowerIdleMachine::Disabled ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 537 of file poweridlestatemachine.cpp.

◆ DisableTimer()

BOOLEAN FxPowerIdleMachine::DisableTimer ( VOID  )

Definition at line 1381 of file poweridlestatemachine.cpp.

1402 {
1403  KIRQL irql;
1404  BOOLEAN disabledImmediately;
1405 
1406  m_Lock.Acquire(&irql);
1407 
1409 
1410  //
1411  // If FxPowerIdleTimerStarted is still set after disabling the state machine,
1412  // then we could not cancel the timer and we must wait for the timer expired
1413  // event to be posted to this state machine. This state machine will then
1414  // post a PwrPolIoPresent event to power policy.
1415  //
1417  disabledImmediately = FALSE;
1418  }
1419  else {
1420  disabledImmediately = TRUE;
1421  }
1422 
1423  m_Lock.Release(irql);
1424 
1425  return disabledImmediately;
1426 }
#define TRUE
Definition: types.h:120
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
VOID ProcessEventLocked(__in FxPowerIdleEvents Event)

◆ Disabling()

FxPowerIdleStates FxPowerIdleMachine::Disabling ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 1161 of file poweridlestatemachine.cpp.

1177 {
1178  if (This->CancelIdleTimer()) {
1179  return FxIdleDisabled;
1180  }
1181  else {
1183  }
1184 }

◆ DisablingTimerExpired()

FxPowerIdleStates FxPowerIdleMachine::DisablingTimerExpired ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 1187 of file poweridlestatemachine.cpp.

1203 {
1204  This->m_Flags &= ~FxPowerIdleTimerStarted;
1205 
1206 #if (FX_CORE_MODE==FX_CORE_KERNEL_MODE)
1208 #else
1211  TRUE // ProcessEventOnDifferentThread
1212  );
1213 #endif
1214 
1215  return FxIdleDisabled;
1216 }
#define TRUE
Definition: types.h:120
VOID PowerPolicyProcessEvent(__in FxPowerPolicyEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
__inline FxPkgPnp * GetPnpPkg(__inout FxPowerIdleMachine *This)

◆ EnableTimer()

VOID FxPowerIdleMachine::EnableTimer ( VOID  )

Definition at line 1356 of file poweridlestatemachine.cpp.

1372 {
1373  KIRQL irql;
1374 
1375  m_Lock.Acquire(&irql);
1377  m_Lock.Release(irql);
1378 }
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID ProcessEventLocked(__in FxPowerIdleEvents Event)

◆ GoingToDx()

FxPowerIdleStates FxPowerIdleMachine::GoingToDx ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 785 of file poweridlestatemachine.cpp.

802 {
803  This->m_D0NotificationEvent.Clear();
804  return FxIdleInDx;
805 }

◆ InD0Locked()

BOOLEAN FxPowerIdleMachine::InD0Locked ( VOID  )
inlineprotected

Definition at line 253 of file fxpoweridlestatemachine.hpp.

256  {
258  }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG ReadState(VOID)
Definition: fxwaitlock.hpp:160

Referenced by IoIncrementWithFlags().

◆ InDx()

static FxPowerIdleStates FxPowerIdleMachine::InDx ( __inout FxPowerIdleMachine This)
staticprotected

◆ InDxDisabled()

FxPowerIdleStates FxPowerIdleMachine::InDxDisabled ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 944 of file poweridlestatemachine.cpp.

960 {
961  //
962  // Idle timer is being disabled while in Dx. Remain in Dx.
963  //
964  This->m_Flags &= ~FxPowerIdleTimerEnabled;
965 
966  return FxIdleInDx;
967 }

◆ InDxEnabled()

FxPowerIdleStates FxPowerIdleMachine::InDxEnabled ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 970 of file poweridlestatemachine.cpp.

986 {
987  //
988  // Idle timer is being enabled while in Dx. Remain in Dx.
989  //
990  This->m_Flags |= FxPowerIdleTimerEnabled;
991 
992  return FxIdleInDx;
993 }

◆ InDxIoIncrement()

FxPowerIdleStates FxPowerIdleMachine::InDxIoIncrement ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 832 of file poweridlestatemachine.cpp.

848 {
849  FxPkgPnp* pPkgPnp;
850 
852 
853  if (This->m_Flags & FxPowerIdleIoPresentSent) {
856  "WDFDEVICE %p idle (in Dx) not sending io present event (already sent)",
857  pPkgPnp->GetDevice()->GetHandle());
858  }
859  else {
860 #if (FX_CORE_MODE==FX_CORE_KERNEL_MODE)
862 #else
865  TRUE // ProcessEventOnDifferentThread
866  );
867 #endif
868  This->m_Flags |= FxPowerIdleIoPresentSent;
869  }
870 
871  return FxIdleInDx;
872 }
__inline CfxDevice * GetDevice(VOID)
Definition: fxpackage.hpp:46
#define TRUE
Definition: types.h:120
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
FxPkgPnp * pPkgPnp
VOID PowerPolicyProcessEvent(__in FxPowerPolicyEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
#define TRACINGPNP
Definition: dbgtrace.h:67
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
__inline FxPkgPnp * GetPnpPkg(__inout FxPowerIdleMachine *This)

◆ InDxPowerUpFailure()

FxPowerIdleStates FxPowerIdleMachine::InDxPowerUpFailure ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 875 of file poweridlestatemachine.cpp.

891 {
892  //
893  // FxPowerIdleInDx - We are no longer in Dx
894  // FxPowerIdleIoPresentSent = We can send the io present event again
895  //
897 
898  return FxIdlePowerFailed;
899 }

◆ InDxStopped()

FxPowerIdleStates FxPowerIdleMachine::InDxStopped ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 902 of file poweridlestatemachine.cpp.

918 {
919  //
920  // When the machine is in the stopped state, the notification event is in
921  // the signaled state.
922  //
923  This->SendD0Notification();
924 
925  //
926  // We are not longer idle since we are not in the Dx state anymore
927  //
928  This->m_Flags &= ~FxPowerIdleInDx;
929 
930  //
931  // We are no longer enabled since we are stopped from the Dx state
932  //
933  This->m_Flags &= ~FxPowerIdleTimerEnabled;
934 
935  //
936  // We can send the io present event again
937  //
938  This->m_Flags &= ~FxPowerIdleIoPresentSent;
939 
940  return FxIdleStopped;
941 }

◆ Init()

_Must_inspect_result_ NTSTATUS FxPowerIdleMachine::Init ( VOID  )

Definition at line 377 of file poweridlestatemachine.cpp.

380 {
382 
383  //
384  // For KM, event initialize always succeeds. For UM, it might fail.
385  //
387  if (!NT_SUCCESS(status)) {
388  return status;
389  }
390 
391  //
392  // For KM, timer initialize always succeeds. For UM, it might fail.
393  //
395  if (!NT_SUCCESS(status)) {
396  return status;
397  }
398 
399  Reset();
400 
401  return STATUS_SUCCESS;
402 }
CHECK_RETURN_IF_USER_MODE __inline NTSTATUS Initialize(__in_opt PVOID TimerContext, __in MdDeferredRoutine TimerCallback, __in LONG Period)
Definition: mxtimerkm.h:119
CHECK_RETURN_IF_USER_MODE NTSTATUS Initialize(__in BOOLEAN InitialState=FALSE)
Definition: fxwaitlock.hpp:51
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static MdDeferredRoutineType _PowerTimeoutDpcRoutine
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by FxPowerPolicyOwnerSettings::Init().

◆ IoDecrement()

VOID FxPowerIdleMachine::IoDecrement ( __in_opt PVOID  Tag = NULL,
__in_opt LONG  Line = 0,
__in_opt PSTR  File = NULL 
)

Definition at line 1735 of file poweridlestatemachine.cpp.

1754 {
1755  KIRQL irql;
1756  FxPkgPnp* pPkgPnp;
1758  ULONG count;
1759 
1760  pPkgPnp = GetPnpPkg(this);
1762 
1763  m_Lock.Acquire(&irql);
1764 
1765  if (m_IoCount == 0) {
1766  //
1767  // We can get here for the following reasons:
1768  // 1. Driver called WdfDevicveStopIdle/WdfDeviceResumeIdle in a mismatched
1769  // manner. This is a driver bug.
1770  // 2. Framework did power deref without a corresponding power ref.
1771  // This would be a framework bug.
1772  //
1773  // We will break into debugger if verifier is turned on. This will allow
1774  // developers to catch this problem during develeopment.
1775  // We limit this break to version 1.11+ because otherwise older drivers
1776  // may hit this, and if they cannot be fixed for some reason, then
1777  // verifier would need to be turned off to avoid the break which is not
1778  // desirable.
1779  //
1782  "WDFDEVICE 0x%p !devobj 0x%p The device is being power-dereferenced"
1783  " without a matching power-reference. This could occur if driver"
1784  " incorrectly calls WdfDeviceResumeIdle without a matching call to"
1785  " WdfDeviceStopIdle.",
1786  pPkgPnp->GetDevice()->GetHandle(),
1788 
1791  }
1792  }
1793 
1794  ASSERT(m_IoCount > 0);
1795  count = --m_IoCount;
1797  m_Lock.Release(irql);
1798 
1799  if (m_TagTracker != NULL) {
1801  }
1802 }
__inline CfxDevice * GetDevice(VOID)
Definition: fxpackage.hpp:46
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
GLuint GLuint GLsizei count
Definition: gl.h:1545
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
FxPkgPnp * pPkgPnp
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define ASSERT(a)
Definition: mode.c:44
_Must_inspect_result_ BOOLEAN IsVerificationEnabled(__in ULONG Major, __in ULONG Minor, __in FxVerifierDownlevelOption DownLevel)
Definition: fxglobals.h:286
VOID UpdateTagHistory(__in PVOID Tag, __in LONG Line, __in_opt PSTR File, __in FxTagRefType RefType, __in ULONG RefCount)
Definition: ncftp.h:79
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACINGPNP
Definition: dbgtrace.h:67
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
__inline FxPkgPnp * GetPnpPkg(__inout FxPowerIdleMachine *This)
VOID ProcessEventLocked(__in FxPowerIdleEvents Event)
unsigned int ULONG
Definition: retypes.h:1
Definition: File.h:15
FxVerifierDbgBreakPoint(pFxDriverGlobals)

Referenced by FxPkgPnp::PowerDereference().

◆ IoIncrement()

_Must_inspect_result_ NTSTATUS FxPowerIdleMachine::IoIncrement ( VOID  )

Definition at line 1639 of file poweridlestatemachine.cpp.

1658 {
1660 }
_Must_inspect_result_ NTSTATUS IoIncrementWithFlags(__in FxPowerReferenceFlags Flags, __out_opt PULONG Count=NULL)

◆ IoIncrementWithFlags()

_Must_inspect_result_ NTSTATUS FxPowerIdleMachine::IoIncrementWithFlags ( __in FxPowerReferenceFlags  Flags,
__out_opt PULONG  Count = NULL 
)

Definition at line 1664 of file poweridlestatemachine.cpp.

1690 {
1691  NTSTATUS status;
1692  KIRQL irql;
1693 
1694  m_Lock.Acquire(&irql);
1695 
1697  //
1698  // fail without incrementing the count because we are in an
1699  // invalid power state
1700  //
1702  COVERAGE_TRAP();
1703  }
1704  else if ((m_Flags & FxPowerIdleIsStarted) == 0x0) {
1705  //
1706  // The state machine is not yet in a started state
1707  //
1709  }
1710  else {
1711  m_IoCount++;
1712  if (Count != NULL) {
1713  *Count = m_IoCount;
1714  }
1715 
1717 
1718  if (InD0Locked()) {
1720  }
1721  else {
1725  }
1726  }
1727  }
1728  m_Lock.Release(irql);
1729 
1730  return status;
1731 }
GLint x0
Definition: linetemp.h:95
LONG NTSTATUS
Definition: precomp.h:26
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define COVERAGE_TRAP()
Definition: fxmacros.hpp:246
int Count
Definition: noreturn.cpp:7
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_POWER_STATE_INVALID
Definition: ntstatus.h:831
#define NULL
Definition: types.h:112
VOID ProcessEventLocked(__in FxPowerIdleEvents Event)
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by IoIncrement(), and PowerReferenceWorker().

◆ IsTransitioning()

BOOLEAN FxPowerIdleMachine::IsTransitioning ( VOID  )
inlineprotected

Definition at line 226 of file fxpoweridlestatemachine.hpp.

229  {
231  }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG ReadState(VOID)
Definition: fxwaitlock.hpp:160

◆ PowerFailed()

FxPowerIdleStates FxPowerIdleMachine::PowerFailed ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 1219 of file poweridlestatemachine.cpp.

1235 {
1236  //
1237  // By this time, the timer should be stopped
1238  //
1239  ASSERT((This->m_Flags & FxPowerIdleTimerStarted) == 0);
1240 
1241  This->m_Flags |= FxPowerIdlePowerFailed;
1242 
1243  //
1244  // We are no longer enabled to time out since we are in a failed state
1245  //
1246  This->m_Flags &= ~FxPowerIdleTimerEnabled;
1247 
1248  //
1249  // Wake up any waiters and indicate failure to them.
1250  //
1251  This->SendD0Notification();
1252 
1253  return FxIdleDisabled;
1254 }
#define ASSERT(a)
Definition: mode.c:44

◆ PowerReference()

_Must_inspect_result_ NTSTATUS FxPowerIdleMachine::PowerReference ( __in BOOLEAN  WaitForD0,
__in_opt PVOID  Tag = NULL,
__in_opt LONG  Line = 0,
__in_opt PSTR  File = NULL 
)
inline

Definition at line 193 of file fxpoweridlestatemachine.hpp.

199  {
201  }
_Must_inspect_result_ NTSTATUS PowerReferenceWorker(__in BOOLEAN WaitForD0, __in FxPowerReferenceFlags Flags, __in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
Definition: ncftp.h:79
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN WaitForD0
Definition: wdfdevice.h:4003
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
Definition: File.h:15

Referenced by FxPkgPnp::PowerReference().

◆ PowerReferenceWithFlags()

_Must_inspect_result_ NTSTATUS FxPowerIdleMachine::PowerReferenceWithFlags ( __in FxPowerReferenceFlags  Flags)
inline

Definition at line 205 of file fxpoweridlestatemachine.hpp.

208  {
209  return PowerReferenceWorker(FALSE, // WaitForD0
210  Flags);
211  }
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Must_inspect_result_ NTSTATUS PowerReferenceWorker(__in BOOLEAN WaitForD0, __in FxPowerReferenceFlags Flags, __in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)

◆ PowerReferenceWorker()

_Must_inspect_result_ NTSTATUS FxPowerIdleMachine::PowerReferenceWorker ( __in BOOLEAN  WaitForD0,
__in FxPowerReferenceFlags  Flags,
__in_opt PVOID  Tag = NULL,
__in_opt LONG  Line = 0,
__in_opt PSTR  File = NULL 
)
protected

Definition at line 1480 of file poweridlestatemachine.cpp.

1509 {
1510  NTSTATUS status;
1511  KIRQL irql;
1512  ULONG count = 0;
1513 
1514 
1515 
1516 
1517 
1518 
1519 
1520 
1521 
1522 
1523 
1524 
1525 
1526 
1527 
1528 
1529 
1530 
1531 
1532  //
1533  // Poke the state machine
1534  //
1536 
1537  //
1538  // STATUS_PENDING indicates a Dx to D0 transition is occurring right now
1539  //
1540  if (status == STATUS_PENDING) {
1541  if (WaitForD0) {
1542  FxPkgPnp* pPkgPnp;
1543 
1545 
1546  //
1547  // With the current usage, if WaitForD0 is TRUE, then the only
1548  // acceptable flag is FxPowerReferenceDefault.
1549  //
1550  // If the usage changes in the future such that it is acceptable to
1551  // have WaitForD0 set to TRUE and some flag(s) set, then the ASSERT
1552  // below should be updated accordingly (or removed altogether).
1553  //
1555 
1556  pPkgPnp = GetPnpPkg(this);
1557 
1560  "WDFDEVICE %p in thread %p waiting synchronously for Dx to D0 "
1561  "transition",
1562  pPkgPnp->GetDevice()->GetHandle(),
1564 
1565  //
1566  // Returns success always
1567  //
1569 
1570  m_Lock.Acquire(&irql);
1571 
1572  //
1573  // If WaitForD0 is TRUE, then the FxPowerIdleSendPnpPowerUpEvent
1574  // flag can't be set. That flag is only used when the PnP state
1575  // machine waits asynchronously for the device to power up during
1576  // query-remove.
1577  //
1579 
1580  if ((m_Flags & FxPowerIdlePowerFailed) != 0x0 ||
1581  (m_Flags & FxPowerIdleIsStarted) == 0x0) {
1582 
1583  //
1584  // Event was set because a power up or down failure occurred
1585  //
1587 
1591  "WDFDEVICE %p waiting for D0 in thread %p failed because of "
1592  "power failure, %!STATUS!",
1593  pPkgPnp->GetDevice()->GetHandle(),
1595  status);
1596  }
1597  else {
1598  COVERAGE_TRAP();
1601  "WDFDEVICE %p waiting for D0 in thread %p failed because of "
1602  "invalid state , %!STATUS!",
1603  pPkgPnp->GetDevice()->GetHandle(),
1605  }
1606 
1607  //
1608  // Decrement the io count that was taken above
1609  //
1610  ASSERT(m_IoCount > 0);
1611  m_IoCount--;
1613  }
1614  else {
1615  //
1616  // Successfully returned to D0
1617  //
1619  }
1620  m_Lock.Release(irql);
1621  }
1622  }
1623 
1624  if (m_TagTracker != NULL) {
1625  //
1626  // Only track the reference if the call was successful
1627  // and the counter was actually incremented.
1628  //
1629  if (status == STATUS_SUCCESS || status == STATUS_PENDING) {
1631  }
1632  }
1633 
1634  return status;
1635 }
__inline CfxDevice * GetDevice(VOID)
Definition: fxpackage.hpp:46
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
GLint x0
Definition: linetemp.h:95
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
GLuint GLuint GLsizei count
Definition: gl.h:1545
LONG NTSTATUS
Definition: precomp.h:26
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define COVERAGE_TRAP()
Definition: fxmacros.hpp:246
FxPkgPnp * pPkgPnp
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define ASSERT(a)
Definition: mode.c:44
#define STATUS_PENDING
Definition: ntstatus.h:82
static __inline KIRQL MxGetCurrentIrql()
Definition: mxgeneralkm.h:86
VOID UpdateTagHistory(__in PVOID Tag, __in LONG Line, __in_opt PSTR File, __in FxTagRefType RefType, __in ULONG RefCount)
Definition: ncftp.h:79
_Must_inspect_result_ NTSTATUS IoIncrementWithFlags(__in FxPowerReferenceFlags Flags, __out_opt PULONG Count=NULL)
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN WaitForD0
Definition: wdfdevice.h:4003
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
#define TRACINGPNP
Definition: dbgtrace.h:67
static __inline MxThread MxGetCurrentThread()
Definition: mxgeneralkm.h:61
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define STATUS_POWER_STATE_INVALID
Definition: ntstatus.h:831
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
__inline FxPkgPnp * GetPnpPkg(__inout FxPowerIdleMachine *This)
VOID ProcessEventLocked(__in FxPowerIdleEvents Event)
unsigned int ULONG
Definition: retypes.h:1
Definition: File.h:15
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
#define APC_LEVEL
Definition: env_spec_w32.h:695
Definition: ps.c:97

Referenced by PowerReference(), and PowerReferenceWithFlags().

◆ PowerUp()

FxPowerIdleStates FxPowerIdleMachine::PowerUp ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 996 of file poweridlestatemachine.cpp.

1012 {
1013  //
1014  // FxPowerIdleInDx - we are not longer idle since we are not in the Dx state
1015  // anymore
1016  // FxPowerIdleIoPresentSent - We can send the io present event again
1017  //
1019 
1020  This->SendD0Notification();
1021 
1022  return FxIdlePowerUpComplete;
1023 }

◆ PowerUpComplete()

FxPowerIdleStates FxPowerIdleMachine::PowerUpComplete ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 1026 of file poweridlestatemachine.cpp.

1042 {
1043  if (This->m_Flags & FxPowerIdleTimerEnabled) {
1044  if (This->m_Flags & FxPowerIdleTimerStarted) {
1045  COVERAGE_TRAP();
1046  return FxIdleTimerRunning;
1047  }
1048  else {
1049  return FxIdleCheckIoCount;
1050  }
1051  }
1052  else {
1053  //
1054  // Not enabled, better not have a timer running
1055  //
1056  ASSERT((This->m_Flags & FxPowerIdleTimerStarted) == 0);
1057 
1058  return FxIdleDisabled;
1059  }
1060 }
#define COVERAGE_TRAP()
Definition: fxmacros.hpp:246
#define ASSERT(a)
Definition: mode.c:44

◆ ProcessEventLocked()

VOID FxPowerIdleMachine::ProcessEventLocked ( __in FxPowerIdleEvents  Event)
protected

Definition at line 1923 of file poweridlestatemachine.cpp.

1939 {
1940  const FxIdleStateTable* entry;
1941  FxPowerIdleStates newState;
1942  FxPkgPnp* pPkgPnp;
1943 
1944  pPkgPnp = GetPnpPkg(this);
1945 
1948  (sizeof(m_EventHistory)/sizeof(m_EventHistory[0]));
1949 
1951  newState = FxIdleMax;
1952 
1953  for (ULONG i = 0; i < entry->TargetStatesCount; i++) {
1954  if (entry->TargetStates[i].PowerIdleEvent == Event) {
1955  DO_EVENT_TRAP(&entry->TargetStates[i]);
1956  newState = entry->TargetStates[i].PowerIdleState;
1957  break;
1958  }
1959  }
1960 
1961  if (newState == FxIdleMax) {
1962  switch (Event) {
1965  //
1966  // We always can handle io increment, io decrement, and query return
1967  // to idle from any state...
1968  //
1969  break;
1970 
1971  case PowerIdleEventEnabled:
1973  //
1974  // Getting an enable event while enabled is OK
1975  //
1976  break;
1977  }
1978  // || || Fall || ||
1979  // \/ \/ through \/ \/
1980 
1981  default:
1982  //
1983  // ...but we should not be dropping any other events from this state.
1984  //
1985 
1986  //
1989  "WDFDEVICE 0x%p !devobj 0x%p power idle state %!FxPowerIdleStates!"
1990  " dropping event %!FxPowerIdleEvents!",
1991  pPkgPnp->GetDevice()->GetHandle(),
1994 
1995  COVERAGE_TRAP();
1996  }
1997  }
1998 
1999  while (newState != FxIdleMax) {
2000 
2003  "WDFDEVICE 0x%p !devobj 0x%p entering power idle state "
2004  "%!FxPowerIdleStates! from %!FxPowerIdleStates!",
2005  pPkgPnp->GetDevice()->GetHandle(),
2007  newState, m_CurrentIdleState);
2008 
2009  m_StateHistory[m_StateHistoryIndex] = newState;
2011  (sizeof(m_StateHistory)/sizeof(m_StateHistory[0]));
2012 
2013  m_CurrentIdleState = newState;
2015 
2016  if (entry->StateFunc != NULL) {
2017  newState = entry->StateFunc(this);
2018  }
2019  else {
2020  newState = FxIdleMax;
2021  }
2022  }
2023 }
__inline CfxDevice * GetDevice(VOID)
Definition: fxpackage.hpp:46
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define TRACINGPNPPOWERSTATES
Definition: dbgtrace.h:69
FxPowerIdleEvents m_EventHistory[FxPowerIdleEventQueueDepth]
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:467
#define DO_EVENT_TRAP(x)
Definition: fxpkgpnp.hpp:61
#define COVERAGE_TRAP()
Definition: fxmacros.hpp:246
FxPkgPnp * pPkgPnp
FxPowerIdleStates m_StateHistory[FxPowerIdleEventQueueDepth]
uint32_t entry
Definition: isohybrid.c:63
FxPowerIdleStates m_CurrentIdleState
#define TRACINGPNP
Definition: dbgtrace.h:67
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const FxIdleStateTable m_StateTable[]
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
__inline FxPkgPnp * GetPnpPkg(__inout FxPowerIdleMachine *This)
unsigned int ULONG
Definition: retypes.h:1

Referenced by __drv_maxIRQL(), DisableTimer(), EnableTimer(), IoDecrement(), IoIncrementWithFlags(), PowerReferenceWorker(), ProcessPowerEvent(), Start(), and Stop().

◆ ProcessPowerEvent()

VOID FxPowerIdleMachine::ProcessPowerEvent ( __in FxPowerIdleEvents  Event)

Definition at line 1891 of file poweridlestatemachine.cpp.

1906 {
1907  KIRQL irql;
1908 
1909  //
1910  // All other event types have specialized public functions
1911  //
1916 
1917  m_Lock.Acquire(&irql);
1919  m_Lock.Release(irql);
1920 }
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define ASSERT(a)
Definition: mode.c:44
VOID ProcessEventLocked(__in FxPowerIdleEvents Event)

Referenced by FxPkgPnp::PowerSendIdlePowerEvent(), FxPkgPnp::PowerSendPowerDownEvents(), and FxPkgPnp::PowerSendPowerDownFailureEvent().

◆ QueryReturnToIdle()

BOOLEAN FxPowerIdleMachine::QueryReturnToIdle ( VOID  )

Definition at line 1805 of file poweridlestatemachine.cpp.

1823 {
1824  KIRQL irql;
1825  BOOLEAN result;
1826 
1827  //
1828  // To return to idle, the following must be true
1829  // 1) the device must be in Dx (FxPowerIdleInDx)
1830  // 2) the timer must *NOT* be running
1831  // 3) an IO count of zero
1832  //
1833  m_Lock.Acquire(&irql);
1834 
1835  // 1
1837  // 2 3
1838  (m_Flags & FxPowerIdleTimerStarted) == 0 && m_IoCount == 0x0) {
1839  result = TRUE;
1840  }
1841  else {
1842  result = FALSE;
1843  }
1844 
1845  //
1846  // If the caller is querying about returning to idle, then they have
1847  // processed the io present event that we previously sent. We must clear
1848  // the flag, otherwise the following can occur
1849  // 1) new io arrives, send the io present message
1850  // 2) return to idle (io count goes to zero)
1851  // 3) get queried to return to idle, return TRUE
1852  // 4) new io arrives, we do not send the new io present message because the
1853  // FxPowerIdleIoPresentSent flag is set.
1854  //
1856 
1857  m_Lock.Release(irql);
1858 
1859  return result;
1860 }
GLint x0
Definition: linetemp.h:95
GLuint64EXT * result
Definition: glext.h:11304
#define TRUE
Definition: types.h:120
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN

◆ Reset()

VOID FxPowerIdleMachine::Reset ( VOID  )

Definition at line 1313 of file poweridlestatemachine.cpp.

1328 {
1329  FxPkgPnp* pPkgPnp;
1331 
1333 
1334  m_IoCount = 0;
1335  m_Flags = 0x0;
1336 
1337  pPkgPnp = GetPnpPkg(this);
1339 
1342  //
1343  // Ignore potential failure, power ref tracking is not an essential feature.
1344  //
1349  pPkgPnp->GetDevice());
1350  }
1351 
1353 }
__inline CfxDevice * GetDevice(VOID)
Definition: fxpackage.hpp:46
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
FxDriverGlobalsDebugExtension * DebugExtension
Definition: fxglobals.h:376
FxTrackPowerOption TrackPower
Definition: fxglobals.h:145
static _Must_inspect_result_ NTSTATUS __inline CreateAndInitialize(__out FxTagTracker **TagTracker, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxTagTrackerType Type, __in BOOLEAN CaptureStack, __in FxObject *Owner, __in_opt PVOID CreateTag=NULL)
FxPkgPnp * pPkgPnp
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define ASSERT(a)
Definition: mode.c:44
FxPowerIdleStates m_CurrentIdleState
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define NULL
Definition: types.h:112
__inline FxPkgPnp * GetPnpPkg(__inout FxPowerIdleMachine *This)

Referenced by Init().

◆ SendD0Notification()

VOID FxPowerIdleMachine::SendD0Notification ( VOID  )
protected

Definition at line 1863 of file poweridlestatemachine.cpp.

1866 {
1868 
1870 
1872 
1873  //
1874  // Send an event to the Pnp state machine indicating that the device is
1875  // now in D0.
1876  //
1877 #if (FX_CORE_MODE==FX_CORE_KERNEL_MODE)
1879 #else
1880  GetPnpPkg(this)->PnpProcessEvent(
1882  TRUE // ProcessEventOnDifferentThread
1883  );
1884 #endif
1885 
1886  }
1887  return;
1888 }
VOID PnpProcessEvent(__in FxPnpEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
#define TRUE
Definition: types.h:120
VOID Set(VOID)
Definition: fxwaitlock.hpp:144
__inline FxPkgPnp * GetPnpPkg(__inout FxPowerIdleMachine *This)

Referenced by Reset().

◆ Start()

VOID FxPowerIdleMachine::Start ( VOID  )

Definition at line 1429 of file poweridlestatemachine.cpp.

1446 {
1447  KIRQL irql;
1448  m_Lock.Acquire(&irql);
1450  m_Lock.Release(irql);
1451 }
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID ProcessEventLocked(__in FxPowerIdleEvents Event)

◆ Started()

FxPowerIdleStates FxPowerIdleMachine::Started ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 453 of file poweridlestatemachine.cpp.

468 {
469  This->m_Flags |= FxPowerIdleIsStarted;
470 
471  //
472  // We are in the started state, but we are not powered up.
473  //
474  This->m_D0NotificationEvent.Clear();
475 
476  return FxIdleMax;
477 }

◆ StartedPowerFailed()

FxPowerIdleStates FxPowerIdleMachine::StartedPowerFailed ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 506 of file poweridlestatemachine.cpp.

522 {
523  //
524  // Failed to initially power up
525  //
526  This->m_Flags |= FxPowerIdlePowerFailed;
527 
528  //
529  // We assume in the started state that the event is set
530  //
531  ASSERT(This->m_D0NotificationEvent.ReadState() == 0);
532 
533  return FxIdleStarted;
534 }
#define ASSERT(a)
Definition: mode.c:44

◆ StartedPowerUp()

FxPowerIdleStates FxPowerIdleMachine::StartedPowerUp ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 480 of file poweridlestatemachine.cpp.

496 {
497  //
498  // Moving from the started state to the powered on state
499  //
500  This->SendD0Notification();
501 
502  return FxIdleDisabled;
503 }

◆ StartTimer()

FxPowerIdleStates FxPowerIdleMachine::StartTimer ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 614 of file poweridlestatemachine.cpp.

630 {
631  ASSERT((This->m_Flags & FxPowerIdleTimerEnabled) && This->m_IoCount == 0);
632 
633  This->m_Flags |= FxPowerIdleTimerStarted;
634  This->m_PowerTimeoutTimer.Start(This->m_PowerTimeout,
636 
637  return FxIdleTimerRunning;
638 }
#define ASSERT(a)
Definition: mode.c:44
static const ULONG m_IdleTimerTolerableDelayMS

◆ Stop()

VOID FxPowerIdleMachine::Stop ( VOID  )

Definition at line 1454 of file poweridlestatemachine.cpp.

1470 {
1471  KIRQL irql;
1472 
1473  m_Lock.Acquire(&irql);
1475  m_Lock.Release(irql);
1476 }
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID ProcessEventLocked(__in FxPowerIdleEvents Event)

◆ Stopped()

FxPowerIdleStates FxPowerIdleMachine::Stopped ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 431 of file poweridlestatemachine.cpp.

446 {
447  This->m_Flags &= ~FxPowerIdleIsStarted;
448 
449  return FxIdleMax;
450 }

◆ TimedOutDisabled()

FxPowerIdleStates FxPowerIdleMachine::TimedOutDisabled ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 1063 of file poweridlestatemachine.cpp.

1079 {
1080  //
1081  // Notify any waiters that we are now in D0
1082  //
1083  This->SendD0Notification();
1084 
1085  //
1086  // We can send the io present event again
1087  //
1088  This->m_Flags &= ~FxPowerIdleIoPresentSent;
1089 
1090  return FxIdleDisabled;
1091 }

◆ TimedOutEnabled()

FxPowerIdleStates FxPowerIdleMachine::TimedOutEnabled ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 1094 of file poweridlestatemachine.cpp.

1097 {
1098  //
1099  // Notify any waiters that we are now in D0
1100  //
1101  This->SendD0Notification();
1102 
1103  //
1104  // We can send the io present event again
1105  //
1106  This->m_Flags &= ~FxPowerIdleIoPresentSent;
1107 
1108  return FxIdleCheckIoCount;
1109 }

◆ TimedOutIoIncrement()

FxPowerIdleStates FxPowerIdleMachine::TimedOutIoIncrement ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 685 of file poweridlestatemachine.cpp.

703 {
704  FxPkgPnp* pPkgPnp;
705 
707 
708  if (This->m_Flags & FxPowerIdleIoPresentSent) {
711  "WDFDEVICE %p idle (in D0) not sending io present event (already sent)",
712  pPkgPnp->GetDevice()->GetHandle());
713  }
714  else {
715 #if (FX_CORE_MODE==FX_CORE_KERNEL_MODE)
717 #else
720  TRUE // ProcessEventOnDifferentThread
721  );
722 #endif
723 
724  This->m_Flags |= FxPowerIdleIoPresentSent;
725  }
726 
727  return FxIdleTimedOut;
728 }
__inline CfxDevice * GetDevice(VOID)
Definition: fxpackage.hpp:46
#define TRUE
Definition: types.h:120
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
FxPkgPnp * pPkgPnp
VOID PowerPolicyProcessEvent(__in FxPowerPolicyEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
#define TRACINGPNP
Definition: dbgtrace.h:67
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
__inline FxPkgPnp * GetPnpPkg(__inout FxPowerIdleMachine *This)

◆ TimedOutPowerDown()

FxPowerIdleStates FxPowerIdleMachine::TimedOutPowerDown ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 731 of file poweridlestatemachine.cpp.

748 {
749  //
750  // We can send the io present event again
751  //
752  This->m_Flags &= ~FxPowerIdleIoPresentSent;
753 
754  return FxIdleGoingToDx;
755 }

◆ TimedOutPowerDownFailed()

FxPowerIdleStates FxPowerIdleMachine::TimedOutPowerDownFailed ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 758 of file poweridlestatemachine.cpp.

775 {
776  //
777  // We can send the io present event again
778  //
779  This->m_Flags &= ~FxPowerIdleIoPresentSent;
780 
781  return FxIdlePowerFailed;
782 }

◆ TimerExpired()

FxPowerIdleStates FxPowerIdleMachine::TimerExpired ( __inout FxPowerIdleMachine This)
staticprotected

◆ TimingOut()

FxPowerIdleStates FxPowerIdleMachine::TimingOut ( __inout FxPowerIdleMachine This)
staticprotected

Definition at line 642 of file poweridlestatemachine.cpp.

658 {
659 #if (FX_CORE_MODE==FX_CORE_KERNEL_MODE)
661 #else
664  TRUE // ProcessEventOnDifferentThread
665  );
666 #endif
667 
668  //
669  // Timer is no longer running. Used when we disable the state machine and
670  // need to know the timer's running state.
671  //
672  //
673  This->m_Flags &= ~FxPowerIdleTimerStarted;
674 
675  //
676  // While the device is still powered up, we are no longer in D0 in terms of
677  // PowerReference returning immmediately if TRUE is specified to that call.
678  //
679  This->m_D0NotificationEvent.Clear();
680 
681  return FxIdleTimedOut;
682 }
#define TRUE
Definition: types.h:120
VOID PowerPolicyProcessEvent(__in FxPowerPolicyEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
__inline FxPkgPnp * GetPnpPkg(__inout FxPowerIdleMachine *This)

◆ WaitForD0()

VOID FxPowerIdleMachine::WaitForD0 ( VOID  )
inline

Definition at line 184 of file fxpoweridlestatemachine.hpp.

187  {
189  }
NTSTATUS EnterCRAndWaitAndLeave(VOID)
Definition: fxwaitlock.hpp:87

Referenced by PowerReferenceWorker().

Member Data Documentation

◆ @4536

union { ... }

◆ _PowerTimeoutDpcRoutine

MdDeferredRoutineType FxPowerIdleMachine::_PowerTimeoutDpcRoutine
staticprotected

Definition at line 277 of file fxpoweridlestatemachine.hpp.

Referenced by Init().

◆ InDx

FxPowerIdleStates FxPowerIdleMachine::InDx

Definition at line 494 of file fxpoweridlestatemachine.hpp.

◆ IoPresentSent

UCHAR FxPowerIdleMachine::IoPresentSent

Definition at line 499 of file fxpoweridlestatemachine.hpp.

◆ IsStarted

UCHAR FxPowerIdleMachine::IsStarted

Definition at line 498 of file fxpoweridlestatemachine.hpp.

◆ m_BusyStates

◆ m_CurrentIdleState

FxPowerIdleStates FxPowerIdleMachine::m_CurrentIdleState
protected

Definition at line 516 of file fxpoweridlestatemachine.hpp.

Referenced by FxPowerIdleMachine(), ProcessEventLocked(), and Reset().

◆ m_D0NotificationEvent

FxCREvent FxPowerIdleMachine::m_D0NotificationEvent
protected

◆ m_DisabledStates

◆ m_DisablingWaitForTimeoutStates

const FxPowerIdleTargetState FxPowerIdleMachine::m_DisablingWaitForTimeoutStates
staticprotected

◆ m_EventHistory

FxPowerIdleEvents FxPowerIdleMachine::m_EventHistory[FxPowerIdleEventQueueDepth]
protected

Definition at line 521 of file fxpoweridlestatemachine.hpp.

Referenced by FxPowerIdleMachine(), and ProcessEventLocked().

◆ m_EventHistoryIndex

UCHAR FxPowerIdleMachine::m_EventHistoryIndex
protected

Definition at line 507 of file fxpoweridlestatemachine.hpp.

Referenced by FxPowerIdleMachine(), and ProcessEventLocked().

◆ m_Flags

◆ m_FlagsByName

struct { ... } FxPowerIdleMachine::m_FlagsByName

◆ m_IdleTimerTolerableDelayMS

const ULONG FxPowerIdleMachine::m_IdleTimerTolerableDelayMS = 100
staticprotected

Definition at line 547 of file fxpoweridlestatemachine.hpp.

Referenced by StartTimer().

◆ m_InDxStates

◆ m_IoCount

ULONG FxPowerIdleMachine::m_IoCount
protected

◆ m_Lock

◆ m_PowerFailedWaitForTimeoutStates

const FxPowerIdleTargetState FxPowerIdleMachine::m_PowerFailedWaitForTimeoutStates
staticprotected
Initial value:

Definition at line 537 of file fxpoweridlestatemachine.hpp.

◆ m_PowerTimeout

LARGE_INTEGER FxPowerIdleMachine::m_PowerTimeout

◆ m_PowerTimeoutTimer

MxTimer FxPowerIdleMachine::m_PowerTimeoutTimer
protected

Definition at line 475 of file fxpoweridlestatemachine.hpp.

Referenced by CancelIdleTimer(), and Init().

◆ m_StartedStates

◆ m_StateHistory

FxPowerIdleStates FxPowerIdleMachine::m_StateHistory[FxPowerIdleEventQueueDepth]
protected

Definition at line 526 of file fxpoweridlestatemachine.hpp.

Referenced by FxPowerIdleMachine(), and ProcessEventLocked().

◆ m_StateHistoryIndex

UCHAR FxPowerIdleMachine::m_StateHistoryIndex
protected

Definition at line 511 of file fxpoweridlestatemachine.hpp.

Referenced by FxPowerIdleMachine(), and ProcessEventLocked().

◆ m_StateTable

const FxIdleStateTable FxPowerIdleMachine::m_StateTable
staticprotected

Definition at line 539 of file fxpoweridlestatemachine.hpp.

Referenced by CheckAssumptions(), and ProcessEventLocked().

◆ m_StoppedStates

const FxPowerIdleTargetState FxPowerIdleMachine::m_StoppedStates
staticprotected
Initial value:

Definition at line 528 of file fxpoweridlestatemachine.hpp.

◆ m_TagTracker

FxTagTracker* FxPowerIdleMachine::m_TagTracker
protected

◆ m_TimedOutStates

◆ m_TimerRunningStates

◆ m_WaitForTimeoutStates

◆ SendPnpPowerUpEvent

UCHAR FxPowerIdleMachine::SendPnpPowerUpEvent

Definition at line 500 of file fxpoweridlestatemachine.hpp.

◆ TimerCanceled

UCHAR FxPowerIdleMachine::TimerCanceled

Definition at line 495 of file fxpoweridlestatemachine.hpp.

◆ TimerEnabled

UCHAR FxPowerIdleMachine::TimerEnabled

Definition at line 493 of file fxpoweridlestatemachine.hpp.

◆ TimerPowerFailed

UCHAR FxPowerIdleMachine::TimerPowerFailed

Definition at line 497 of file fxpoweridlestatemachine.hpp.

◆ TimerStarted

UCHAR FxPowerIdleMachine::TimerStarted

Definition at line 496 of file fxpoweridlestatemachine.hpp.


The documentation for this class was generated from the following files: