ReactOS 0.4.16-dev-401-g45b008d
FxPkgPnp Class Referenceabstract

#include <fxpkgpnp.hpp>

Inheritance diagram for FxPkgPnp:
Collaboration diagram for FxPkgPnp:

Public Member Functions

VOID PnpProcessEvent (__in FxPnpEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
 
VOID PowerProcessEvent (__in FxPowerEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
 
VOID PowerPolicyProcessEvent (__in FxPowerPolicyEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
 
BOOLEAN ShouldProcessPnpEventOnDifferentThread (__in KIRQL CurrentIrql, __in BOOLEAN CallerSpecifiedProcessingOnDifferentThread)
 
BOOLEAN ShouldProcessPowerPolicyEventOnDifferentThread (__in KIRQL CurrentIrql, __in BOOLEAN CallerSpecifiedProcessingOnDifferentThread)
 
VOID CleanupStateMachines (__in BOOLEAN ClenaupPnp)
 
VOID CleanupDeviceFromFailedCreate (__in MxEvent *WaitEvent)
 
virtual _Must_inspect_result_ NTSTATUS Initialize (__in PWDFDEVICE_INIT DeviceInit)
 
_Must_inspect_result_ NTSTATUS PostCreateDeviceInitialize (VOID)
 
virtual VOID FinishInitialize (__inout PWDFDEVICE_INIT DeviceInit)
 
VOID SetSpecialFileSupport (__in WDF_SPECIAL_FILE_TYPE FileType, __in BOOLEAN Supported)
 
_Must_inspect_result_ NTSTATUS RegisterCallbacks (__in PWDF_PNPPOWER_EVENT_CALLBACKS DispatchTable)
 
VOID RegisterPowerPolicyCallbacks (__in PWDF_POWER_POLICY_EVENT_CALLBACKS Callbacks)
 
NTSTATUS RegisterPowerPolicyWmiInstance (__in const GUID *Guid, __in FxWmiInstanceInternalCallbacks *Callbacks, __out FxWmiInstanceInternal **Instance)
 
NTSTATUS PowerPolicySetS0IdleSettings (__in PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings)
 
NTSTATUS AssignPowerFrameworkSettings (__in PWDF_POWER_FRAMEWORK_SETTINGS PowerFrameworkSettings)
 
NTSTATUS PowerPolicySetSxWakeSettings (__in PWDF_DEVICE_POWER_POLICY_WAKE_SETTINGS Settings, __in BOOLEAN ArmForWakeIfChildrenAreArmedForWake, __in BOOLEAN IndicateChildWakeOnParentWake)
 
BOOLEAN PowerIndicateWaitWakeStatus (__in NTSTATUS WaitWakeStatus)
 
BOOLEAN PowerPolicyIsWakeEnabled (VOID)
 
ULONG PowerPolicyGetCurrentWakeReason (VOID)
 
BOOLEAN __inline PowerPolicyShouldPropagateWakeStatusToChildren (VOID)
 
VOID ChildRemoved (VOID)
 
VOID PowerPolicySetS0IdleState (__in BOOLEAN State)
 
VOID PowerPolicySetSxWakeState (__in BOOLEAN State)
 
VOID SetPowerCaps (__in PWDF_DEVICE_POWER_CAPABILITIES PowerCapabilities)
 
VOID SetPnpCaps (__in PWDF_DEVICE_PNP_CAPABILITIES PnpCapabilities)
 
VOID GetPnpState (__out PWDF_DEVICE_STATE State)
 
VOID SetPnpState (__in PWDF_DEVICE_STATE State)
 
VOID SetDeviceFailed (__in WDF_DEVICE_FAILED_ACTION FailedAction)
 
VOID SetChildBusInformation (__in PPNP_BUS_INFORMATION BusInformation)
 
_Must_inspect_result_ NTSTATUS HandleQueryBusInformation (__inout FxIrp *Irp)
 
_Must_inspect_result_ NTSTATUS __inline PowerReference (__in BOOLEAN WaitForD0, __in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
 
VOID __inline PowerDereference (__in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
 
BOOLEAN HasPowerThread (VOID)
 
VOID QueueToPowerThread (__in PWORK_QUEUE_ITEM WorkItem)
 
_Must_inspect_result_ NTSTATUS AddUsageDevice (__in MdDeviceObject DependentDevice)
 
VOID RemoveUsageDevice (__in MdDeviceObject DependentDevice)
 
_Must_inspect_result_ NTSTATUS AddRemovalDevice (__in MdDeviceObject DependentDevice)
 
VOID RemoveRemovalDevice (__in MdDeviceObject DependentDevice)
 
VOID ClearRemovalDevicesList (VOID)
 
_Must_inspect_result_ NTSTATUS AllocateEnumInfo (VOID)
 
VOID AddChildList (__in FxChildList *List)
 
VOID RemoveChildList (__in FxChildList *List)
 
VOID ChildListNotifyRemove (__inout PLONG PendingCount)
 
_Must_inspect_result_ NTSTATUS AllocateDmaEnablerList (VOID)
 
VOID AddDmaEnabler (__in FxDmaEnabler *Enabler)
 
VOID RemoveDmaEnabler (__in FxDmaEnabler *Enabler)
 
VOID RevokeDmaEnablerResources (__in FxDmaEnabler *Enabler)
 
VOID AddQueryInterface (__in FxQueryInterface *QI, __in BOOLEAN Lock)
 
VOID QueryForD3ColdInterface (VOID)
 
VOID DropD3ColdInterface (VOID)
 
BOOLEAN IsPowerPolicyOwner (VOID)
 
BOOLEAN SupportsWakeInterrupt (VOID)
 
BOOLEAN IsS0IdleWakeFromS0Enabled (VOID)
 
BOOLEAN IsS0IdleSystemManaged (VOID)
 
BOOLEAN IsS0IdleUsbSSEnabled (VOID)
 
BOOLEAN IsSxWakeEnabled (VOID)
 
_Must_inspect_result_ NTSTATUS PowerPolicyCanChildPowerUp (__out PBOOLEAN PowerUp)
 
VOID PowerPolicyChildPoweredDown (VOID)
 
POWER_ACTION GetSystemPowerAction (VOID)
 
VOID ProcessDelayedDeletion (VOID)
 
VOID SignalDeviceRemovedEvent (VOID)
 
virtual NTSTATUS FireAndForgetIrp (FxIrp *Irp)=0
 
FxCmResListGetTranslatedResourceList (VOID)
 
FxCmResListGetRawResourceList (VOID)
 
ULONG GetInterruptObjectCount (VOID)
 
VOID AckPendingWakeInterruptOperation (__in BOOLEAN ProcessPowerEventOnDifferentThread)
 
VOID SendEventToAllWakeInterrupts (__in enum FxWakeInterruptEvents WakeInterruptEvent)
 
_Must_inspect_result_ NTSTATUS ValidateCmResource (__inout PCM_PARTIAL_RESOURCE_DESCRIPTOR *CmResourceRaw, __inout PCM_PARTIAL_RESOURCE_DESCRIPTOR *CmResource)
 
_Must_inspect_result_ NTSTATUS ValidateInterruptResourceCm (__in PCM_PARTIAL_RESOURCE_DESCRIPTOR CmIntResourceRaw, __in PCM_PARTIAL_RESOURCE_DESCRIPTOR CmIntResource, __in PWDF_INTERRUPT_CONFIG Configuration)
 
BOOLEAN IsDefaultReleaseHardwareOrder (VOID)
 
BOOLEAN HasMultipleInterrupts (VOID)
 
VOID WakeInterruptCreated (VOID)
 
- Public Member Functions inherited from FxPackage
 FxPackage (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in CfxDevice *Device, __in WDFTYPE Type)
 
virtual NTSTATUS Dispatch (__in MdIrp Irp)=0
 
__inline CfxDeviceGetDevice (VOID)
 
 DECLARE_INTERNAL_NEW_OPERATOR ()
 
- Public Member Functions inherited from FxNonPagedObject
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
virtual ~FxNonPagedObject (VOID)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_maxIRQL(DISPATCH_LEVEL) __drv_setsIRQL(DISPATCH_LEVEL) VOID Lock(__out __drv_deref(__drv_savesIRQL) PKIRQL PreviousIrql)
 
 _Releases_lock_ (this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID Unlock(__in __drv_restoresIRQL KIRQL PreviousIrql)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) VOID LockAtDispatch(VOID)
 
 _Requires_lock_held_ (this->m_NPLock.m_Lock) _Releases_lock_(this -> m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID UnlockFromDispatch(VOID)
 
- Public Member Functions inherited from FxObject
PVOID GetCOMWrapper ()
 
void SetCOMWrapper (__drv_aliasesMem PVOID Wrapper)
 
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
virtual ~FxObject (VOID)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType Type)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in USHORT ExtraSize=0)
 
VOID operator delete (__in PVOID Memory)
 
VOID SetNoContextHeader (VOID)
 
PVOID __inline GetObjectHandle (VOID)
 
__inline FxContextHeaderGetContextHeader (VOID)
 
__inline PFX_DRIVER_GLOBALS GetDriverGlobals (VOID)
 
WDFTYPE GetType (VOID)
 
USHORT GetObjectSize (VOID)
 
LONG GetRefCnt (VOID)
 
FxTagTrackerGetTagTracker (VOID)
 
CfxDeviceGetDevice (VOID)
 
CfxDeviceBaseGetDeviceBase (VOID)
 
VOID SetDeviceBase (__in CfxDeviceBase *DeviceBase)
 
__inline VOID CallCleanup (VOID)
 
ULONG __inline AddRef (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG Release (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG AddRefOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG ReleaseOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__in FxQueryInterfaceParams *Params)
 
VOID MarkTraceState (VOID)
 
BOOLEAN __inline IsTraceState (VOID)
 
VOID __inline TraceDroppedEvent (__in FxObjectDroppedEvent Event)
 
VOID MarkPassiveDispose (__in FxObjectLockState State=ObjectLock)
 
VOID MarkPassiveCallbacks (__in FxObjectLockState State=ObjectLock)
 
VOID MarkForceDisposeThread (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsPassiveCallbacks (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsPassiveDispose (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsForceDisposeThread (__in BOOLEAN AcquireLock=TRUE)
 
VOID MarkCommitted (VOID)
 
BOOLEAN IsCommitted (VOID)
 
VOID MarkDisposeOverride (__in FxObjectLockState State=ObjectLock)
 
VOID MarkNoDeleteDDI (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsNoDeleteDDI (VOID)
 
_Must_inspect_result_ NTSTATUS Commit (__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
 
VOID DeleteFromFailedCreate (VOID)
 
VOID ClearEvtCallbacks (VOID)
 
BOOLEAN EarlyDispose (VOID)
 
virtual VOID DeleteObject (VOID)
 
virtual BOOLEAN Dispose (VOID)
 
_Must_inspect_result_ NTSTATUS AssignParentObject (__in FxObject *ParentObject)
 
_Must_inspect_result_ NTSTATUS AddContext (__in FxContextHeader *Header, __in PVOID *Context, __in PWDF_OBJECT_ATTRIBUTES Attributes)
 
_Must_inspect_result_ NTSTATUS RemoveParentAssignment (VOID)
 
_Must_inspect_result_ FxObjectGetParentObjectReferenced (__in PVOID Tag)
 
BOOLEAN IsDisposed (VOID)
 

Public Attributes

FxPnpStateAndCaps m_PnpStateAndCaps
 
ULONG m_PnpCapsAddress
 
ULONG m_PnpCapsUINumber
 
FxPowerCaps m_PowerCaps
 
BOOLEAN m_Failed
 
BYTE m_SystemPowerState
 
BYTE m_DevicePowerState
 
BYTE m_DevicePowerStateOld
 
FxRelatedDeviceListm_UsageDependentDeviceList
 
FxRelatedDeviceListm_RemovalDeviceList
 
FxWaitLockInternal m_QueryInterfaceLock
 
SINGLE_LIST_ENTRY m_QueryInterfaceHead
 
FxWaitLockInternal m_DeviceInterfaceLock
 
SINGLE_LIST_ENTRY m_DeviceInterfaceHead
 
BOOLEAN m_DeviceInterfacesCanBeEnabled
 
BOOLEAN m_SpecialSupport [WdfSpecialFileMax-1]
 
LONG m_SpecialFileCount [WdfSpecialFileMax-1]
 
ULONG m_DeviceStopCount
 
FxPnpMachine m_PnpMachine
 
FxPowerMachine m_PowerMachine
 
FxPowerPolicyMachine m_PowerPolicyMachine
 
FxSelfManagedIoMachinem_SelfManagedIoMachine
 
SharedPowerData m_SharedPower
 
D3COLD_SUPPORT_INTERFACE m_D3ColdInterface
 
FxPnpDeviceUsageNotification m_DeviceUsageNotification
 
FxPnpDeviceUsageNotificationEx m_DeviceUsageNotificationEx
 
FxPnpDeviceRelationsQuery m_DeviceRelationsQuery
 
FxPnpDeviceD0Entry m_DeviceD0Entry
 
FxPnpDeviceD0EntryPostInterruptsEnabled m_DeviceD0EntryPostInterruptsEnabled
 
FxPnpDeviceD0ExitPreInterruptsDisabled m_DeviceD0ExitPreInterruptsDisabled
 
FxPnpDeviceD0Exit m_DeviceD0Exit
 
FxPnpDevicePrepareHardware m_DevicePrepareHardware
 
FxPnpDeviceReleaseHardware m_DeviceReleaseHardware
 
FxPnpDeviceQueryStop m_DeviceQueryStop
 
FxPnpDeviceQueryRemove m_DeviceQueryRemove
 
FxPnpDeviceSurpriseRemoval m_DeviceSurpriseRemoval
 

Protected Member Functions

 FxPkgPnp (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in CfxDevice *Device, __in WDFTYPE Type)
 
 ~FxPkgPnp ()
 
virtual BOOLEAN Dispose (VOID)
 
virtual _Must_inspect_result_ NTSTATUS Dispatch (__in MdIrp Irp)
 
virtual const PFN_PNP_POWER_CALLBACKGetDispatchPnp (VOID)=0
 
virtual const PFN_PNP_POWER_CALLBACKGetDispatchPower (VOID)=0
 
VOID DeleteDevice (VOID)
 
VOID SetInternalFailure (VOID)
 
NTSTATUS CompletePowerRequest (__inout FxIrp *Irp, __in NTSTATUS Status)
 
NTSTATUS CompletePnpRequest (__inout FxIrp *Irp, __in NTSTATUS Status)
 
PNP_DEVICE_STATE HandleQueryPnpDeviceState (__in PNP_DEVICE_STATE PnpDeviceState)
 
_Must_inspect_result_ NTSTATUS HandleQueryBusRelations (__inout FxIrp *Irp)
 
_Must_inspect_result_ NTSTATUS HandleQueryDeviceRelations (__inout FxIrp *Irp, __inout FxRelatedDeviceList *List)
 
_Must_inspect_result_ NTSTATUS HandleQueryInterface (__inout FxIrp *Irp, __out PBOOLEAN CompleteRequest)
 
_Must_inspect_result_ NTSTATUS QueryForCapabilities (VOID)
 
VOID PnpAssignInterruptsSyncIrql (VOID)
 
_Must_inspect_result_ NTSTATUS PnpMatchResources (VOID)
 
 __drv_when (!NT_SUCCESS(return), __drv_arg(ResourcesMatched, _Must_inspect_result_)) NTSTATUS PnpPrepareHardware(__out PBOOLEAN ResourcesMatched)
 
_Must_inspect_result_ NTSTATUS PnpPrepareHardwareInternal (VOID)
 
_Must_inspect_result_ NTSTATUS PnpReleaseHardware (VOID)
 
_Must_inspect_result_ NTSTATUS PnpEnableInterfacesAndRegisterWmi (VOID)
 
_Must_inspect_result_ NTSTATUS PnpSurpriseRemoval (__inout FxIrp *Irp)
 
NTSTATUS FilterResourceRequirements (__in IO_RESOURCE_REQUIREMENTS_LIST **IoList)
 
virtual VOID PowerReleasePendingDeviceIrp (BOOLEAN IrpMustBePresent=TRUE)=0
 
VOID AddInterruptObject (__in FxInterrupt *Interrupt)
 
VOID RemoveInterruptObject (__in FxInterrupt *Interrupt)
 
VOID PnpProcessEventInner (__inout FxPostProcessInfo *Info)
 
VOID PowerProcessEventInner (__inout FxPostProcessInfo *Info)
 
VOID PowerPolicyProcessEventInner (__inout FxPostProcessInfo *Info)
 
VOID PnpEnterNewState (__in WDF_DEVICE_PNP_STATE State)
 
VOID PowerEnterNewState (__in WDF_DEVICE_POWER_STATE State)
 
VOID PowerPolicyEnterNewState (__in WDF_DEVICE_POWER_POLICY_STATE State)
 
VOID NotPowerPolicyOwnerEnterNewState (__in WDF_DEVICE_POWER_POLICY_STATE NewState)
 
_Must_inspect_result_ NTSTATUS DispatchWaitWake (__inout FxIrp *Irp)
 
VOID SaveState (__in BOOLEAN UseCanSaveState)
 
_Must_inspect_result_ NTSTATUS PnpDeviceUsageNotification (__inout FxIrp *Irp)
 
LONG GetPnpStateInternal (VOID)
 
LONG GetPnpCapsInternal (VOID)
 
virtual BOOLEAN PnpSendStartDeviceDownTheStackOverload (VOID)=0
 
virtual WDF_DEVICE_PNP_STATE PnpEventCheckForDevicePresenceOverload (VOID)=0
 
virtual WDF_DEVICE_PNP_STATE PnpEventEjectHardwareOverload (VOID)=0
 
virtual WDF_DEVICE_PNP_STATE PnpGetPostRemoveState (VOID)=0
 
virtual WDF_DEVICE_PNP_STATE PnpEventPdoRemovedOverload (VOID)=0
 
virtual WDF_DEVICE_PNP_STATE PnpEventFdoRemovedOverload (VOID)=0
 
virtual VOID PnpEventSurpriseRemovePendingOverload (VOID)
 
VOID PnpEventRemovedCommonCode (VOID)
 
VOID PnpPowerPolicyStart (VOID)
 
VOID PnpPowerPolicyStop (VOID)
 
VOID PnpPowerPolicySurpriseRemove (VOID)
 
VOID PnpPowerPolicyRemove (VOID)
 
VOID PnpFinishProcessingIrp (__in BOOLEAN IrpMustBePresent=TRUE)
 
VOID PnpDisableInterfaces (VOID)
 
virtual NTSTATUS SendIrpSynchronously (FxIrp *Irp)=0
 
virtual WDF_DEVICE_POWER_STATE PowerCheckDeviceTypeOverload (VOID)=0
 
virtual WDF_DEVICE_POWER_STATE PowerCheckDeviceTypeNPOverload (VOID)=0
 
virtual NTSTATUS PowerCheckParentOverload (BOOLEAN *ParentOn)=0
 
virtual NTSTATUS PowerEnableWakeAtBusOverload (VOID)
 
virtual VOID PowerDisableWakeAtBusOverload (VOID)
 
virtual VOID PowerParentPowerDereference (VOID)=0
 
VOID PowerGotoDx (VOID)
 
BOOLEAN PowerGotoDxIoStopped (VOID)
 
BOOLEAN PowerGotoDxIoStoppedNP (VOID)
 
BOOLEAN PowerDmaEnableAndScan (__in BOOLEAN ImplicitPowerUp)
 
VOID PowerCompletePendedWakeIrp (VOID)
 
VOID PowerCompleteWakeRequestFromWithinMachine (__in NTSTATUS Status)
 
BOOLEAN PowerMakeWakeRequestNonCancelable (__in NTSTATUS Status)
 
BOOLEAN PowerIsWakeRequestPresent (VOID)
 
VOID PowerSendIdlePowerEvent (__in FxPowerIdleEvents Event)
 
VOID PowerSendPowerDownEvents (__in FxPowerDownType Type)
 
VOID PowerSendPowerUpEvents (VOID)
 
VOID PowerSendPowerDownFailureEvent (__in FxPowerDownType Type)
 
VOID PowerSendPowerUpFailureEvent (VOID)
 
VOID PowerSetDevicePowerState (__in WDF_POWER_DEVICE_STATE State)
 
_Must_inspect_result_ BOOLEAN PowerDmaPowerUp (VOID)
 
BOOLEAN PowerDmaPowerDown (VOID)
 
VOID PowerConnectInterruptFailed (VOID)
 
VOID PowerPolicyUpdateSystemWakeSource (__in FxIrp *Irp)
 
_Must_inspect_result_ NTSTATUS PowerPolicySendDevicePowerRequest (__in DEVICE_POWER_STATE DeviceState, __in SendDeviceRequestAction Action)
 
_Must_inspect_result_ NTSTATUS PowerPolicySendWaitWakeRequest (__in SYSTEM_POWER_STATE SystemState)
 
VOID PowerPolicyCompleteSystemPowerIrp (VOID)
 
BOOLEAN PowerPolicyCancelWaitWake (VOID)
 
VOID PowerPolicySubmitUsbIdleNotification (VOID)
 
BOOLEAN PowerPolicyCancelUsbSSIfCapable (VOID)
 
VOID PowerPolicyCancelUsbSS (VOID)
 
SYSTEM_POWER_STATE PowerPolicyGetPendingSystemState (VOID)
 
_Must_inspect_result_ NTSTATUS PowerPolicyHandleSystemQueryPower (__in SYSTEM_POWER_STATE QueryState)
 
BOOLEAN PowerPolicyCanWakeFromSystemState (__in SYSTEM_POWER_STATE SystemState)
 
SYSTEM_POWER_STATE PowerPolicyGetDeviceDeepestSystemWakeState (VOID)
 
DEVICE_POWER_STATE PowerPolicyGetDeviceDeepestDeviceWakeState (__in SYSTEM_POWER_STATE SystemState)
 
BOOLEAN IsPresentPendingPnpIrp (VOID)
 
VOID SetPendingPnpIrp (__inout FxIrp *Irp, __in BOOLEAN MarkIrpPending=TRUE)
 
VOID SetPendingPnpIrpStatus (__in NTSTATUS Status)
 
MdIrp ClearPendingPnpIrp (VOID)
 
MdIrp GetPendingPnpIrp (VOID)
 
VOID SetPendingDevicePowerIrp (__inout FxIrp *Irp)
 
MdIrp ClearPendingDevicePowerIrp (VOID)
 
VOID SetPendingSystemPowerIrp (__inout FxIrp *Irp)
 
MdIrp ClearPendingSystemPowerIrp (VOID)
 
MdIrp GetPendingSystemPowerIrp (VOID)
 
BOOLEAN IsDevicePowerUpIrpPending (VOID)
 
BOOLEAN IsUsageSupported (__in DEVICE_USAGE_NOTIFICATION_TYPE Usage)
 
VOID SetUsageSupport (__in DEVICE_USAGE_NOTIFICATION_TYPE Usage, __in BOOLEAN Supported)
 
LONG AdjustUsageCount (__in DEVICE_USAGE_NOTIFICATION_TYPE Usage, __in BOOLEAN Add)
 
LONG GetUsageCount (__in __range(1, 4) ULONG Usage)
 
BOOLEAN IsInSpecialUse (VOID)
 
ULONG SetUsageNotificationFlags (__in DEVICE_USAGE_NOTIFICATION_TYPE Type, __in BOOLEAN InPath)
 
VOID RevertUsageNotificationFlags (__in DEVICE_USAGE_NOTIFICATION_TYPE Type, __in BOOLEAN InPath, __in ULONG OldFlags)
 
VOID CommitUsageNotification (__in DEVICE_USAGE_NOTIFICATION_TYPE Type, __in ULONG OldFlags)
 
_Must_inspect_result_ NTSTATUS CreatePowerThread (VOID)
 
- Protected Member Functions inherited from FxObject
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
FxObjectDebugExtensionGetDebugExtension (VOID)
 
BOOLEAN IsDebug (VOID)
 
VOID AllocateTagTracker (__in WDFTYPE Type)
 
virtual VOID SelfDestruct (VOID)
 
PVOID __inline GetObjectHandleUnchecked (VOID)
 
VOID __inline DestroyChildren (VOID)
 
VOID DeleteEarlyDisposedObject (VOID)
 

Static Protected Member Functions

static _Must_inspect_result_ NTSTATUS _PnpStartDevice (__inout FxPkgPnp *This, __inout FxIrp *Irp)
 
static _Must_inspect_result_ NTSTATUS _PnpQueryStopDevice (__inout FxPkgPnp *This, __inout FxIrp *Irp)
 
static _Must_inspect_result_ NTSTATUS _PnpCancelStopDevice (__inout FxPkgPnp *This, __inout FxIrp *Irp)
 
static _Must_inspect_result_ NTSTATUS _PnpStopDevice (__inout FxPkgPnp *This, __inout FxIrp *Irp)
 
static _Must_inspect_result_ NTSTATUS _PnpQueryRemoveDevice (__inout FxPkgPnp *This, __inout FxIrp *Irp)
 
static _Must_inspect_result_ NTSTATUS _PnpCancelRemoveDevice (__inout FxPkgPnp *This, __inout FxIrp *Irp)
 
static _Must_inspect_result_ NTSTATUS _PnpRemoveDevice (__inout FxPkgPnp *This, __inout FxIrp *Irp)
 
static VOID _PnpProcessEventInner (__inout FxPkgPnp *This, __inout FxPostProcessInfo *Info, __in PVOID WorkerContext)
 
static VOID _PowerProcessEventInner (__in FxPkgPnp *This, __in FxPostProcessInfo *Info, __in PVOID WorkerContext)
 
static VOID _PowerPolicyProcessEventInner (__inout FxPkgPnp *This, __inout FxPostProcessInfo *Info, __in PVOID WorkerContext)
 
static _Must_inspect_result_ NTSTATUS _DispatchWaitWake (__inout FxPkgPnp *This, __inout FxIrp *Irp)
 
static _Must_inspect_result_ NTSTATUS _PnpDeviceUsageNotification (__inout FxPkgPnp *This, __inout FxIrp *Irp)
 
static VOID _SetPowerCapState (__in ULONG Index, __in DEVICE_POWER_STATE State, __out PULONG Result)
 
static DEVICE_POWER_STATE _GetPowerCapState (__in ULONG Index, __in ULONG State)
 
static WDF_DEVICE_PNP_STATE PnpEventCheckForDevicePresence (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventEjectHardware (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventInitStarting (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventInitSurpriseRemoved (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventHardwareAvailable (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventEnableInterfaces (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventHardwareAvailablePowerPolicyFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventQueryRemoveAskDriver (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventQueryRemoveEnsureDeviceAwake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventQueryRemovePending (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventQueryRemoveStaticCheck (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventQueriedRemoving (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventQueryStopAskDriver (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventQueryStopEnsureDeviceAwake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventQueryStopPending (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventQueryStopStaticCheck (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventQueryCanceled (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventRemoved (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventPdoRemoved (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventRemovedPdoWait (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventRemovedPdoSurpriseRemoved (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventRemovingDisableInterfaces (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventRestarting (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventStarted (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventStartedCancelStop (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventStartedCancelRemove (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventStartedRemoving (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventStartingFromStopped (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventStopped (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventStoppedWaitForStartCompletion (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventStartedStopping (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventSurpriseRemoved (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventInitQueryRemove (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventInitQueryRemoveCanceled (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventFdoRemoved (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventQueriedSurpriseRemove (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventSurpriseRemoveIoStarted (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventFailedPowerDown (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventFailedIoStarting (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventFailedOwnHardware (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventFailedPowerPolicyRemoved (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventFailedSurpriseRemoved (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventFailedStarted (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventFailedInit (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventPdoInitFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventRestart (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventRestartReleaseHardware (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventRestartHardwareAvailable (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventPdoRestart (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventRemovedChildrenRemoved (__inout FxPkgPnp *This)
 
static WDF_DEVICE_PNP_STATE PnpEventFinal (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerCheckDeviceType (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerCheckDeviceTypeNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerEnablingWakeAtBus (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerEnablingWakeAtBusNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerCheckParentState (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerCheckParentStateNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerDZero (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerD0NP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerD0BusWakeOwner (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerD0BusWakeOwnerNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerD0ArmedForWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerD0ArmedForWakeNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoImplicitD3DisarmWakeAtBus (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerD0DisarmingWakeAtBus (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerD0DisarmingWakeAtBusNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerD0Starting (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerD0StartingConnectInterrupt (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerD0StartingDmaEnable (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerD0StartingStartSelfManagedIo (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerDecideD0State (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoD3Stopped (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerStartingCheckDeviceType (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerStartingChild (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerDxDisablingWakeAtBus (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerDxDisablingWakeAtBusNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDNotZero (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDNotZeroNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDNotZeroIoStopped (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDNotZeroIoStoppedNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDxNPFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDxArmedForWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDxArmedForWakeNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerDNotZeroNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDxIoStoppedArmedForWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDxIoStoppedArmedForWakeNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerCheckParentStateArmedForWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerCheckParentStateArmedForWakeNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerStartSelfManagedIo (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerStartSelfManagedIoNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerStartSelfManagedIoFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerStartSelfManagedIoFailedNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerWakePending (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerWakePendingNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerWaking (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerWakingNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerWakingConnectInterrupt (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerWakingConnectInterruptNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerWakingConnectInterruptFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerWakingConnectInterruptFailedNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerWakingDmaEnable (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerWakingDmaEnableNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerWakingDmaEnableFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerWakingDmaEnableFailedNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerReportPowerUpFailedDerefParent (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerReportPowerUpFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerPowerFailedPowerDown (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerReportPowerDownFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerInitialConnectInterruptFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerInitialDmaEnableFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerInitialSelfManagedIoFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerInitialPowerUpFailedDerefParent (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerInitialPowerUpFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerDxSurpriseRemovedPowerDown (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerDxSurpriseRemovedPowerUp (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerDxStoppedDisarmWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerDxStoppedDisarmWakeNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDxStoppedDisableInterruptNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDxStopped (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoStopped (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerStoppedCompleteDx (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerDxStoppedDecideDxState (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerDxStoppedArmForWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerDxStoppedArmForWakeNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerFinalPowerDownFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerD0SurpriseRemoved (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerSurpriseRemoved (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerUpFailedDerefParent (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerUpFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDxFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerGotoDxStoppedDisableInterrupt (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerUpFailedDerefParentNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerUpFailedNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerNotifyingD0ExitToWakeInterrupts (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerNotifyingD0EntryToWakeInterrupts (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerNotifyingD0ExitToWakeInterruptsNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_STATE PowerNotifyingD0EntryToWakeInterruptsNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStarting (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStartingPoweredUp (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStartingPoweredUpFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStartingSucceeded (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStartingFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStartingDecideS0Wake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStartedIdleCapable (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolIdleCapableDeviceIdle (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolDeviceIdleReturnToActive (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolDeviceIdleSleeping (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolDeviceIdleStopping (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredNoWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredNoWakeCompletePowerDown (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWaitingUnarmedQueryIdle (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolS0NoWakePowerUp (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolS0NoWakeCompletePowerUp (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemSleepFromDeviceWaitingUnarmed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemSleepNeedWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemSleepNeedWakeCompletePowerUp (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemSleepPowerRequestFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolCheckPowerPageable (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleepingWakeWakeArrived (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleepingWakeRevertArmWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemAsleepWakeArmed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWakeEnabled (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWakeEnabledWakeCanceled (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWakeDisarm (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWakeTriggeredS0 (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWokeDisarm (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleepingWakeWakeArrivedNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleepingWakeRevertArmWakeNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleepingWakePowerDownFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleepingWakePowerDownFailedWakeCanceled (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemAsleepWakeArmedNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWakeEnabledNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWakeEnabledWakeCanceledNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWakeDisarmNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWakeTriggeredS0NP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWokeDisarmNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWakeCompletePowerUp (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleeping (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleepingNoWakePowerDown (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleepingNoWakeCompletePowerDown (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleepingNoWakeDxRequestFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleepingWakePowerDown (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleepingSendWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemAsleepNoWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWakeDisabled (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceToD0 (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceToD0CompletePowerUp (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeQueryIdle (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStartedWakeCapable (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWakeCapableDeviceIdle (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWakeCapableUsbSSCompleted (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredDecideUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapablePowerDown (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapableSendWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapableUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapableWakeArrived (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapableCancelWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapableWakeCanceled (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapableCleanup (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapableDxAllocFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapableUndoPowerDown (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCompletedPowerDown (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCompletedPowerUp (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCompletedHardwareStarted (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWaitingArmedUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWaitingArmedQueryIdle (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolIoPresentArmed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolIoPresentArmedWakeCanceled (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolS0WakeDisarm (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolS0WakeCompletePowerUp (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeSucceeded (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCompletedDisarm (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWakeFailedUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapablePowerDownFailedCancelWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapablePowerDownFailedWakeCanceled (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapablePowerDownFailedUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolCancelingWakeForSystemSleep (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolCancelingWakeForSystemSleepWakeCanceled (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolDisarmingWakeForSystemSleepCompletePowerUp (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolPowerUpForSystemSleepFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWokeFromS0UsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWokeFromS0 (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWokeFromS0NotifyDriver (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingResetDevice (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingResetDeviceCompletePowerUp (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingResetDeviceFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingD0 (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingD0Failed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingDisarmWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingDisarmWakeCancelWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingDisarmWakeWakeCanceled (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStopping (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingSucceeded (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingSendStatus (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppedRemoving (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolRemoved (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolRestarting (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolRestartingFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingCancelTimer (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingCancelUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingCancelWake (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolCancelUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStarted (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStartedCancelTimer (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStartedWakeCapableCancelTimerForSleep (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStartedWakeCapableSleepingUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStartedIdleCapableCancelTimerForSleep (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolDeviceD0PowerRequestFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolDevicePowerRequestFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSleepingPowerDownNotProcessed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapablePowerDownNotProcessed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredNoWakePowerDownNotProcessed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredNoWakeUndoPowerDown (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredNoWakeReturnToActive (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredNoWakePoweredDownDisableIdleTimer (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolPowerUpForSystemSleepNotSeen (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWaitingArmedStoppingCancelUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWaitingArmedWakeFailedCancelUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWaitingArmedIoPresentCancelUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWaitingArmedWakeSucceededCancelUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolCancelingUsbSSForSystemSleep (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolStoppingD0CancelUsbSS (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolWaitingArmedWakeInterruptFired (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWakeInterruptFired (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolSystemWakeDeviceWakeInterruptFiredNP (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE PowerPolTimerExpiredWakeCapableWakeInterruptArrived (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerStarting (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerStarted (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerGotoDx (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerGotoDxInDx (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerGotoD0 (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerGotoD0InD0 (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerStopping (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerStoppingSendStatus (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerStartingFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerStoppingFailed (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerStoppingPoweringUp (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerStoppingPoweringDown (__inout FxPkgPnp *This)
 
static WDF_DEVICE_POWER_POLICY_STATE NotPowerPolOwnerRemoved (__inout FxPkgPnp *This)
 
static VOID _PowerSetSystemWakeSource (__in FxIrp *Irp)
 
static CPPNP_STATE_TABLE GetPnpTableEntry (__in WDF_DEVICE_PNP_STATE State)
 
static CPPOWER_STATE_TABLE GetPowerTableEntry (__in WDF_DEVICE_POWER_STATE State)
 
static CPPOWER_POLICY_STATE_TABLE GetPowerPolicyTableEntry (__in WDF_DEVICE_POWER_POLICY_STATE State)
 
static _Must_inspect_result_ CPNOT_POWER_POLICY_OWNER_STATE_TABLE GetNotPowerPolicyOwnerTableEntry (__in WDF_DEVICE_POWER_POLICY_STATE State)
 
static NTSTATUS _S0IdleQueryInstance (__in CfxDevice *Device, __in FxWmiInstanceInternal *Instance, __in ULONG OutBufferSize, __out PVOID OutBuffer, __out PULONG BufferUsed)
 
static NTSTATUS _S0IdleSetInstance (__in CfxDevice *Device, __in FxWmiInstanceInternal *Instance, __in ULONG InBufferSize, __in PVOID InBuffer)
 
static NTSTATUS _S0IdleSetItem (__in CfxDevice *Device, __in FxWmiInstanceInternal *Instance, __in ULONG DataItemId, __in ULONG InBufferSize, __in PVOID InBuffer)
 
static NTSTATUS _SxWakeQueryInstance (__in CfxDevice *Device, __in FxWmiInstanceInternal *Instaace, __in ULONG OutBufferSize, __out PVOID OutBuffer, __out PULONG BufferUsed)
 
static NTSTATUS _SxWakeSetInstance (__in CfxDevice *Device, __in FxWmiInstanceInternal *Instance, __in ULONG InBufferSize, __in PVOID InBuffer)
 
static NTSTATUS _SxWakeSetItem (__in CfxDevice *Device, __in FxWmiInstanceInternal *Instance, __in ULONG DataItemId, __in ULONG InBufferSize, __in PVOID InBuffer)
 
static DEVICE_USAGE_NOTIFICATION_TYPE _SpecialTypeToUsage (__in WDF_SPECIAL_FILE_TYPE Type)
 
static WDF_SPECIAL_FILE_TYPE _UsageToSpecialType (__in DEVICE_USAGE_NOTIFICATION_TYPE Type)
 
- Static Protected Member Functions inherited from FxObject
static PVOID _GetBase (__in FxObject *Object)
 

Protected Attributes

MxEventm_DeviceRemoveProcessed
 
LONG m_PendingChildCount
 
BYTE m_DeviceWake [DeviceWakeStates]
 
BYTE m_SystemWake
 
BYTE m_FailedAction
 
BYTE m_SetDeviceRemoveProcessed
 
POWER_THREAD_INTERFACE m_PowerThreadInterface
 
FxEnumerationInfom_EnumInfo
 
FxCmResListm_Resources
 
FxCmResListm_ResourcesRaw
 
FxSpinLockTransactionedListm_DmaEnablerList
 
PNP_BUS_INFORMATION m_BusInformation
 
UCHAR m_BusEnumRetries
 
UCHAR m_SystemPowerAction
 
BOOLEAN m_CapsQueried
 
BOOLEAN m_InternalFailure
 
BOOLEAN m_HasPowerThread
 
BOOLEAN m_ReleaseHardwareAfterDescendantsOnFailure
 
PFN_IO_CONNECT_INTERRUPT_EX m_IoConnectInterruptEx
 
PFN_IO_DISCONNECT_INTERRUPT_EX m_IoDisconnectInterruptEx
 
PFN_IO_REPORT_INTERRUPT_ACTIVE m_IoReportInterruptActive
 
PFN_IO_REPORT_INTERRUPT_INACTIVE m_IoReportInterruptInactive
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

Static Protected Attributes

static MdCancelRoutineType _PowerWaitWakeCancelRoutine
 
static MdRequestPowerCompleteType _PowerPolDeviceWaitWakeComplete
 
static MdRequestPowerCompleteType _PowerPolDevicePowerDownComplete
 
static MdRequestPowerCompleteType _PowerPolDevicePowerUpComplete
 
static MdCompletionRoutineType _PowerPolicyWaitWakeCompletionRoutine
 
static MdCompletionRoutineType _PowerPolicyUsbSelectiveSuspendCompletionRoutine
 
static const GUID GUID_POWER_THREAD_INTERFACE
 

Private Member Functions

VOID DisconnectInterruptNP (VOID)
 
NTSTATUS UpdateWmiInstanceForS0Idle (__in FxWmiInstanceAction Action)
 
VOID ReadRegistryS0Idle (__in PCUNICODE_STRING ValueName, __out BOOLEAN *Enabled)
 
NTSTATUS UpdateWmiInstanceForSxWake (__in FxWmiInstanceAction Action)
 
VOID ReadRegistrySxWake (__in PCUNICODE_STRING ValueName, __out BOOLEAN *Enabled)
 
VOID WriteStateToRegistry (__in HANDLE RegKey, __in PUNICODE_STRING ValueName, __in ULONG Value)
 
NTSTATUS ReadStateFromRegistry (_In_ PCUNICODE_STRING ValueName, _Out_ PULONG Value)
 
NTSTATUS UpdateWmiInstance (_In_ FxWmiInstanceAction Action, _In_ BOOLEAN ForS0Idle)
 
VOID PowerPolicyCheckAssumptions (VOID)
 
VOID PowerCheckAssumptions (VOID)
 
VOID PnpCheckAssumptions (VOID)
 
VOID NotifyResourceobjectsToReleaseResources (VOID)
 
_Must_inspect_result_ NTSTATUS NotifyResourceObjectsD0 (__in ULONG NotifyFlags)
 
NTSTATUS NotifyResourceObjectsDx (__in ULONG NotifyFlags)
 
BOOLEAN PnpCheckAndIncrementRestartCount (VOID)
 
BOOLEAN PnpIncrementRestartCountLogic (_In_ HANDLE RestartKey, _In_ BOOLEAN CreatedNewKey)
 
VOID PnpCleanupForRemove (__in BOOLEAN GracefulRemove)
 
virtual NTSTATUS ProcessRemoveDeviceOverload (FxIrp *Irp)=0
 
virtual VOID DeleteSymbolicLinkOverload (BOOLEAN GracefulRemove)=0
 
virtual VOID QueryForReenumerationInterface (VOID)=0
 
virtual VOID ReleaseReenumerationInterface (VOID)=0
 
virtual NTSTATUS AskParentToRemoveAndReenumerate (VOID)=0
 
_Must_inspect_result_ NTSTATUS CreatePowerThreadIfNeeded (VOID)
 
virtual NTSTATUS QueryForPowerThread (VOID)=0
 
VOID ReleasePowerThread (VOID)
 
_Must_inspect_result_ NTSTATUS HandleQueryInterfaceForPowerThread (__inout FxIrp *Irp, __out PBOOLEAN CompleteRequest)
 
_Must_inspect_result_ NTSTATUS PnpPowerReferenceSelf (VOID)
 
VOID PnpPowerDereferenceSelf (VOID)
 
BOOLEAN PowerPolicyCanIdlePowerDown (__in DEVICE_POWER_STATE DxState)
 
VOID PowerPolicyPostParentToD0ToChildren (VOID)
 
VOID PowerPolicyChildrenCanPowerUp (VOID)
 
VOID __inline PowerPolicyDisarmWakeFromSx (VOID)
 
_Must_inspect_result_ NTSTATUS PowerPolicyPowerDownForSx (__in DEVICE_POWER_STATE DxState, __in SendDeviceRequestAction Action)
 
VOID PowerPolicyBlockChildrenPowerUp (VOID)
 
_Must_inspect_result_ NTSTATUS PnpPowerReferenceDuringQueryPnp (VOID)
 

Static Private Member Functions

static VOID _PowerThreadEnqueue (__in PVOID Context, __in PWORK_QUEUE_ITEM WorkItem)
 
static VOID STDCALL _PowerThreadInterfaceReference (__inout PVOID Context)
 
static VOID STDCALL _PowerThreadInterfaceDereference (__inout PVOID Context)
 

Private Attributes

friend FxPnpMachine
 
friend FxPowerMachine
 
friend FxPowerPolicyMachine
 
friend FxPowerPolicyOwnerSettings
 
friend FxInterrupt
 
FxCREvent m_CleanupEventUm
 
MxEvent m_RemoveEventUm
 
ULONG m_InterruptObjectCount
 
LIST_ENTRY m_InterruptListHead
 
ULONG m_WakeInterruptCount
 
ULONG m_WakeInterruptPendingAckCount
 
BOOLEAN m_SystemWokenByWakeInterrupt
 
BOOLEAN m_WakeInterruptsKeepConnected
 
BOOLEAN m_AchievedStart
 
FxSystemThreadm_PowerThread
 
LONG m_PowerThreadInterfaceReferenceCount
 
FxCREventm_PowerThreadEvent
 
MdIrp m_PendingPnPIrp
 
MdIrp m_PendingSystemPowerIrp
 
MdIrp m_PendingDevicePowerIrp
 
FxPnpStateCallbackm_PnpStateCallbacks
 
FxPowerStateCallbackm_PowerStateCallbacks
 
FxPowerPolicyStateCallbackm_PowerPolicyStateCallbacks
 

Static Private Attributes

static const PNP_STATE_TABLE m_WdfPnpStates []
 
static const POWER_STATE_TABLE m_WdfPowerStates []
 
static const POWER_POLICY_STATE_TABLE m_WdfPowerPolicyStates []
 
static const NOT_POWER_POLICY_OWNER_STATE_TABLE m_WdfNotPowerPolicyOwnerStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpInitOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpInitStartingOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpHardwareAvailableOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpQueryStopPendingOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpRemovedPdoWaitOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpRestartingOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpStartedOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpQueryRemovePendingOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpQueriedRemovingOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpInitQueryRemoveOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpStoppedOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpStoppedWaitForStartCompletionOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpStartedStoppingOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpStartedStoppingFailedOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpEjectFailedOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpStartedRemovingOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpFailedPowerDownOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpFailedIoStartingOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpFailedWaitForRemoveOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpRestartOtherStates []
 
static const PNP_EVENT_TARGET_STATE m_PnpRestartReleaseHardware []
 
static const PNP_EVENT_TARGET_STATE m_PnpRestartHardwareAvailableOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_PowerD0OtherStates []
 
static const POWER_EVENT_TARGET_STATE m_PowerD0NPOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_PowerD0BusWakeOwnerOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_PowerD0BusWakeOwnerNPOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_PowerD0ArmedForWakeOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_PowerD0ArmedForWakeNPOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_PowerDNotZeroOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_PowerDNotZeroNPOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_DxArmedForWakeOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_DxArmedForWakeNPOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_WakePendingOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_WakePendingNPOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_DxSurpriseRemovedOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_PowerStoppedOtherStates []
 
static const POWER_EVENT_TARGET_STATE m_PowerDxStoppedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolObjectCreatedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStartingOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStartedIdleCapableOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolIdleCapableDeviceIdleOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredNoWakeOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredNoWakeCompletePowerDownOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolWaitingUnarmedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolS0NoWakePowerUpOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolS0NoWakeCompletePowerUpOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemSleepNeedWakeOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemSleepNeedWakeCompletePowerUpOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemAsleepWakeArmedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemAsleepWakeArmedNPOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceToD0OtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceToD0CompletePowerUpOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStartedWakeCapableOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolWakeCapableDeviceIdleOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapablePowerDownOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableSendWakeOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableUsbSSOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolWaitingArmedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolDisarmingWakeForSystemSleepCompletePowerUpOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolCancelingWakeForSystemSleepWakeCanceledOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolWokeFromS0OtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingResetDeviceOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingResetDeviceCompletePowerUpOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingD0OtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingDisarmWakeOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingDisarmWakeCancelWakeOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolIoPresentArmedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolIoPresentArmedWakeCanceledOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolS0WakeCompletePowerUpOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableWakeSucceededOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableWakeFailedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapablePowerDownFailedCancelWakeOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolCancelingWakeForSystemSleepOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableWakeArrivedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableCancelWakeOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCompletedPowerDownOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCompletedPowerUpOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeEnabledOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeEnabledNPOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeEnabledWakeCanceledOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeEnabledWakeCanceledNPOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingWakeWakeArrivedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeTriggeredS0OtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeTriggeredS0NPOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeCompletePowerUpOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingNoWakePowerDownOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingNoWakeCompletePowerDownOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingWakePowerDownOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingSendWakeOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingWakeWakeArrivedNPOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingWakePowerDownFailedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStartedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStartedWaitForIdleTimeoutOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolDevicePowerRequestFailedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolRestartingOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingCancelWakeOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolCancelUsbSSOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingWakeRevertArmWakeOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingWakeRevertArmWakeNPOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolRemovedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableWakeInterruptArrivedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapablePowerDownFailedWakeInterruptArrivedOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolWaitingArmedWakeInterruptFiredDuringPowerDownOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerObjectCreatedStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStartingStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStartingSucceededStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStartingFailedStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerGotoDxStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerGotoDxInDxStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerDxStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerGotoD0States []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerGotoD0InD0States []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStoppedStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStoppingWaitForImplicitPowerDownStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStoppingPoweringUpStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStoppingPoweringDownStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerRemovedStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolWaitingArmedWakeInterruptFiredOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeInterruptFiredOtherStates []
 
static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeInterruptFiredNPOtherStates []
 
static const PWCHAR m_RestartStartAchievedName = RESTART_START_ACHIEVED_NAME
 
static const PWCHAR m_RestartStartTimeName = RESTART_START_TIME_NAME
 
static const PWCHAR m_RestartCountName = RESTART_COUNT_NAME
 
static const ULONG m_RestartTimePeriodMaximum = 60
 
static const ULONG m_RestartCountMaximum = 5
 

Additional Inherited Members

- Static Public Member Functions inherited from FxObject
static FxObject_FromDisposeEntry (__in PSINGLE_LIST_ENTRY Entry)
 
static FxObject_GetObjectFromHandle (__in WDFOBJECT Handle, __inout PWDFOBJECT_OFFSET ObjectOffset)
 
static PVOID __inline _ToHandle (__in FxObject *Object)
 
static VOID __inline _ReferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static VOID __inline _DereferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static PVOID _GetDebugBase (__in FxObject *Object)
 
static PFX_POOL_HEADER _CleanupPointer (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Object)
 
static _Must_inspect_result_ NTSTATUS _GetEffectiveLock (__in FxObject *Object, __in_opt IFxHasCallbacks *Callbacks, __in BOOLEAN AutomaticLocking, __in BOOLEAN PassiveCallbacks, __out FxCallbackLock **CallbackLock, __out_opt FxObject **CallbackLockObject)
 
static _Must_inspect_result_ NTSTATUS _ObjectQuery (_In_ FxObject *Object, _In_ CONST GUID *Guid, _In_ ULONG QueryBufferLength, _Out_writes_bytes_(QueryBufferLength) PVOID QueryBuffer)
 

Detailed Description

Definition at line 488 of file fxpkgpnp.hpp.

Constructor & Destructor Documentation

◆ FxPkgPnp()

FxPkgPnp::FxPkgPnp ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in CfxDevice Device,
__in WDFTYPE  Type 
)
protected

Definition at line 48 of file fxpkgpnp.cpp.

52 :
53 FxPackage(FxDriverGlobals, Device, Type)
54{
55 ULONG i;
56
60
61 //
62 // Initialize the structures to the default state and then override the
63 // non WDF std default values to the unsupported / off values.
64 //
72
82 ;
83
86
95 ;
96
99
103
105 for (i = 0; i < PowerSystemMaximum; i++) {
107 }
108
112
123
128
129 //
130 // We only set the pending child count to 1 once we know we have successfully
131 // created an FxDevice and initialized it fully. If we delete an FxDevice
132 // which is half baked, it cannot have any FxChildLists which have any
133 // pending children on them.
134 //
136
138
141
142 m_Failed = FALSE;
144
148
153
157
159
161
164
172
176
178
179#if (FX_CORE_MODE==FX_CORE_KERNEL_MODE)
180 //
181 // Interrupt APIs for Vista and forward
182 //
185
186 //
187 // Interrupt APIs for Windows 8 and forward
188 //
191
192#endif
193
195
197}
Type
Definition: Type.h:7
VOID MarkDisposeOverride(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1101
MdIrp m_PendingPnPIrp
Definition: fxpkgpnp.hpp:4360
FxPnpStateCallback * m_PnpStateCallbacks
Definition: fxpkgpnp.hpp:4374
ULONG m_PnpCapsUINumber
Definition: fxpkgpnp.hpp:4091
FxCmResList * m_Resources
Definition: fxpkgpnp.hpp:4220
PFN_IO_REPORT_INTERRUPT_INACTIVE m_IoReportInterruptInactive
Definition: fxpkgpnp.hpp:4294
FxSystemThread * m_PowerThread
Definition: fxpkgpnp.hpp:4350
static VOID STDCALL _PowerThreadInterfaceDereference(__inout PVOID Context)
Definition: fxpkgpnp.cpp:5292
ULONG m_InterruptObjectCount
Definition: fxpkgpnp.hpp:4308
SINGLE_LIST_ENTRY m_DeviceInterfaceHead
Definition: fxpkgpnp.hpp:4126
FxSelfManagedIoMachine * m_SelfManagedIoMachine
Definition: fxpkgpnp.hpp:4155
LONG m_SpecialFileCount[WdfSpecialFileMax-1]
Definition: fxpkgpnp.hpp:4139
FxCmResList * m_ResourcesRaw
Definition: fxpkgpnp.hpp:4225
FxRelatedDeviceList * m_UsageDependentDeviceList
Definition: fxpkgpnp.hpp:4113
PFN_IO_DISCONNECT_INTERRUPT_EX m_IoDisconnectInterruptEx
Definition: fxpkgpnp.hpp:4289
FxPowerStateCallback * m_PowerStateCallbacks
Definition: fxpkgpnp.hpp:4376
BOOLEAN m_ReleaseHardwareAfterDescendantsOnFailure
Definition: fxpkgpnp.hpp:4277
static VOID STDCALL _PowerThreadInterfaceReference(__inout PVOID Context)
Definition: fxpkgpnp.cpp:5262
LONG m_PendingChildCount
Definition: fxpkgpnp.hpp:4178
LONG m_PowerThreadInterfaceReferenceCount
Definition: fxpkgpnp.hpp:4352
UCHAR m_SystemPowerAction
Definition: fxpkgpnp.hpp:4242
BYTE m_SetDeviceRemoveProcessed
Definition: fxpkgpnp.hpp:4198
BYTE m_FailedAction
Definition: fxpkgpnp.hpp:4191
FxEnumerationInfo * m_EnumInfo
Definition: fxpkgpnp.hpp:4215
BOOLEAN m_InternalFailure
Definition: fxpkgpnp.hpp:4249
static VOID _SetPowerCapState(__in ULONG Index, __in DEVICE_POWER_STATE State, __out PULONG Result)
Definition: fxpkgpnp.cpp:5616
BOOLEAN m_Failed
Definition: fxpkgpnp.hpp:4095
MxEvent * m_DeviceRemoveProcessed
Definition: fxpkgpnp.hpp:4172
POWER_THREAD_INTERFACE m_PowerThreadInterface
Definition: fxpkgpnp.hpp:4213
BYTE m_DevicePowerStateOld
Definition: fxpkgpnp.hpp:4108
PFN_IO_REPORT_INTERRUPT_ACTIVE m_IoReportInterruptActive
Definition: fxpkgpnp.hpp:4293
FxCREvent * m_PowerThreadEvent
Definition: fxpkgpnp.hpp:4354
FxPowerPolicyStateCallback * m_PowerPolicyStateCallbacks
Definition: fxpkgpnp.hpp:4378
SINGLE_LIST_ENTRY m_QueryInterfaceHead
Definition: fxpkgpnp.hpp:4122
FxSpinLockTransactionedList * m_DmaEnablerList
Definition: fxpkgpnp.hpp:4227
BOOLEAN m_AchievedStart
Definition: fxpkgpnp.hpp:4344
MdIrp m_PendingSystemPowerIrp
Definition: fxpkgpnp.hpp:4366
BOOLEAN m_SpecialSupport[WdfSpecialFileMax-1]
Definition: fxpkgpnp.hpp:4133
BOOLEAN m_CapsQueried
Definition: fxpkgpnp.hpp:4247
BYTE m_DevicePowerState
Definition: fxpkgpnp.hpp:4105
FxPowerCaps m_PowerCaps
Definition: fxpkgpnp.hpp:4093
ULONG m_PnpCapsAddress
Definition: fxpkgpnp.hpp:4090
static VOID _PowerThreadEnqueue(__in PVOID Context, __in PWORK_QUEUE_ITEM WorkItem)
Definition: fxpkgpnp.hpp:3944
BOOLEAN m_WakeInterruptsKeepConnected
Definition: fxpkgpnp.hpp:4339
SharedPowerData m_SharedPower
Definition: fxpkgpnp.hpp:4161
ULONG m_WakeInterruptCount
Definition: fxpkgpnp.hpp:4316
BYTE m_SystemPowerState
Definition: fxpkgpnp.hpp:4102
LIST_ENTRY m_InterruptListHead
Definition: fxpkgpnp.hpp:4310
ULONG m_DeviceStopCount
Definition: fxpkgpnp.hpp:4146
FxPnpStateAndCaps m_PnpStateAndCaps
Definition: fxpkgpnp.hpp:4088
FxRelatedDeviceList * m_RemovalDeviceList
Definition: fxpkgpnp.hpp:4115
BOOLEAN m_DeviceInterfacesCanBeEnabled
Definition: fxpkgpnp.hpp:4128
ULONG m_WakeInterruptPendingAckCount
Definition: fxpkgpnp.hpp:4323
BOOLEAN m_HasPowerThread
Definition: fxpkgpnp.hpp:4256
PFN_IO_CONNECT_INTERRUPT_EX m_IoConnectInterruptEx
Definition: fxpkgpnp.hpp:4288
MdIrp m_PendingDevicePowerIrp
Definition: fxpkgpnp.hpp:4372
D3COLD_SUPPORT_INTERFACE m_D3ColdInterface
Definition: fxpkgpnp.hpp:4166
BOOLEAN m_SystemWokenByWakeInterrupt
Definition: fxpkgpnp.hpp:4330
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
@ ObjectDoNotLock
Definition: fxobject.hpp:128
@ FxPnpCapSilentInstallUseDefault
Definition: fxpkgpnp.hpp:309
@ FxPnpStateResourcesChangedUseDefault
Definition: fxpkgpnp.hpp:277
@ FxPnpStateDisabledUseDefault
Definition: fxpkgpnp.hpp:252
@ FxPnpCapHardwareDisabledUseDefault
Definition: fxpkgpnp.hpp:319
@ FxPnpCapSurpriseRemovalOKUseDefault
Definition: fxpkgpnp.hpp:314
@ FxPnpCapUniqueIDUseDefault
Definition: fxpkgpnp.hpp:304
@ FxPnpCapEjectSupportedUseDefault
Definition: fxpkgpnp.hpp:289
@ FxPnpStateNotDisableableUseDefault
Definition: fxpkgpnp.hpp:267
@ FxPnpCapLockSupportedUseDefault
Definition: fxpkgpnp.hpp:284
@ FxPnpStateRemovedUseDefault
Definition: fxpkgpnp.hpp:272
@ FxPnpStateDontDisplayInUIUseDefault
Definition: fxpkgpnp.hpp:257
@ FxPnpStateFailedUseDefault
Definition: fxpkgpnp.hpp:262
@ FxPnpCapDockDeviceUseDefault
Definition: fxpkgpnp.hpp:299
@ FxPnpCapRemovableUseDefault
Definition: fxpkgpnp.hpp:294
@ FxPnpCapNoDisplayInUIUseDefault
Definition: fxpkgpnp.hpp:324
@ FxPowerCapWakeFromD0UseDefault
Definition: fxpkgpnp.hpp:383
@ FxPowerCapDeviceD2UseDefault
Definition: fxpkgpnp.hpp:378
@ FxPowerCapWakeFromD2UseDefault
Definition: fxpkgpnp.hpp:393
@ FxPowerCapDeviceD1UseDefault
Definition: fxpkgpnp.hpp:373
@ FxPowerCapWakeFromD1UseDefault
Definition: fxpkgpnp.hpp:388
@ FxPowerCapWakeFromD3UseDefault
Definition: fxpkgpnp.hpp:398
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
@ PowerSystemMaximum
Definition: ntpoapi.h:42
@ PowerSystemWorking
Definition: ntpoapi.h:36
@ PowerActionNone
Definition: ntpoapi.h:123
@ PowerDeviceMaximum
Definition: ntpoapi.h:53
FxLibraryGlobalsType FxLibraryGlobals
Definition: globals.cpp:95
PFN_IO_REPORT_INTERRUPT_INACTIVE IoReportInterruptInactive
Definition: fxglobals.h:764
PFN_IO_DISCONNECT_INTERRUPT_EX IoDisconnectInterruptEx
Definition: fxglobals.h:732
PFN_IO_CONNECT_INTERRUPT_EX IoConnectInterruptEx
Definition: fxglobals.h:730
PFN_IO_REPORT_INTERRUPT_ACTIVE IoReportInterruptActive
Definition: fxglobals.h:762
ULONG D3Latency
Definition: fxpkgpnp.hpp:425
BYTE SystemWake
Definition: fxpkgpnp.hpp:413
ULONG D2Latency
Definition: fxpkgpnp.hpp:424
ULONG D1Latency
Definition: fxpkgpnp.hpp:423
USHORT Caps
Definition: fxpkgpnp.hpp:406
BYTE DeviceWake
Definition: fxpkgpnp.hpp:412
ULONG States
Definition: fxpkgpnp.hpp:418
BOOLEAN m_ExtendWatchDogTimer
Definition: fxpkgpnp.hpp:196
BOOLEAN m_WaitWakeOwner
Definition: fxpkgpnp.hpp:186
MdIrp m_WaitWakeIrp
Definition: fxpkgpnp.hpp:180
PVOID Context
Definition: miniport.h:123
USHORT Version
Definition: miniport.h:122
USHORT Size
Definition: miniport.h:121
PINTERFACE_REFERENCE InterfaceReference
Definition: miniport.h:124
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: miniport.h:125
PFN_POWER_THREAD_ENQUEUE PowerThreadEnqueue
Definition: fxpkgpnp.hpp:110
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:637
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
@ WdfPowerDeviceD3Final
Definition: wdfdevice.h:427
@ WdfDeviceFailedUndefined
Definition: wdfdevice.h:468
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ ~FxPkgPnp()

FxPkgPnp::~FxPkgPnp ( )
protected

Definition at line 199 of file fxpkgpnp.cpp.

200{
202
204
205 //
206 // We should either have zero pending children or we never made it out of
207 // the init state during a failed WDFDEVICE create or failed EvtDriverDeviceAdd
208 //
211
212
214 while (ple != NULL) {
216
218
219 //
220 // Advance to the next before deleting the current
221 //
222 ple = ple->Next;
223
224 //
225 // No longer in the list
226 //
227 pDI->m_Entry.Next = NULL;
228
229 delete pDI;
230 }
232
233 if (m_DmaEnablerList != NULL) {
234 delete m_DmaEnablerList;
236 }
237
238 if (m_RemovalDeviceList != NULL) {
239 delete m_RemovalDeviceList;
241 }
242
246 }
247
248 if (m_PnpStateCallbacks != NULL) {
249 delete m_PnpStateCallbacks;
250 }
251
254 }
255
258 }
259
263 }
264
265 if (m_EnumInfo != NULL) {
266 delete m_EnumInfo;
268 }
269
270 if (m_Resources != NULL) {
271 m_Resources->RELEASE(this);
273 }
274
275 if (m_ResourcesRaw != NULL) {
276 m_ResourcesRaw->RELEASE(this);
278 }
279
281}
static FxDeviceInterface * _FromEntry(__in PSINGLE_LIST_ENTRY Entry)
SINGLE_LIST_ENTRY m_Entry
__inline WDF_DEVICE_PNP_STATE GetDevicePnpState()
Definition: fxdevice.hpp:1149
CfxDevice * m_Device
Definition: fxobject.hpp:329
static __inline VOID MxAssert(__in BOOLEAN Condition)
Definition: mxgeneralkm.h:165
static __inline KIRQL MxGetCurrentIrql()
Definition: mxgeneralkm.h:86
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
PSINGLE_LIST_ENTRY ple
#define ASSERT(a)
Definition: mode.c:44
Definition: ntbasedef.h:636
@ WdfDevStatePnpInit
Definition: wdfdevice.h:69

Member Function Documentation

◆ __drv_when()

FxPkgPnp::__drv_when ( NT_SUCCESSreturn,
__drv_arg(ResourcesMatched, _Must_inspect_result_  
)
protected

◆ _DispatchWaitWake()

_Must_inspect_result_ NTSTATUS FxPkgPnp::_DispatchWaitWake ( __inout FxPkgPnp This,
__inout FxIrp Irp 
)
staticprotected

Definition at line 2400 of file fxpkgpnp.cpp.

2425{
2426 return This->DispatchWaitWake(Irp);
2427}
_In_ PIRP Irp
Definition: csq.h:116

◆ _GetPowerCapState()

DEVICE_POWER_STATE FxPkgPnp::_GetPowerCapState ( __in ULONG  Index,
__in ULONG  State 
)
staticprotected

Definition at line 5657 of file fxpkgpnp.cpp.

5676{
5677 ASSERT(Index < 8);
5678 // isolate the value and normalize it
5679 return (DEVICE_POWER_STATE) ((State & (0xF << (Index * 4))) >> (Index * 4));
5680}
enum _DEVICE_POWER_STATE DEVICE_POWER_STATE
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by FxPkgPdo::HandleQueryCapabilities(), FxPkgFdo::HandleQueryCapabilitiesCompletion(), and PowerPolSleepingNoWakePowerDown().

◆ _PnpCancelRemoveDevice()

_Must_inspect_result_ NTSTATUS FxPkgPnp::_PnpCancelRemoveDevice ( __inout FxPkgPnp This,
__inout FxIrp Irp 
)
staticprotected

Definition at line 2026 of file fxpkgpnp.cpp.

2049{
2050 //
2051 // Seed the irp with success
2052 //
2053 Irp->SetStatus(STATUS_SUCCESS);
2054
2055 //
2056 // Pend it and transition the state machine
2057 //
2058
2059 This->SetPendingPnpIrp(Irp);
2060 This->PnpProcessEvent(PnpEventCancelRemove);
2061
2062 return STATUS_PENDING;
2063}
#define STATUS_PENDING
Definition: d3dkmdt.h:43
@ PnpEventCancelRemove
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ _PnpCancelStopDevice()

_Must_inspect_result_ NTSTATUS FxPkgPnp::_PnpCancelStopDevice ( __inout FxPkgPnp This,
__inout FxIrp Irp 
)
staticprotected

Definition at line 1901 of file fxpkgpnp.cpp.

1928{
1929 //
1930 // Seed the irp with success
1931 //
1932 Irp->SetStatus(STATUS_SUCCESS);
1933
1934 //
1935 // Pend it and transition the state machine
1936 //
1937 This->SetPendingPnpIrp(Irp);
1938 This->PnpProcessEvent(PnpEventCancelStop);
1939
1940 return STATUS_PENDING;
1941}
@ PnpEventCancelStop

◆ _PnpDeviceUsageNotification()

_Must_inspect_result_ NTSTATUS FxPkgPnp::_PnpDeviceUsageNotification ( __inout FxPkgPnp This,
__inout FxIrp Irp 
)
staticprotected

Definition at line 3857 of file fxpkgpnp.cpp.

3861{
3862 return This->PnpDeviceUsageNotification(Irp);
3863}

◆ _PnpProcessEventInner()

VOID FxPkgPnp::_PnpProcessEventInner ( __inout FxPkgPnp This,
__inout FxPostProcessInfo Info,
__in PVOID  WorkerContext 
)
staticprotected

Definition at line 952 of file pnpstatemachine.cpp.

957{
958 UNREFERENCED_PARAMETER(WorkerContext);
959
960 //
961 // Take the state machine lock.
962 //
963 This->m_PnpMachine.m_StateMachineLock.AcquireLock(
964 This->GetDriverGlobals()
965 );
966
967 //
968 // Call the function that will actually run the state machine.
969 //
970 This->PnpProcessEventInner(Info);
971
972 //
973 // We are being called from the work item and m_WorkItemRunning is > 0, so
974 // we cannot be deleted yet.
975 //
976 ASSERT(Info->SomethingToDo() == FALSE);
977
978 //
979 // Now release the lock
980 //
981 This->m_PnpMachine.m_StateMachineLock.ReleaseLock(
982 This->GetDriverGlobals()
983 );
984}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Referenced by PostCreateDeviceInitialize().

◆ _PnpQueryRemoveDevice()

_Must_inspect_result_ NTSTATUS FxPkgPnp::_PnpQueryRemoveDevice ( __inout FxPkgPnp This,
__inout FxIrp Irp 
)
staticprotected

Definition at line 1981 of file fxpkgpnp.cpp.

2005{
2006 //
2007 // By default we handle this state.
2008 //
2009 Irp->SetStatus(STATUS_SUCCESS);
2010
2011 //
2012 // Keep this IRP around, since we're going to deal with it later.
2013 //
2014 This->SetPendingPnpIrp(Irp);
2015
2016 //
2017 // Now run the state machine on this thread.
2018 //
2019 This->PnpProcessEvent(PnpEventQueryRemove);
2020
2021 return STATUS_PENDING;
2022}
@ PnpEventQueryRemove

◆ _PnpQueryStopDevice()

_Must_inspect_result_ NTSTATUS FxPkgPnp::_PnpQueryStopDevice ( __inout FxPkgPnp This,
__inout FxIrp Irp 
)
staticprotected

Definition at line 1850 of file fxpkgpnp.cpp.

1885{
1886 //
1887 // Keep this IRP around, since we're going to deal with it later.
1888 //
1889 This->SetPendingPnpIrp(Irp);
1890
1891 //
1892 // Now run the state machine on this thread.
1893 //
1894 This->PnpProcessEvent(PnpEventQueryStop);
1895
1896 return STATUS_PENDING;
1897}
@ PnpEventQueryStop

◆ _PnpRemoveDevice()

_Must_inspect_result_ NTSTATUS FxPkgPnp::_PnpRemoveDevice ( __inout FxPkgPnp This,
__inout FxIrp Irp 
)
staticprotected

Definition at line 2275 of file fxpkgpnp.cpp.

2298{
2299#if (FX_CORE_MODE==FX_CORE_USER_MODE)
2300 MxEvent * event = This->m_RemoveEventUm.GetSelfPointer();
2301#else
2302 MxEvent eventOnStack;
2303 eventOnStack.Initialize(SynchronizationEvent, FALSE);
2304 MxEvent * event = eventOnStack.GetSelfPointer();
2305#endif
2306
2308
2310 This->m_Device->GetRemoveLock(),
2311 Irp->GetIrp());
2312
2313#if DBG
2315#else
2317#endif
2318
2319 //
2320 // Keep this object around after m_Device has RELEASE'ed its reference to
2321 // this package.
2322 //
2323 This->ADDREF(Irp);
2324
2325 //
2326 // Removes are always success
2327 //
2328 Irp->SetStatus(STATUS_SUCCESS);
2329
2330 ASSERT(This->m_DeviceRemoveProcessed == NULL);
2331 This->m_DeviceRemoveProcessed = event;
2332
2333 //
2334 // Post the event and wait for the FxDevice to destroy itself or determine
2335 // it has not been reported missing yet (for PDOs and bus filters).
2336 //
2337 This->PnpProcessEvent(PnpEventRemove);
2338
2340 This->GetDriverGlobals(), TRACE_LEVEL_INFORMATION, TRACINGPNP,
2341 "WDFDEVICE %p, !devobj %p waiting for remove event to finish processing",
2342 This->m_Device->GetHandle(), This->m_Device->GetDeviceObject());
2343
2344 //
2345 // No need to wait in a critical region because we are in the context of a
2346 // pnp request which is in the system context.
2347 //
2348 event->WaitFor(Executive, KernelMode, FALSE, NULL);
2349
2350 This->m_DeviceRemoveProcessed = NULL;
2351
2352 status = This->ProcessRemoveDeviceOverload(Irp);
2353
2354 //
2355 // Release the reference added at the top. This is most likely going to be
2356 // the last reference on the package for KMDF. For UMDF, host manages the
2357 // lifetime of FxDevice so this may not be the last release for UMDF.
2358 //
2359 This->RELEASE(Irp);
2360
2361 return status;
2362}
LONG NTSTATUS
Definition: precomp.h:26
CHECK_RETURN_IF_USER_MODE __inline NTSTATUS Initialize(__in EVENT_TYPE Type, __in BOOLEAN InitialState)
Definition: mxeventkm.h:55
MxEvent * GetSelfPointer(VOID)
Definition: mxevent.h:110
static __inline NTSTATUS MxAcquireRemoveLock(__in MdRemoveLock RemoveLock, __in_opt PVOID Tag)
Definition: mxgeneralkm.h:268
#define TRACINGPNP
Definition: dbgtrace.h:67
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
@ PnpEventRemove
struct _cl_event * event
Definition: glext.h:7739
#define KernelMode
Definition: asm.h:38
@ SynchronizationEvent
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
Definition: ps.c:97
@ Executive
Definition: ketypes.h:415

◆ _PnpStartDevice()

_Must_inspect_result_ NTSTATUS FxPkgPnp::_PnpStartDevice ( __inout FxPkgPnp This,
__inout FxIrp Irp 
)
staticprotected

Definition at line 1823 of file fxpkgpnp.cpp.

1841{
1842 This->SetPendingPnpIrp(Irp);
1843 This->PnpProcessEvent(PnpEventStartDevice);
1844
1845 return STATUS_PENDING;
1846}
@ PnpEventStartDevice

◆ _PnpStopDevice()

_Must_inspect_result_ NTSTATUS FxPkgPnp::_PnpStopDevice ( __inout FxPkgPnp This,
__inout FxIrp Irp 
)
staticprotected

Definition at line 1945 of file fxpkgpnp.cpp.

1964{
1965 //
1966 // Seed the irp with success
1967 //
1968 Irp->SetStatus(STATUS_SUCCESS);
1969
1970 //
1971 // Pend and transition the state machine
1972 //
1973 This->SetPendingPnpIrp(Irp);
1974 This->PnpProcessEvent(PnpEventStop);
1975
1976 return STATUS_PENDING;
1977}
@ PnpEventStop

◆ _PowerPolicyProcessEventInner()

VOID FxPkgPnp::_PowerPolicyProcessEventInner ( __inout FxPkgPnp This,
__inout FxPostProcessInfo Info,
__in PVOID  WorkerContext 
)
staticprotected

Definition at line 3048 of file powerpolicystatemachine.cpp.

3053{
3054
3056
3057 //
3058 // Take the state machine lock.
3059 //
3060 This->m_PowerPolicyMachine.m_StateMachineLock.AcquireLock(
3061 This->GetDriverGlobals()
3062 );
3063
3064 //
3065 // Call the function that will actually run the state machine.
3066 //
3067 This->PowerPolicyProcessEventInner(Info);
3068
3069 //
3070 // We are being called from the work item and m_WorkItemRunning is > 0, so
3071 // we cannot be deleted yet.
3072 //
3073 ASSERT(Info->SomethingToDo() == FALSE);
3074
3075 //
3076 // Now release the lock
3077 //
3078 This->m_PowerPolicyMachine.m_StateMachineLock.ReleaseLock(
3079 This->GetDriverGlobals()
3080 );
3081}

Referenced by PostCreateDeviceInitialize().

◆ _PowerProcessEventInner()

VOID FxPkgPnp::_PowerProcessEventInner ( __in FxPkgPnp This,
__in FxPostProcessInfo Info,
__in PVOID  WorkerContext 
)
staticprotected

Definition at line 1309 of file powerstatemachine.cpp.

1314{
1315
1316 UNREFERENCED_PARAMETER(WorkerContext);
1317
1318 //
1319 // Take the state machine lock.
1320 //
1321 This->m_PowerMachine.m_StateMachineLock.AcquireLock(
1322 This->GetDriverGlobals()
1323 );
1324
1325 //
1326 // Call the function that will actually run the state machine.
1327 //
1328 This->PowerProcessEventInner(Info);
1329
1330 //
1331 // We are being called from the work item and m_WorkItemRunning is > 0, so
1332 // we cannot be deleted yet.
1333 //
1334 ASSERT(Info->SomethingToDo() == FALSE);
1335
1336 //
1337 // Now release the lock
1338 //
1339 This->m_PowerMachine.m_StateMachineLock.ReleaseLock(
1340 This->GetDriverGlobals()
1341 );
1342}

Referenced by PostCreateDeviceInitialize().

◆ _PowerSetSystemWakeSource()

VOID FxPkgPnp::_PowerSetSystemWakeSource ( __in FxIrp Irp)
staticprotected

Definition at line 133 of file powerstatemachinekm.cpp.

148{
149 PoSetSystemWake(Irp->GetIrp());
150}

Referenced by PowerMakeWakeRequestNonCancelable().

◆ _PowerThreadEnqueue()

static VOID FxPkgPnp::_PowerThreadEnqueue ( __in PVOID  Context,
__in PWORK_QUEUE_ITEM  WorkItem 
)
inlinestaticprivate

Definition at line 3944 of file fxpkgpnp.hpp.

3948 {
3950
3951 result = ((FxPkgPnp*) Context)->m_PowerThread->QueueWorkItem(WorkItem);
3952#if DBG
3953 ASSERT(result);
3954#else
3956#endif
3957 }
unsigned char BOOLEAN
GLuint64EXT * result
Definition: glext.h:11304
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
Definition: wdfworkitem.h:115

Referenced by FxPkgPnp().

◆ _PowerThreadInterfaceDereference()

VOID FxPkgPnp::_PowerThreadInterfaceDereference ( __inout PVOID  Context)
staticprivate

Definition at line 5292 of file fxpkgpnp.cpp.

5310{
5311 FxPkgPnp* pThis;
5312
5313 pThis = (FxPkgPnp*) Context;
5314
5316 pThis->m_PowerThreadEvent->Set();
5317 }
5318}
#define InterlockedDecrement
Definition: armddk.h:52
VOID Set(VOID)
Definition: fxwaitlock.hpp:144

Referenced by FxPkgPnp().

◆ _PowerThreadInterfaceReference()

VOID FxPkgPnp::_PowerThreadInterfaceReference ( __inout PVOID  Context)
staticprivate

Definition at line 5262 of file fxpkgpnp.cpp.

5277{
5278 LONG count;
5279
5282 );
5283
5284#if DBG
5285 ASSERT(count >= 2);
5286#else
5288#endif
5289}
#define InterlockedIncrement
Definition: armddk.h:53
GLuint GLuint GLsizei count
Definition: gl.h:1545
long LONG
Definition: pedump.c:60

Referenced by FxPkgPnp().

◆ _S0IdleQueryInstance()

NTSTATUS FxPkgPnp::_S0IdleQueryInstance ( __in CfxDevice Device,
__in FxWmiInstanceInternal Instance,
__in ULONG  OutBufferSize,
__out PVOID  OutBuffer,
__out PULONG  BufferUsed 
)
staticprotected

Definition at line 3455 of file fxpkgpnp.cpp.

3462{
3463 *((BOOLEAN*) OutBuffer) =
3465 *BufferUsed = sizeof(BOOLEAN);
3466
3467 return STATUS_SUCCESS;
3468}
FxPowerPolicyMachine m_PowerPolicyMachine
Definition: fxpkgpnp.hpp:4153
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
FxPowerPolicyOwnerSettings * m_Owner
_In_ ULONG _Out_ PULONG BufferUsed
Definition: wdfwmi.h:92

◆ _S0IdleSetInstance()

NTSTATUS FxPkgPnp::_S0IdleSetInstance ( __in CfxDevice Device,
__in FxWmiInstanceInternal Instance,
__in ULONG  InBufferSize,
__in PVOID  InBuffer 
)
staticprotected

Definition at line 3471 of file fxpkgpnp.cpp.

3477{
3478 BOOLEAN value;
3479
3480
3481 //
3482 // FxWmiIrpHandler makes sure the buffer is at least one byte big, so we
3483 // don't check the buffer size.
3484 //
3485
3486 value = *(PBOOLEAN) InBuffer;
3487
3489
3490 return STATUS_SUCCESS;
3491}
VOID PowerPolicySetS0IdleState(__in BOOLEAN State)
Definition: fxpkgpnp.cpp:3710
unsigned char * PBOOLEAN
Definition: typedefs.h:53
Definition: pdh_main.c:94

◆ _S0IdleSetItem()

NTSTATUS FxPkgPnp::_S0IdleSetItem ( __in CfxDevice Device,
__in FxWmiInstanceInternal Instance,
__in ULONG  DataItemId,
__in ULONG  InBufferSize,
__in PVOID  InBuffer 
)
staticprotected

Definition at line 3494 of file fxpkgpnp.cpp.

3501{
3502 BOOLEAN value;
3503
3504 if (DataItemId != 0) {
3506 }
3507
3508 if (InBufferSize < sizeof(BOOLEAN)) {
3510 }
3511
3512 value = *(BOOLEAN*) InBuffer;
3514
3515 return STATUS_SUCCESS;
3516}
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106
_In_ ULONG DataItemId
Definition: wdfwmi.h:123

◆ _SetPowerCapState()

VOID FxPkgPnp::_SetPowerCapState ( __in ULONG  Index,
__in DEVICE_POWER_STATE  State,
__out PULONG  Result 
)
staticprotected

Definition at line 5616 of file fxpkgpnp.cpp.

5639{
5640 //
5641 // We store off state in 4 bits, starting at the lowest byte
5642 //
5643 ASSERT(Index < 8);
5644
5645 //
5646 // Erase the old value
5647 //
5648 *Result &= ~(0xF << (Index * 4));
5649
5650 //
5651 // Write in the new one
5652 //
5653 *Result |= (0xF & State) << (Index * 4);
5654}
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by FxPkgPnp(), FxPowerPolicyOwnerSettings::FxPowerPolicyOwnerSettings(), QueryForCapabilities(), and SetPowerCaps().

◆ _SpecialTypeToUsage()

static DEVICE_USAGE_NOTIFICATION_TYPE FxPkgPnp::_SpecialTypeToUsage ( __in WDF_SPECIAL_FILE_TYPE  Type)
inlinestaticprotected

Definition at line 3187 of file fxpkgpnp.hpp.

3190 {
3191 switch (Type) {
3196 default: ASSERT(FALSE);return DeviceUsageTypePaging;
3197 }
3198 }
@ WdfSpecialFileBoot
Definition: wdfdevice.h:445
@ WdfSpecialFileHibernation
Definition: wdfdevice.h:443
@ WdfSpecialFileDump
Definition: wdfdevice.h:444
@ WdfSpecialFilePaging
Definition: wdfdevice.h:442
@ DeviceUsageTypeHibernation
Definition: iotypes.h:1171
@ DeviceUsageTypeBoot
Definition: iotypes.h:1173
@ DeviceUsageTypeDumpFile
Definition: iotypes.h:1172
@ DeviceUsageTypePaging
Definition: iotypes.h:1170

Referenced by PnpDeviceUsageNotification(), and SetSpecialFileSupport().

◆ _SxWakeQueryInstance()

NTSTATUS FxPkgPnp::_SxWakeQueryInstance ( __in CfxDevice Device,
__in FxWmiInstanceInternal Instaace,
__in ULONG  OutBufferSize,
__out PVOID  OutBuffer,
__out PULONG  BufferUsed 
)
staticprotected

Definition at line 3519 of file fxpkgpnp.cpp.

3526{
3527 *((BOOLEAN*) OutBuffer) =
3529 *BufferUsed = sizeof(BOOLEAN);
3530
3531 return STATUS_SUCCESS;
3532}

◆ _SxWakeSetInstance()

NTSTATUS FxPkgPnp::_SxWakeSetInstance ( __in CfxDevice Device,
__in FxWmiInstanceInternal Instance,
__in ULONG  InBufferSize,
__in PVOID  InBuffer 
)
staticprotected

Definition at line 3535 of file fxpkgpnp.cpp.

3541{
3542 BOOLEAN value;
3543
3544 //
3545 // FxWmiIrpHandler makes sure that the buffer is at least one byte big, so
3546 // we don't check the buffer size
3547 //
3548 value = *(PBOOLEAN) InBuffer;
3549
3551
3552 return STATUS_SUCCESS;
3553}
VOID PowerPolicySetSxWakeState(__in BOOLEAN State)
Definition: fxpkgpnp.cpp:3720

◆ _SxWakeSetItem()

NTSTATUS FxPkgPnp::_SxWakeSetItem ( __in CfxDevice Device,
__in FxWmiInstanceInternal Instance,
__in ULONG  DataItemId,
__in ULONG  InBufferSize,
__in PVOID  InBuffer 
)
staticprotected

Definition at line 3556 of file fxpkgpnp.cpp.

3563{
3564 BOOLEAN value;
3565
3566 if (DataItemId != 0) {
3568 }
3569
3570 if (InBufferSize < sizeof(BOOLEAN)) {
3572 }
3573
3574 value = *(BOOLEAN*) InBuffer;
3576
3577 return STATUS_SUCCESS;
3578}

◆ _UsageToSpecialType()

static WDF_SPECIAL_FILE_TYPE FxPkgPnp::_UsageToSpecialType ( __in DEVICE_USAGE_NOTIFICATION_TYPE  Type)
inlinestaticprotected

Definition at line 3202 of file fxpkgpnp.hpp.

3205 {
3206 switch (Type) {
3211 default: ASSERT(FALSE); return WdfSpecialFilePaging;
3212 }
3213 }

Referenced by PnpDeviceUsageNotification().

◆ AckPendingWakeInterruptOperation()

VOID FxPkgPnp::AckPendingWakeInterruptOperation ( __in BOOLEAN  ProcessPowerEventOnDifferentThread)

Definition at line 6211 of file fxpkgpnp.cpp.

6232{
6236 ProcessPowerEventOnDifferentThread
6237 );
6238 }
6239}
VOID PowerProcessEvent(__in FxPowerEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
@ PowerWakeInterruptCompleteTransition

◆ AddChildList()

VOID FxPkgPnp::AddChildList ( __in FxChildList List)

Definition at line 4970 of file fxpkgpnp.cpp.

4973{
4975 "Adding FxChildList %p, WDFCHILDLIST %p", List,
4976 List->GetHandle());
4977
4979 &List->m_TransactionLink);
4980}
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
NTSTATUS Add(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxTransactionedEntry *Entry)
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
FxWaitLockTransactionedList m_ChildListList
Definition: fxpkgpnp.hpp:485
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by FxDevice::AddChildList().

◆ AddDmaEnabler()

VOID FxPkgPnp::AddDmaEnabler ( __in FxDmaEnabler Enabler)

Definition at line 277 of file fxpkgpnpkm.cpp.

280{
282 "Adding DmaEnabler %p, WDFDMAENABLER %p",
283 Enabler, Enabler->GetObjectHandle());
284
285 m_DmaEnablerList->Add(GetDriverGlobals(), &Enabler->m_TransactionLink);
286}

Referenced by FxDevice::AddDmaEnabler().

◆ AddInterruptObject()

VOID FxPkgPnp::AddInterruptObject ( __in FxInterrupt Interrupt)
protected

Definition at line 5928 of file fxpkgpnp.cpp.

5959{
5962}
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:379

Referenced by FxInterrupt::Initialize().

◆ AddQueryInterface()

VOID FxPkgPnp::AddQueryInterface ( __in FxQueryInterface QI,
__in BOOLEAN  Lock 
)

Definition at line 5017 of file fxpkgpnp.cpp.

5035{
5037
5038 if (Lock) {
5040 }
5041
5042 ASSERT(QI->m_Entry.Next == NULL);
5043
5044 //
5045 // Iterate until we find the end of the list and then append the new
5046 // structure. ppPrev is the pointer to the Next pointer value. When we
5047 // get to the end, ppPrev will be equal to the Next field which points to NULL.
5048 //
5051
5052 while (pCur != NULL) {
5053 ppPrev = &pCur->Next;
5054 pCur = pCur->Next;
5055 }
5056
5057 *ppPrev = &QI->m_Entry;
5058
5059 if (Lock) {
5061 }
5062}
FxWaitLockInternal m_QueryInterfaceLock
Definition: fxpkgpnp.hpp:4120
SINGLE_LIST_ENTRY * pCur
SINGLE_LIST_ENTRY ** ppPrev
#define QI(I)
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127

◆ AddRemovalDevice()

_Must_inspect_result_ NTSTATUS FxPkgPnp::AddRemovalDevice ( __in MdDeviceObject  DependentDevice)

Definition at line 4753 of file fxpkgpnp.cpp.

4756{
4757 FxRelatedDevice* pRelated;
4759
4760 if (m_RemovalDeviceList == NULL) {
4761 KIRQL irql;
4762
4763 Lock(&irql);
4764 if (m_RemovalDeviceList == NULL) {
4766
4767 if (m_RemovalDeviceList != NULL) {
4769 }
4770 else {
4772
4775 "Could not allocate removal device list for WDFDEVICE %p, "
4776 "%!STATUS!", m_Device->GetHandle(), status);
4777 }
4778 }
4779 else {
4780 //
4781 // another thread allocated the list already
4782 //
4784 }
4785 Unlock(irql);
4786
4787 if (!NT_SUCCESS(status)) {
4788 return status;
4789 }
4790 }
4791
4792 pRelated = new(GetDriverGlobals())
4794 if (pRelated == NULL) {
4796 }
4797
4799
4800 if (NT_SUCCESS(status)) {
4801 //
4802 // RemovalRelations are queried automatically by PnP when the device is
4803 // going to be query removed. No need to tell pnp that the list changed
4804 // until it needs to query for it.
4805 //
4806 DO_NOTHING();
4807 }
4808 else {
4809 pRelated->DeleteFromFailedCreate();
4810 }
4811
4812 return status;
4813}
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
_Must_inspect_result_ NTSTATUS Add(__in PFX_DRIVER_GLOBALS Globals, __inout FxRelatedDevice *Entry)
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define DO_NOTHING()
Definition: mxgeneral.h:32
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ PDEVICE_OBJECT DependentDevice
Definition: wdfdevice.h:2263

◆ AddUsageDevice()

_Must_inspect_result_ NTSTATUS FxPkgPnp::AddUsageDevice ( __in MdDeviceObject  DependentDevice)

Definition at line 4685 of file fxpkgpnp.cpp.

4688{
4689 FxRelatedDevice* pRelated;
4691
4693 KIRQL irql;
4694
4695 Lock(&irql);
4698
4701 }
4702 else {
4704
4707 "Could not allocate usage device list for WDFDEVICE %p, "
4708 "%!STATUS!", m_Device->GetHandle(), status);
4709 }
4710
4711 }
4712 else {
4713 //
4714 // another thread allocated the list already
4715 //
4717 }
4718 Unlock(irql);
4719
4720 if (!NT_SUCCESS(status)) {
4721 return status;
4722 }
4723 }
4724
4725 pRelated = new(GetDriverGlobals())
4727
4728 if (pRelated == NULL) {
4730 }
4731
4733
4734 if (!NT_SUCCESS(status)) {
4735 pRelated->DeleteFromFailedCreate();
4736 }
4737
4738 return status;
4739}

◆ AdjustUsageCount()

LONG FxPkgPnp::AdjustUsageCount ( __in DEVICE_USAGE_NOTIFICATION_TYPE  Usage,
__in BOOLEAN  Add 
)
inlineprotected

Definition at line 3147 of file fxpkgpnp.hpp.

3151 {
3152 if (Add) {
3154 }
3155 else {
3157 }
3158 }
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:384

Referenced by RevertUsageNotificationFlags(), and SetUsageNotificationFlags().

◆ AllocateDmaEnablerList()

_Must_inspect_result_ NTSTATUS FxPkgPnp::AllocateDmaEnablerList ( VOID  )

Definition at line 241 of file fxpkgpnpkm.cpp.

244{
247 KIRQL irql;
248
249 if (m_DmaEnablerList != NULL) {
250 return STATUS_SUCCESS;
251 }
252
253 Lock(&irql);
254 if (m_DmaEnablerList == NULL) {
256
257 if (pList != NULL) {
260 }
261 else {
263 }
264 }
265 else {
266 //
267 // Already have a DMA list
268 //
270 }
271 Unlock(irql);
272
273 return status;
274}
FxChildList * pList

Referenced by FxDevice::AllocateDmaEnablerList().

◆ AllocateEnumInfo()

_Must_inspect_result_ NTSTATUS FxPkgPnp::AllocateEnumInfo ( VOID  )

Definition at line 4920 of file fxpkgpnp.cpp.

4923{
4924 KIRQL irql;
4926
4927 if (m_EnumInfo != NULL) {
4928 return STATUS_SUCCESS;
4929 }
4930
4931 Lock(&irql);
4932 if (m_EnumInfo == NULL) {
4934
4935 if (m_EnumInfo != NULL) {
4937
4938 if (!NT_SUCCESS(status)) {
4939 delete m_EnumInfo;
4940 m_EnumInfo = NULL;
4941
4943 TRACINGPNP,
4944 "Could not initialize enum info for "
4945 "WDFDEVICE %p, %!STATUS!",
4947 }
4948
4949 }
4950 else {
4952
4954 "Could not allocate enum info for WDFDEVICE %p, "
4955 "%!STATUS!", m_Device->GetHandle(), status);
4956 }
4957 }
4958 else {
4959 //
4960 // another thread allocated the list already
4961 //
4963 }
4964 Unlock(irql);
4965
4966 return status;
4967}
NTSTATUS Initialize(VOID)
Definition: fxpkgpnp.hpp:442

Referenced by FxDevice::AllocateEnumInfo(), and FxPkgFdo::Initialize().

◆ AskParentToRemoveAndReenumerate()

virtual NTSTATUS FxPkgPnp::AskParentToRemoveAndReenumerate ( VOID  )
privatepure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

Referenced by SetDeviceFailed().

◆ AssignPowerFrameworkSettings()

NTSTATUS FxPkgPnp::AssignPowerFrameworkSettings ( __in PWDF_POWER_FRAMEWORK_SETTINGS  PowerFrameworkSettings)

Definition at line 6243 of file fxpkgpnp.cpp.

6246{
6247// NTSTATUS status;
6248// PPO_FX_COMPONENT_IDLE_STATE idleStates = NULL;
6249// ULONG idleStatesSize = 0;
6250// PPO_FX_COMPONENT component = NULL;
6251// ULONG componentSize = 0;
6252// PPOX_SETTINGS poxSettings = NULL;
6253// ULONG poxSettingsSize = 0;
6254// BYTE * buffer = NULL;
6255
6256// if (FALSE==(IdleTimeoutManagement::_SystemManagedIdleTimeoutAvailable())) {
6257// //
6258// // If system-managed idle timeout is not available on this OS, then
6259// // there is nothing to do.
6260// //
6261// DoTraceLevelMessage(
6262// GetDriverGlobals(), TRACE_LEVEL_INFORMATION, TRACINGPNP,
6263// "WDFDEVICE %p !devobj %p Power framework is not supported on the "
6264// "current OS. Therefore, the power framework settings will not take "
6265// "effect.",
6266// m_Device->GetHandle(),
6267// m_Device->GetDeviceObject()
6268// );
6269// return STATUS_SUCCESS;
6270// }
6271
6272// if (NULL != PowerFrameworkSettings->Component) {
6273// //
6274// // Caller should ensure that IdleStateCount is not zero
6275// //
6276// ASSERT(0 != PowerFrameworkSettings->Component->IdleStateCount);
6277
6278// //
6279// // Compute buffer size needed for storing F-states
6280// //
6281// status = RtlULongMult(
6282// PowerFrameworkSettings->Component->IdleStateCount,
6283// sizeof(*(PowerFrameworkSettings->Component->IdleStates)),
6284// &idleStatesSize
6285// );
6286// if (FALSE == NT_SUCCESS(status)) {
6287// DoTraceLevelMessage(
6288// GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
6289// "WDFDEVICE %p !devobj %p Unable to compute length of buffer "
6290// "required to store F-states. RtlULongMult failed with "
6291// "%!STATUS!",
6292// m_Device->GetHandle(),
6293// m_Device->GetDeviceObject(),
6294// status
6295// );
6296// goto exit;
6297// }
6298
6299// //
6300// // Compute buffer size needed for storing component information
6301// // (including F-states)
6302// //
6303// status = RtlULongAdd(idleStatesSize,
6304// sizeof(*component),
6305// &componentSize);
6306// if (FALSE == NT_SUCCESS(status)) {
6307// DoTraceLevelMessage(
6308// GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
6309// "WDFDEVICE %p !devobj %p Unable to compute length of buffer "
6310// "required to store driver's component information. RtlULongAdd "
6311// "failed with %!STATUS!",
6312// m_Device->GetHandle(),
6313// m_Device->GetDeviceObject(),
6314// status
6315// );
6316// goto exit;
6317// }
6318// }
6319
6320// //
6321// // Compute total buffer size needed for power framework settings
6322// //
6323// status = RtlULongAdd(componentSize,
6324// sizeof(*poxSettings),
6325// &poxSettingsSize);
6326// if (FALSE == NT_SUCCESS(status)) {
6327// DoTraceLevelMessage(
6328// GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
6329// "WDFDEVICE %p !devobj %p Unable to compute length of buffer "
6330// "required to store driver's power framework settings. RtlULongAdd "
6331// "failed with %!STATUS!",
6332// m_Device->GetHandle(),
6333// m_Device->GetDeviceObject(),
6334// status
6335// );
6336// goto exit;
6337// }
6338
6339// //
6340// // Allocate memory to copy the settings
6341// //
6342// buffer = (BYTE *) MxMemory::MxAllocatePoolWithTag(NonPagedPool,
6343// poxSettingsSize,
6344// GetDriverGlobals()->Tag);
6345// if (NULL == buffer) {
6346// status = STATUS_INSUFFICIENT_RESOURCES;
6347// DoTraceLevelMessage(
6348// GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
6349// "WDFDEVICE %p !devobj %p Unable to allocate buffer required to "
6350// "store F-states. %!STATUS!",
6351// m_Device->GetHandle(),
6352// m_Device->GetDeviceObject(),
6353// status
6354// );
6355// goto exit;
6356// }
6357
6358// //
6359// // Set our pointers to point to appropriate locations in the buffer.
6360// //
6361// // NOTES:
6362// // - The array of F-states comes first because it has ULONGLONG members
6363// // because of which it has the biggest alignment requirement.
6364// // - The logic below works even if the client driver did not specify any
6365// // component information. In that case idleStatesSize and componentSize
6366// // are both 0 and 'poxSettings' points to the beginning of the allocated
6367// // buffer
6368// //
6369// idleStates = (PPO_FX_COMPONENT_IDLE_STATE) buffer;
6370// component = (PPO_FX_COMPONENT) (buffer + idleStatesSize);
6371// poxSettings = (PPOX_SETTINGS) (buffer + componentSize);
6372
6373// //
6374// // Copy the relevant parts of the settings buffer
6375// //
6376// poxSettings->EvtDeviceWdmPostPoFxRegisterDevice =
6377// PowerFrameworkSettings->EvtDeviceWdmPostPoFxRegisterDevice;
6378// poxSettings->EvtDeviceWdmPrePoFxUnregisterDevice =
6379// PowerFrameworkSettings->EvtDeviceWdmPrePoFxUnregisterDevice;
6380// poxSettings->Component = PowerFrameworkSettings->Component;
6381// poxSettings->ComponentActiveConditionCallback =
6382// PowerFrameworkSettings->ComponentActiveConditionCallback;
6383// poxSettings->ComponentIdleConditionCallback =
6384// PowerFrameworkSettings->ComponentIdleConditionCallback;
6385// poxSettings->ComponentIdleStateCallback =
6386// PowerFrameworkSettings->ComponentIdleStateCallback;
6387// poxSettings->PowerControlCallback =
6388// PowerFrameworkSettings->PowerControlCallback;
6389// poxSettings->PoFxDeviceContext = PowerFrameworkSettings->PoFxDeviceContext;
6390
6391// if (NULL != PowerFrameworkSettings->Component) {
6392// //
6393// // Copy the component information
6394// //
6395// poxSettings->Component = component;
6396// RtlCopyMemory(poxSettings->Component,
6397// PowerFrameworkSettings->Component,
6398// sizeof(*component));
6399
6400// //
6401// // Caller should ensure that IdleStates is not NULL
6402// //
6403// ASSERT(NULL != PowerFrameworkSettings->Component->IdleStates);
6404
6405// //
6406// // Copy the F-states
6407// //
6408// poxSettings->Component->IdleStates = idleStates;
6409// RtlCopyMemory(poxSettings->Component->IdleStates,
6410// PowerFrameworkSettings->Component->IdleStates,
6411// idleStatesSize);
6412// }
6413
6414// //
6415// // Commit these settings
6416// //
6417// status = m_PowerPolicyMachine.m_Owner->
6418// m_IdleSettings.m_TimeoutMgmt.CommitPowerFrameworkSettings(
6419// GetDriverGlobals(),
6420// poxSettings
6421// );
6422// if (FALSE == NT_SUCCESS(status)) {
6423// goto exit;
6424// }
6425
6426// status = STATUS_SUCCESS;
6427
6428// exit:
6429// if (FALSE == NT_SUCCESS(status)) {
6430// if (NULL != buffer) {
6431// MxMemory::MxFreePool(buffer);
6432// }
6433// }
6434// return status;
6436 return STATUS_SUCCESS;
6437}
#define ROSWDFNOTIMPLEMENTED
Definition: fxglobals.h:52

◆ ChildListNotifyRemove()

VOID FxPkgPnp::ChildListNotifyRemove ( __inout PLONG  PendingCount)

Definition at line 4999 of file fxpkgpnp.cpp.

5002{
5004
5005 ple = NULL;
5006
5007 if (m_EnumInfo != NULL) {
5011 }
5013 }
5014}
VOID NotifyDeviceRemove(__inout PLONG ChildCount)
static FxChildList * _FromEntry(__in FxTransactionedEntry *Entry)
_Must_inspect_result_ FxTransactionedEntry * GetNextEntry(__in_opt FxTransactionedEntry *Entry)
VOID UnlockFromEnum(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
VOID LockForEnum(__in PFX_DRIVER_GLOBALS FxDriverGlobals)

◆ ChildRemoved()

VOID FxPkgPnp::ChildRemoved ( VOID  )
inline

Definition at line 3415 of file fxpkgpnp.hpp.

3418 {
3419 LONG c;
3420
3421 //
3422 // Called by a child that we are waiting on its removal
3423 //
3425 ASSERT(c >= 0);
3426
3427 if (c == 0) {
3429 }
3430 }
VOID PnpProcessEvent(__in FxPnpEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
@ PnpEventChildrenRemovalComplete
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80

Referenced by PnpEventFinal().

◆ CleanupDeviceFromFailedCreate()

VOID FxPkgPnp::CleanupDeviceFromFailedCreate ( __in MxEvent WaitEvent)

Definition at line 2190 of file fxpkgpnp.cpp.

2218{
2220
2221 //
2222 // Caller must initialize the event as Synchronization event and it should
2223 // be passed as non-signalled. But we Clear it just to be sure.
2224 //
2225 WaitEvent->Clear();
2226
2227 ADDREF(WaitEvent);
2228
2230 m_DeviceRemoveProcessed = WaitEvent;
2231
2232 //
2233 // Simulate a remove event coming to the device. After this call returns
2234 // m_Device is still valid and must be deleted.
2235 //
2237
2238 //
2239 // No need to wait in a critical region because we are in the context of a
2240 // pnp request which is in the system context.
2241 //
2242 WaitEvent->WaitFor(Executive, KernelMode, FALSE, NULL);
2244
2245 RELEASE(WaitEvent);
2246}
#define ADDREF(_tag)
Definition: fxobject.hpp:49
#define RELEASE(_tag)
Definition: fxobject.hpp:50

Referenced by FxDevice::DeleteDeviceFromFailedCreateNoDelete().

◆ CleanupStateMachines()

VOID FxPkgPnp::CleanupStateMachines ( __in BOOLEAN  ClenaupPnp)

Definition at line 2066 of file fxpkgpnp.cpp.

2069{
2070#if (FX_CORE_MODE==FX_CORE_USER_MODE)
2072#else
2073 FxCREvent eventOnStack;
2074 eventOnStack.Initialize();
2075 FxCREvent * event = eventOnStack.GetSelfPointer();
2076#endif
2077
2078 //
2079 // Order of shutdown is important here.
2080 // o Pnp initiates events to power policy.
2081 // o Power policy initiates events to power and device-power-requirement
2082 // o Power does not initiate any events
2083 // o Device-power-requirement does not initiate any events
2084 //
2085 // By shutting them down in the order in which they send events, we can
2086 // guarantee that no new events will be posted into the subsidiary state
2087 // machines.
2088 //
2089
2090 //
2091 // This will shut off the pnp state machine and synchronize any outstanding
2092 // threads of execution.
2093 //
2094 if (CleanupPnp && m_PnpMachine.SetFinished(
2095 event
2096 ) == FALSE) {
2099 "WDFDEVICE %p, !devobj %p waiting for pnp state machine to finish",
2101
2102 //
2103 // Process the event *before* completing the irp so that this event is in
2104 // the queue before the device remove event which will be processed
2105 // right after the start irp has been completed.
2106 //
2107 event->EnterCRAndWaitAndLeave();
2108 }
2109
2110 //
2111 // Even though event is a SynchronizationEvent, so we need to reset it for
2112 // the next wait because SetFinished will set it if even if the transition
2113 // to the finished state is immediate
2114 //
2115 event->Clear();
2116
2120 "WDFDEVICE %p, !devobj %p waiting for pwr pol state machine to finish",
2122
2123 event->EnterCRAndWaitAndLeave();
2124 }
2125
2126 //
2127 // See previous comment about why we Clear()
2128 //
2129 event->Clear();
2130
2134 "WDFDEVICE %p, !devobj %p waiting for pwr state machine to finish",
2136
2137 event->EnterCRAndWaitAndLeave();
2138 }
2139
2140 if (IsPowerPolicyOwner()) {
2141 //
2142 // See previous comment about why we Clear()
2143 //
2144 event->Clear();
2145
2147 m_DevicePowerRequirementMachine) {
2148
2150 m_DevicePowerRequirementMachine->SetFinished(event)) {
2151
2154 "WDFDEVICE %p, !devobj %p waiting for device power "
2155 "requirement state machine to finish",
2158
2159 event->EnterCRAndWaitAndLeave();
2160 }
2161 }
2162
2164 }
2165
2166 //
2167 // Release the power thread if we have one either through creation or query.
2168 // Since the power policy state machine is off, we should no longer need
2169 // a dedicated thread.
2170 //
2171 // *** NOTE ***
2172 // The power thread must be released *BEFORE* sending the irp down the stack
2173 // because this can happen
2174 // 1) this driver is not the power thread owner, but the last client
2175 // 2) we send the pnp irp first
2176 // 3) the power thread owner waits on this thread for all the clients to go
2177 // away, but this device still has a reference on it
2178 // 4) this device will not release the reference b/c the owner is waiting
2179 // in the same thread.
2180 //
2182
2183 //
2184 // Deref the reenumeration interface
2185 //
2187}
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
virtual VOID ReleaseReenumerationInterface(VOID)=0
FxPowerMachine m_PowerMachine
Definition: fxpkgpnp.hpp:4152
VOID ReleasePowerThread(VOID)
Definition: fxpkgpnp.cpp:5180
FxPnpMachine m_PnpMachine
Definition: fxpkgpnp.hpp:4151
FxCREvent m_CleanupEventUm
Definition: fxpkgpnp.hpp:4304
FxCREvent * GetSelfPointer(VOID)
Definition: fxwaitlock.hpp:180
CHECK_RETURN_IF_USER_MODE NTSTATUS Initialize(__in BOOLEAN InitialState=FALSE)
Definition: fxwaitlock.hpp:51
BOOLEAN SetFinished(__in FxCREvent *Event)
Definition: eventqueue.cpp:91
_In_ PWDFDEVICE_INIT _In_ BOOLEAN IsPowerPolicyOwner
Definition: wdfdevice.h:2966

Referenced by FxDevice::DeleteDeviceFromFailedCreateNoDelete(), ProcessDelayedDeletion(), FxPkgFdo::ProcessRemoveDeviceOverload(), and FxPkgPdo::ProcessRemoveDeviceOverload().

◆ ClearPendingDevicePowerIrp()

MdIrp FxPkgPnp::ClearPendingDevicePowerIrp ( VOID  )
inlineprotected

Definition at line 3069 of file fxpkgpnp.hpp.

3072 {
3073 MdIrp irp;
3074
3077
3078 return irp;
3079 }
FxIrp * irp
IWudfIrp * MdIrp
Definition: mxum.h:103

Referenced by FxPkgFdo::PowerReleasePendingDeviceIrp(), and FxPkgPdo::PowerReleasePendingDeviceIrp().

◆ ClearPendingPnpIrp()

MdIrp FxPkgPnp::ClearPendingPnpIrp ( VOID  )
inlineprotected

Definition at line 3029 of file fxpkgpnp.hpp.

3032 {
3033 MdIrp irp;
3034
3037
3038 return irp;
3039 }

Referenced by FxPkgPdo::_PnpEject(), PnpFinishProcessingIrp(), PnpProcessEventInner(), and FxPkgFdo::PnpSendStartDeviceDownTheStackOverload().

◆ ClearPendingSystemPowerIrp()

MdIrp FxPkgPnp::ClearPendingSystemPowerIrp ( VOID  )
inlineprotected

Definition at line 3092 of file fxpkgpnp.hpp.

3095 {
3096 MdIrp irp;
3097
3100
3101 return irp;
3102 }

◆ ClearRemovalDevicesList()

VOID FxPkgPnp::ClearRemovalDevicesList ( VOID  )

Definition at line 4832 of file fxpkgpnp.cpp.

4835{
4837
4838 if (m_RemovalDeviceList == NULL) {
4839 return;
4840 }
4841
4845 }
4847
4848 //
4849 // RemovalRelations are queried automatically by PnP when the device is
4850 // going to be query removed. No need to tell pnp that the list changed
4851 // until it needs to query for it.
4852 //
4853}
VOID UnlockFromEnum(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
VOID Remove(__in PFX_DRIVER_GLOBALS Globals, __in MdDeviceObject Device)
VOID LockForEnum(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
_Must_inspect_result_ FxRelatedDevice * GetNextEntry(__in_opt FxRelatedDevice *Entry)
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

◆ CommitUsageNotification()

VOID FxPkgPnp::CommitUsageNotification ( __in DEVICE_USAGE_NOTIFICATION_TYPE  Type,
__in ULONG  OldFlags 
)
protected

Definition at line 4614 of file fxpkgpnp.cpp.

4639{
4640 PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
4641 ULONG newFlags;
4642
4643 newFlags = m_Device->GetDeviceObjectFlags();
4644
4646 (newFlags & DO_POWER_PAGABLE) == 0) {
4647 //
4648 // We transitioned from a power pageable to a non power pageable
4649 // device. Move the power state machine to the appropriate
4650 // state.
4651 //
4653 }
4654
4655 if ((OldFlags & DO_POWER_PAGABLE) == 0 &&
4656 (newFlags & DO_POWER_PAGABLE) == DO_POWER_PAGABLE) {
4657 //
4658 // We transitioned from a non power pageable to a power pageable
4659 // device. Move the power state machine to the appropriate
4660 // state.
4661 //
4663 }
4664
4665 //
4666 // Notify PNP that it should no longer be able
4667 // to disable this device.
4668 //
4669 MxDeviceObject physicalDeviceObject(
4671 );
4672 physicalDeviceObject.InvalidateDeviceState(
4674 );
4675
4677 FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP,
4678 "After: special count %d, flags 0x%x, device %p (WDFDEVICE %p)",
4679 GetUsageCount(Type), newFlags,
4681}
ULONG __inline GetDeviceObjectFlags(VOID)
Definition: fxdevice.hpp:192
MdDeviceObject __inline GetPhysicalDevice(VOID)
Definition: fxdevice.hpp:228
LONG GetUsageCount(__in __range(1, 4) ULONG Usage)
Definition: fxpkgpnp.hpp:3161
SHORT OldFlags
Definition: fxioqueue.cpp:1325
@ PowerMarkPageable
@ PowerMarkNonpageable
#define DO_POWER_PAGABLE

Referenced by PnpDeviceUsageNotification().

◆ CompletePnpRequest()

NTSTATUS FxPkgPnp::CompletePnpRequest ( __inout FxIrp Irp,
__in NTSTATUS  Status 
)
protected

Definition at line 5752 of file fxpkgpnp.cpp.

5756{
5757 MdIrp pIrp = Irp->GetIrp();
5758
5759 Irp->SetStatus(Status);
5760 Irp->CompleteRequest(IO_NO_INCREMENT);
5761
5763 pIrp);
5764
5765 return Status;
5766}
MdRemoveLock GetRemoveLock(VOID)
Definition: fxdevicekm.hpp:47
MdIrp GetIrp(VOID)
Definition: fxirpum.cpp:15
static __inline VOID MxReleaseRemoveLock(__in MdRemoveLock RemoveLock, __in PVOID Tag)
Definition: mxgeneralkm.h:278
FxIrp * pIrp
Status
Definition: gdiplustypes.h:25
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by FxPkgPdo::_PnpEject(), FxPkgPdo::_PnpFilterResourceRequirements(), FxPkgPdo::_PnpQueryBusInformation(), FxPkgPdo::_PnpQueryDeviceText(), FxPkgFdo::_PnpQueryInterface(), FxPkgPdo::_PnpQueryInterface(), FxPkgFdo::_PnpQueryPnpDeviceState(), FxPkgPdo::_PnpSetLock(), FxPkgFdo::_PnpStartDeviceCompletionRoutine(), FxPkgPdo::_QueryCapsWorkItem(), FxPkgPdo::FireAndForgetIrp(), PnpDeviceUsageNotification(), FxPkgFdo::PnpFilterResourceRequirements(), PnpFinishProcessingIrp(), FxPkgFdo::PnpQueryCapabilities(), FxPkgPdo::PnpQueryCapabilities(), FxPkgFdo::PnpQueryDeviceRelations(), FxPkgPdo::PnpQueryDeviceRelations(), FxPkgPdo::PnpQueryResourceRequirements(), FxPkgPdo::PnpQueryResources(), FxPkgFdo::PnpSendStartDeviceDownTheStackOverload(), and FxPkgPdo::ProcessRemoveDeviceOverload().

◆ CompletePowerRequest()

NTSTATUS FxPkgPnp::CompletePowerRequest ( __inout FxIrp Irp,
__in NTSTATUS  Status 
)
protected

Definition at line 5404 of file fxpkgpnp.cpp.

5408{
5409 MdIrp irp;
5410
5411 //
5412 // Once we call CompleteRequest, 2 things happen
5413 // 1) this object may go away
5414 // 2) Irp->m_Irp will be cleared
5415 //
5416 // As such, we capture the underlying WDM objects so that we can use them
5417 // to release the remove lock and use the PIRP *value* as a tag to release
5418 // the remlock.
5419 //
5420 irp = Irp->GetIrp();
5421
5422 Irp->SetStatus(Status);
5423 Irp->StartNextPowerIrp();
5424 Irp->CompleteRequest(IO_NO_INCREMENT);
5425
5427 irp);
5428
5429 return Status;
5430}

Referenced by FxPkgPdo::_DispatchQueryPower(), FxPkgFdo::DispatchSystemQueryPower(), FxPkgPdo::DispatchSystemSetPower(), DispatchWaitWake(), FxPkgPdo::FireAndForgetIrp(), PowerCompletePendedWakeIrp(), PowerPolicyCancelWaitWake(), PowerPolicyCompleteSystemPowerIrp(), FxPkgFdo::PowerReleasePendingDeviceIrp(), and FxPkgPdo::PowerReleasePendingDeviceIrp().

◆ CreatePowerThread()

_Must_inspect_result_ NTSTATUS FxPkgPnp::CreatePowerThread ( VOID  )
protected

Definition at line 5125 of file fxpkgpnp.cpp.

5142{
5143 FxSystemThread *pThread, *pOld;
5145
5147 &pThread,
5151
5152 if (!NT_SUCCESS(status)) {
5153 return status;
5154 }
5155
5156 //
5157 // Simple locking logic in case N requests are conncurrent. (The requests
5158 // never should be concurrent, but in the case that there are 2 usage
5159 // notifications coming in from two different sources, it could
5160 // theoritically happen.)
5161 //
5163 (PVOID*) &m_PowerThread, pThread, NULL);
5164
5165 if (pOld != NULL) {
5166 //
5167 // Someone also set the thread pointer value at the same time, free
5168 // our new one here.
5169 //
5170 pThread->ExitThread();
5171 pThread->DeleteObject();
5172 }
5173
5175
5176 return STATUS_SUCCESS;
5177}
static _Must_inspect_result_ NTSTATUS _CreateAndInit(__deref_out FxSystemThread **SystemThread, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in WDFDEVICE Device, __in MdDeviceObject DeviceObject)
#define TRUE
Definition: types.h:120
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129

Referenced by FxPkgFdo::QueryForPowerThread(), and FxPkgPdo::QueryForPowerThread().

◆ CreatePowerThreadIfNeeded()

_Must_inspect_result_ NTSTATUS FxPkgPnp::CreatePowerThreadIfNeeded ( VOID  )
private

Definition at line 158 of file pnpstatemachinekm.cpp.

171{
174
175
176
177
178
179
180
181
182
183
184
185
186 pTopOfStack.SetObject(
188
189 ASSERT(pTopOfStack.GetObject() != NULL);
190
191 if (pTopOfStack.GetObject() != NULL) {
192 //
193 // If the top of the stack is not power pageable, the stack needs a power
194 // thread. Query for it if we are not a PDO (and create it if the lower
195 // stack does not support it), and create it if we are a PDO.
196 //
197 // Some stacks send a usage notification when processing a start device, so
198 // a notification could have already traveled through the stack by the time
199 // the start irp has completed back up to this device.
200 //
201 if ((pTopOfStack.GetFlags() & DO_POWER_PAGABLE) == 0 &&
202 HasPowerThread() == FALSE) {
204
205 if (!NT_SUCCESS(status)) {
208 }
209 }
210
211 pTopOfStack.DereferenceObject();
212 pTopOfStack.SetObject(NULL);
213 }
214
215 return status;
216}
__inline MdDeviceObject GetAttachedDeviceReference(VOID)
Definition: fxdevice.hpp:429
VOID SetInternalFailure(VOID)
Definition: fxpkgpnp.cpp:4856
VOID SetPendingPnpIrpStatus(__in NTSTATUS Status)
Definition: fxpkgpnp.hpp:3018
virtual NTSTATUS QueryForPowerThread(VOID)=0
BOOLEAN HasPowerThread(VOID)
Definition: fxpkgpnp.hpp:3508
PDEVICE_OBJECT pTopOfStack

◆ DeleteDevice()

VOID FxPkgPnp::DeleteDevice ( VOID  )
protected

Definition at line 2249 of file fxpkgpnp.cpp.

2261{
2262 //
2263 // This will detach and delete the device object
2264 //
2265 m_Device->Destroy();
2266
2267 //
2268 // If this is the last reference, this will free the memory for the device
2269 //
2271}
virtual VOID DeleteObject(VOID)
Definition: fxdevice.cpp:1135
VOID Destroy(VOID)
Definition: fxdevicekm.cpp:329

Referenced by ProcessDelayedDeletion(), FxPkgFdo::ProcessRemoveDeviceOverload(), and FxPkgPdo::ProcessRemoveDeviceOverload().

◆ DeleteSymbolicLinkOverload()

virtual VOID FxPkgPnp::DeleteSymbolicLinkOverload ( BOOLEAN  GracefulRemove)
privatepure virtual

Referenced by PnpCleanupForRemove().

◆ DisconnectInterruptNP()

VOID FxPkgPnp::DisconnectInterruptNP ( VOID  )
private

Definition at line 4758 of file powerstatemachine.cpp.

4761{
4762 //
4763 // NotifyResourceObjectsDx will call IoDisconnectInterrupt. Since we
4764 // are in the NP path, this may cause a deadlock between this thread and
4765 // paging I/O. Log something to the IFR so that if the watchdog timer kicks
4766 // in, at least we have context as to why we died.
4767 //
4770 "Force disconnecting interrupts on !devobj 0x%p, WDFDEVICE %p",
4772 m_Device->GetHandle());
4773
4774 //
4775 // NotifyResourceObjectsDx will log any errors
4776 //
4778}
NTSTATUS NotifyResourceObjectsDx(__in ULONG NotifyFlags)
Definition: fxpkgpnp.cpp:6104
@ NotifyResourcesForceDisconnect
Definition: fxpkgpnp.hpp:210

◆ Dispatch()

_Must_inspect_result_ NTSTATUS FxPkgPnp::Dispatch ( __in MdIrp  Irp)
protectedvirtual

Implements FxPackage.

Definition at line 520 of file fxpkgpnp.cpp.

545{
547 FxIrp irp(Irp);
548
549#if (FX_CORE_MODE==FX_CORE_KERNEL_MODE)
551#endif
552
554
555 switch (irp.GetMinorFunction()) {
564 case IRP_MN_EJECT:
568 "WDFDEVICE 0x%p !devobj 0x%p, IRP_MJ_PNP, %!pnpmn! IRP 0x%p",
572 break;
573
577 "WDFDEVICE 0x%p !devobj 0x%p, IRP_MJ_PNP, %!pnpmn! "
578 "type %!DEVICE_RELATION_TYPE! IRP 0x%p",
583 break;
584
585 default:
588 "WDFDEVICE 0x%p !devobj 0x%p, IRP_MJ_PNP, %!pnpmn! IRP 0x%p",
592 break;
593 }
594
596 status = (*GetDispatchPnp()[irp.GetMinorFunction()])(this, &irp);
597 }
598 else {
599 //
600 // For Pnp IRPs we don't understand, just forget about them
601 //
603 }
604 }
605 else {
606 //
607 // If this isn't a PnP Irp, it must be a power irp.
608 //
609 switch (irp.GetMinorFunction()) {
610 case IRP_MN_WAIT_WAKE:
611 case IRP_MN_SET_POWER:
615 "WDFDEVICE 0x%p !devobj 0x%p IRP_MJ_POWER, %!pwrmn! "
616 "IRP 0x%p for %!SYSTEM_POWER_STATE! (S%d)",
622 }
623 else {
626 "WDFDEVICE 0x%p !devobj 0x%p IRP_MJ_POWER, %!pwrmn! "
627 "IRP 0x%p for %!DEVICE_POWER_STATE!",
632 }
633 break;
634
635 default:
638 "WDFDEVICE 0x%p !devobj 0x%p IRP_MJ_POWER, %!pwrmn! IRP 0x%p",
642 break;
643 }
644
646
649 }
650 else {
651 //
652 // For Power IRPs we don't understand, just forget about them
653 //
655 }
656 }
657
658 return status;
659}
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
Definition: fxirp.hpp:28
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
DEVICE_RELATION_TYPE GetParameterQDRType()
Definition: fxirpum.cpp:731
POWER_STATE_TYPE GetParameterPowerType()
Definition: fxirpum.cpp:683
SYSTEM_POWER_STATE GetParameterPowerStateSystemState()
Definition: fxirpum.cpp:707
DEVICE_POWER_STATE GetParameterPowerStateDeviceState()
Definition: fxirpum.cpp:695
UCHAR GetMinorFunction(VOID)
Definition: fxirpum.cpp:297
virtual const PFN_PNP_POWER_CALLBACK * GetDispatchPower(VOID)=0
virtual const PFN_PNP_POWER_CALLBACK * GetDispatchPnp(VOID)=0
virtual NTSTATUS FireAndForgetIrp(FxIrp *Irp)=0
FX_TRACK_DRIVER(fxDriverGlobals)
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_WAIT_WAKE
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IRP_MN_EJECT
#define IRP_MN_START_DEVICE
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_SET_POWER
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
#define IRP_MJ_POWER
_In_ SYSTEM_POWER_STATE SystemPowerState
Definition: iotypes.h:7519
#define IRP_MN_QUERY_POWER
#define IRP_MN_QUERY_REMOVE_DEVICE

◆ DispatchWaitWake()

_Must_inspect_result_ NTSTATUS FxPkgPnp::DispatchWaitWake ( __inout FxIrp Irp)
protected

Definition at line 2431 of file fxpkgpnp.cpp.

2446{
2447 PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
2449 PIRP oldIrp;
2450 KIRQL irql;
2451
2452 if (IsPowerPolicyOwner()) {
2454 //
2455 // A power irp arrived, but we did not request it. log and bugcheck
2456 //
2459 "Received wait wake power irp %p on device %p, but the irp was "
2460 "not requested by the device (the power policy owner)",
2461 Irp->GetIrp(), m_Device->GetDeviceObject());
2462
2464 WDF_POWER_MULTIPLE_PPO, // specific type
2465 (ULONG_PTR)m_Device->GetDeviceObject(), //parm 2
2466 (ULONG_PTR)Irp->GetIrp()); // parm 3
2467
2468 /* NOTREACHED */
2469 }
2470
2471 //
2472 // We are no longer requesting a power irp because we received the one
2473 // we requested.
2474 //
2476 }
2477
2478 //
2479 // The Framework has the concept of a "Wait/Wake Owner." This is the layer
2480 // in the stack that is enabling and disabling wake at the bus level. This
2481 // is probably the PDO or a bus filter like ACPI.sys. This is distinct
2482 // from being the "Power Policy Owner," which would mean that this driver
2483 // is deciding what D-state is appropriate for the device, and also
2484 // sending Wait/Wake IRPs.
2485 //
2486
2489
2491 //
2492 // We only allow one pended wait wake irp in the stack at a time.
2493 // Fail this secondary wait wake request.
2494 //
2496
2499 "Failing wait wake irp %p with %!STATUS! because wait wake irp "
2500 "%p already pended",
2502 }
2503 else {
2504 MdCancelRoutine pRoutine;
2505
2506 //
2507 // No wait wake irp is currently in the stack, so attempt to set
2508 // a cancel routine and transition the power state machine into a
2509 // a state where it can arm the device at the bus level for this
2510 // child.
2511 //
2512 // The power state machine expects the wait wake irp to have a cancel
2513 // routine set in all states. For those states which require a
2514 // non cancelable irp, those states clear the cancel routine as
2515 // appropriate.
2516 //
2517 pRoutine = Irp->SetCancelRoutine(_PowerWaitWakeCancelRoutine);
2518#if DBG
2519 ASSERT(pRoutine == NULL);
2520#else
2521 UNREFERENCED_PARAMETER(pRoutine);
2522#endif
2524
2525 if (Irp->IsCanceled()) {
2528 "wait wake irp %p already canceled", Irp->GetIrp());
2529
2530 //
2531 // This IRP has already been cancelled, we must clear the cancel
2532 // routine before completing the IRP.
2533 //
2534 pRoutine = Irp->SetCancelRoutine(NULL);
2535
2536 if (pRoutine != NULL) {
2537 //
2538 // Our cancel routine will not be called
2539 //
2540#if DBG
2542#else
2543 UNREFERENCED_PARAMETER(pRoutine);
2544#endif
2545 Irp->SetStatus(STATUS_CANCELLED);
2547 }
2548 }
2549
2550 if (status == STATUS_PENDING) {
2551 //
2552 // Either we successfully set the cancel routine or the irp
2553 // was canceled and the cancel routine is about to run when
2554 // we drop the lock. If the routine is about to run, we still
2555 // need to setup m_SharedPower to values that it expects.
2556 //
2557 Irp->MarkIrpPending();
2558 m_SharedPower.m_WaitWakeIrp = Irp->GetIrp();
2559 }
2560 }
2562
2563 if (NT_SUCCESS(status)) {
2564 //
2565 // Post to the appropriate matchines
2566 //
2568
2569 if (IsPowerPolicyOwner()) {
2571 }
2572 }
2573 else {
2575 }
2576
2577 return status;
2578 }
2579 else if (IsPowerPolicyOwner()) {
2580 //
2581 // Try to set m_WaitWakeIrp to the new IRP value only if the current
2582 // value of m_WaitWakeIrp is NULL because there can only be one
2583 // active wait wake irp in the stack at a time. Since the power policy
2584 // state machine never sends more then one, this is really a guard
2585 // against some other device in the stack sending a wait wake irp to
2586 // this device in the wrong state.
2587 //
2590 Irp->GetIrp(),
2591 NULL
2592 );
2593
2594 //
2595 // If oldIrp is NULL then there was no previous irp and we successfully
2596 // exchanged the new PIRP value into m_WaitWakeIrp
2597 //
2598 if (oldIrp == NULL) {
2600
2601 //
2602 // NOTE: There is a built in race condition here that WDF cannot
2603 // solve with the given WDM primitives. After arming the
2604 // device for wake, there is a window where the wait wake irp
2605 // has not yet been processed by the wait wake owner. Until
2606 // the wake request is processed, wake events could be generated
2607 // and lost. There is nothing we can do about this until we
2608 // have synchronous "goto Dx and arm" command available.
2609 //
2610 Irp->CopyCurrentIrpStackLocationToNext();
2611 Irp->SetCompletionRoutineEx(m_Device->GetDeviceObject(),
2613 this);
2614
2615 //
2616 // Technically, there should be a PDO vs FDO overload here which
2617 // does the right thing w/regard to this request and if it is at the
2618 // bottom of the stack or not. But, by design, we check for
2619 // m_WaitWakeOwner first which has the direct side affect of making
2620 // it impossible for a PDO to get to this point.
2621 //
2622 ASSERT(m_Device->IsFdo());
2623
2624 status = Irp->PoCallDriver(m_Device->GetAttachedDevice());
2625
2626 //
2627 // Send the wake arrived after sending the request as commented above.
2628 // This window between sending the request and sending the event to
2629 // the state machine allows the wait owner to complete the request
2630 // immediately. When completed synchronously, it has an effect on
2631 // both wake scenarios:
2632 //
2633 // 1) wake from S0: the device never transitions to Dx and the idle
2634 // timer is resumed if no i/o is present
2635 //
2636 // 2) wake from sx: the device is disarmed for wake from Sx and
2637 // put into Dx with being armed for wake.
2638 //
2640 }
2641 else {
2643
2645 FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP,
2646 "already have a ww irp %p, failing new ww irp %p with %!STATUS!",
2647 oldIrp, Irp->GetIrp(), status);
2648
2650 }
2651 }
2652 else {
2653 //
2654 // Not the power policy owner, not the wait wake irp owner, ignore the
2655 // irp
2656 //
2657 // This will release the remove lock.
2658 //
2660 }
2661
2662 return status;
2663}
struct _IRP * PIRP
MdDeviceObject __inline GetAttachedDevice(VOID)
Definition: fxdevice.hpp:210
__inline BOOLEAN IsFdo(VOID)
Definition: fxdevice.hpp:1227
static MdCancelRoutineType _PowerWaitWakeCancelRoutine
Definition: fxpkgpnp.hpp:2736
NTSTATUS CompletePowerRequest(__inout FxIrp *Irp, __in NTSTATUS Status)
Definition: fxpkgpnp.cpp:5404
static MdCompletionRoutineType _PowerPolicyWaitWakeCompletionRoutine
Definition: fxpkgpnp.hpp:2801
VOID PowerPolicyProcessEvent(__in FxPowerPolicyEvent Event, __in BOOLEAN ProcessEventOnDifferentThread=FALSE)
@ PowerWakeArrival
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
WUDF_DRIVER_CANCEL * MdCancelRoutine
Definition: mxum.h:143
#define STATUS_POWER_STATE_INVALID
Definition: ntstatus.h:831
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
@ WDF_POWER_MULTIPLE_PPO
Definition: wdfbugcodes.h:70

◆ Dispose()

BOOLEAN FxPkgPnp::Dispose ( VOID  )
protectedvirtual

Reimplemented from FxObject.

Definition at line 284 of file fxpkgpnp.cpp.

287{
289
290 //
291 // All of the interrupts were freed during this object's dispose path. This
292 // is because all of the interrupts were attached as children to this object.
293 //
294 // It is safe to just reinitialize the list head.
295 //
297
299
300 //
301 // A derived class can insert an embedded FxQueryInterface into the QI list,
302 // so clear out the list before the destructor chain runs. (The derived
303 // class will be destructed first, as such, the embedded FxQueryInterface
304 // will also destruct first and complain it is still in a list.
305 //
307
308 //
309 // Clear out the head while holding the lock so that we synchronize against
310 // processing a QI while deleting the list.
311 //
313
315
316 while (ple != NULL) {
317 FxQueryInterface* pQI;
318
320
321 //
322 // Advance before we potentiall free the structure
323 //
324 ple = ple->Next;
325
326 //
327 // FxQueryInterface's destructor requires Next be NULL
328 //
329 pQI->m_Entry.Next = NULL;
330
331 if (pQI->m_EmbeddedInterface == FALSE) {
332 delete pQI;
333 }
334 }
335
336#if (FX_CORE_MODE==FX_CORE_KERNEL_MODE)
338#endif
339
340 //
341 // Call up the hierarchy
342 //
343 return FxPackage::Dispose(); // __super call
344}
virtual BOOLEAN Dispose(VOID)
VOID DropD3ColdInterface(VOID)
Definition: fxpkgpnpkm.cpp:615
static FxQueryInterface * _FromEntry(__in PSINGLE_LIST_ENTRY Entry)
SINGLE_LIST_ENTRY m_Entry

◆ DropD3ColdInterface()

VOID FxPkgPnp::DropD3ColdInterface ( VOID  )

Definition at line 615 of file fxpkgpnpkm.cpp.

Referenced by Dispose().

◆ FilterResourceRequirements()

NTSTATUS FxPkgPnp::FilterResourceRequirements ( __in IO_RESOURCE_REQUIREMENTS_LIST **  IoList)
protected

Definition at line 16 of file fxpkgpnpkm.cpp.

74{
75 ULONG altResListIndex;
76 PIO_RESOURCE_REQUIREMENTS_LIST pIoRequirementList;
78
79 pIoRequirementList = *IoList;
80
81 if (pIoRequirementList == NULL) {
82 return STATUS_SUCCESS;
83 }
84
86 //
87 // No interrupt objects created to filter resource requirements.
88 //
89 return STATUS_SUCCESS;
90 }
91
92 pIoResList = pIoRequirementList->List;
93
94 //
95 // Parse one or more alternative resource lists.
96 //
97 for (altResListIndex = 0;
98 altResListIndex < pIoRequirementList->AlternativeLists;
99 altResListIndex++) {
100 PLIST_ENTRY pIntListEntryForMSI;
101 PLIST_ENTRY pIntListEntryForLBI;
102 BOOLEAN multiMessageMSI22Found;
103 BOOLEAN previousDescMSI;
104 ULONG descIndex;
105
106 multiMessageMSI22Found = FALSE;
107 previousDescMSI = FALSE;
108
109 pIntListEntryForMSI = &m_InterruptListHead;
110 pIntListEntryForLBI = &m_InterruptListHead;
111
112 //
113 // Traverse each _IO_RESOURCE_LISTs looking for interrupt descriptors
114 // and call FilterResourceRequirements method so that it can apply
115 // policy set on the interrupt object into the resource-descriptor.
116 //
117
118 for (descIndex = 0; descIndex < pIoResList->Count; descIndex++) {
119 ULONG messageCount;
121 FxInterrupt* pInterruptInstance;
122
123 pIoDesc = &pIoResList->Descriptors[descIndex];
124
125 switch (pIoDesc->Type) {
127
129
130 previousDescMSI = TRUE;
131
132 //
133 // We will advance to the next interrupt object if the resource
134 // is not an alternate resource descriptor. A resource list can
135 // have a preferred and zero or more alternate resource descriptors
136 // for the same resource. We need to apply the same policy on the
137 // alternate desc that we applied on the preferred one in case one
138 // of the alernate desc is selected for this device. An alternate
139 // resource descriptor can't be the first descriptor in a list.
140 //
141 if ((pIoDesc->Option & IO_RESOURCE_ALTERNATIVE) == 0) {
142 pIntListEntryForMSI = pIntListEntryForMSI->Flink;
143 }
144
145 if (pIntListEntryForMSI == &m_InterruptListHead) {
148 "Not enough interrupt objects created for MSI by WDFDEVICE 0x%p ",
150 break;
151 }
152
153 pInterruptInstance = CONTAINING_RECORD(pIntListEntryForMSI, FxInterrupt, m_PnpList);
154 messageCount = pIoDesc->u.Interrupt.MaximumVector - pIoDesc->u.Interrupt.MinimumVector + 1;
155
156 if (messageCount > 1) {
157 //
158 // PCI spec guarantees that there can be only one preferred/default
159 // MSI 2.2 descriptor in a single list.
160 //
161 if ((pIoDesc->Option & IO_RESOURCE_ALTERNATIVE) == 0) {
162#if DBG
163 ASSERT(multiMessageMSI22Found == FALSE);
164#else
165 UNREFERENCED_PARAMETER(multiMessageMSI22Found);
166#endif
167 multiMessageMSI22Found = TRUE;
168
169 }
170 }
171 else {
172 //
173 // This is either single message MSI 2.2 or MSI-X interrupts
174 //
175 DO_NOTHING();
176 }
177
178 pInterruptInstance->FilterResourceRequirements(pIoDesc);
179 }
180 else {
181
182 //
183 // We will advance to next interrupt object if the desc is not an alternate
184 // descriptor. For non PCI devices, the first LBI interrupt desc can't be an
185 // alternate descriptor.
186 //
187 if ((pIoDesc->Option & IO_RESOURCE_ALTERNATIVE) == 0) {
188 pIntListEntryForLBI = pIntListEntryForLBI->Flink;
189 }
190
191 //
192 // An LBI can be first alternate resource if there are preceding MSI(X) descriptors
193 // listed in the list. In that case, this descriptor is the alternate interrupt resource
194 // for all of the MSI messages. As a result, we will use the first interrupt object from
195 // the list if this ends up being assigned by the system instead of MSI.
196 //
197 if (previousDescMSI) {
199 pIntListEntryForLBI = m_InterruptListHead.Flink;
200 previousDescMSI = FALSE;
201 }
202
203 //
204 // There can be one or more LBI interrupts and each LBI interrupt
205 // could have zero or more alternate descriptors.
206 //
207 if (pIntListEntryForLBI == &m_InterruptListHead) {
210 "Not enough interrupt objects created for LBI by WDFDEVICE 0x%p ",
212 break;
213 }
214
215 pInterruptInstance = CONTAINING_RECORD(pIntListEntryForLBI, FxInterrupt, m_PnpList);
216
217 pInterruptInstance->FilterResourceRequirements(pIoDesc);
218 }
219
220 break;
221
222 default:
223 break;
224 }
225 }
226
227 //
228 // Since the Descriptors is a variable length list, you cannot get to the next
229 // alternate list by doing pIoRequirementList->List[altResListIndex].
230 // Descriptors[descIndex] will now point to the end of the descriptor list.
231 // If there is another alternate list, it would be begin there.
232 //
233 pIoResList = (PIO_RESOURCE_LIST) &pIoResList->Descriptors[descIndex];
234 }
235
236 return STATUS_SUCCESS;
237}
static BOOLEAN _IsMessageInterrupt(__in USHORT ResourceFlags)
VOID FilterResourceRequirements(__inout PIO_RESOURCE_DESCRIPTOR IoResourceDescriptor)
FxIoResList * pIoResList
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
union _IO_RESOURCE_DESCRIPTOR::@2059 u
struct _IO_RESOURCE_DESCRIPTOR::@2059::@2062 Interrupt
IO_RESOURCE_LIST List[1]
Definition: iotypes.h:2747
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
struct _IO_RESOURCE_LIST * PIO_RESOURCE_LIST
#define IO_RESOURCE_ALTERNATIVE

Referenced by FxPkgFdo::PnpFilterResourceRequirements().

◆ FinishInitialize()

VOID FxPkgPnp::FinishInitialize ( __inout PWDFDEVICE_INIT  DeviceInit)
virtual

Definition at line 1240 of file fxpkgpnp.cpp.

1259{
1260 //
1261 // Reassign the state callback arrays away from the init struct.
1262 // Set the init field to NULL so that it does not attempt to free the array
1263 // when it is destroyed.
1264 //
1265 m_PnpStateCallbacks = DeviceInit->PnpPower.PnpStateCallbacks;
1266 DeviceInit->PnpPower.PnpStateCallbacks = NULL;
1267
1268 m_PowerStateCallbacks = DeviceInit->PnpPower.PowerStateCallbacks;
1269 DeviceInit->PnpPower.PowerStateCallbacks = NULL;
1270
1271 m_PowerPolicyStateCallbacks = DeviceInit->PnpPower.PowerPolicyStateCallbacks;
1272 DeviceInit->PnpPower.PowerPolicyStateCallbacks = NULL;
1273
1274 //
1275 // Bias the count towards one so that we can optimize the synchronous
1276 // cleanup case when the device is being destroyed.
1277 //
1279
1280 //
1281 // Now "Add" this device in the terms that the PnP state machine uses. This
1282 // will be in the context of an actual AddDevice function for FDOs, and
1283 // something very much like it for PDOs.
1284 //
1285 // Important that the posting of the event is after setting of the state
1286 // callback arrays so that we can guarantee that any state transition
1287 // callback will be made.
1288 //
1290}
@ PnpEventAddDevice
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113

Referenced by FxDevice::_Create(), and FxPkgPdo::FinishInitialize().

◆ FireAndForgetIrp()

virtual NTSTATUS FxPkgPnp::FireAndForgetIrp ( FxIrp Irp)
pure virtual

Referenced by Dispatch(), and DispatchWaitWake().

◆ GetDispatchPnp()

virtual const PFN_PNP_POWER_CALLBACK * FxPkgPnp::GetDispatchPnp ( VOID  )
protectedpure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

Referenced by Dispatch().

◆ GetDispatchPower()

virtual const PFN_PNP_POWER_CALLBACK * FxPkgPnp::GetDispatchPower ( VOID  )
protectedpure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

Referenced by Dispatch().

◆ GetInterruptObjectCount()

ULONG FxPkgPnp::GetInterruptObjectCount ( VOID  )
inline

Definition at line 3812 of file fxpkgpnp.hpp.

3815 {
3817 }

◆ GetNotPowerPolicyOwnerTableEntry()

static _Must_inspect_result_ CPNOT_POWER_POLICY_OWNER_STATE_TABLE FxPkgPnp::GetNotPowerPolicyOwnerTableEntry ( __in WDF_DEVICE_POWER_POLICY_STATE  State)
inlinestaticprotected

Definition at line 2928 of file fxpkgpnp.hpp.

2931 {
2932 ULONG i;
2933
2934 for (i = 0;
2936 i++) {
2937 if (m_WdfNotPowerPolicyOwnerStates[i].CurrentTargetState == State) {
2939 }
2940 }
2941
2942 return NULL;
2943 }
static const NOT_POWER_POLICY_OWNER_STATE_TABLE m_WdfNotPowerPolicyOwnerStates[]
Definition: fxpkgpnp.hpp:4383
WDF_DEVICE_POWER_POLICY_STATE CurrentTargetState
@ WdfDevStatePwrPolNull
Definition: wdfdevice.h:385

Referenced by NotPowerPolicyOwnerEnterNewState(), and PowerPolicyProcessEventInner().

◆ GetPendingPnpIrp()

MdIrp FxPkgPnp::GetPendingPnpIrp ( VOID  )
inlineprotected

Definition at line 3042 of file fxpkgpnp.hpp.

3045 {
3046 return m_PendingPnPIrp;
3047 }

Referenced by PnpFinishProcessingIrp().

◆ GetPendingSystemPowerIrp()

MdIrp FxPkgPnp::GetPendingSystemPowerIrp ( VOID  )
inlineprotected

Definition at line 3105 of file fxpkgpnp.hpp.

3108 {
3110 }

◆ GetPnpCapsInternal()

LONG FxPkgPnp::GetPnpCapsInternal ( VOID  )
protected

Definition at line 5466 of file fxpkgpnp.cpp.

5483{
5484 LONG caps;
5485 KIRQL irql;
5486
5487 Lock(&irql);
5489 Unlock(irql);
5490
5491 return caps;
5492}
@ FxPnpCapMask
Definition: fxpkgpnp.hpp:327

Referenced by FxPkgFdo::HandleQueryCapabilities(), FxPkgPdo::HandleQueryCapabilities(), FxPkgFdo::HandleQueryCapabilitiesCompletion(), and HandleQueryPnpDeviceState().

◆ GetPnpState()

VOID FxPkgPnp::GetPnpState ( __out PWDF_DEVICE_STATE  State)

Definition at line 5549 of file fxpkgpnp.cpp.

5565{
5566 LONG state;
5567
5569
5571 SET_TRI_STATE_FROM_STATE_BITS(state, State, DontDisplayInUI);
5573 SET_TRI_STATE_FROM_STATE_BITS(state, State, NotDisableable);
5575 SET_TRI_STATE_FROM_STATE_BITS(state, State, ResourcesChanged);
5576}
static int state
Definition: maze.c:121
LONG GetPnpStateInternal(VOID)
Definition: fxpkgpnp.cpp:5433
@ Removed
Definition: fbtusb.h:86
@ Disabled
Definition: mountmgr.h:178
#define SET_TRI_STATE_FROM_STATE_BITS(state, S, FieldName)
Definition: pnppriv.hpp:189
@ Failed
Definition: arc.h:79

◆ GetPnpStateInternal()

LONG FxPkgPnp::GetPnpStateInternal ( VOID  )
protected

Definition at line 5433 of file fxpkgpnp.cpp.

5450{
5451 LONG state;
5452 KIRQL irql;
5453
5454 //
5455 // State is shared with the caps bits. Use a lock to guard against
5456 // corruption of the value between these 2 values
5457 //
5458 Lock(&irql);
5460 Unlock(irql);
5461
5462 return state;
5463}
@ FxPnpStateMask
Definition: fxpkgpnp.hpp:280

Referenced by GetPnpState(), and HandleQueryPnpDeviceState().

◆ GetPnpTableEntry()

static CPPNP_STATE_TABLE FxPkgPnp::GetPnpTableEntry ( __in WDF_DEVICE_PNP_STATE  State)
inlinestaticprotected

Definition at line 2853 of file fxpkgpnp.hpp.

2856 {
2858 }
static const PNP_STATE_TABLE m_WdfPnpStates[]
Definition: fxpkgpnp.hpp:4380
@ WdfDevStatePnpObjectCreated
Definition: wdfdevice.h:64
FORCEINLINE ULONG WdfDevStateNormalize(_In_ ULONG State)
Definition: wdfdevice.h:1225

Referenced by PnpEnterNewState(), and PnpProcessEventInner().

◆ GetPowerPolicyTableEntry()

static CPPOWER_POLICY_STATE_TABLE FxPkgPnp::GetPowerPolicyTableEntry ( __in WDF_DEVICE_POWER_POLICY_STATE  State)
inlinestaticprotected

Definition at line 2871 of file fxpkgpnp.hpp.

2874 {
2876 }
static const POWER_POLICY_STATE_TABLE m_WdfPowerPolicyStates[]
Definition: fxpkgpnp.hpp:4382
@ WdfDevStatePwrPolObjectCreated
Definition: wdfdevice.h:232

Referenced by PowerPolicyEnterNewState(), and PowerPolicyProcessEventInner().

◆ GetPowerTableEntry()

static CPPOWER_STATE_TABLE FxPkgPnp::GetPowerTableEntry ( __in WDF_DEVICE_POWER_STATE  State)
inlinestaticprotected

Definition at line 2862 of file fxpkgpnp.hpp.

2865 {
2867 }
static const POWER_STATE_TABLE m_WdfPowerStates[]
Definition: fxpkgpnp.hpp:4381
@ WdfDevStatePowerObjectCreated
Definition: wdfdevice.h:130

Referenced by PowerEnterNewState(), and PowerProcessEventInner().

◆ GetRawResourceList()

FxCmResList * FxPkgPnp::GetRawResourceList ( VOID  )
inline

Definition at line 3804 of file fxpkgpnp.hpp.

3807 {
3808 return m_ResourcesRaw;
3809 }

◆ GetSystemPowerAction()

POWER_ACTION FxPkgPnp::GetSystemPowerAction ( VOID  )
inline

Definition at line 3768 of file fxpkgpnp.hpp.

3771 {
3773 }
POWER_ACTION
Definition: ntpoapi.h:122

◆ GetTranslatedResourceList()

FxCmResList * FxPkgPnp::GetTranslatedResourceList ( VOID  )
inline

Definition at line 3796 of file fxpkgpnp.hpp.

3799 {
3800 return m_Resources;
3801 }

Referenced by FxDevice::GetTranslatedResources().

◆ GetUsageCount()

LONG FxPkgPnp::GetUsageCount ( __in __range(1, 4) ULONG  Usage)
inlineprotected

◆ HandleQueryBusInformation()

_Must_inspect_result_ NTSTATUS FxPkgPnp::HandleQueryBusInformation ( __inout FxIrp Irp)

Definition at line 947 of file fxpkgpnp.cpp.

950{
952
953 //
954 // Probably is a better check then this to see if the driver set the bus
955 // information
956 //
957 if (m_BusInformation.BusTypeGuid.Data1 != 0x0) {
958 PPNP_BUS_INFORMATION pBusInformation;
960
964
965 if (pBusInformation != NULL) {
966 //
967 // Initialize the PNP_BUS_INFORMATION structure with the data
968 // from PDO properties.
969 //
970 RtlCopyMemory(pBusInformation,
972 sizeof(PNP_BUS_INFORMATION));
973
974 Irp->SetInformation((ULONG_PTR) pBusInformation);
976 }
977 else {
978 Irp->SetInformation(NULL);
980
983 "WDFDEVICE %p could not allocate PNP_BUS_INFORMATION string, "
984 " %!STATUS!", m_Device->GetHandle(), status);
985 }
986 }
987 else {
988 status = Irp->GetStatus();
989 }
990
991 return status;
992}
PNP_BUS_INFORMATION m_BusInformation
Definition: fxpkgpnp.hpp:4232
static __inline PVOID MxAllocatePoolWithTag(__in POOL_TYPE PoolType, __in SIZE_T NumberOfBytes, __in ULONG Tag)
Definition: mxmemorykm.h:30
#define PagedPool
Definition: env_spec_w32.h:308
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
struct _PNP_BUS_INFORMATION * PPNP_BUS_INFORMATION

Referenced by FxPkgPdo::_PnpQueryBusInformation().

◆ HandleQueryBusRelations()

_Must_inspect_result_ NTSTATUS FxPkgPnp::HandleQueryBusRelations ( __inout FxIrp Irp)
protected

Definition at line 758 of file fxpkgpnp.cpp.

775{
777 PDEVICE_RELATIONS pRelations;
779 NTSTATUS status, listStatus;
780 BOOLEAN changed;
781
782 //
783 // Before we do anything, callback into the driver
784 //
786
787 //
788 // Default to success unless list processing fails
789 //
791
792 //
793 // Keep track of changes made by any list object. If anything changes,
794 // remember it for post-processing.
795 //
796 changed = FALSE;
797
798 pRelations = (PDEVICE_RELATIONS) Irp->GetInformation();
799
800 if (m_EnumInfo != NULL) {
802
803 pList->LockForEnum(GetDriverGlobals());
804 }
805 else {
806 pList = NULL;
807 }
808
809 ple = NULL;
810 while (pList != NULL && (ple = pList->GetNextEntry(ple)) != NULL) {
811 FxChildList* pChildList;
812
813 pChildList = FxChildList::_FromEntry(ple);
814
815 //
816 // ProcessBusRelations will free and reallocate pRelations if necessary
817 //
818 listStatus = pChildList->ProcessBusRelations(&pRelations);
819
820 //
821 // STATUS_NOT_SUPPORTED is a special value. It indicates that the call
822 // to ProcessBusRelations did not modify pRelations in any way.
823 //
824 if (listStatus == STATUS_NOT_SUPPORTED) {
825 continue;
826 }
827
828
829 if (!NT_SUCCESS(listStatus)) {
832 "WDFDEVICE %p, WDFCHILDLIST %p returned %!STATUS! from "
833 "processing bus relations",
834 m_Device->GetHandle(), pChildList->GetHandle(), listStatus);
835 status = listStatus;
836 break;
837 }
838
839 //
840 // We updated pRelations, change the status later
841 //
842 changed = TRUE;
843 }
844
845 //
846 // By checking for NT_SUCCESS(status) below we account for
847 // both the cases - list changed, as well as list unchanged but possibly
848 // children being reported missing (that doesn't involve list change).
849 //
850 if (NT_SUCCESS(status)) {
851
852 ple = NULL;
853 while (pList != NULL && (ple = pList->GetNextEntry(ple)) != NULL) {
854 FxChildList* pChildList;
855
856 pChildList = FxChildList::_FromEntry(ple);
857
858 //
859 // invoke the ReportedMissing callback for for children that are
860 // being reporte missing
861 //
862 pChildList->InvokeReportedMissingCallback();
863 }
864 }
865
866 if (pList != NULL) {
867 pList->UnlockFromEnum(GetDriverGlobals());
868 }
869
870 if (NT_SUCCESS(status) && changed == FALSE) {
871 //
872 // Went through the entire list of FxChildList objects, but no object
873 // modified the pRelations, so restore the caller's NTSTATUS.
874 //
875 status = Irp->GetStatus();
876 }
877
878 //
879 // Re-set the relations into the structure so that any changes that any call
880 // to FxChildList::ProcessBusRelations takes effect and is reported.
881 //
882 Irp->SetInformation((ULONG_PTR) pRelations);
883 Irp->SetStatus(status);
884
887 "WDFDEVICE %p, returning %!STATUS! from processing bus relations",
889 );
890
891 if (NT_SUCCESS(status) && pRelations != NULL) {
892 ULONG i;
893
896 "WDFDEVICE %p returning %d devices in relations %p",
897 m_Device->GetHandle(), pRelations->Count, pRelations
898 );
899
900 //
901 // Try to not consume an IFR entry per DO reported. Instead, report up
902 // to 4 at a time.
903 //
904 for (i = 0; i < pRelations->Count && GetDriverGlobals()->FxVerboseOn; i += 4) {
905 if (i + 3 < pRelations->Count) {
908 "PDO %p PDO %p PDO %p PDO %p",
909 pRelations->Objects[i],
910 pRelations->Objects[i+1],
911 pRelations->Objects[i+2],
912 pRelations->Objects[i+3]
913 );
914 }
915 else if (i + 2 < pRelations->Count) {
918 "PDO %p PDO %p PDO %p",
919 pRelations->Objects[i],
920 pRelations->Objects[i+1],
921 pRelations->Objects[i+2]
922 );
923 }
924 else if (i + 1 < pRelations->Count) {
927 "PDO %p PDO %p",
928 pRelations->Objects[i],
929 pRelations->Objects[i+1]
930 );
931 }
932 else {
935 "PDO %p",
936 pRelations->Objects[i]
937 );
938 }
939 }
940 }
941
942 return status;
943}
WDFCHILDLIST GetHandle(VOID)
VOID InvokeReportedMissingCallback(VOID)
_Must_inspect_result_ NTSTATUS ProcessBusRelations(__inout PDEVICE_RELATIONS *DeviceRelations)
FxPnpDeviceRelationsQuery m_DeviceRelationsQuery
Definition: fxpkgpnp.hpp:4549
VOID Invoke(__in WDFDEVICE Device, __in DEVICE_RELATION_TYPE RelationType)
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
BOOLEAN FxVerboseOn
Definition: fxglobals.h:462
@ BusRelations
Definition: iotypes.h:2152
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS

Referenced by FxPkgFdo::PnpQueryDeviceRelations(), and FxPkgPdo::PnpQueryDeviceRelations().

◆ HandleQueryDeviceRelations()

_Must_inspect_result_ NTSTATUS FxPkgPnp::HandleQueryDeviceRelations ( __inout FxIrp Irp,
__inout FxRelatedDeviceList List 
)
protected

Definition at line 996 of file fxpkgpnp.cpp.

1018{
1019 PDEVICE_RELATIONS pPriorRelations, pNewRelations;
1022 ULONG count;
1023 size_t size;
1025 BOOLEAN retry;
1027
1028 if (List == NULL) {
1029 //
1030 // Indicate that we didn't modify the irp at all since we have no list
1031 //
1032 return STATUS_NOT_SUPPORTED;
1033 }
1034
1036 type = Irp->GetParameterQDRType();
1038
1039 //
1040 // Notify driver that he should re-scan for device relations.
1041 //
1043
1044 pPriorRelations = (PDEVICE_RELATIONS) Irp->GetInformation();
1045 retry = FALSE;
1046
1047 count = 0;
1048
1049 List->LockForEnum(pFxDriverGlobals);
1050
1051 //
1052 // Count how many entries there are in the list
1053 //
1054 for (entry = NULL; (entry = List->GetNextEntry(entry)) != NULL; count++) {
1055 DO_NOTHING();
1056 }
1057
1058 //
1059 // If we have
1060 // 1) no devices in the list AND
1061 // a) we have nothing to report OR
1062 // b) we have something to report and there are previous relations (which
1063 // if left unchanged will be used to report our missing devices)
1064 //
1065 // THEN we have nothing else to do, just return
1066 //
1067 if (count == 0 &&
1068 (List->m_NeedReportMissing == 0 || pPriorRelations != NULL)) {
1069 List->UnlockFromEnum(pFxDriverGlobals);
1070 return STATUS_NOT_SUPPORTED;
1071 }
1072
1073 if (pPriorRelations != NULL) {
1074 //
1075 // Looks like another driver in the stack has already added some
1076 // entries. Make sure we allocate space for these additional entries.
1077 //
1078 count += pPriorRelations->Count;
1079 }
1080
1081 //
1082 // Allocate space for the device relations structure (which includes
1083 // space for one PDEVICE_OBJECT, and then allocate enough additional
1084 // space for the extra PDEVICE_OBJECTS we need.
1085 //
1086 // (While no FxChildList objects are used in this function, this static
1087 // function from the class computes what we need.)
1088 //
1090
1093
1094 if (pNewRelations == NULL) {
1095 //
1096 // Dereference any previously reported relations before exiting. They
1097 // are dereferenced here because the PNP manager will see error and not
1098 // do anything while the driver which added these objects expects the
1099 // pnp manager to do the dereference. Since this device is changing the
1100 // status, it must act like the pnp manager.
1101 //
1102 if (pPriorRelations != NULL) {
1103 ULONG i;
1104
1105 for (i = 0; i < pPriorRelations->Count; i++) {
1106 Mx::MxDereferenceObject(pPriorRelations->Objects[i]);
1107 }
1108 }
1109
1110 if (List->IncrementRetries() < 3) {
1111 retry = TRUE;
1112 }
1113
1115
1118 "WDFDEVICE %p could not allocate device relations for type %d string, "
1119 " %!STATUS!", m_Device->GetHandle(), type, status);
1120
1121 goto Done;
1122 }
1123
1124 RtlZeroMemory(pNewRelations, size);
1125
1126 //
1127 // If there was an existing device relations structure, copy
1128 // the entries to the new structure.
1129 //
1130 if (pPriorRelations != NULL && pPriorRelations->Count > 0) {
1132 pNewRelations,
1133 pPriorRelations,
1135 );
1136 }
1137
1138 //
1139 // Walk the list and return the relations here
1140 //
1141 for (entry = NULL;
1142 (entry = List->GetNextEntry(entry)) != NULL;
1143 pNewRelations->Count++) {
1144 MdDeviceObject pdo;
1145
1146 pdo = entry->GetDevice();
1147
1150 }
1151
1152 //
1153 // Add it to the DEVICE_RELATIONS structure. Pnp dictates that each
1154 // PDO in the list be referenced.
1155 //
1156 pNewRelations->Objects[pNewRelations->Count] = reinterpret_cast<PDEVICE_OBJECT>(pdo);
1158 }
1159
1160Done:
1161 if (NT_SUCCESS(status)) {
1162 List->ZeroRetries();
1163 }
1164
1165 List->UnlockFromEnum(GetDriverGlobals());
1166
1167 if (pPriorRelations != NULL) {
1168 MxMemory::MxFreePool(pPriorRelations);
1169 }
1170
1171 if (retry) {
1172 MxDeviceObject physicalDeviceObject(
1174 );
1175
1176 physicalDeviceObject.InvalidateDeviceRelations(type);
1177 }
1178
1179 Irp->SetStatus(status);
1180 Irp->SetInformation((ULONG_PTR) pNewRelations);
1181
1182 return status;
1183}
static size_t _ComputeRelationsSize(__in ULONG Count)
static __inline VOID MxFreePool(__in PVOID Ptr)
Definition: mxmemorykm.h:41
static __inline VOID MxDereferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:247
static __inline VOID MxReferenceObject(__in PVOID Object)
Definition: mxgeneralkm.h:238
@ RelatedDeviceStateNeedsReportPresent
@ RelatedDeviceStateReportedPresent
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
uint32_t entry
Definition: isohybrid.c:63
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE

Referenced by FxPkgFdo::PnpQueryDeviceRelations(), and FxPkgPdo::PnpQueryDeviceRelations().

◆ HandleQueryInterface()

_Must_inspect_result_ NTSTATUS FxPkgPnp::HandleQueryInterface ( __inout FxIrp Irp,
__out PBOOLEAN  CompleteRequest 
)
protected

Definition at line 1493 of file fxpkgpnp.cpp.

1518{
1520 const GUID* pInterfaceType;
1522 FxQueryInterface *pQI;
1523 PVOID pFound;
1524 PINTERFACE pExposedInterface;
1525 PVOID pExposedInterfaceSpecificData;
1526 BOOLEAN sendToParent;
1527
1529
1531
1532 pFound = NULL;
1533 pQI = NULL;
1534 pExposedInterface = NULL;
1535 pExposedInterfaceSpecificData = NULL;
1536 sendToParent = FALSE;
1537
1538 pInterfaceType = Irp->GetParameterQueryInterfaceType();
1539 //
1540 // The power thread is special cased because it has a different semantic
1541 // then the usual QI irp that we expose to the driver writer. In this case,
1542 // we want to fill in the interface if the lower stack does not support it.
1543 //
1544 if (FxIsEqualGuid(pInterfaceType, &GUID_POWER_THREAD_INTERFACE)) {
1546 }
1547 else if (FxIsEqualGuid(pInterfaceType, &GUID_REENUMERATE_SELF_INTERFACE_STANDARD)) {
1548 if (m_Device->IsPdo()) {
1549 return ((FxPkgPdo*) this)->HandleQueryInterfaceForReenumerate(
1551 }
1552 }
1553
1554 status = Irp->GetStatus();
1555
1556 //
1557 // Walk the interface collection and return the appropriate interface.
1558 //
1560
1561 for (ple = m_QueryInterfaceHead.Next; ple != NULL; ple = ple->Next) {
1563
1564 if (FxIsEqualGuid(Irp->GetParameterQueryInterfaceType(),
1565 &pQI->m_InterfaceType)) {
1566
1567 pExposedInterface = Irp->GetParameterQueryInterfaceInterface();
1568 pExposedInterfaceSpecificData =
1569 Irp->GetParameterQueryInterfaceInterfaceSpecificData();
1570
1571 if (pQI->m_Interface != NULL) {
1572 //
1573 // NOTE: If a driver has exposed the same interface GUID with
1574 // different sizes as a ways of versioning, then the driver
1575 // writer can specify the minimum size and version number
1576 // and then fill in the remaining fields in the callback
1577 // below.
1578 //
1579 if (pQI->m_Interface->Size <= Irp->GetParameterQueryInterfaceSize() &&
1580 pQI->m_Interface->Version <= Irp->GetParameterQueryInterfaceVersion()) {
1581
1582 if (pQI->m_ImportInterface == FALSE) {
1583 //
1584 // Expose the interface to the requesting driver.
1585 //
1586 RtlCopyMemory(pExposedInterface,
1587 pQI->m_Interface,
1588 pQI->m_Interface->Size);
1589 }
1590 else {
1591 //
1592 // The interface contains data which the driver wants
1593 // before copying over its information, so don't do a
1594 // copy and let the event callback do the copy
1595 //
1596 DO_NOTHING();
1597 }
1598 }
1599 else {
1601 break;
1602 }
1603 }
1604
1605 callback.m_Method = pQI->m_ProcessRequest.m_Method;
1606 sendToParent = pQI->m_SendQueryToParentStack;
1607 pFound = pQI;
1608
1610 break;
1611 }
1612 }
1613
1615
1616 if (!NT_SUCCESS(status) || pFound == NULL) {
1617 goto Done;
1618 }
1619
1620 //
1621 // Let the driver see the interface before it is handed out.
1622 //
1623 status = callback.Invoke(m_Device->GetHandle(),
1624 (LPGUID) Irp->GetParameterQueryInterfaceType(),
1625 pExposedInterface,
1626 pExposedInterfaceSpecificData);
1627
1628 //
1629 // STATUS_NOT_SUPPORTED is a special cased error code which indicates that
1630 // the QI should travel down the rest of the stack.
1631 //
1633 goto Done;
1634 }
1635
1636 //
1637 // If it is meant for the parent, send it down the parent stack
1638 //
1639 if (sendToParent) {
1641 goto Done;
1642 }
1643
1644 //
1645 // Reference the interface before returning it to the requesting driver.
1646 // If this is an import interface, the event callback is free to not fill
1647 // in the InterfaceReference function pointer.
1648 //
1649 if (pExposedInterface->InterfaceReference != NULL) {
1650 pExposedInterface->InterfaceReference(pExposedInterface->Context);
1651 }
1652
1653 //
1654 // If we are not a PDO in the stack, then send the fully formatted QI request
1655 // down the stack to allow others to filter the interface.
1656 //
1657 if (m_Device->IsPdo() == FALSE) {
1659
1660 Irp->SetStatus(status);
1661 Irp->CopyCurrentIrpStackLocationToNext();
1662 status = Irp->SendIrpSynchronously(m_Device->GetAttachedDevice());
1663 }
1664
1665Done:
1666 if (pFound != NULL) {
1668 }
1669
1670 return status;
1671}
PFN_WDF_DEVICE_PROCESS_QUERY_INTERFACE_REQUEST m_Method
__inline BOOLEAN IsPdo(VOID)
Definition: fxdevice.hpp:1245
_Must_inspect_result_ NTSTATUS HandleQueryInterfaceForPowerThread(__inout FxIrp *Irp, __out PBOOLEAN CompleteRequest)
Definition: fxpkgpnp.cpp:1437
static const GUID GUID_POWER_THREAD_INTERFACE
Definition: fxpkgpnp.hpp:4282
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
_Must_inspect_result_ BOOLEAN __inline FxIsEqualGuid(__in CONST GUID *Lhs, __in CONST GUID *Rhs)
Definition: fxglobals.h:977
_Must_inspect_result_ NTSTATUS PnpPassThroughQI(__in CfxDevice *Device, __inout FxIrp *Irp)
Definition: fxpkgpnp.cpp:1351
static IPrintDialogCallback callback
Definition: printdlg.c:326
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:650
BOOLEAN m_SendQueryToParentStack
FxDeviceProcessQueryInterfaceRequest m_ProcessRequest

Referenced by FxPkgFdo::_PnpQueryInterface().

◆ HandleQueryInterfaceForPowerThread()

_Must_inspect_result_ NTSTATUS FxPkgPnp::HandleQueryInterfaceForPowerThread ( __inout FxIrp Irp,
__out PBOOLEAN  CompleteRequest 
)
private

Definition at line 1437 of file fxpkgpnp.cpp.

1441{
1443
1445
1446 //
1447 // Send the request down the stack first. If someone lower handles it
1448 // or failed trying to, just return their status
1449 //
1451
1453 //
1454 // Success or failure trying to handle it
1455 //
1456 return status;
1457 }
1458
1459 //
1460 // The semantic of this QI is that it sent down while processing start or
1461 // a device usage notification on the way *up* the stack. That means that
1462 // by the time the QI gets to the lower part of the stack, the power thread
1463 // will have already been allocated and exported.
1464 //
1466
1467 if (Irp->GetParameterQueryInterfaceVersion() == 1 &&
1468 Irp->GetParameterQueryInterfaceSize() >=
1470 //
1471 // Expose the interface to the requesting driver.
1472 //
1474
1476
1477 //
1478 // Caller assumes a reference has been taken.
1479 //
1482 );
1483 }
1484 else {
1486 }
1487
1488 return status;
1489}
virtual NTSTATUS SendIrpSynchronously(FxIrp *Irp)=0
VOID CopyQueryInterfaceToIrpStack(__in PPOWER_THREAD_INTERFACE PowerThreadInterface, __in FxIrp *Irp)
Definition: supportkm.cpp:32

Referenced by HandleQueryInterface().

◆ HandleQueryPnpDeviceState()

PNP_DEVICE_STATE FxPkgPnp::HandleQueryPnpDeviceState ( __in PNP_DEVICE_STATE  PnpDeviceState)
protected

Definition at line 662 of file fxpkgpnp.cpp.

683{
684 LONG state;
685
687
688 //
689 // Return device state set by driver.
690 //
691 SET_PNP_DEVICE_STATE_BIT(&PnpDeviceState,
693 state,
694 Disabled);
695 SET_PNP_DEVICE_STATE_BIT(&PnpDeviceState,
697 state,
698 DontDisplayInUI);
699 SET_PNP_DEVICE_STATE_BIT(&PnpDeviceState,
701 state,
702 Failed);
703 SET_PNP_DEVICE_STATE_BIT(&PnpDeviceState,
705 state,
706 NotDisableable);
707 SET_PNP_DEVICE_STATE_BIT(&PnpDeviceState,
709 state,
710 Removed);
711 SET_PNP_DEVICE_STATE_BIT(&PnpDeviceState,
713 state,
714 ResourcesChanged);
715
717 LONG caps;
718
719 //
720 // Mask off all caps except for NoDispalyInUI
721 //
723
724 //
725 // If the driver didn't specify pnp state, see if they specified no
726 // display as a capability. For raw PDOs and just usability, it is not
727 // always clear to the driver writer that they must set both the pnp cap
728 // and the pnp state for the no display in UI property to stick after
729 // the device has been started.
730 //
731 if (caps == FxPnpCapNoDisplayInUITrue) {
732 PnpDeviceState |= PNP_DEVICE_DONT_DISPLAY_IN_UI;
733 }
734 else if (caps == FxPnpCapNoDisplayInUIFalse) {
735 PnpDeviceState &= ~PNP_DEVICE_DONT_DISPLAY_IN_UI;
736 }
737 }
738
739 //
740 // Return device state maintained by frameworks.
741 //
742 if (IsInSpecialUse()) {
743 PnpDeviceState |= PNP_DEVICE_NOT_DISABLEABLE;
744 }
745
746 //
747 // If there is an internal failure, then indicate that up to pnp.
748 //
750 PnpDeviceState |= PNP_DEVICE_FAILED;
751 }
752
753 return PnpDeviceState;
754}
LONG GetPnpCapsInternal(VOID)
Definition: fxpkgpnp.cpp:5466
BOOLEAN IsInSpecialUse(VOID)
Definition: fxpkgpnp.hpp:3170
@ FxPnpStateDontDisplayInUIMask
Definition: fxpkgpnp.hpp:258
@ FxPnpCapNoDisplayInUIMask
Definition: fxpkgpnp.hpp:325
@ FxPnpCapNoDisplayInUITrue
Definition: fxpkgpnp.hpp:323
@ FxPnpCapNoDisplayInUIFalse
Definition: fxpkgpnp.hpp:322
#define SET_PNP_DEVICE_STATE_BIT(State, ExternalState, value, Name)
Definition: pnppriv.hpp:258
#define PNP_DEVICE_NOT_DISABLEABLE
Definition: iotypes.h:1006
#define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED
Definition: iotypes.h:1005
#define PNP_DEVICE_FAILED
Definition: iotypes.h:1003
#define PNP_DEVICE_DONT_DISPLAY_IN_UI
Definition: iotypes.h:1002
#define PNP_DEVICE_DISABLED
Definition: iotypes.h:1001
#define PNP_DEVICE_REMOVED
Definition: iotypes.h:1004

Referenced by FxPkgFdo::HandleQueryPnpDeviceStateCompletion().

◆ HasMultipleInterrupts()

BOOLEAN FxPkgPnp::HasMultipleInterrupts ( VOID  )
inline

Definition at line 4066 of file fxpkgpnp.hpp.

4069 {
4070 return (m_InterruptObjectCount > 1 ? TRUE : FALSE);
4071 }

Referenced by GetDriverInfo().

◆ HasPowerThread()

BOOLEAN FxPkgPnp::HasPowerThread ( VOID  )
inline

◆ Initialize()

_Must_inspect_result_ NTSTATUS FxPkgPnp::Initialize ( __in PWDFDEVICE_INIT  DeviceInit)
virtual

Reimplemented in FxPkgFdo, and FxPkgPdo.

Definition at line 349 of file fxpkgpnp.cpp.

373{
376
378
379 m_ReleaseHardwareAfterDescendantsOnFailure = (DeviceInit->ReleaseHardwareOrderOnFailure ==
381
383 if (!NT_SUCCESS(status)) {
386 "Could not initialize QueryInterfaceLock for "
387 "WDFDEVICE %p, %!STATUS!",
389 return status;
390 }
391
393 if (!NT_SUCCESS(status)) {
396 "Could not initialize DeviceInterfaceLock for "
397 "WDFDEVICE %p, %!STATUS!",
399 return status;
400 }
401
402 //
403 // Initialize preallocated events for UM
404 // (For KM, events allocated on stack are used since event initialization
405 // doesn't fail in KM)
406 //
407#if (FX_CORE_MODE==FX_CORE_USER_MODE)
408
410 if (!NT_SUCCESS(status)) {
413 "Could not initialize cleanup event for "
414 "WDFDEVICE %p, %!STATUS!",
416 return status;
417 }
418
420 if (!NT_SUCCESS(status)) {
423 "Could not initialize remove event for "
424 "WDFDEVICE %p, %!STATUS!",
426 return status;
427 }
428#endif
429
430 if (DeviceInit->IsPwrPolOwner()) {
433
436 }
437
439 if (!NT_SUCCESS(status)) {
440 return status;
441 }
442
443#if (FX_CORE_MODE==FX_CORE_KERNEL_MODE)
445#endif
446 }
447
448 //
449 // we will change the access flags on the object later on when we build up
450 // the list from the wdm resources
451 //
454 m_Device,
457 if (!NT_SUCCESS(status)) {
458 return status;
459 }
460
463 m_Device);
464
465 //
466 // This should never fail
467 //
469 if (!NT_SUCCESS(status)) {
472 return status;
473 }
474
475 m_Resources->ADDREF(this);
476
477 //
478 // we will change the access flags on the object later on when we build up
479 // the list from the wdm resources
480 //
483 m_Device,
486 if (!NT_SUCCESS(status)) {
487 return status;
488 }
489
492 m_Device);
493
494 //
495 // This should never fail
496 //
498 if (!NT_SUCCESS(status)) {
501 return status;
502 }
503
504 m_ResourcesRaw->ADDREF(this);
505
506 status = RegisterCallbacks(&DeviceInit->PnpPower.PnpPowerEventCallbacks);
507 if (!NT_SUCCESS(status)) {
508 return status;
509 }
510
511 if (IsPowerPolicyOwner()) {
512 RegisterPowerPolicyCallbacks(&DeviceInit->PnpPower.PolicyEventCallbacks);
513 }
514
515 return status;
516}
static _Must_inspect_result_ NTSTATUS _CreateAndInit(__in FxCmResList **ResourceList, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in CfxDevice *Device, __in_opt PWDF_OBJECT_ATTRIBUTES ListAttributes, __in UCHAR AccessFlags)
Definition: fxresource.hpp:400
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
VOID RegisterPowerPolicyCallbacks(__in PWDF_POWER_POLICY_EVENT_CALLBACKS Callbacks)
Definition: fxpkgpnp.cpp:2715
FxWaitLockInternal m_DeviceInterfaceLock
Definition: fxpkgpnp.hpp:4124
MxEvent m_RemoveEventUm
Definition: fxpkgpnp.hpp:4305
friend FxPowerPolicyOwnerSettings
Definition: fxpkgpnp.hpp:493
VOID QueryForD3ColdInterface(VOID)
Definition: fxpkgpnpkm.cpp:538
_Must_inspect_result_ NTSTATUS RegisterCallbacks(__in PWDF_PNPPOWER_EVENT_CALLBACKS DispatchTable)
Definition: fxpkgpnp.cpp:2667
CHECK_RETURN_IF_USER_MODE NTSTATUS Initialize()
Definition: fxwaitlock.hpp:235
@ FxResourceNoAccess
Definition: fxresource.hpp:274
_Must_inspect_result_ NTSTATUS Init(VOID)
@ WdfReleaseHardwareOrderOnFailureAfterDescendants
Definition: wdfdevice.h:476
#define WDF_NO_HANDLE
Definition: wdftypes.h:107
#define WDF_NO_OBJECT_ATTRIBUTES
Definition: wdftypes.h:105

Referenced by FxPkgFdo::Initialize(), FxPkgPdo::Initialize(), and FxDevice::PdoInitialize().

◆ IsDefaultReleaseHardwareOrder()

BOOLEAN FxPkgPnp::IsDefaultReleaseHardwareOrder ( VOID  )
inline

Definition at line 4054 of file fxpkgpnp.hpp.

4057 {
4058#if FX_IS_KERNEL_MODE
4060#else
4061 return FALSE;
4062#endif
4063 }
@ WdfReleaseHardwareOrderOnFailureEarly
Definition: wdfdevice.h:475

Referenced by GetDriverInfo().

◆ IsDevicePowerUpIrpPending()

BOOLEAN FxPkgPnp::IsDevicePowerUpIrpPending ( VOID  )
inlineprotected

Definition at line 3113 of file fxpkgpnp.hpp.

3116 {
3119
3120 if (irp.GetIrp() == NULL) {
3121 return FALSE;
3122 }
3123
3125
3126 return (state == PowerDeviceD0 ? TRUE : FALSE);
3127 }
@ PowerDeviceD0
Definition: ntpoapi.h:49

Referenced by SaveState().

◆ IsInSpecialUse()

BOOLEAN FxPkgPnp::IsInSpecialUse ( VOID  )
inlineprotected

Definition at line 3170 of file fxpkgpnp.hpp.

3173 {
3178 return FALSE;
3179 }
3180 else {
3181 return TRUE;
3182 }
3183 }

Referenced by HandleQueryPnpDeviceState(), and SetUsageNotificationFlags().

◆ IsPowerPolicyOwner()

◆ IsPresentPendingPnpIrp()

BOOLEAN FxPkgPnp::IsPresentPendingPnpIrp ( VOID  )
inlineprotected

Definition at line 3004 of file fxpkgpnp.hpp.

3007 {
3008 return (m_PendingPnPIrp != NULL) ? TRUE : FALSE;
3009 }

Referenced by PnpFinishProcessingIrp().

◆ IsS0IdleSystemManaged()

BOOLEAN FxPkgPnp::IsS0IdleSystemManaged ( VOID  )
inline

Definition at line 3645 of file fxpkgpnp.hpp.

3648 {
3649 if (IsPowerPolicyOwner()) {
3651 }
3652 else {
3653 return FALSE;
3654 }
3655 }
IdleTimeoutManagement m_TimeoutMgmt

Referenced by GetDriverInfo().

◆ IsS0IdleUsbSSEnabled()

BOOLEAN FxPkgPnp::IsS0IdleUsbSSEnabled ( VOID  )
inline

Definition at line 3658 of file fxpkgpnp.hpp.

Referenced by GetDriverInfo().

◆ IsS0IdleWakeFromS0Enabled()

BOOLEAN FxPkgPnp::IsS0IdleWakeFromS0Enabled ( VOID  )
inline

Definition at line 3632 of file fxpkgpnp.hpp.

3635 {
3636 if (IsPowerPolicyOwner()) {
3638 }
3639 else {
3640 return FALSE;
3641 }
3642 }

Referenced by GetDriverInfo().

◆ IsSxWakeEnabled()

BOOLEAN FxPkgPnp::IsSxWakeEnabled ( VOID  )
inline

Definition at line 3672 of file fxpkgpnp.hpp.

3675 {
3676 if (IsPowerPolicyOwner()) {
3678 }
3679 else {
3680 return FALSE;
3681 }
3682 }

Referenced by GetDriverInfo().

◆ IsUsageSupported()

BOOLEAN FxPkgPnp::IsUsageSupported ( __in DEVICE_USAGE_NOTIFICATION_TYPE  Usage)
inlineprotected

Definition at line 3130 of file fxpkgpnp.hpp.

3133 {
3134 return m_SpecialSupport[((ULONG)Usage)-1];
3135 }

Referenced by PnpDeviceUsageNotification(), and SaveState().

◆ NotifyResourceObjectsD0()

_Must_inspect_result_ NTSTATUS FxPkgPnp::NotifyResourceObjectsD0 ( __in ULONG  NotifyFlags)
private

Definition at line 6055 of file fxpkgpnp.cpp.

6075{
6076 FxInterrupt* pInterrupt;
6079
6082 ple = ple->Flink) {
6083
6084 //
6085 // Connect the interrupts
6086 //
6087 pInterrupt = CONTAINING_RECORD(ple, FxInterrupt, m_PnpList);
6088
6089 status = pInterrupt->Connect(NotifyFlags);
6090
6091 if (!NT_SUCCESS(status)) {
6093 "WDFINTERRUPT %p failed to connect, %!STATUS!",
6094 pInterrupt->GetHandle(), status);
6095
6096 return status;
6097 }
6098 }
6099
6100 return STATUS_SUCCESS;
6101}
_Must_inspect_result_ NTSTATUS Connect(__in ULONG NotifyFlags)
WDFINTERRUPT GetHandle(VOID)

◆ NotifyResourceObjectsDx()

NTSTATUS FxPkgPnp::NotifyResourceObjectsDx ( __in ULONG  NotifyFlags)
private

Definition at line 6104 of file fxpkgpnp.cpp.

6121{
6122 FxInterrupt* pInterrupt;
6124 NTSTATUS status, finalStatus;
6125
6126 finalStatus = STATUS_SUCCESS;
6127
6128 //
6129 // Disconect in the reverse order in which we connected the interrupts
6130 //
6133 ple = ple->Blink) {
6134
6135 //
6136 // Disconnect interrupts and then tell them that they no longer
6137 // own their resources.
6138 //
6139 pInterrupt = CONTAINING_RECORD(ple, FxInterrupt, m_PnpList);
6140
6141 status = pInterrupt->Disconnect(NotifyFlags);
6142
6143 if (!NT_SUCCESS(status)) {
6144 //
6145 // When we encounter an error we still disconnect the remaining
6146 // interrupts b/c we would just do it later during device tear down
6147 // (might as well do it now).
6148 //
6150 "WDFINTERRUPT %p failed to disconnect, %!STATUS!",
6151 pInterrupt->GetHandle(), status);
6152 //
6153 // Overwriting a previous finalStatus is OK, we'll just report the
6154 // last one
6155 //
6156 finalStatus = status;
6157 }
6158 }
6159
6160 return finalStatus;
6161}
_Must_inspect_result_ NTSTATUS Disconnect(__in ULONG NotifyFlags)
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122

Referenced by DisconnectInterruptNP(), PowerConnectInterruptFailed(), PowerGotoDxIoStopped(), and PowerGotoDxIoStoppedNP().

◆ NotifyResourceobjectsToReleaseResources()

VOID FxPkgPnp::NotifyResourceobjectsToReleaseResources ( VOID  )
private

Definition at line 5990 of file fxpkgpnp.cpp.

6009{
6010 FxInterrupt* interruptInstance;
6011 PLIST_ENTRY intListEntry;
6012
6013 //
6014 // Revoke each of the interrupts.
6015 //
6016
6017 intListEntry = m_InterruptListHead.Flink;
6018
6019 while (intListEntry != &m_InterruptListHead) {
6020
6021 //
6022 // Disconnect interrupts and then tell them that they no longer
6023 // own their resources.
6024 //
6025
6026 interruptInstance = CONTAINING_RECORD(intListEntry, FxInterrupt, m_PnpList);
6027 interruptInstance->RevokeResources();
6028 intListEntry = intListEntry->Flink;
6029 }
6030
6031 //
6032 // Now revoke each of the DMA enablers (only system-mode enablers
6033 // will be affected by this)
6034 //
6035
6036 if (m_DmaEnablerList != NULL) {
6037 FxTransactionedEntry* listEntry;
6038
6040
6041 for (listEntry = m_DmaEnablerList->GetNextEntry(NULL);
6042 listEntry != NULL;
6043 listEntry = m_DmaEnablerList->GetNextEntry(listEntry)) {
6045 (FxDmaEnabler *) listEntry->GetTransactionedObject()
6046 );
6047 }
6048
6050 }
6051}
VOID RevokeResources(VOID)
VOID RevokeDmaEnablerResources(__in FxDmaEnabler *Enabler)
Definition: fxpkgpnpkm.cpp:529
FxObject * GetTransactionedObject(VOID)

Referenced by PnpCleanupForRemove().

◆ NotPowerPolicyOwnerEnterNewState()

VOID FxPkgPnp::NotPowerPolicyOwnerEnterNewState ( __in WDF_DEVICE_POWER_POLICY_STATE  NewState)
protected

Definition at line 270 of file notpowerpolicyownerstatemachine.cpp.

273{
275 WDF_DEVICE_POWER_POLICY_STATE currentState, newState;
277
278 currentState = m_Device->GetDevicePowerPolicyState();
279 newState = NewState;
280
281 while (newState != WdfDevStatePwrPolNull) {
284 "WDFDEVICE 0x%p !devobj 0x%p entering not power policy owner state "
285 "%!WDF_DEVICE_POWER_POLICY_STATE! from "
286 "%!WDF_DEVICE_POWER_POLICY_STATE!", m_Device->GetHandle(),
287 m_Device->GetDeviceObject(), newState, currentState);
288
290 //
291 // Callback for leaving the old state
292 //
293 RtlZeroMemory(&data, sizeof(data));
294
296 data.Data.LeaveState.CurrentState = currentState;
297 data.Data.LeaveState.NewState = newState;
298
302 &data);
303 }
304
307
309 //
310 // Callback for entering the new state
311 //
312 RtlZeroMemory(&data, sizeof(data));
313
315 data.Data.EnterState.CurrentState = currentState;
316 data.Data.EnterState.NewState = newState;
317
321 &data);
322 }
323
325 currentState = newState;
326
328
329 //
330 // Call the state handler, if there is one.
331 //
332 if (entry->StateFunc != NULL) {
333 newState = entry->StateFunc(this);
334 }
335 else {
336 newState = WdfDevStatePwrPolNull;
337 }
338
340 //
341 // Callback for post processing the new state
342 //
343 RtlZeroMemory(&data, sizeof(data));
344
346 data.Data.PostProcessState.CurrentState = currentState;
347
351 &data);
352 }
353 }
354}
__inline VOID SetDevicePowerPolicyState(__in WDF_DEVICE_POWER_POLICY_STATE DeviceState)
Definition: fxdevice.hpp:1191
__inline WDF_DEVICE_POWER_POLICY_STATE GetDevicePowerPolicyState()
Definition: fxdevice.hpp:1165
static _Must_inspect_result_ CPNOT_POWER_POLICY_OWNER_STATE_TABLE GetNotPowerPolicyOwnerTableEntry(__in WDF_DEVICE_POWER_POLICY_STATE State)
Definition: fxpkgpnp.hpp:2928
#define TRACINGPNPPOWERSTATES
Definition: dbgtrace.h:69
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned short USHORT
Definition: pedump.c:61
UCHAR IncrementHistoryIndex(VOID)
FxPowerPolicyMachineStateHistory m_States
VOID Invoke(__in WDF_DEVICE_POWER_POLICY_STATE State, __in WDF_STATE_NOTIFICATION_TYPE Type, __in WDFDEVICE Device, __in PCWDF_DEVICE_POWER_POLICY_NOTIFICATION_DATA NotificationData)
USHORT History[FxPowerPolicyEventQueueDepth]
@ StateNotificationEnterState
Definition: wdfdevice.h:392
@ StateNotificationPostProcessState
Definition: wdfdevice.h:393
@ StateNotificationLeaveState
Definition: wdfdevice.h:394
enum _WDF_DEVICE_POWER_POLICY_STATE WDF_DEVICE_POWER_POLICY_STATE

Referenced by PowerPolicyProcessEventInner().

◆ NotPowerPolOwnerGotoD0()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerGotoD0 ( __inout FxPkgPnp This)
staticprotected

Definition at line 419 of file notpowerpolicyownerstatemachine.cpp.

422{
423 This->PowerProcessEvent(PowerCompleteD0);
425}
@ PowerCompleteD0

◆ NotPowerPolOwnerGotoD0InD0()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerGotoD0InD0 ( __inout FxPkgPnp This)
staticprotected

Definition at line 428 of file notpowerpolicyownerstatemachine.cpp.

431{
432 This->PowerProcessEvent(PowerCompleteD0);
434}

◆ NotPowerPolOwnerGotoDx()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerGotoDx ( __inout FxPkgPnp This)
staticprotected

Definition at line 401 of file notpowerpolicyownerstatemachine.cpp.

404{
405 This->PowerProcessEvent(PowerCompleteDx);
407}
@ PowerCompleteDx

◆ NotPowerPolOwnerGotoDxInDx()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerGotoDxInDx ( __inout FxPkgPnp This)
staticprotected

Definition at line 410 of file notpowerpolicyownerstatemachine.cpp.

413{
414 This->PowerProcessEvent(PowerCompleteDx);
416}

◆ NotPowerPolOwnerRemoved()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerRemoved ( __inout FxPkgPnp This)
staticprotected

Definition at line 571 of file notpowerpolicyownerstatemachine.cpp.

586{
587 //
588 // Since we are not the power policy owner, there is nothing to be done.
589 // Indicate to the PNP state machine that we are ready for removal.
590 //
591 This->PnpProcessEvent(PnpEventPwrPolRemoved);
593}
@ PnpEventPwrPolRemoved

◆ NotPowerPolOwnerStarted()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerStarted ( __inout FxPkgPnp This)
staticprotected

Definition at line 379 of file notpowerpolicyownerstatemachine.cpp.

395{
396 This->PnpProcessEvent(PnpEventPwrPolStarted);
398}
@ PnpEventPwrPolStarted
@ WdfDevStatePwrPolStartingSucceeded
Definition: wdfdevice.h:234

◆ NotPowerPolOwnerStarting()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerStarting ( __inout FxPkgPnp This)
staticprotected

Definition at line 357 of file notpowerpolicyownerstatemachine.cpp.

373{
374 This->PowerProcessEvent(PowerImplicitD0);
376}
@ PowerImplicitD0

◆ NotPowerPolOwnerStartingFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerStartingFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 481 of file notpowerpolicyownerstatemachine.cpp.

497{
498 This->PnpProcessEvent(PnpEventPwrPolStartFailed);
500}
@ PnpEventPwrPolStartFailed

◆ NotPowerPolOwnerStopping()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerStopping ( __inout FxPkgPnp This)
staticprotected

Definition at line 437 of file notpowerpolicyownerstatemachine.cpp.

453{
454 This->PowerProcessEvent(PowerImplicitD3);
456}
@ PowerImplicitD3
@ WdfDevStatePwrPolStoppingWaitingForImplicitPowerDown
Definition: wdfdevice.h:353

◆ NotPowerPolOwnerStoppingFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerStoppingFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 503 of file notpowerpolicyownerstatemachine.cpp.

519{
520 This->PnpProcessEvent(PnpEventPwrPolStopFailed);
522}
@ PnpEventPwrPolStopFailed
@ WdfDevStatePwrPolStopped
Definition: wdfdevice.h:331

◆ NotPowerPolOwnerStoppingPoweringDown()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerStoppingPoweringDown ( __inout FxPkgPnp This)
staticprotected

Definition at line 548 of file notpowerpolicyownerstatemachine.cpp.

565{
566 This->PowerProcessEvent(PowerCompleteDx);
568}

◆ NotPowerPolOwnerStoppingPoweringUp()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerStoppingPoweringUp ( __inout FxPkgPnp This)
staticprotected

Definition at line 525 of file notpowerpolicyownerstatemachine.cpp.

542{
543 This->PowerProcessEvent(PowerCompleteD0);
545}

◆ NotPowerPolOwnerStoppingSendStatus()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::NotPowerPolOwnerStoppingSendStatus ( __inout FxPkgPnp This)
staticprotected

Definition at line 459 of file notpowerpolicyownerstatemachine.cpp.

475{
476 This->PnpProcessEvent(PnpEventPwrPolStopped);
478}
@ PnpEventPwrPolStopped

◆ PnpAssignInterruptsSyncIrql()

VOID FxPkgPnp::PnpAssignInterruptsSyncIrql ( VOID  )
protected

Definition at line 4097 of file pnpstatemachine.cpp.

4118{
4120 FxInterrupt* pInterrupt;
4121
4124 ple = ple->Flink) {
4125
4126 KIRQL syncIrql;
4127
4128 pInterrupt = CONTAINING_RECORD(ple, FxInterrupt, m_PnpList);
4129
4130 syncIrql = pInterrupt->GetResourceIrql();
4131
4132 if (syncIrql == PASSIVE_LEVEL) {
4133 //
4134 // The irql associated with the resources assigned is passive,
4135 // this can happen in the following scenarios:
4136 //
4137 // (1) no resources were assigned. Skip this interrupt b/c it has
4138 // no associated resources. Note: setting the SynchronizeIrql
4139 // to PASSIVE_LEVEL is a no-op.
4140 //
4141 // (2) this interrupt is handled at passive-level.
4142 // Set SynchronizeIrql to passive-level and continue.
4143 //
4144 pInterrupt->SetSyncIrql(PASSIVE_LEVEL);
4145 continue;
4146 }
4147
4148 if (pInterrupt->IsSharedSpinLock() == FALSE) {
4149 //
4150 // If the interrupt spinlock is not shared, it's sync irql is the
4151 // irql assigned to it in the resources.
4152 //
4153 pInterrupt->SetSyncIrql(syncIrql);
4154 }
4155 else if (pInterrupt->IsSyncIrqlSet() == FALSE) {
4156 FxInterrupt* pFwdInterrupt;
4157 PLIST_ENTRY pleFwd;
4158
4159 //
4160 // Find all of the other interrupts which share the lock and compute
4161 // the max sync irql.
4162 //
4163 for (pleFwd = ple->Flink;
4164 pleFwd != &m_InterruptListHead;
4165 pleFwd = pleFwd->Flink) {
4166
4167 pFwdInterrupt = CONTAINING_RECORD(pleFwd, FxInterrupt, m_PnpList);
4168
4169 //
4170 // If the 2 do not share the same lock, they are not in the same
4171 // set.
4172 //
4173 if (pFwdInterrupt->SharesLock(pInterrupt) == FALSE) {
4174 continue;
4175 }
4176
4177 if (pFwdInterrupt->GetResourceIrql() > syncIrql) {
4178 syncIrql = pFwdInterrupt->GetResourceIrql();
4179 }
4180 }
4181
4182 //
4183 // Now that we found the max sync irql, set it for all interrupts in
4184 // the set which share the lock
4185 //
4186 for (pleFwd = ple->Flink;
4187 pleFwd != &m_InterruptListHead;
4188 pleFwd = pleFwd->Flink) {
4189
4190 pFwdInterrupt = CONTAINING_RECORD(pleFwd, FxInterrupt, m_PnpList);
4191
4192 //
4193 // If the 2 do not share the same lock, they are not in the same
4194 // set.
4195 //
4196 if (pFwdInterrupt->SharesLock(pInterrupt) == FALSE) {
4197 continue;
4198 }
4199
4200 pFwdInterrupt->SetSyncIrql(syncIrql);
4201 }
4202
4203 //
4204 // Set the sync irql for the first interrupt in the set. We have set
4205 // the sync irql for all other interrupts in the set.
4206 //
4207 pInterrupt->SetSyncIrql(syncIrql);
4208 }
4209 else {
4210 //
4211 // If IsSyncIrqlSet is TRUE, we already covered this interrupt in a
4212 // previous pass of this loop when we computed the max sync irql for
4213 // an interrupt set.
4214 //
4215 ASSERT(pInterrupt->GetSyncIrql() > PASSIVE_LEVEL);
4216 DO_NOTHING();
4217 }
4218 }
4219}
BOOLEAN IsSyncIrqlSet(VOID)
VOID SetSyncIrql(KIRQL SyncIrql)
BOOLEAN IsSharedSpinLock(VOID)
BOOLEAN SharesLock(FxInterrupt *Interrupt)
KIRQL GetSyncIrql(VOID)
KIRQL GetResourceIrql(VOID)

Referenced by __drv_when().

◆ PnpCheckAndIncrementRestartCount()

BOOLEAN FxPkgPnp::PnpCheckAndIncrementRestartCount ( VOID  )
private

Definition at line 39 of file pnpstatemachinekm.cpp.

57{
60 ULONG disposition = 0;
61
62 DECLARE_CONST_UNICODE_STRING(keyNameRestart, L"Restart");
63
65 if (!NT_SUCCESS(status)) {
66 return FALSE;
67 }
68
69 //
70 // We ask for a volatile key so that upon reboot, the count is purged and we
71 // start a new fresh restart count.
72 //
73 status = FxRegKey::_Create(settings.m_Key,
74 &keyNameRestart,
75 &restart.m_Key,
78 &disposition);
79 if (!NT_SUCCESS(status)) {
80 return FALSE;
81 }
82
84 disposition == REG_CREATED_NEW_KEY);
85}
struct mke2fs_defaults settings[]
void restart(int argc, const char *argv[])
Definition: cmds.c:2115
_Must_inspect_result_ NTSTATUS OpenSettingsKey(__out HANDLE *Key, __in ACCESS_MASK DesiredAccess=STANDARD_RIGHTS_ALL)
Definition: fxdevicekm.cpp:818
BOOLEAN PnpIncrementRestartCountLogic(_In_ HANDLE RestartKey, _In_ BOOLEAN CreatedNewKey)
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
#define L(x)
Definition: ntvdm.h:50
#define DECLARE_CONST_UNICODE_STRING(_variablename, _string)
Definition: wdfcore.h:161

◆ PnpCheckAssumptions()

VOID FxPkgPnp::PnpCheckAssumptions ( VOID  )
private

Definition at line 752 of file pnpstatemachine.cpp.

771{
772 WDFCASSERT(sizeof(FxPnpStateInfo) == sizeof(ULONG));
773
774 WDFCASSERT((sizeof(m_WdfPnpStates)/sizeof(m_WdfPnpStates[0]))
775 ==
777
778 // we assume these are the same length when we update the history index
780 ==
782 sizeof(m_PnpMachine.m_States.History[0])));
783}
FxPnpMachineStateHistory m_States
FxPnpEvent m_Queue[PnpEventQueueDepth]
USHORT History[PnpEventQueueDepth]
#define WDFCASSERT(c)
Definition: wdfassert.h:93
@ WdfDevStatePnpNull
Definition: wdfdevice.h:122

◆ PnpCleanupForRemove()

VOID FxPkgPnp::PnpCleanupForRemove ( __in BOOLEAN  GracefulRemove)
private

Definition at line 2210 of file pnpstatemachine.cpp.

2228{
2229 //
2230 // Disable WMI.
2231 //
2233
2234 //
2235 // Disable any device interfaces.
2236 //
2238
2239 DeleteSymbolicLinkOverload(GracefulRemove);
2240
2241
2242
2243
2244
2245
2246
2247
2248 // Flush/purge top-edge queues
2251 );
2252
2253 //
2254 // Invoke EvtDeviceSelfManagedIoFlush
2255 //
2258 }
2259
2260 //
2261 // Tell all the resource objects that they no longer own anything.
2262 //
2264
2265 //
2266 // Flush persistent state to permanent storage. We do this in the failed
2267 // state for the surprise removed case. By storing the state when we are
2268 // surprise removed, if the stack is reenumerated, it will pick up the saved
2269 // state that was just committed. If the state was saved during remove
2270 // device it can be too late because the new instance of the same device
2271 // could already be up and running and not pick up the saved state.
2272 //
2273 // It is important to save the state before completing the (potentially)
2274 // pended pnp irp. Completing the pnp irp will allow a new instance of the
2275 // device to be enumerated and we want to save state before that happens.
2276 //
2278
2280 //
2281 // Don't care about the return code, just blindly try to complete the
2282 // wake request. The function can handle the case where there is no
2283 // irp to complete.
2284 //
2286 }
2287}
#define SaveState(State)
VOID WmiPkgDeregister(VOID)
Definition: fxdevicekm.cpp:497
FxPkgIo * m_PkgIo
Definition: fxdevice.hpp:669
_Must_inspect_result_ NTSTATUS StopProcessingForPower(__in FxIoStopProcessingForPowerAction Action)
Definition: fxpkgio.cpp:1143
VOID PnpDisableInterfaces(VOID)
virtual VOID DeleteSymbolicLinkOverload(BOOLEAN GracefulRemove)=0
VOID NotifyResourceobjectsToReleaseResources(VOID)
Definition: fxpkgpnp.cpp:5990
BOOLEAN PowerIndicateWaitWakeStatus(__in NTSTATUS WaitWakeStatus)
@ FxIoStopProcessingForPowerPurgeManaged
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136

◆ PnpDeviceUsageNotification()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PnpDeviceUsageNotification ( __inout FxIrp Irp)
protected

Definition at line 3867 of file fxpkgpnp.cpp.

3870{
3872 FxRelatedDevice *pDependent;
3873 FxAutoIrp relatedIrp(NULL), parentIrp(NULL);
3874 MxDeviceObject topOfParentStack;
3877 MxDeviceObject pAttached;
3878 MdIrp pNewIrp;
3880 BOOLEAN inPath, supported;
3881 ULONG oldFlags;
3882 MxAutoWorkItem workItem;
3883
3885 "Entering DeviceUsageNotification handler");
3886
3888
3889 type = Irp->GetParameterUsageNotificationType();
3890 inPath = Irp->GetParameterUsageNotificationInPath();
3891 supported = FALSE;
3892
3895 "type %x, in path %x, can support paging %x, dump file %x, "
3896 "hiber file %x, boot file %x",
3897 type, inPath,
3902
3903
3906 if (inPath) {
3907 if (m_Device->IsFilter()) {
3908 //
3909 // Filters always support usage notifications
3910 //
3911 supported = TRUE;
3912 }
3913 else {
3914 supported = IsUsageSupported(type);
3915 }
3916 }
3917 else {
3918 //
3919 // We always handle notifications where we are out of the path
3920 //
3921 supported = TRUE;
3922 }
3923 }
3924
3925 if (supported == FALSE) {
3927
3930 "Usage type %x not supported, %!STATUS!", type, status);
3931
3932 return CompletePnpRequest(Irp, status);
3933 }
3934
3935 //
3936 // Usage notification IRP gets forwarded to parent stack or to
3937 // dependent stack. Since in such cases (with deep device tree) the stack
3938 // may run out quickly, ensure there is enough stack, otherwise use a
3939 // workitem.
3940 //
3942 (m_Device->IsPdo() ||
3944
3945 status = workItem.Allocate(m_Device->GetDeviceObject());
3946 if (!NT_SUCCESS(status)) {
3949 "WDFDEVICE %p !devobj %p could not allocate workitem "
3950 "to send usage notification type %d, inpath %d, %!STATUS!",
3953 type, inPath, status);
3954
3955 return CompletePnpRequest(Irp, status);
3956 }
3957 }
3958
3959 //
3960 // Usage notification is supported. Set the flags on the device object
3961 // before processing this any further and save the current flags on the
3962 // device object.
3963 //
3964 oldFlags = SetUsageNotificationFlags(type, inPath);
3965
3966 if (m_Device->IsPdo()) {
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979 topOfParentStack.SetObject(
3981
3982 pNewIrp = FxIrp::AllocateIrp(topOfParentStack.GetStackSize());
3983 if (pNewIrp != NULL) {
3984 parentIrp.SetIrp(pNewIrp);
3985
3986 //
3987 // parentIrp now owns the irp
3988 //
3989 pNewIrp = NULL;
3990
3991 status = SendDeviceUsageNotification(&topOfParentStack,
3992 &parentIrp,
3993 &workItem,
3994 Irp,
3995 FALSE);
3996 }
3997 else {
3999
4002 "WDFDEVICE %p could not allocate PIRP for parent !devobj %p to "
4003 "send usage notification type %d, inpath %d, %!STATUS!",
4004 m_Device->GetHandle(), topOfParentStack.GetObject(),
4005 type, inPath, status);
4006 }
4007 topOfParentStack.DereferenceObject();
4008 topOfParentStack.SetObject(NULL);
4009
4010 if (!NT_SUCCESS(status)) {
4012 "Exit %!STATUS!", status);
4013
4014 RevertUsageNotificationFlags(type, inPath, oldFlags);
4015 return CompletePnpRequest(Irp, status);
4016 }
4017 }
4018
4019 maxStack = 0;
4020 pDependent = NULL;
4021
4022 //
4023 // If the driver supports the given special file, lets notify dependent
4024 // stacks.
4025 //
4026
4027 //
4028 // LockForEnum will lock out new changes to the list until we unlock the list.
4029 // We remain at passive level once we are locked.
4030 //
4032 //
4033 // We capture the m_UsageDependentDeviceList pointer value so that we
4034 // always use the same pointer value and that we have matched actions
4035 // (lock for enum / unlock from enum). What we are trying to avoid is
4036 // this:
4037 // 1) we do not lock for enum because m_UsageDependentDeviceList == NULL
4038 // 2) in the middle of this function, m_UsageDependentDeviceList is
4039 // assigned a pointer value
4040 // 3) we try to unlock from enum later (or iterate, thinking the enum
4041 // lock is held) by checking m_UsageDependentDeviceList for NULL, and
4042 // now that is != NULL, use it.
4043 //
4044 // By capturing the pointer now, we either have a list or not and we don't
4045 // hit situations 2 or 3. So, the rule is every subseqeunt time we need
4046 // to check if there is valid m_UsageDependentDeviceList pointer, we
4047 // use pList, but when we use the list, we can use m_UsageDependentDeviceList
4048 // directly.
4049 //
4051
4053
4054 while ((pDependent = m_UsageDependentDeviceList->GetNextEntry(pDependent)) != NULL) {
4055
4056 MxDeviceObject deviceObject(pDependent->GetDevice());
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4071
4072 if (pAttached.GetStackSize() > maxStack) {
4073 maxStack = pAttached.GetStackSize();
4074 }
4075
4076 pAttached.DereferenceObject();
4077 }
4078 }
4079 else {
4080 pList = NULL;
4081 }
4082
4083 if (maxStack > 0) {
4084 //
4085 // If we have a maxStack size, we have a list as well
4086 //
4088
4089 //
4090 // Allocate one irp for all the stacks so that we don't have an
4091 // allocation later. This way, once we have the irp, we can send the
4092 // usage notification to all stacks reliably, as well as the reverting
4093 // of the notification if we encounter failure.
4094 //
4095 pNewIrp = FxIrp::AllocateIrp(maxStack);
4096 if (pNewIrp == NULL) {
4098
4101 "WDFDEVICE %p could not allocate IRP to send usage notifications"
4102 " to related stacks, type %d, inpath %d, status %!STATUS!",
4103 m_Device->GetHandle(), type, inPath, status);
4104 }
4105 else {
4106 MxDeviceObject dependentDevice;
4107
4108 //
4109 // relatedIrp will free the irp when it goes out of scope
4110 //
4111 relatedIrp.SetIrp(pNewIrp);
4112
4113 //
4114 // Walk our collection of dependent device stacks, and notify
4115 // each stack of the device notification. If any fail, notify
4116 // the stacks who already were told of the reverted behavior.
4117 //
4118 pDependent = NULL;
4119 while ((pDependent = m_UsageDependentDeviceList->GetNextEntry(pDependent)) != NULL) {
4120 dependentDevice.SetObject(pDependent->GetDevice());
4121 status = SendDeviceUsageNotification(&dependentDevice,
4122 &relatedIrp,
4123 &workItem,
4124 Irp,
4125 FALSE);
4126
4127 if (!NT_SUCCESS(status)) {
4128 FxRelatedDevice* pDependent2;
4129
4130 pDependent2 = NULL;
4131
4132 //
4133 // A device failed the device usage notification request.
4134 // Notify the stacks that didn't fail, so they can unwind
4135 // the operation.
4136 //
4137 while ((pDependent2 = m_UsageDependentDeviceList->GetNextEntry(pDependent2)) != NULL &&
4138 pDependent2 != pDependent) {
4139 dependentDevice.SetObject(pDependent2->GetDevice());
4140
4141 //
4142 // We're already in a failure path. We can't do anything
4143 // about yet another failure. So we ignore the return
4144 // value.
4145 //
4146 (void) SendDeviceUsageNotification(&dependentDevice,
4147 &relatedIrp,
4148 &workItem,
4149 Irp,
4150 TRUE);
4151 }
4152
4153 //
4154 // Now break out of our outter loop.
4155 //
4156 break;
4157 }
4158 }
4159 }
4160 }
4161
4162 //
4163 // If we are successful to this point, then send the IRP down the
4164 // stack.
4165 //
4166 if (NT_SUCCESS(status)) {
4167 BOOLEAN referenceSucceeded, sendDown;
4168
4169 referenceSucceeded = FALSE;
4170 sendDown = TRUE;
4171
4172 //
4173 // Make sure the stack is in D0 before sending down the request. This
4174 // will at least guarantee that all devices below this one are in D0
4175 // when the make the transition from power pageable to non or vice versa.
4176 //
4177 if (IsPowerPolicyOwner()) {
4179
4180 if (NT_SUCCESS(status)) {
4181 referenceSucceeded = TRUE;
4182 }
4183 else {
4184 Irp->SetStatus(status);
4185 sendDown = FALSE;
4186 }
4187 }
4188
4189 if (sendDown) {
4190 //
4191 // If we supported the usage, set the status to success, otherwise we
4192 // keep the status in the irp as it arrived to this device
4193 //
4194 if (supported) {
4195 Irp->SetStatus(status);
4196 }
4198 }
4199
4200 //
4201 // Transitioning from a thread which was power pagable to non power
4202 // pagable. We now need a power thread for the stack, ask for it.
4203 // Note that there is no need for power thread in case of "boot"
4204 // notification since boot notification doesn't require clearing device's
4205 // DO_POWER_PAGABLE flag (power thread is required when handling power
4206 // irp at dispatch level which can happen if the DO_POWER_PAGABLE flag
4207 // is cleared).
4208 //
4209 // NOTE: Once we have a power thread, we never go back to using work
4210 // items even though the stack may revert to power pagable.
4211 // This is an acceptable tradeoff between resource usage and
4212 // WDF complexity.
4213 //
4214 //
4215 if (NT_SUCCESS(status) &&
4216 inPath &&
4217 (HasPowerThread() == FALSE) &&
4219 ) {
4221
4222 if (!NT_SUCCESS(status)) {
4223 //
4224 // Keep status the same through out so we can set it back in
4225 // the irp when we are done.
4226 //
4227 if (m_Device->IsPdo()) {
4228 //
4229 // need to revert our parent's stack
4230 //
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243 topOfParentStack.SetObject(
4245
4246 //
4247 // Ignore the status because we can't do anything on failure
4248 //
4249 (void) SendDeviceUsageNotification(&topOfParentStack,
4250 &parentIrp,
4251 &workItem,
4252 Irp,
4253 TRUE);
4254
4255 topOfParentStack.DereferenceObject();
4256 }
4257 else {
4258 //
4259 // Notify the stack below us
4260 //
4261 Irp->CopyCurrentIrpStackLocationToNext();
4262 Irp->SetParameterUsageNotificationInPath(FALSE);
4263
4264 //
4265 // Required for pnp irps
4266 //
4267 Irp->SetStatus(STATUS_NOT_SUPPORTED);
4268
4269 //
4270 // Ignore the status because we can't do anything on failure
4271 //
4272 (void) Irp->SendIrpSynchronously(m_Device->GetAttachedDevice());
4273 }
4274
4275 Irp->SetStatus(status);
4276 }
4277 }
4278
4279 //
4280 // Now check whether the lower devices succeeded or failed. If they
4281 // failed, back out our changes and propogate the failure.
4282 //
4283 if (!NT_SUCCESS(status)) {
4284 //
4285 // Revert the flags set on the device object.
4286 //
4287 RevertUsageNotificationFlags(type, inPath, oldFlags);
4288
4289 //
4290 // Notify dependent stacks of the failure.
4291 //
4292 pDependent = NULL;
4293
4294 //
4295 // See pList initiatilazation as to why we compare pList for != NULL
4296 // and not m_UsageDependentDeviceList.
4297 //
4298 if (pList != NULL) {
4299 MxDeviceObject dependentDevice;
4300
4301 while ((pDependent = m_UsageDependentDeviceList->GetNextEntry(pDependent)) != NULL) {
4302 dependentDevice.SetObject(pDependent->GetDevice());
4303
4304 //
4305 // We're already in a failure path. We can't do anything
4306 // about yet another failure. So we ignore the return value.
4307 //
4308 (void) SendDeviceUsageNotification(&dependentDevice,
4309 &relatedIrp,
4310 &workItem,
4311 Irp,
4312 TRUE);
4313 }
4314 }
4315 }
4316
4317 //
4318 // By this point, we have propagated the notification to dependent devices
4319 // and lower stack, and if anyone failed during that time, we also
4320 // propagated failure to dependent stacks and lower stack.
4321 // If status is success at this point, invoke the driver's callback.
4322 //
4323 if (NT_SUCCESS(status)) {
4324 //
4325 // Invoke callback. Note that only one of the callbacks
4326 // DeviceUsageNotification or DeviceUsgeNotificationEx will get
4327 // invoked since only one of the callbacks at a time is supported.
4328 // We ensured that during registration of the callback.
4329 // Note that Ex callback will return success if driver did not
4330 // supply any callback.
4331 //
4334 inPath);
4335
4339 inPath
4340 );
4341
4342 if (!NT_SUCCESS(status)) {
4343 //
4344 // Driver's callback returned failure. We need to propagate
4345 // failure to lower stack and dependent stacks.
4346 //
4347 //
4348 // Keep status the same through out so we can set it back in
4349 // the irp when we are done.
4350 //
4351 if (m_Device->IsPdo()) {
4352 //
4353 // need to revert our parent's stack
4354 //
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367 topOfParentStack.SetObject(
4369
4370 //
4371 // Ignore the status because we can't do anything on failure
4372 //
4373 (void) SendDeviceUsageNotification(&topOfParentStack,
4374 &parentIrp,
4375 &workItem,
4376 Irp,
4377 TRUE);
4378
4379 topOfParentStack.DereferenceObject();
4380 }
4381 else {
4382 //
4383 // Notify the stack below us
4384 //
4385 Irp->CopyCurrentIrpStackLocationToNext();
4386 Irp->SetParameterUsageNotificationInPath(FALSE);
4387
4388 //
4389 // Required for pnp irps
4390 //
4391 Irp->SetStatus(STATUS_NOT_SUPPORTED);
4392
4393 //
4394 // Ignore the status because we can't do anything on failure
4395 //
4396 (void) Irp->SendIrpSynchronously(m_Device->GetAttachedDevice());
4397 }
4398
4399 Irp->SetStatus(status);
4400
4401 //
4402 // Revert the flags set on the device object.
4403 //
4404 RevertUsageNotificationFlags(type, inPath, oldFlags);
4405
4406 //
4407 // Notify dependent stacks of the failure.
4408 //
4409 pDependent = NULL;
4410
4411 //
4412 // See pList initiatilazation as to why we compare pList for != NULL
4413 // and not m_UsageDependentDeviceList.
4414 //
4415 if (pList != NULL) {
4416 MxDeviceObject dependentDevice;
4417
4418 while ((pDependent = m_UsageDependentDeviceList->GetNextEntry(pDependent)) != NULL) {
4419 dependentDevice.SetObject(pDependent->GetDevice());
4420
4421 //
4422 // We're already in a failure path. We can't do anything
4423 // about yet another failure. So we ignore the return value.
4424 //
4425 (void) SendDeviceUsageNotification(&dependentDevice,
4426 &relatedIrp,
4427 &workItem,
4428 Irp,
4429 TRUE);
4430 }
4431 }
4432 }
4433
4434 if (NT_SUCCESS(status)) {
4435
4436 CommitUsageNotification(type, oldFlags);
4437
4438 //
4439 // If we are in the dump file path, we cannot idle out because we
4440 // can experience a crash dump at any time.
4441 //
4443 //
4444 // Add a reference everytime we are notified of being in the
4445 // path, no need to match the first inPath notification and the
4446 // last !inPath notification.
4447 //
4448 if (inPath) {
4449 NTSTATUS refStatus;
4450
4452
4453 //
4454 // Since our previous synchronous power reference succeeded,
4455 // an addtional reference while we are powered up should
4456 // never fail.
4457 //
4458 refStatus = PowerReference(FALSE);
4459#if DBG
4460 ASSERT(NT_SUCCESS(refStatus));
4461#else
4462 UNREFERENCED_PARAMETER(refStatus);
4463#endif
4464 }
4465 else {
4466 ASSERT(GetUsageCount(type) >= 0);
4468 }
4469 }
4470 }
4471 }
4472
4473 //
4474 // We no longer need to be in D0 if we don't have to be.
4475 //
4476 if (referenceSucceeded) {
4479 }
4480 }
4481
4482 //
4483 // See pList initiatilazation as to why we compare pList for != NULL
4484 // and not m_UsageDependentDeviceList.
4485 //
4486 if (pList != NULL) {
4488 }
4489
4491 "Exit %!STATUS!", status);
4492
4493 return CompletePnpRequest(Irp, status);
4494}
CfxDevice * m_ParentDevice
Definition: fxdevice.hpp:569
__inline BOOLEAN IsFilter()
Definition: fxdevice.hpp:1408
static _Must_inspect_result_ MdIrp AllocateIrp(_In_ CCHAR StackSize, _In_opt_ FxDevice *Device=NULL)
Definition: fxirpum.cpp:1089
static WDF_SPECIAL_FILE_TYPE _UsageToSpecialType(__in DEVICE_USAGE_NOTIFICATION_TYPE Type)
Definition: fxpkgpnp.hpp:3202
FxPnpDeviceUsageNotificationEx m_DeviceUsageNotificationEx
Definition: fxpkgpnp.hpp:4548
_Must_inspect_result_ NTSTATUS __inline PowerReference(__in BOOLEAN WaitForD0, __in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxpkgpnp.hpp:3486
ULONG SetUsageNotificationFlags(__in DEVICE_USAGE_NOTIFICATION_TYPE Type, __in BOOLEAN InPath)
Definition: fxpkgpnp.cpp:4497
BOOLEAN IsUsageSupported(__in DEVICE_USAGE_NOTIFICATION_TYPE Usage)
Definition: fxpkgpnp.hpp:3130
static DEVICE_USAGE_NOTIFICATION_TYPE _SpecialTypeToUsage(__in WDF_SPECIAL_FILE_TYPE Type)
Definition: fxpkgpnp.hpp:3187
VOID CommitUsageNotification(__in DEVICE_USAGE_NOTIFICATION_TYPE Type, __in ULONG OldFlags)
Definition: fxpkgpnp.cpp:4614
VOID __inline PowerDereference(__in_opt PVOID Tag=NULL, __in_opt LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxpkgpnp.hpp:3498
FxPnpDeviceUsageNotification m_DeviceUsageNotification
Definition: fxpkgpnp.hpp:4547
VOID RevertUsageNotificationFlags(__in DEVICE_USAGE_NOTIFICATION_TYPE Type, __in BOOLEAN InPath, __in ULONG OldFlags)
Definition: fxpkgpnp.cpp:4578
NTSTATUS CompletePnpRequest(__inout FxIrp *Irp, __in NTSTATUS Status)
Definition: fxpkgpnp.cpp:5752
_Must_inspect_result_ NTSTATUS Invoke(__in WDFDEVICE Device, __in WDF_SPECIAL_FILE_TYPE NotificationType, __in BOOLEAN InPath)
VOID Invoke(__in WDFDEVICE Device, __in WDF_SPECIAL_FILE_TYPE NotificationType, __in BOOLEAN InPath)
MdDeviceObject GetDevice(VOID)
__inline VOID SetObject(__in_opt MdDeviceObject DeviceObject)
CCHAR GetStackSize(VOID)
VOID DereferenceObject()
__inline MdDeviceObject GetObject(VOID)
MdDeviceObject GetAttachedDeviceReference(VOID)
_Must_inspect_result_ __inline NTSTATUS Allocate(__in MdDeviceObject DeviceObject, __in_opt PVOID ThreadPoolEnv=NULL)
Definition: mxworkitemkm.h:41
static __inline BOOLEAN MxHasEnoughRemainingThreadStack(VOID)
Definition: mxgeneralkm.h:298
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
MxDeviceObject deviceObject
#define maxStack
Definition: rtf.h:1090
_Must_inspect_result_ NTSTATUS SendDeviceUsageNotification(__in MxDeviceObject *RelatedDevice, __inout FxIrp *RelatedIrp, __in MxWorkItem *Workitem, __in FxIrp *OriginalIrp, __in BOOLEAN Revert)
Definition: supportkm.cpp:220
char CCHAR
Definition: typedefs.h:51
@ WdfSpecialFileMax
Definition: wdfdevice.h:446
enum _DEVICE_USAGE_NOTIFICATION_TYPE DEVICE_USAGE_NOTIFICATION_TYPE

◆ PnpDisableInterfaces()

VOID FxPkgPnp::PnpDisableInterfaces ( VOID  )
protected

Definition at line 3822 of file pnpstatemachine.cpp.

3837{
3839
3841
3843
3844 for (ple = m_DeviceInterfaceHead.Next; ple != NULL; ple = ple->Next) {
3845
3849 }
3850
3852}
VOID SetState(__in BOOLEAN State)
FxDeviceInterface * pDeviceInterface

Referenced by PnpCleanupForRemove().

◆ PnpEnableInterfacesAndRegisterWmi()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PnpEnableInterfacesAndRegisterWmi ( VOID  )
protected

Definition at line 3412 of file pnpstatemachine.cpp.

3427{
3430
3432
3433 //
3434 // Enable any device interfaces.
3435 //
3437
3439
3440 for (ple = m_DeviceInterfaceHead.Next; ple != NULL; ple = ple->Next) {
3442
3444
3445
3446
3447
3448
3449
3450#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
3451 //
3452 // By this time, the device interface, no matter what the WDFDEVICE role
3453 // will have been registered.
3454 //
3456#endif
3458
3460 }
3461
3463
3464 if (NT_SUCCESS(status)) {
3466 }
3467
3468 if (!NT_SUCCESS(status)) {
3471 }
3472
3473 return status;
3474}
UNICODE_STRING m_SymbolicLinkName
NTSTATUS WmiPkgRegister(VOID)
Definition: fxdevicekm.cpp:488

◆ PnpEnterNewState()

VOID FxPkgPnp::PnpEnterNewState ( __in WDF_DEVICE_PNP_STATE  State)
protected

Definition at line 1156 of file pnpstatemachine.cpp.

1172{
1174 WDF_DEVICE_PNP_STATE currentState, newState;
1176
1177 currentState = m_Device->GetDevicePnpState();
1178 newState = State;
1179
1180 while (newState != WdfDevStatePnpNull) {
1183 "WDFDEVICE 0x%p !devobj 0x%p entering PnP State "
1184 "%!WDF_DEVICE_PNP_STATE! from %!WDF_DEVICE_PNP_STATE!",
1187 newState,
1188 currentState);
1189
1190 if (m_PnpStateCallbacks != NULL) {
1191 //
1192 // Callback for leaving the old state
1193 //
1194 RtlZeroMemory(&data, sizeof(data));
1195
1197 data.Data.LeaveState.CurrentState = currentState;
1198 data.Data.LeaveState.NewState = newState;
1199
1200 m_PnpStateCallbacks->Invoke(currentState,
1203 &data);
1204 }
1205
1207 (USHORT) newState;
1208
1209 if (m_PnpStateCallbacks != NULL) {
1210 //
1211 // Callback for entering the new state
1212 //
1213 RtlZeroMemory(&data, sizeof(data));
1214
1216 data.Data.EnterState.CurrentState = currentState;
1217 data.Data.EnterState.NewState = newState;
1218
1219 m_PnpStateCallbacks->Invoke(newState,
1222 &data);
1223 }
1224
1225 m_Device->SetDevicePnpState(newState);
1226 currentState = newState;
1227
1228 entry = GetPnpTableEntry(currentState);
1229
1230 //
1231 // Call the state handler if one is present and record our new state
1232 //
1233 if (entry->StateFunc != NULL) {
1234 newState = entry->StateFunc(this);
1235
1236 //
1237 // Validate the return value if FX_STATE_MACHINE_VERIFY is enabled
1238 //
1239 VALIDATE_PNP_STATE(currentState, newState);
1240 }
1241 else {
1242 newState = WdfDevStatePnpNull;
1243 }
1244
1245 if (m_PnpStateCallbacks != NULL) {
1246 //
1247 // Callback for post processing the new state
1248 //
1249 RtlZeroMemory(&data, sizeof(data));
1250
1252 data.Data.PostProcessState.CurrentState = currentState;
1253
1254 m_PnpStateCallbacks->Invoke(currentState,
1257 &data);
1258 }
1259 }
1260}
__inline VOID SetDevicePnpState(__in WDF_DEVICE_PNP_STATE DeviceState)
Definition: fxdevice.hpp:1173
static CPPNP_STATE_TABLE GetPnpTableEntry(__in WDF_DEVICE_PNP_STATE State)
Definition: fxpkgpnp.hpp:2853
#define VALIDATE_PNP_STATE(_CurrentState, _NewState)
VOID Invoke(__in WDF_DEVICE_PNP_STATE State, __in WDF_STATE_NOTIFICATION_TYPE Type, __in WDFDEVICE Device, __in PCWDF_DEVICE_PNP_NOTIFICATION_DATA NotificationData)
enum _WDF_DEVICE_PNP_STATE WDF_DEVICE_PNP_STATE

Referenced by PnpProcessEventInner().

◆ PnpEventCheckForDevicePresence()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventCheckForDevicePresence ( __inout FxPkgPnp This)
staticprotected

Definition at line 1263 of file pnpstatemachine.cpp.

1282{
1283 return This->PnpEventCheckForDevicePresenceOverload();
1284}

◆ PnpEventCheckForDevicePresenceOverload()

virtual WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventCheckForDevicePresenceOverload ( VOID  )
protectedpure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

◆ PnpEventEjectHardware()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventEjectHardware ( __inout FxPkgPnp This)
staticprotected

Definition at line 1287 of file pnpstatemachine.cpp.

1306{
1307 return This->PnpEventEjectHardwareOverload();
1308}

◆ PnpEventEjectHardwareOverload()

virtual WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventEjectHardwareOverload ( VOID  )
protectedpure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

◆ PnpEventEnableInterfaces()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventEnableInterfaces ( __inout FxPkgPnp This)
staticprotected

Definition at line 1458 of file pnpstatemachine.cpp.

1478{
1480
1481 status = This->PnpEnableInterfacesAndRegisterWmi();
1482
1483 if (!NT_SUCCESS(status)) {
1484 //
1485 // Upon failure, PnpEnableInterfacesAndRegisterWmi already marked the
1486 // irp as failed and recorded an internal error.
1487 //
1488 // FailedPowerDown will gracefully tear down the stack and bring it out
1489 // of D0.
1490 //
1492 }
1493
1494 return WdfDevStatePnpStarted;
1495}
@ WdfDevStatePnpStarted
Definition: wdfdevice.h:89
@ WdfDevStatePnpFailedPowerDown
Definition: wdfdevice.h:104

◆ PnpEventFailed()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 2875 of file pnpstatemachine.cpp.

2892{
2893 This->PnpCleanupForRemove(FALSE);
2894
2895 //
2896 // Tell the power policy state machine to prepare for device removal
2897 //
2898 This->PnpPowerPolicyRemove();
2899
2900 return WdfDevStatePnpNull;
2901}

◆ PnpEventFailedInit()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventFailedInit ( __inout FxPkgPnp This)
staticprotected

Definition at line 3042 of file pnpstatemachine.cpp.

3057{
3058 //
3059 // Release the power thread that we may have previously acquired in
3060 // HardwareAvailable.
3061 //
3062 This->ReleasePowerThread();
3063
3064 //
3065 // Deref the reenumeration interface
3066 //
3067 This->ReleaseReenumerationInterface();
3068
3069 This->PnpFinishProcessingIrp();
3070
3071 return WdfDevStatePnpInit;
3072}

◆ PnpEventFailedIoStarting()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventFailedIoStarting ( __inout FxPkgPnp This)
staticprotected

Definition at line 2824 of file pnpstatemachine.cpp.

2841{
2842 This->PnpPowerPolicySurpriseRemove();
2843
2844 return WdfDevStatePnpNull;
2845}

◆ PnpEventFailedOwnHardware()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventFailedOwnHardware ( __inout FxPkgPnp This)
staticprotected

Definition at line 2848 of file pnpstatemachine.cpp.

2865{
2866 //
2867 // Invoke EvtDeviceReleaseHardware
2868 //
2869 (void) This->PnpReleaseHardware();
2870
2871 return WdfDevStatePnpFailed;
2872}
@ WdfDevStatePnpFailed
Definition: wdfdevice.h:107

◆ PnpEventFailedPowerDown()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventFailedPowerDown ( __inout FxPkgPnp This)
staticprotected

Definition at line 2788 of file pnpstatemachine.cpp.

2812{
2813 //
2814 // Normal stop so that the power state machine will go through the power off
2815 // path and not skip directly to off like it would if we sent it a surprise
2816 // remove notification.
2817 //
2818 This->PnpPowerPolicyStop();
2819
2820 return WdfDevStatePnpNull;
2821}

◆ PnpEventFailedPowerPolicyRemoved()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventFailedPowerPolicyRemoved ( __inout FxPkgPnp This)
staticprotected

Definition at line 2904 of file pnpstatemachine.cpp.

2920{
2921 //
2922 // Finish processing any pended PnP IRP. Since we can reach this state from
2923 // states where a pnp irp was *not* pended, we do not require a pnp irp to
2924 // have been pended when trying to complete it.
2925 //
2926 This->PnpFinishProcessingIrp(FALSE);
2927
2928 //
2929 // Request reenumeration if the client driver asked for it or if there was
2930 // an internal failure *and* if the client driver didn't specify failure...
2931 // AND if we have not yet exceeded our restart count within a period of time.
2932 //
2933 if ((This->m_FailedAction == WdfDeviceFailedAttemptRestart ||
2934 (This->m_FailedAction == WdfDeviceFailedUndefined && This->m_InternalFailure))
2935 &&
2936 This->PnpCheckAndIncrementRestartCount()) {
2937 //
2938 // No need to invalidate state because we are in a state waiting for
2939 // a remove device anyways so failure is imminent.
2940 //
2941 This->AskParentToRemoveAndReenumerate();
2942 }
2943
2944 if (This->m_FailedAction != WdfDeviceFailedUndefined || This->m_InternalFailure) {
2945 //
2946 // If the failure occurred in this device, then tear down the stack if
2947 // we are in a state in which pnp thinks we are started. If we are
2948 // already in a stopped state, this invalidation will do no harm.
2949 //
2950 MxDeviceObject physicalDeviceObject(
2951 This->m_Device->GetPhysicalDevice()
2952 );
2953
2954 //
2955 // We need to pass FDO as a parameter as UMDF currently doesn't have
2956 // PDOs and instead needs FDO to invalidate device state.
2957 //
2958 physicalDeviceObject.InvalidateDeviceState(
2959 This->m_Device->GetDeviceObject() //FDO
2960 );
2961 }
2962
2964}
@ WdfDevStatePnpFailedWaitForRemove
Definition: wdfdevice.h:110
@ WdfDeviceFailedAttemptRestart
Definition: wdfdevice.h:469

◆ PnpEventFailedStarted()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventFailedStarted ( __inout FxPkgPnp This)
staticprotected

Definition at line 3014 of file pnpstatemachine.cpp.

3031{
3032 //
3033 // Complete the pended start irp with error
3034 //
3035 This->SetPendingPnpIrpStatus(STATUS_INVALID_DEVICE_STATE);
3036 This->PnpFinishProcessingIrp();
3037
3039}

◆ PnpEventFailedSurpriseRemoved()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventFailedSurpriseRemoved ( __inout FxPkgPnp This)
staticprotected

Definition at line 2967 of file pnpstatemachine.cpp.

2988{
2989 //
2990 // Invoke EvtDeviceSurpriseRemove
2991 //
2992 This->m_DeviceSurpriseRemoval.Invoke(This->m_Device->GetHandle());
2993
2994 //
2995 // Call the overloaded surprise remove handler
2996 //
2997 This->PnpEventSurpriseRemovePendingOverload();
2998
2999 //
3000 // The surprise remove irp was pended, complete it now. The irp need not
3001 // be present. If we failed before the surprise irp was sent and the irp
3002 // arrived in the middle of processing the failure, we could have completed
3003 // the s.r. irp in FailedWaitForRemove, which is OK.
3004 //
3005 This->PnpFinishProcessingIrp(FALSE);
3006
3007 //
3008 // Return back to the failed state where will wait for remove
3009 //
3011}

◆ PnpEventFdoRemoved()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventFdoRemoved ( __inout FxPkgPnp This)
staticprotected

Definition at line 2709 of file pnpstatemachine.cpp.

2724{
2725 return This->PnpEventFdoRemovedOverload();
2726}

◆ PnpEventFdoRemovedOverload()

virtual WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventFdoRemovedOverload ( VOID  )
protectedpure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

◆ PnpEventFinal()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventFinal ( __inout FxPkgPnp This)
staticprotected

Definition at line 3325 of file pnpstatemachine.cpp.

3341{
3343
3344 //
3345 // We may not have a pnp irp at this stage (esp for PDO which are in the
3346 // removed state and whose parent is being removed) so we use the function
3347 // pointer as the unique tag.
3348 //
3349 // IoReleaseRemoveLockAndWait requires an outstanding reference to release,
3350 // so acquire it before calling it if we are in the case where the PDO is
3351 // being removed with no outstanding PNP remove irp b/c the parent is being
3352 // removed.
3353 //
3354 if (This->m_DeviceRemoveProcessed == NULL) {
3356 This->m_Device->GetRemoveLock(),
3358
3361 }
3362
3363 //
3364 // Indicate to the parent device that we are removed now (vs the destructor
3365 // of the object where we would never reach because in the case of the PDO
3366 // being removed b/c the parent is going away, the parent has a reference
3367 // on the PDO).
3368
3369
3370
3371
3372
3373
3374
3375 if (This->m_Device->m_ParentWaitingOnChild) {
3376 (This->m_Device->m_ParentDevice->m_PkgPnp)->ChildRemoved();
3377 }
3378
3379
3380 if (This->m_DeviceRemoveProcessed == NULL) {
3381 //
3382 // We can get into this state w/out an event to set when a PDO (this
3383 // device) is in the removed state and then the parent is removed.
3384 //
3385
3386 //
3387 // After this is called, any irp dispatched to FxDevice::DispatchWithLock
3388 // will fail with STATUS_INVALID_DEVICE_REQUEST.
3389 //
3391 This->m_Device->GetRemoveLock(),
3393
3394 //
3395 // Delete the object when we exit the state machine. Dispose was run
3396 // early in a previous state.
3397 //
3398 This->m_PnpMachine.SetDelayedDeletion();
3399 }
3400 else {
3401 //
3402 // The thread which received the pnp remove irp will delete the device
3403 //
3404 This->m_SetDeviceRemoveProcessed = TRUE;
3405 }
3406
3407 return WdfDevStatePnpNull;
3408}
VOID ChildRemoved(VOID)
Definition: fxpkgpnp.hpp:3415
static WDF_DEVICE_PNP_STATE PnpEventFinal(__inout FxPkgPnp *This)
static __inline VOID MxReleaseRemoveLockAndWait(__in MdRemoveLock RemoveLock, __in PVOID Tag)
Definition: mxgeneralkm.h:288

Referenced by PnpEventFinal().

◆ PnpEventHardwareAvailable()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventHardwareAvailable ( __inout FxPkgPnp This)
staticprotected

Definition at line 1365 of file pnpstatemachine.cpp.

1381{
1383 BOOLEAN matched;
1384
1386 matched = FALSE;
1387
1388 This->QueryForReenumerationInterface();
1389
1390 status = This->CreatePowerThreadIfNeeded();
1391
1392 if (NT_SUCCESS(status)) {
1393 status = This->PnpPrepareHardware(&matched);
1394 }
1395
1396 if (!NT_SUCCESS(status)) {
1397 if (matched == FALSE) {
1398 //
1399 // NOTE: consider going to WdfDevStatePnpFailed instead of yet
1400 // another failed state out of start device handling.
1401 //
1402
1403 //
1404 // We can handle remove out of the init state, revert back to that
1405 // state.
1406 //
1408 }
1409 else {
1410 //
1411 // EvtDevicePrepareHardware is what failed, goto a state where we
1412 // undo that call.
1413 //
1415 }
1416 }
1417
1418 //
1419 // We only query for the capabilities for the power policy owner because
1420 // we use the capabilities to determine the right Dx state when we want to
1421 // wake from S0 or Sx. Since only the power policy owner can enable wake
1422 // behavior, only the owner needs to query for the information.
1423 //
1424 // ALSO, if we are a filter, there are issues in stacks wrt pnp reentrancy.
1425
1426
1427
1428
1429
1430
1431
1432 //
1433 if (This->IsPowerPolicyOwner()) {
1434 //
1435 // Query the stack for capabilities before telling the stack hw is
1436 // available
1437 //
1438 status = This->QueryForCapabilities();
1439
1440 if (!NT_SUCCESS(status)) {
1442 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
1443 "could not query caps for stack, %!STATUS!", status);
1444
1445 This->SetPendingPnpIrpStatus(status);
1447 }
1448
1449 This->m_CapsQueried = TRUE;
1450 }
1451
1452 This->PnpPowerPolicyStart();
1453
1454 return WdfDevStatePnpNull;
1455}
@ WdfDevStatePnpFailedOwnHardware
Definition: wdfdevice.h:106
@ WdfDevStatePnpFailedInit
Definition: wdfdevice.h:111

◆ PnpEventHardwareAvailablePowerPolicyFailed()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventHardwareAvailablePowerPolicyFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 1498 of file pnpstatemachine.cpp.

1516{
1517 This->SetPendingPnpIrpStatus(STATUS_DEVICE_POWER_FAILURE);
1518
1520}
#define STATUS_DEVICE_POWER_FAILURE
Definition: ntstatus.h:394

◆ PnpEventInitQueryRemove()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventInitQueryRemove ( __inout FxPkgPnp This)
staticprotected

Definition at line 2659 of file pnpstatemachine.cpp.

2674{
2675 FxIrp irp(This->ClearPendingPnpIrp());
2676
2678 This->FireAndForgetIrp(&irp);
2679
2680 return WdfDevStatePnpNull;
2681}
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457

◆ PnpEventInitQueryRemoveCanceled()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventInitQueryRemoveCanceled ( __inout FxPkgPnp This)
staticprotected

Definition at line 2684 of file pnpstatemachine.cpp.

2700{
2701 FxIrp irp(This->ClearPendingPnpIrp());
2702
2703 This->FireAndForgetIrp(&irp);
2704
2705 return WdfDevStatePnpInit;
2706}

◆ PnpEventInitStarting()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventInitStarting ( __inout FxPkgPnp This)
staticprotected

Definition at line 1311 of file pnpstatemachine.cpp.

1327{
1328 if (This->PnpSendStartDeviceDownTheStackOverload() == FALSE) {
1329 //
1330 // Start was sent asynchronously down the stack, the irp's completion
1331 // routine will move the state machine to the new state.
1332 //
1333 return WdfDevStatePnpNull;
1334 }
1335
1337}
@ WdfDevStatePnpHardwareAvailable
Definition: wdfdevice.h:72

◆ PnpEventInitSurpriseRemoved()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventInitSurpriseRemoved ( __inout FxPkgPnp This)
staticprotected

Definition at line 1340 of file pnpstatemachine.cpp.

1358{
1359 This->PnpFinishProcessingIrp(TRUE);
1360
1361 return WdfDevStatePnpInit;
1362}

◆ PnpEventPdoInitFailed()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventPdoInitFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 3075 of file pnpstatemachine.cpp.

3090{
3091 COVERAGE_TRAP();
3092
3093
3094 This->m_Device->EarlyDispose();
3095
3096 //
3097 // All the children are in the disposed state, destroy them all. m_Device
3098 // is not destroyed in this call.
3099 //
3100
3101 This->m_Device->DestroyChildren();
3102
3103 return WdfDevStatePnpFinal;
3104}
#define COVERAGE_TRAP()
Definition: fxmacros.hpp:246
@ WdfDevStatePnpFinal
Definition: wdfdevice.h:117

◆ PnpEventPdoRemoved()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventPdoRemoved ( __inout FxPkgPnp This)
staticprotected

Definition at line 2127 of file pnpstatemachine.cpp.

2143{
2144 return This->PnpEventPdoRemovedOverload();
2145}

◆ PnpEventPdoRemovedOverload()

virtual WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventPdoRemovedOverload ( VOID  )
protectedpure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

◆ PnpEventPdoRestart()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventPdoRestart ( __inout FxPkgPnp This)
staticprotected

Definition at line 3227 of file pnpstatemachine.cpp.

3243{
3244 //
3245 // Since this is a PDO and it is being restarted, it could have had an internal
3246 // failure during its previous start. Since we use m_InternalFailure to set
3247 // PNP_DEVICE_FAILED when handling IRP_MN_QUERY_PNP_DEVICE_STATE, it should
3248 // be set to FALSE so we don't immediately fail the device after the start
3249 // has been succeeded.
3250 //
3251 This->m_InternalFailure = FALSE;
3252 This->m_Failed = FALSE;
3253
3254 //
3255 // The PDO is being restarted and could have previous had a power thread
3256 // running. If so, the reference count goes to zero when removed from a
3257 // started state. Reset back to 1.
3258 //
3259 This->m_PowerThreadInterfaceReferenceCount = 1;
3260
3261 //
3262 // The count is decremented on the initial started->removed transition (and
3263 // not subsequent removed -> removed transitiosn). On removed -> restarted,
3264 // we need to set the count back to a bias of 1 so when we process the remove
3265 // again we can know if there are any pending child (of this PDO) removals
3266 // that we must wait for.
3267 //
3268 This->m_PendingChildCount = 1;
3269
3270 //
3271 // Reset WMI state
3272 //
3273 // This->m_Device->m_PkgWmi->ResetStateForPdoRestart(); __REACTOS__
3274
3275
3276 This->m_Device->m_PkgIo->ResetStateForRestart();
3277
3278 if (This->IsPowerPolicyOwner()) {
3279 This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.Reset();
3280 }
3281
3282 //
3283 // Set STATUS_SUCCESS in the irp so that the stack will start smoothly after
3284 // we have powered up.
3285 //
3286 This->SetPendingPnpIrpStatus(STATUS_SUCCESS);
3287
3288 //
3289 // This flag is set on the wake-enabled device powering down path,
3290 // but if the device power down failed it may not have been cleared.
3291 //
3292 This->m_WakeInterruptsKeepConnected = FALSE;
3293
3294
3295 //
3296 // This flag is cleared so we can reacquire the start time and state
3297 //
3298 This->m_AchievedStart = FALSE;
3299
3301}

◆ PnpEventQueriedRemoving()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventQueriedRemoving ( __inout FxPkgPnp This)
staticprotected

Definition at line 1743 of file pnpstatemachine.cpp.

1758{
1759 //
1760 // It is important to stop power policy before releasing the reference.
1761 // If the reference was released first, we could get into a situation where
1762 // we immediately go idle and then we must send a D0 irp when in the remove.
1763 // If there are devices on top of this device and we send a D0 irp during
1764 // remove processing, the upper devices will be sent an irp after getting a
1765 // pnp remove (and either crash or fail the power irp upon receiving it).
1766 //
1767 This->PnpPowerPolicyStop();
1768 This->PnpPowerDereferenceSelf();
1769
1770 return WdfDevStatePnpNull;
1771}

◆ PnpEventQueriedSurpriseRemove()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventQueriedSurpriseRemove ( __inout FxPkgPnp This)
staticprotected

Definition at line 2729 of file pnpstatemachine.cpp.

2745{
2746 COVERAGE_TRAP();
2747
2748 This->PnpPowerDereferenceSelf();
2749
2751}
@ WdfDevStatePnpSurpriseRemoveIoStarted
Definition: wdfdevice.h:103

◆ PnpEventQueryCanceled()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventQueryCanceled ( __inout FxPkgPnp This)
staticprotected

Definition at line 2060 of file pnpstatemachine.cpp.

2076{
2077 This->PnpPowerDereferenceSelf();
2078
2079 return WdfDevStatePnpStarted;
2080}

◆ PnpEventQueryRemoveAskDriver()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventQueryRemoveAskDriver ( __inout FxPkgPnp This)
staticprotected

Definition at line 1523 of file pnpstatemachine.cpp.

1540{
1543
1544 //
1545 // First, call the driver. If it succeeds, look at whether
1546 // it managed to stop its stuff.
1547 //
1548 status = This->m_DeviceQueryRemove.Invoke(This->m_Device->GetHandle());
1549
1550 if (NT_SUCCESS(status)) {
1551 //
1552 // The driver has stopped all of its self managed io. Proceed to
1553 // stop everything before passing the request down the stack.
1554 //
1556 }
1557 else {
1558 //
1559 // The callback didn't manage to stop. Go back to the Started state
1560 // where we will complete the pended pnp irp
1561 //
1563 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
1564 "EvtDeviceQueryRemove failed, %!STATUS!", status);
1565
1568 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
1569 "EvtDeviceQueryRemove returned an invalid status "
1570 "STATUS_NOT_SUPPORTED");
1571
1572 if (This->GetDriverGlobals()->IsVerificationEnabled(1, 11, OkForDownLevel)) {
1573 FxVerifierDbgBreakPoint(This->GetDriverGlobals());
1574 }
1575 }
1576
1578 }
1579
1580 This->SetPendingPnpIrpStatus(status);
1581
1582 return state;
1583}
FxVerifierDbgBreakPoint(pFxDriverGlobals)
@ OkForDownLevel
Definition: fxglobals.h:80
@ WdfDevStatePnpQueryRemoveEnsureDeviceAwake
Definition: wdfdevice.h:119

◆ PnpEventQueryRemoveEnsureDeviceAwake()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventQueryRemoveEnsureDeviceAwake ( __inout FxPkgPnp This)
staticprotected

Definition at line 1586 of file pnpstatemachine.cpp.

1600{
1603
1604 //
1605 // Make sure that the device is powered on before we send the query remove
1606 // on its way. If we do this after we send the query remove, we could race
1607 // with the remove which removes the reference and we want the device
1608 // powered on when processing remove.
1609 //
1610 status = This->PnpPowerReferenceDuringQueryPnp();
1611 if (STATUS_PENDING == status) {
1612 //
1613 // Device is transitioning to D0. The Pnp state machine will wait in
1614 // the current state until the transition is complete
1615 //
1617 }
1618 else if (NT_SUCCESS(status)) {
1619 //
1620 // Already in D0
1621 //
1623 }
1624 else {
1626 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
1627 "StopIdle on WDFDEVICE %p failed, %!STATUS!, failing query remove",
1628 This->m_Device->GetHandle(), status);
1629
1630 This->SetPendingPnpIrpStatus(status);
1631
1632 //
1633 // The Started state will complete the irp when it sees the failure
1634 // status set on the irp.
1635 //
1637 }
1638
1639 return state;
1640}
@ WdfDevStatePnpQueryRemovePending
Definition: wdfdevice.h:76

◆ PnpEventQueryRemovePending()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventQueryRemovePending ( __inout FxPkgPnp This)
staticprotected

Definition at line 1643 of file pnpstatemachine.cpp.

1659{
1660 FxIrp irp;
1661
1662 irp.SetIrp(This->ClearPendingPnpIrp());
1663 (void) This->FireAndForgetIrp(&irp);
1664 return WdfDevStatePnpNull;
1665}
MdIrp SetIrp(MdIrp irp)
Definition: fxirpkm.hpp:71

◆ PnpEventQueryRemoveStaticCheck()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventQueryRemoveStaticCheck ( __inout FxPkgPnp This)
staticprotected

Definition at line 1668 of file pnpstatemachine.cpp.

1688{
1690 BOOLEAN completeQuery;
1691
1692 completeQuery = TRUE;
1693
1694 if (This->m_DeviceStopCount != 0) {
1696 This->GetDriverGlobals(), TRACE_LEVEL_INFORMATION, TRACINGPNP,
1697 "Failing QueryRemoveDevice because the driver "
1698 "has indicated that it cannot be stopped, count %d",
1699 This->m_DeviceStopCount);
1700
1702 }
1703 else if (This->IsInSpecialUse()) {
1705 This->GetDriverGlobals(), TRACE_LEVEL_INFORMATION, TRACINGPNP,
1706 "Failing QueryRemoveDevice due to open special file counts "
1707 "(paging %d, hiber %d, dump %d, boot %d)",
1708 This->GetUsageCount(WdfSpecialFilePaging),
1709 This->GetUsageCount(WdfSpecialFileHibernation),
1710 This->GetUsageCount(WdfSpecialFileDump),
1711 This->GetUsageCount(WdfSpecialFileBoot));
1712
1714 }
1715 else {
1716 //
1717 // Go on to next state in the "remove" progression.
1718 //
1719 completeQuery = FALSE;
1721 }
1722
1723 if (completeQuery) {
1724 //
1725 // Store the status which Started will complete
1726 //
1727 This->SetPendingPnpIrpStatus(status);
1728
1729 //
1730 // Revert to started
1731 //
1732 return WdfDevStatePnpStarted;
1733 }
1734 else {
1735 //
1736 // Wait for the other state machines to stop
1737 //
1739 }
1740}
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:70
@ WdfDevStatePnpQueryRemoveAskDriver
Definition: wdfdevice.h:75

◆ PnpEventQueryStopAskDriver()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventQueryStopAskDriver ( __inout FxPkgPnp This)
staticprotected

Definition at line 1774 of file pnpstatemachine.cpp.

1791{
1794
1795 //
1796 // First, call the driver. If it succeeds, look at whether
1797 // it managed to stop its stuff.
1798 //
1799 status = This->m_DeviceQueryStop.Invoke(This->m_Device->GetHandle());
1800
1801 if (NT_SUCCESS(status)) {
1802 //
1803 // Tell the other state machines to stop
1804 //
1806 }
1807 else {
1809 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
1810 "EvtDeviceQueryStop failed, %!STATUS!", status);
1811
1814 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
1815 "EvtDeviceQueryStop returned an invalid status "
1816 "STATUS_NOT_SUPPORTED");
1817
1818 if (This->GetDriverGlobals()->IsVerificationEnabled(1, 11, OkForDownLevel)) {
1819 FxVerifierDbgBreakPoint(This->GetDriverGlobals());
1820 }
1821 }
1822
1823 //
1824 // The callback didn't manage to stop. Go back to the Started state.
1825 //
1827 }
1828
1829 This->SetPendingPnpIrpStatus(status);
1830
1831 return state;
1832}
@ WdfDevStatePnpQueryStopEnsureDeviceAwake
Definition: wdfdevice.h:120

◆ PnpEventQueryStopEnsureDeviceAwake()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventQueryStopEnsureDeviceAwake ( __inout FxPkgPnp This)
staticprotected

Definition at line 1835 of file pnpstatemachine.cpp.

1849{
1852
1853 //
1854 // Make sure that the device is powered on before we send the query stop
1855 // on its way. If we do this after we send the query stop, we could race
1856 // with the stop and we want the device powered on when processing stop.
1857 //
1858 status = This->PnpPowerReferenceDuringQueryPnp();
1859 if (STATUS_PENDING == status) {
1860 //
1861 // Device is transitioning to D0. The Pnp state machine will wait in
1862 // the current state until the transition is complete
1863 //
1865 }
1866 else if (NT_SUCCESS(status)) {
1867 //
1868 // Already in D0
1869 //
1871 }
1872 else {
1874 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
1875 "StopIdle on WDFDEVICE %p failed, %!STATUS!, failing query stop",
1876 This->m_Device->GetHandle(), status);
1877
1878 This->SetPendingPnpIrpStatus(status);
1879
1880 //
1881 // The Started state will complete the irp when it sees the failure
1882 // status set on the irp.
1883 //
1885 }
1886
1887 return state;
1888}
@ WdfDevStatePnpQueryStopPending
Definition: wdfdevice.h:80

◆ PnpEventQueryStopPending()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventQueryStopPending ( __inout FxPkgPnp This)
staticprotected

Definition at line 1891 of file pnpstatemachine.cpp.

1908{
1909 FxIrp irp;
1910
1911 irp.SetIrp(This->ClearPendingPnpIrp());
1912 (void) This->FireAndForgetIrp(&irp);
1913 return WdfDevStatePnpNull;
1914}

◆ PnpEventQueryStopStaticCheck()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventQueryStopStaticCheck ( __inout FxPkgPnp This)
staticprotected

Definition at line 1917 of file pnpstatemachine.cpp.

1936{
1938 BOOLEAN completeQuery = TRUE;
1939
1940 if (This->m_DeviceStopCount != 0) {
1942 This->GetDriverGlobals(), TRACE_LEVEL_INFORMATION, TRACINGPNP,
1943 "Failing QueryStopDevice because the driver "
1944 "has indicated that it cannot be stopped, count %d",
1945 This->m_DeviceStopCount);
1946
1948 }
1949 else if (This->IsInSpecialUse()) {
1951 This->GetDriverGlobals(), TRACE_LEVEL_INFORMATION, TRACINGPNP,
1952 "Failing QueryStopDevice due to open special file counts (paging %d,"
1953 " hiber %d, dump %d, boot %d)",
1954 This->GetUsageCount(WdfSpecialFilePaging),
1955 This->GetUsageCount(WdfSpecialFileHibernation),
1956 This->GetUsageCount(WdfSpecialFileDump),
1957 This->GetUsageCount(WdfSpecialFileBoot));
1958
1960 }
1961 else {
1962 //
1963 // Go on to next state in the "stop" progression.
1964 //
1966 completeQuery = FALSE;
1967 }
1968
1969 if (completeQuery) {
1970 //
1971 // Set the state which started will complete the request with
1972 //
1973 This->SetPendingPnpIrpStatus(status);
1974
1975 //
1976 // Revert to started
1977 //
1978 return WdfDevStatePnpStarted;
1979 }
1980 else {
1981 //
1982 // Go ask power what the self managed io state is
1983 //
1985 }
1986}
@ WdfDevStatePnpQueryStopAskDriver
Definition: wdfdevice.h:79

◆ PnpEventRemoved()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventRemoved ( __inout FxPkgPnp This)
staticprotected

Definition at line 2083 of file pnpstatemachine.cpp.

2099{
2100 //
2101 // Remove any child PDOs which may still be lingering around. We do
2102 // the cleanup here so that we do it only once for the PDO which is being
2103 // removed (but may stick around) b/c it was not reported as missing.
2104 //
2105 //
2106 // Iterate over all of the reported children
2107 //
2108 This->ChildListNotifyRemove(&This->m_PendingChildCount);
2109
2110 //
2111 // Decrement our bias from when the device was (re)started. If all of the
2112 // children removed themselves synchronously, we just move to the cleanup
2113 // state, otherwise wait for all the children to fully process the remove
2114 // before remove the parent so that ordering of removal between parent and
2115 // child is guaranteed (where the order is that all children are cleaned
2116 // up before the parent is cleaned up).
2117 //
2118 if (InterlockedDecrement(&This->m_PendingChildCount) > 0) {
2120 }
2121 else {
2123 }
2124}
@ WdfDevStatePnpRemovedChildrenRemoved
Definition: wdfdevice.h:118
@ WdfDevStatePnpRemovedWaitForChildren
Definition: wdfdevice.h:101

◆ PnpEventRemovedChildrenRemoved()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventRemovedChildrenRemoved ( __inout FxPkgPnp This)
staticprotected

Definition at line 3304 of file pnpstatemachine.cpp.

3320{
3321 return This->PnpGetPostRemoveState();
3322}

◆ PnpEventRemovedCommonCode()

VOID FxPkgPnp::PnpEventRemovedCommonCode ( VOID  )
protected

Definition at line 1989 of file pnpstatemachine.cpp.

2005{
2006 //
2007 // Purge non power managed queues now
2008 //
2011 );
2012
2015 }
2016
2017 //
2018 // Cleanup WMI *after* EvtDeviceSelfManagedIoCleanup b/c we want to cleanup
2019 // after a well known and documented time. The WMI docs state that you can
2020 // register providers and instances all the way through
2021 // EvtDeviceSelfManagedIoCleanup, so we mark WMI as cleaned up after that
2022 // call.
2023 //
2025
2026 //
2027 // Mark the device as removed.
2028 //
2029 m_PnpStateAndCaps.Value &= ~FxPnpStateRemovedMask;
2031
2032 //
2033 // Now call the driver and tell it to cleanup all its software state.
2034 //
2035 // We do the dispose early here before deleting the object
2036 // since the PNP remove event is the main trigger for
2037 // the Dispose chain in the framework.
2038 //
2039 // (Almost everything in the driver is rooted on the device object)
2040 //
2041
2043
2044 //
2045 // All the children are in the disposed state, destroy them all. m_Device
2046 // is not destroyed in this call.
2047 //
2048
2050
2051 //
2052 // Wait for all children to drain out and cleanup.
2053 //
2054
2056
2057}
FxDisposeList * m_DisposeList
Definition: fxdevice.hpp:466
VOID WmiPkgCleanup(VOID)
Definition: fxdevicekm.cpp:505
VOID WaitForEmpty(VOID)
VOID __inline DestroyChildren(VOID)
Definition: fxobject.hpp:464
BOOLEAN EarlyDispose(VOID)
@ FxIoStopProcessingForPowerPurgeNonManaged
@ FxPnpStateRemovedTrue
Definition: fxpkgpnp.hpp:271

Referenced by FxPkgFdo::PnpEventFdoRemovedOverload(), and FxPkgPdo::PnpEventPdoRemovedOverload().

◆ PnpEventRemovedPdoSurpriseRemoved()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventRemovedPdoSurpriseRemoved ( __inout FxPkgPnp This)
staticprotected

Definition at line 2173 of file pnpstatemachine.cpp.

2189{
2190 //
2191 // Invoke EvtDeviceSurpriseRemove
2192 //
2193 This->m_DeviceSurpriseRemoval.Invoke(This->m_Device->GetHandle());
2194
2195 //
2196 // Call the overloaded surprise remove handler since
2197 // PnpEventSurpriseRemovePendingOverload will not get called
2198 //
2199 This->PnpEventSurpriseRemovePendingOverload();
2200
2201 //
2202 // The surprise remove irp was pended, complete it now
2203 //
2204 This->PnpFinishProcessingIrp();
2205
2207}
@ WdfDevStatePnpRemovedPdoWait
Definition: wdfdevice.h:85

◆ PnpEventRemovedPdoWait()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventRemovedPdoWait ( __inout FxPkgPnp This)
staticprotected

Definition at line 2148 of file pnpstatemachine.cpp.

2164{
2165 if (This->m_DeviceRemoveProcessed != NULL) {
2166 This->m_SetDeviceRemoveProcessed = TRUE;
2167 }
2168
2169 return WdfDevStatePnpNull;
2170}

◆ PnpEventRemovingDisableInterfaces()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventRemovingDisableInterfaces ( __inout FxPkgPnp This)
staticprotected

Definition at line 2290 of file pnpstatemachine.cpp.

2308{
2310
2311 //
2312 // Surprise remove path releases hardware first then disables the interfaces,
2313 // so do the same in the graceful remove path.
2314 //
2315
2316 //
2317 // Call the driver and tell it to unmap resources.
2318 //
2319 status = This->PnpReleaseHardware();
2320 if (!NT_SUCCESS(status)) {
2321 //
2322 // The driver failed to unmap resources. Presumably this means that
2323 // there are now some leaked PTEs. Just log the failure.
2324 //
2326 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
2327 "EvtDeviceReleaseHardware %p failed, %!STATUS!",
2328 This->m_Device->GetHandle(), status);
2329 }
2330
2331 This->PnpCleanupForRemove(TRUE);
2332
2333 //
2334 // Tell the power policy state machine to prepare for device removal
2335 //
2336 This->PnpPowerPolicyRemove();
2337
2338 return WdfDevStatePnpNull;
2339}

◆ PnpEventRestart()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventRestart ( __inout FxPkgPnp This)
staticprotected

Definition at line 3107 of file pnpstatemachine.cpp.

3123{
3124 //
3125 // Stop the power policy machine so that we simulate stopping first
3126 //
3127 This->PnpPowerPolicyStop();
3128
3129 return WdfDevStatePnpNull;
3130}

◆ PnpEventRestartHardwareAvailable()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventRestartHardwareAvailable ( __inout FxPkgPnp This)
staticprotected

Definition at line 3180 of file pnpstatemachine.cpp.

3197{
3199 BOOLEAN matched;
3200
3201 status = This->PnpPrepareHardware(&matched);
3202
3203 if (!NT_SUCCESS(status)) {
3204 if (matched == FALSE) {
3205 //
3206 // Wait for the remove irp to come in
3207 //
3208 COVERAGE_TRAP();
3209 return WdfDevStatePnpFailed;
3210 }
3211 else {
3212 //
3213 // EvtDevicePrepareHardware is what failed, goto a state where we
3214 // undo that call.
3215 //
3216 COVERAGE_TRAP();
3218 }
3219 }
3220
3221 This->PnpPowerPolicyStart();
3222
3223 return WdfDevStatePnpNull;
3224}

◆ PnpEventRestarting()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventRestarting ( __inout FxPkgPnp This)
staticprotected

Definition at line 2441 of file pnpstatemachine.cpp.

2457{
2458 //
2459 // Send an event to the Power Policy State Machine
2460 // telling it to "Start."
2461 //
2462 This->PnpPowerPolicyStart();
2463
2464 return WdfDevStatePnpNull;
2465}

◆ PnpEventRestartReleaseHardware()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventRestartReleaseHardware ( __inout FxPkgPnp This)
staticprotected

Definition at line 3133 of file pnpstatemachine.cpp.

3148{
3150
3151 status = This->PnpReleaseHardware();
3152 if (!NT_SUCCESS(status)) {
3154 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
3155 "EvtDeviceReleaseHardware failed with %!STATUS!", status);
3156
3157 COVERAGE_TRAP();
3158
3159 This->SetInternalFailure();
3160 This->SetPendingPnpIrpStatus(status);
3161
3162 return WdfDevStatePnpFailed;
3163 }
3164
3165 if (This->PnpSendStartDeviceDownTheStackOverload() == FALSE) {
3166 //
3167 // The start irp's completion routine will move the state machine into
3168 // the new state.
3169 //
3170 return WdfDevStatePnpNull;
3171 }
3172
3173 //
3174 // Start happened synchronously. Transition to the new state now.
3175 //
3177}
@ WdfDevStatePnpRestartHardwareAvailable
Definition: wdfdevice.h:115

◆ PnpEventStarted()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventStarted ( __inout FxPkgPnp This)
staticprotected

Definition at line 2342 of file pnpstatemachine.cpp.

2357{
2358
2359 This->m_AchievedStart = TRUE;
2360
2361 //
2362 // Log Telemetry event for the FDO
2363 //
2364 if (This->m_Device->IsPdo() == FALSE) {
2365 This->m_Device->FxLogDeviceStartTelemetryEvent();
2366 }
2367
2368 This->PnpFinishProcessingIrp();
2369
2370 return WdfDevStatePnpNull;
2371}

◆ PnpEventStartedCancelRemove()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventStartedCancelRemove ( __inout FxPkgPnp This)
staticprotected

Definition at line 2396 of file pnpstatemachine.cpp.

2412{
2414
2415 return WdfDevStatePnpStarted;
2416}

◆ PnpEventStartedCancelStop()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventStartedCancelStop ( __inout FxPkgPnp This)
staticprotected

Definition at line 2374 of file pnpstatemachine.cpp.

2390{
2392 return WdfDevStatePnpStarted;
2393}

◆ PnpEventStartedRemoving()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventStartedRemoving ( __inout FxPkgPnp This)
staticprotected

Definition at line 2419 of file pnpstatemachine.cpp.

2434{
2435 This->PnpPowerPolicyStop();
2436
2437 return WdfDevStatePnpNull;
2438}

◆ PnpEventStartedStopping()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventStartedStopping ( __inout FxPkgPnp This)
staticprotected

Definition at line 2595 of file pnpstatemachine.cpp.

2611{
2612 //
2613 // It is important to stop power policy before releasing the reference.
2614 // If the reference was released first, we could get into a situation where
2615 // we immediately go idle and then we must send a D0 irp when in the remove.
2616 // If there are devices on top of this device and we send a D0 irp during
2617 // remove processing, the upper devices will be sent an irp after getting a
2618 // pnp remove (and either crash or fail the power irp upon receiving it).
2619 //
2620 This->PnpPowerPolicyStop();
2621 This->PnpPowerDereferenceSelf();
2622
2623 return WdfDevStatePnpNull;
2624}

◆ PnpEventStartingFromStopped()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventStartingFromStopped ( __inout FxPkgPnp This)
staticprotected

Definition at line 2468 of file pnpstatemachine.cpp.

2485{
2487 BOOLEAN matched;
2488
2489 status = This->PnpPrepareHardware(&matched);
2490
2491 if (!NT_SUCCESS(status)) {
2492 //
2493 // We can handle remove out of the init state, revert back to that state
2494 //
2495 if (matched == FALSE) {
2496 //
2497 // Wait for the remove irp to come in
2498 //
2499 COVERAGE_TRAP();
2500 return WdfDevStatePnpFailed;
2501 }
2502 else {
2503 //
2504 // EvtDevicePrepareHardware is what failed, goto a state where we
2505 // undo that call.
2506 //
2507 COVERAGE_TRAP();
2509 }
2510 }
2511
2513}
@ WdfDevStatePnpRestarting
Definition: wdfdevice.h:88

◆ PnpEventStopped()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventStopped ( __inout FxPkgPnp This)
staticprotected

Definition at line 2516 of file pnpstatemachine.cpp.

2533{
2536
2537 status = This->PnpReleaseHardware();
2538 if (NT_SUCCESS(status)) {
2539 //
2540 // Tell all the resource objects that they no longer own anything.
2541 //
2542 This->NotifyResourceobjectsToReleaseResources();
2543
2545 }
2546 else {
2548 "EvtDeviceReleaseHardware failed - %!STATUS!",
2549 status);
2550 COVERAGE_TRAP();
2551
2552 This->SetInternalFailure();
2554 }
2555
2556 //
2557 // Send the irp on its merry way. This irp (stop device) cannot be failed
2558 // and must always be sent down the stack.
2559 //
2560 This->PnpFinishProcessingIrp();
2561
2562 return state;
2563}

◆ PnpEventStoppedWaitForStartCompletion()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventStoppedWaitForStartCompletion ( __inout FxPkgPnp This)
staticprotected

Definition at line 2566 of file pnpstatemachine.cpp.

2582{
2583 if (This->PnpSendStartDeviceDownTheStackOverload() == FALSE) {
2584 //
2585 // The start irp's completion routine will move the state machine into
2586 // the new state.
2587 //
2588 return WdfDevStatePnpNull;
2589 }
2590
2592}
@ WdfDevStatePnpStartingFromStopped
Definition: wdfdevice.h:93

◆ PnpEventSurpriseRemoved()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventSurpriseRemoved ( __inout FxPkgPnp This)
staticprotected

Definition at line 2627 of file pnpstatemachine.cpp.

2644{
2645 //
2646 // Invoke EvtDeviceSurpriseRemove
2647 //
2648 This->m_DeviceSurpriseRemoval.Invoke(This->m_Device->GetHandle());
2649
2650 //
2651 // Notify the virtual override of the surprise remove.
2652 //
2653 This->PnpEventSurpriseRemovePendingOverload();
2654
2655 return WdfDevStatePnpFailed;
2656}

◆ PnpEventSurpriseRemoveIoStarted()

WDF_DEVICE_PNP_STATE FxPkgPnp::PnpEventSurpriseRemoveIoStarted ( __inout FxPkgPnp This)
staticprotected

Definition at line 2754 of file pnpstatemachine.cpp.

2772{
2773 //
2774 // Invoke EvtDeviceSurpriseRemove
2775 //
2776
2777 This->m_DeviceSurpriseRemoval.Invoke(This->m_Device->GetHandle());
2778
2779 //
2780 // Notify the virtual override of the surprise remove.
2781 //
2782 This->PnpEventSurpriseRemovePendingOverload();
2783
2785}
@ WdfDevStatePnpFailedIoStarting
Definition: wdfdevice.h:105

◆ PnpEventSurpriseRemovePendingOverload()

VOID FxPkgPnp::PnpEventSurpriseRemovePendingOverload ( VOID  )
protectedvirtual

Reimplemented in FxPkgPdo.

Definition at line 3855 of file pnpstatemachine.cpp.

3858{
3859
3860 //
3861 // Mark all of the children as missing because the parent has just been
3862 // removed. Note that this will happen after all of the children have
3863 // already received the surprise remove event. This is OK because the
3864 // reported status is inspected during the remove device event which will
3865 // happen after the parent finishes processing the surprise event.
3866 //
3867 if (m_EnumInfo != NULL) {
3870
3871 ple = NULL;
3874 }
3875
3877 }
3878}
VOID NotifyDeviceSurpriseRemove(VOID)

Referenced by FxPkgPdo::PnpEventSurpriseRemovePendingOverload().

◆ PnpFinishProcessingIrp()

VOID FxPkgPnp::PnpFinishProcessingIrp ( __in BOOLEAN  IrpMustBePresent = TRUE)
protected

Definition at line 3779 of file pnpstatemachine.cpp.

3794{
3795 FxIrp irp;
3796
3797 UNREFERENCED_PARAMETER(IrpMustBePresent);
3798 ASSERT(IrpMustBePresent == FALSE || IsPresentPendingPnpIrp());
3799
3800 //
3801 // Start device is the only request we handle on the way back up the stack.
3802 // Also, if we fail any pnp irps that we are allowed to fail, we just
3803 // complete them.
3804 //
3805 if (IsPresentPendingPnpIrp()) {
3806
3809 ||
3810 !NT_SUCCESS(irp.GetStatus())) {
3811
3814 }
3815 else {
3817 }
3818 }
3819}
NTSTATUS GetStatus()
Definition: fxirpum.cpp:466
BOOLEAN IsPresentPendingPnpIrp(VOID)
Definition: fxpkgpnp.hpp:3004
MdIrp GetPendingPnpIrp(VOID)
Definition: fxpkgpnp.hpp:3042
MdIrp ClearPendingPnpIrp(VOID)
Definition: fxpkgpnp.hpp:3029

Referenced by PnpProcessEventInner().

◆ PnpGetPostRemoveState()

virtual WDF_DEVICE_PNP_STATE FxPkgPnp::PnpGetPostRemoveState ( VOID  )
protectedpure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

◆ PnpIncrementRestartCountLogic()

BOOLEAN FxPkgPnp::PnpIncrementRestartCountLogic ( _In_ HANDLE  RestartKey,
_In_ BOOLEAN  CreatedNewKey 
)
private

Definition at line 4527 of file pnpstatemachine.cpp.

4586{
4588 ULONG count;
4589 LARGE_INTEGER currentTickCount, startTickCount;
4590 BOOLEAN started, writeTick, writeCount, writeStarted;
4591
4595
4596 count = 0;
4597 started = FALSE;
4598 writeTick = FALSE;
4599 writeCount = FALSE;
4600 writeStarted = FALSE;
4601
4602 Mx::MxQueryTickCount(&currentTickCount);
4603
4604 started = m_AchievedStart;
4605 if (started) {
4606 //
4607 // Save the fact the driver started without failing
4608 //
4609 writeStarted = TRUE;
4610 }
4611
4612
4613 //
4614 // If the key was created right now, there is nothing to check, just write out
4615 // the data.
4616 //
4617 if (CreatedNewKey) {
4618 writeTick = TRUE;
4619 writeCount = TRUE;
4620
4621 //
4622 // First restart
4623 //
4624 count = 1;
4625 }
4626 else {
4627 ULONG length, type;
4628
4629 //
4630 // First try to get the start time of when we first attempted a restart
4631 //
4632 status = FxRegKey::_QueryValue(GetDriverGlobals(),
4633 RestartKey,
4634 &valueNameStartTime,
4635 sizeof(startTickCount.QuadPart),
4636 &startTickCount.QuadPart,
4637 &length,
4638 &type);
4639
4640 if (NT_SUCCESS(status) &&
4641 length == sizeof(startTickCount.QuadPart) && type == REG_BINARY) {
4642
4643 //
4644 // Now try to get the last restart count
4645 //
4646 status = FxRegKey::_QueryULong(RestartKey,
4647 &valueNameCount,
4648 &count);
4649
4651 //
4652 // We read the start time, but not the count. Assume there was
4653 // at least one previous restart.
4654 //
4655 count = 1;
4657 }
4658 }
4659
4660 if (NT_SUCCESS(status)) {
4661 if (currentTickCount.QuadPart < startTickCount.QuadPart) {
4662 //
4663 // Somehow the key survived a reboot or the clock overflowed
4664 // and the current time is less then the last time we started
4665 // timing restarts. Either way, just treat this as the first
4666 // time we are restarting.
4667 //
4668 writeTick = TRUE;
4669 writeCount = TRUE;
4670 count = 1;
4671 }
4672 else {
4673 LONGLONG delta;
4674
4675 //
4676 // Compute the difference in time in 100 ns units
4677 //
4678 delta = (currentTickCount.QuadPart - startTickCount.QuadPart) *
4680
4682 //
4683 // We are within the time limit, see if we are within the
4684 // count limit
4685 count++;
4686
4687 //
4688 // The count starts at one, so include the maximum in the
4689 // compare.
4690 //
4692 writeCount = TRUE;
4693 }
4694 else {
4695 //
4696 // Exceeded the restart count, do not attempt to restart
4697 // the device.
4698 //
4700 }
4701 }
4702 else {
4703 if (started == FALSE) {
4705 status = FxRegKey::_QueryValue(GetDriverGlobals(),
4706 RestartKey,
4707 &valueNameStartAchieved,
4708 sizeof(value),
4709 &value,
4710 &length,
4711 &type);
4712 if (!NT_SUCCESS(status) || length != sizeof(value) ||
4713 type != REG_DWORD) {
4714 value = 0;
4715 }
4716 started = value != 0;
4718 }
4719
4720 if (started) {
4721 //
4722 // Exceeded the time limit. This is treated as a reset of
4723 // the time limit, so we will try to restart and reset the
4724 // start time and restart count.
4725 //
4726 writeTick = TRUE;
4727 writeCount = TRUE;
4728 count = 1;
4729
4730 //
4731 // Erase the fact the driver once started and
4732 // make it do it again to get another 5 attempts to
4733 // restart.
4734 //
4735 writeStarted = TRUE;
4736 started = FALSE;
4737 }
4738 else {
4739 //
4740 // Device never started
4741 //
4743 }
4744 }
4745 }
4746 }
4747 }
4748
4749 if (writeTick) {
4750 //
4751 // Write out the time and the count
4752 //
4753 NTSTATUS status2;
4754 status2 = FxRegKey::_SetValue(RestartKey,
4755 (PUNICODE_STRING)&valueNameStartTime,
4756 REG_BINARY,
4757 &currentTickCount.QuadPart,
4758 sizeof(currentTickCount.QuadPart));
4759 //
4760 // Don't let status report success if it was an error prior to _SetValue
4761 //
4762 if(NT_SUCCESS(status)) {
4763 status = status2;
4764 }
4765 }
4766
4767 if (NT_SUCCESS(status) && writeCount) {
4768 status = FxRegKey::_SetValue(RestartKey,
4769 (PUNICODE_STRING)&valueNameCount,
4770 REG_DWORD,
4771 &count,
4772 sizeof(count));
4773 }
4774
4775 if (writeStarted) {
4776 NTSTATUS status2;
4777 DWORD value = started;
4778 status2 = FxRegKey::_SetValue(RestartKey,
4779 (PUNICODE_STRING)&valueNameStartAchieved,
4780 REG_DWORD,
4781 &value,
4782 sizeof(value));
4783 //
4784 // Don't let status report success if it was an error prior to _SetValue
4785 //
4786 if(NT_SUCCESS(status)) {
4787 status = status2;
4788 }
4789 }
4790
4791 return NT_SUCCESS(status) ? TRUE : FALSE;
4792}
static const ULONG m_RestartTimePeriodMaximum
Definition: fxpkgpnp.hpp:4533
static const ULONG m_RestartCountMaximum
Definition: fxpkgpnp.hpp:4539
static __inline VOID MxQueryTickCount(__out PLARGE_INTEGER TickCount)
Definition: mxgeneralkm.h:116
static __inline ULONG MxQueryTimeIncrement()
Definition: mxgeneralkm.h:125
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define REG_BINARY
Definition: nt_native.h:1496
#define RESTART_START_ACHIEVED_NAME
#define RESTART_COUNT_NAME
#define RESTART_START_TIME_NAME
#define REG_DWORD
Definition: sdbapi.c:596
int64_t LONGLONG
Definition: typedefs.h:68
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
LONGLONG QuadPart
Definition: typedefs.h:114
FORCEINLINE LONGLONG WDF_ABS_TIMEOUT_IN_SEC(_In_ ULONGLONG Time)
Definition: wdfcore.h:71

Referenced by PnpCheckAndIncrementRestartCount().

◆ PnpMatchResources()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PnpMatchResources ( VOID  )
protected

Definition at line 3882 of file pnpstatemachine.cpp.

3905{
3906 PCM_RESOURCE_LIST pResourcesRaw;
3907 PCM_RESOURCE_LIST pResourcesTranslated;
3908 FxResourceCm* resCmRaw;
3909 FxResourceCm* resCmTrans;
3910 FxInterrupt* interrupt;
3913 FxCollectionEntry *curRaw, *curTrans, *endTrans;
3914 ULONG messageCount;
3915 FxIrp irp;
3916
3918 "Entering PnpMatchResources");
3919
3920 //
3921 // We must clear these flags before calling into the event handler because
3922 // it might set these states back (which is OK). If we don't clear these
3923 // states and the start succeeds, we would endlessly report that our
3924 // resources have changed and be restarted over and over.
3925 //
3930
3932 pResourcesRaw = irp.GetParameterAllocatedResources();
3933 pResourcesTranslated = irp.GetParameterAllocatedResourcesTranslated();
3934
3936 if (!NT_SUCCESS(status)) {
3939 "Could not allocate raw resource list for WDFDEVICE 0x%p, %!STATUS!",
3941 goto Done;
3942 }
3943
3944 status = m_Resources->BuildFromWdmList(pResourcesTranslated, FxResourceNoAccess);
3945 if (!NT_SUCCESS(status)) {
3948 "Could not allocate translated resource list for WDFDEVICE 0x%p, %!STATUS!",
3950 goto Done;
3951 }
3952
3953 //
3954 // reset the stored information in all interrupts in the rebalance case
3955 //
3958 ple = ple->Flink) {
3959 interrupt = CONTAINING_RECORD(ple, FxInterrupt, m_PnpList);
3960 interrupt->Reset();
3961 }
3962
3963 //
3964 // Now iterate across the resources, looking for ones that correspond
3965 // to objects that we are managing. Tell those objects about the resources
3966 // that were assigned.
3967 //
3969
3970 endTrans = m_Resources->End();
3971
3972 for (curTrans = m_Resources->Start(), curRaw = m_ResourcesRaw->Start();
3973 curTrans != endTrans;
3974 curTrans = curTrans->Next(), curRaw = curRaw->Next()) {
3975
3976 ASSERT(curTrans->m_Object->GetType() == FX_TYPE_RESOURCE_CM);
3978
3979 resCmRaw = (FxResourceCm*) curRaw->m_Object;
3980
3982 //
3983 // We're looking at an interrupt resource.
3984 //
3985 if (ple->Flink == &m_InterruptListHead) {
3986 //
3987 // Oops, there are no more interrupt objects.
3988 //
3991 "Not enough interrupt objects created by WDFDEVICE 0x%p",
3992 m_Device->GetHandle());
3993 break;
3994 }
3995
3996 resCmTrans = (FxResourceCm*) curTrans->m_Object;
3998
3999 messageCount = resCmRaw->m_Descriptor.u.MessageInterrupt.Raw.MessageCount;
4000
4002 &&
4003 (messageCount > 1)) {
4004 ULONG i;
4005 //
4006 // Multi-message MSI 2.2 needs to be handled differently
4007 //
4008 for (i = 0, ple = ple->Flink;
4009 i < messageCount && ple != &m_InterruptListHead;
4010 i++, ple = ple->Flink) {
4011
4012 //
4013 // Get the next interrupt object.
4014 //
4015 interrupt = CONTAINING_RECORD(ple, FxInterrupt, m_PnpList);
4016
4017 //
4018 // Tell the interrupt object what its resources are.
4019 //
4020 interrupt->AssignResources(&resCmRaw->m_Descriptor,
4021 &resCmTrans->m_Descriptor);
4022 }
4023 }
4024 else {
4025 //
4026 // This is either MSI2.2 with 1 message, MSI-X or Line based.
4027 //
4028 ple = ple->Flink;
4029 interrupt = CONTAINING_RECORD(ple, FxInterrupt, m_PnpList);
4030
4031 //
4032 // Tell the interrupt object what its resources are.
4033 //
4034 interrupt->AssignResources(&resCmRaw->m_Descriptor,
4035 &resCmTrans->m_Descriptor);
4036 }
4037 }
4038 }
4039
4040#if FX_IS_KERNEL_MODE
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050 //
4051 // If there are any pended I/Os that were sent to the target
4052 // that were pended in the transition to stop, then this will
4053 // resend them.
4054 //
4055 // ISSUE: This has the potential of I/O completing
4056 // before the driver's start callback has been called...but,
4057 // this is the same as the PDO pending a sent irp and completing
4058 // it when the PDO is restarted before the FDO has a change to
4059 // process the start irp which was still pended below.
4060 //
4061 if (m_Device->IsFilter()) {
4062 //
4063 // If this is a filter device, then copy the FILE_REMOVABLE_MEDIA
4064 // characteristic from the lower device.
4065 //
4066 if (m_Device->GetAttachedDevice()->Characteristics & FILE_REMOVABLE_MEDIA) {
4067 ULONG characteristics;
4068
4069 characteristics =
4070 m_Device->GetDeviceObject()->Characteristics | FILE_REMOVABLE_MEDIA;
4071
4072 m_Device->GetDeviceObject()->Characteristics = characteristics;
4073 }
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4085 }
4086
4087#endif // FX_IS_KERNEL_MODE
4088
4089Done:
4091 "Exiting PnpMatchResources %!STATUS!", status);
4092
4093 return status;
4094}
_Must_inspect_result_ NTSTATUS BuildFromWdmList(__in PCM_RESOURCE_LIST ResourceList, __in UCHAR AccessFlags)
FxObject * m_Object
FxCollectionEntry * Next(VOID)
VOID SetFilterIoType(VOID)
Definition: fxdevice.cpp:1873
VOID Reset(VOID)
VOID AssignResources(__in PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescRaw, __in PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescTrans)
PCM_RESOURCE_LIST GetParameterAllocatedResources()
Definition: fxirpum.cpp:843
PCM_RESOURCE_LIST GetParameterAllocatedResourcesTranslated()
Definition: fxirpum.cpp:877
WDFTYPE GetType(VOID)
Definition: fxobject.hpp:742
CM_PARTIAL_RESOURCE_DESCRIPTOR m_Descriptor
Definition: fxresource.hpp:251
@ FxPnpStateFailedMask
Definition: fxpkgpnp.hpp:263
@ FxPnpStateResourcesChangedMask
Definition: fxpkgpnp.hpp:278
@ FX_TYPE_RESOURCE_CM
Definition: fxtypes.h:70
if(dx< 0)
Definition: linetemp.h:194
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
_Must_inspect_result_ FxCollectionEntry * Start(VOID)
_Must_inspect_result_ FxCollectionEntry * End(VOID)
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@392 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@392::@396 MessageInterrupt

Referenced by __drv_when().

◆ PnpPowerDereferenceSelf()

VOID FxPkgPnp::PnpPowerDereferenceSelf ( VOID  )
private

Definition at line 5382 of file fxpkgpnp.cpp.

5397{
5398 if (IsPowerPolicyOwner()) {
5400 }
5401}

◆ PnpPowerPolicyRemove()

VOID FxPkgPnp::PnpPowerPolicyRemove ( VOID  )
protected

Definition at line 3759 of file pnpstatemachine.cpp.

◆ PnpPowerPolicyStart()

VOID FxPkgPnp::PnpPowerPolicyStart ( VOID  )
protected

Definition at line 3698 of file pnpstatemachine.cpp.

◆ PnpPowerPolicyStop()

VOID FxPkgPnp::PnpPowerPolicyStop ( VOID  )
protected

Definition at line 3718 of file pnpstatemachine.cpp.

◆ PnpPowerPolicySurpriseRemove()

VOID FxPkgPnp::PnpPowerPolicySurpriseRemove ( VOID  )
protected

Definition at line 3738 of file pnpstatemachine.cpp.

◆ PnpPowerReferenceDuringQueryPnp()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PnpPowerReferenceDuringQueryPnp ( VOID  )
private

Definition at line 5351 of file fxpkgpnp.cpp.

5366{
5367 if (IsPowerPolicyOwner()) {
5368 //
5369 // We want to synchronously wait to move into D0
5370 //
5372 m_PowerIdleMachine.PowerReferenceWithFlags(
5374 );
5375 }
5376 else {
5377 return STATUS_SUCCESS;
5378 }
5379}
@ FxPowerReferenceSendPnpPowerUpEvent

◆ PnpPowerReferenceSelf()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PnpPowerReferenceSelf ( VOID  )
private

Definition at line 5322 of file fxpkgpnp.cpp.

5337{
5338 if (IsPowerPolicyOwner()) {
5339 //
5340 // We want to synchronously wait to move into D0
5341 //
5342 return PowerReference(TRUE);
5343 }
5344 else {
5345 return STATUS_SUCCESS;
5346 }
5347}

◆ PnpPrepareHardwareInternal()

NTSTATUS FxPkgPnp::PnpPrepareHardwareInternal ( VOID  )
protected

Definition at line 219 of file pnpstatemachinekm.cpp.

232{
233 //
234 // nothing to do for KMDF.
235 //
236 return STATUS_SUCCESS;
237}

Referenced by __drv_when().

◆ PnpProcessEvent()

VOID FxPkgPnp::PnpProcessEvent ( __in FxPnpEvent  Event,
__in BOOLEAN  ProcessEventOnDifferentThread = FALSE 
)

Definition at line 823 of file pnpstatemachine.cpp.

840{
842 KIRQL oldIrql;
843
844 //
845 // Take the lock, raising to DISPATCH_LEVEL.
846 //
847 m_PnpMachine.Lock(&oldIrql);
848
849 if (m_PnpMachine.IsFull()) {
852 "WDFDEVICE 0x%p !devobj 0x%p current pnp state %!WDF_DEVICE_PNP_STATE! "
853 "dropping event %!FxPnpEvent! because of a full queue",
857 Event);
858
859 //
860 // The queue is full. Bail.
861 //
862 m_PnpMachine.Unlock(oldIrql);
863
864 ASSERT(!"The PnP queue is full. This shouldn't be able to happen.");
865 return;
866 }
867
871 "WDFDEVICE 0x%p !devobj 0x%p current pnp state %!WDF_DEVICE_PNP_STATE! "
872 "dropping event %!FxPnpEvent! because of a closed queue",
876 Event);
877
878 //
879 // The queue is closed. Bail
880 //
881 m_PnpMachine.Unlock(oldIrql);
882
883 return;
884 }
885
886 //
887 // Enqueue the event. Whether the event goes on the front
888 // or the end of the queue depends on which event it is.
889 //
891 //
892 // Stick it on the front of the queue, making it the next
893 // event that will be processed.
894 //
896 }
897 else {
898 //
899 // Stick it on the end of the queue.
900 //
902 }
903
904 //
905 // Drop the lock.
906 //
907 m_PnpMachine.Unlock(oldIrql);
908
909 //
910 // Now, if we are running at PASSIVE_LEVEL, attempt to run the state
911 // machine on this thread. If we can't do that, then queue a work item.
912 //
913
915 oldIrql,
916 ProcessOnDifferentThread
917 )) {
918
919 LONGLONG timeout = 0;
920
922 &timeout);
923
924 if (FxWaitLockInternal::IsLockAcquired(status)) {
926
927 //
928 // We now hold the state machine lock. So call the function that
929 // dispatches the next state.
930 //
932
934
935 info.Evaluate(this);
936 return;
937 }
938 }
939
940 //
941 // For one reason or another, we couldn't run the state machine on this
942 // thread. So queue a work item to do it. If m_PnPWorkItemEnqueuing
943 // is non-zero, that means that the work item is already being enqueued
944 // on another thread. This is significant, since it means that we can't do
945 // anything with the work item on this thread, but it's okay, since the
946 // work item will pick up our work and do it.
947 //
949}
BOOLEAN ShouldProcessPnpEventOnDifferentThread(__in KIRQL CurrentIrql, __in BOOLEAN CallerSpecifiedProcessingOnDifferentThread)
VOID PnpProcessEventInner(__inout FxPostProcessInfo *Info)
@ PnpPriorityEventsMask
UCHAR InsertAtTail(VOID)
UCHAR InsertAtHead(VOID)
FxWaitLockInternal m_StateMachineLock
BOOLEAN IsClosedLocked(VOID)
BOOLEAN IsFull(VOID)
Definition: dhcpd.h:245

Referenced by FxPkgPdo::_PnpEject(), FxPkgFdo::_PnpStartDeviceCompletionRoutine(), ChildRemoved(), CleanupDeviceFromFailedCreate(), FxChildList::DrainFreeListHead(), FinishInitialize(), FxPkgFdo::PnpSendStartDeviceDownTheStackOverload(), PnpSurpriseRemoval(), PowerSendPowerDownFailureEvent(), PowerSendPowerUpFailureEvent(), and FxPowerIdleMachine::SendD0Notification().

◆ PnpProcessEventInner()

VOID FxPkgPnp::PnpProcessEventInner ( __inout FxPostProcessInfo Info)
protected

Definition at line 987 of file pnpstatemachine.cpp.

997{
998 WDF_DEVICE_PNP_STATE newState;
1001 KIRQL oldIrql;
1002
1003 //
1004 // Process as many events as we can.
1005 //
1006 for ( ; ; ) {
1008
1009 //
1010 // Get an event from the queue.
1011 //
1012 m_PnpMachine.Lock(&oldIrql);
1013
1014 if (m_PnpMachine.IsEmpty()) {
1016
1019 Info->m_FireAndForgetIrp = ClearPendingPnpIrp();
1020
1021 ASSERT(Info->m_FireAndForgetIrp != NULL);
1022 }
1023
1024 Info->m_SetRemovedEvent = m_SetDeviceRemoveProcessed;
1026
1027 //
1028 // The queue is empty.
1029 //
1030 m_PnpMachine.Unlock(oldIrql);
1031
1032 return;
1033 }
1034
1036
1037 //
1038 // At this point, we need to determine whether we can process this
1039 // event.
1040 //
1042 //
1043 // These are always possible to handle.
1044 //
1045 DO_NOTHING();
1046 }
1047 else {
1048 //
1049 // Check to see if this state can handle new events.
1050 //
1051 if (entry->StateInfo.Bits.QueueOpen == FALSE) {
1052 //
1053 // This state can't handle new events.
1054 //
1055 m_PnpMachine.Unlock(oldIrql);
1056 return;
1057 }
1058 }
1059
1061 m_PnpMachine.Unlock(oldIrql);
1062
1063 //
1064 // Find the entry in the PnP state table that corresponds
1065 // to this event.
1066 //
1067 newState = WdfDevStatePnpNull;
1068
1069 if (entry->FirstTargetState.PnpEvent == event) {
1070 newState = entry->FirstTargetState.TargetState;
1071
1072 DO_EVENT_TRAP(&entry->FirstTargetState);
1073 }
1074 else if (entry->OtherTargetStates != NULL) {
1075 ULONG i = 0;
1076
1077 for (i = 0;
1078 entry->OtherTargetStates[i].PnpEvent != PnpEventNull;
1079 i++) {
1080 if (entry->OtherTargetStates[i].PnpEvent == event) {
1081 newState = entry->OtherTargetStates[i].TargetState;
1082 DO_EVENT_TRAP(&entry->OtherTargetStates[i]);
1083 break;
1084 }
1085 }
1086 }
1087
1088 if (newState == WdfDevStatePnpNull) {
1091 "WDFDEVICE 0x%p !devobj 0x%p current pnp state "
1092 "%!WDF_DEVICE_PNP_STATE! dropping event %!FxPnpEvent!",
1096 event);
1097
1098 if ((entry->StateInfo.Bits.KnownDroppedEvents & event) == 0) {
1099 COVERAGE_TRAP();
1100
1103 "WDFDEVICE 0x%p !devobj %p current state "
1104 "%!WDF_DEVICE_PNP_STATE!, policy event %!FxPnpEvent! is not"
1105 " a known dropped event, known dropped events are "
1106 "%!FxPnpEvent!",
1110 event,
1111 entry->StateInfo.Bits.KnownDroppedEvents);
1112
1113 // DIAG: add diag code here
1114 }
1115
1116 //
1117 // This state doesn't respond to the Event. Make sure we do not
1118 // drop an event which pends a pnp irp on the floor though.
1119 //
1120 if (event & PnpEventPending) {
1121 //
1122 // In the case of a previous power up/down failure, the following
1123 // can happen
1124 // 1 invalidate device relations
1125 // 2 failure event is posted to pnp state machine
1126 // 3 process power failure event first, but while processing,
1127 // query device state is completed, and failed /removed is reported
1128 // 4 surprise remove comes, the irp is queued, the event is queued
1129 // 5 processing of power failure event continues, gets to
1130 // Failed and completes the s.r irp
1131 // 6 the surprise remove event is processed (the current value
1132 // of the local var event), but since we are already in the
1133 // Failed state, we ignore this event and end up
1134 // here.
1135 //
1136 // This means that if we are processing surprise remove, we cannot
1137 // 100% expect that an irp has been pended.
1138 //
1141 }
1142 else {
1143 DO_NOTHING();
1144 }
1145 }
1146 else {
1147 //
1148 // Now enter the new state.
1149 //
1150 PnpEnterNewState(newState);
1151 }
1152 }
1153}
VOID PnpEnterNewState(__in WDF_DEVICE_PNP_STATE State)
VOID PnpFinishProcessingIrp(__in BOOLEAN IrpMustBePresent=TRUE)
#define DO_EVENT_TRAP(x)
Definition: fxpkgpnp.hpp:61
@ PnpEventNull
@ PnpEventPending
@ PnpEventSurpriseRemove
VOID IncrementHead(VOID)
BOOLEAN IsEmpty(VOID)
UCHAR GetHead(VOID)
VOID GetFinishedState(__inout FxPostProcessInfo *Info)

Referenced by PnpProcessEvent().

◆ PnpReleaseHardware()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PnpReleaseHardware ( VOID  )
protected

Definition at line 3621 of file pnpstatemachine.cpp.

3638{
3640 FxInterrupt* interrupt;
3641 PLIST_ENTRY le;
3642
3643 //
3644 // Invoke the device's release hardware callback.
3645 //
3649
3653 "EvtDeviceReleaseHardware returned an invalid status "
3654 "STATUS_NOT_SUPPORTED");
3655
3656 if (GetDriverGlobals()->IsVerificationEnabled(1, 11, OkForDownLevel)) {
3658 }
3659 }
3660
3661#if (FX_CORE_MODE == FX_CORE_USER_MODE)
3662 if (NT_SUCCESS(status)) {
3663 //
3664 // make sure driver has unmapped its resources
3665 //
3667 }
3668
3669 //
3670 // delete the register and port resource tables
3671 //
3674#endif
3675
3676 //
3677 // Delete all interrupt objects that were created in the prepare hardware
3678 // callback that the driver did not explicitly delete (in reverse order).
3679 //
3681
3682 while(le != &m_InterruptListHead) {
3683
3684 // Find the interrupt object pointer.
3685 interrupt = CONTAINING_RECORD(le, FxInterrupt, m_PnpList);
3686
3687 // Advance the entry before it becomes invalid.
3688 le = le->Blink;
3689
3690 // Let the interrupt know that 'release hardware' was called.
3691 interrupt->OnPostReleaseHardware();
3692 }
3693
3694 return status;
3695}
VOID DeletePortResourceTable(VOID)
Definition: fxresource.hpp:595
VOID ValidateResourceUnmap(VOID)
VOID DeleteRegisterResourceTable(VOID)
Definition: fxresource.hpp:581
WDFCMRESLIST GetHandle(VOID)
Definition: fxresource.hpp:449
VOID OnPostReleaseHardware(VOID)
FxPnpDeviceReleaseHardware m_DeviceReleaseHardware
Definition: fxpkgpnp.hpp:4557
_Must_inspect_result_ NTSTATUS Invoke(__in WDFDEVICE Device, __in WDFCMRESLIST ResourcesTranslated)

◆ PnpSendStartDeviceDownTheStackOverload()

virtual BOOLEAN FxPkgPnp::PnpSendStartDeviceDownTheStackOverload ( VOID  )
protectedpure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

◆ PnpSurpriseRemoval()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PnpSurpriseRemoval ( __inout FxIrp Irp)
protected

Definition at line 2366 of file fxpkgpnp.cpp.

2387{
2388 //
2389 // Package specific handling
2390 //
2391 Irp->SetStatus(STATUS_SUCCESS);
2394
2395 return STATUS_PENDING;
2396}
VOID SetPendingPnpIrp(__inout FxIrp *Irp, __in BOOLEAN MarkIrpPending=TRUE)
Definition: fxpkgpnp.cpp:4883

Referenced by FxPkgPdo::_PnpSurpriseRemoval().

◆ PostCreateDeviceInitialize()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PostCreateDeviceInitialize ( VOID  )

Definition at line 1187 of file fxpkgpnp.cpp.

1209{
1211
1213 if (!NT_SUCCESS(status)) {
1215 "PnP State Machine init failed, %!STATUS!",
1216 status);
1217 return status;
1218 }
1219
1221 if (!NT_SUCCESS(status)) {
1223 "Power State Machine init failed, %!STATUS!",
1224 status);
1225 return status;
1226 }
1227
1229 if (!NT_SUCCESS(status)) {
1231 "Power Policy State Machine init failed, %!STATUS!",
1232 status);
1233 return status;
1234 }
1235
1236 return status;
1237}
static VOID _PowerProcessEventInner(__in FxPkgPnp *This, __in FxPostProcessInfo *Info, __in PVOID WorkerContext)
static VOID _PnpProcessEventInner(__inout FxPkgPnp *This, __inout FxPostProcessInfo *Info, __in PVOID WorkerContext)
static VOID _PowerPolicyProcessEventInner(__inout FxPkgPnp *This, __inout FxPostProcessInfo *Info, __in PVOID WorkerContext)
_Must_inspect_result_ NTSTATUS Init(__inout FxPkgPnp *Pnp, __in PFN_PNP_EVENT_WORKER WorkerRoutine)
_Must_inspect_result_ NTSTATUS Init(__inout FxPkgPnp *Pnp, __in PFN_PNP_EVENT_WORKER WorkerRoutine, __in PVOID WorkerContext=NULL)
Definition: eventqueue.cpp:370
_Must_inspect_result_ NTSTATUS Init(__inout FxPkgPnp *Pnp, __in PFN_PNP_EVENT_WORKER WorkerRoutine, __in PVOID WorkerContext=NULL)
Definition: eventqueue.cpp:321

Referenced by FxDevice::PdoInitialize(), and FxPkgFdo::PostCreateDeviceInitialize().

◆ PowerCheckAssumptions()

VOID FxPkgPnp::PowerCheckAssumptions ( VOID  )
private

Definition at line 1070 of file powerstatemachine.cpp.

1089{
1090 WDFCASSERT(sizeof(FxPowerStateInfo) == sizeof(ULONG));
1091
1092 WDFCASSERT((sizeof(m_WdfPowerStates)/sizeof(m_WdfPowerStates[0]))
1093 ==
1095
1096 // we assume these are the same length when we update the history index
1098 sizeof(m_PowerMachine.m_Queue.Events[0]))
1099 ==
1101 sizeof(m_PowerMachine.m_States.History[0])));
1102}
FxPowerMachineEventQueue m_Queue
FxPowerMachineStateHistory m_States
USHORT Events[PowerEventQueueDepth]
USHORT History[PowerEventQueueDepth]
@ WdfDevStatePowerNull
Definition: wdfdevice.h:223

◆ PowerCheckDeviceType()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerCheckDeviceType ( __inout FxPkgPnp This)
staticprotected

Definition at line 1692 of file powerstatemachine.cpp.

1709{
1710 return This->PowerCheckDeviceTypeOverload();
1711}

◆ PowerCheckDeviceTypeNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerCheckDeviceTypeNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 1714 of file powerstatemachine.cpp.

1731{
1732 return This->PowerCheckDeviceTypeNPOverload();
1733}

◆ PowerCheckDeviceTypeNPOverload()

virtual WDF_DEVICE_POWER_STATE FxPkgPnp::PowerCheckDeviceTypeNPOverload ( VOID  )
protectedpure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

◆ PowerCheckDeviceTypeOverload()

virtual WDF_DEVICE_POWER_STATE FxPkgPnp::PowerCheckDeviceTypeOverload ( VOID  )
protectedpure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

◆ PowerCheckParentOverload()

virtual NTSTATUS FxPkgPnp::PowerCheckParentOverload ( BOOLEAN ParentOn)
protectedpure virtual

◆ PowerCheckParentState()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerCheckParentState ( __inout FxPkgPnp This)
staticprotected

Definition at line 1622 of file powerstatemachine.cpp.

1639{
1641 BOOLEAN parentOn;
1642
1643 status = This->PowerCheckParentOverload(&parentOn);
1644
1645 if (!NT_SUCCESS(status)) {
1647 }
1648 else if (parentOn) {
1650 }
1651 else {
1653 }
1654}
@ WdfDevStatePowerUpFailed
Definition: wdfdevice.h:213
@ WdfDevStatePowerWaking
Definition: wdfdevice.h:181
@ WdfDevStatePowerWaitForParent
Definition: wdfdevice.h:177

◆ PowerCheckParentStateArmedForWake()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerCheckParentStateArmedForWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 3129 of file powerstatemachine.cpp.

3148{
3150 BOOLEAN parentOn;
3151
3152 status = This->PowerCheckParentOverload(&parentOn);
3153
3154 if (!NT_SUCCESS(status)) {
3156 }
3157 else if (parentOn) {
3159 }
3160 else {
3162 }
3163}
@ WdfDevStatePowerWaitForParentArmedForWake
Definition: wdfdevice.h:171
@ WdfDevStatePowerDxDisablingWakeAtBus
Definition: wdfdevice.h:154

◆ PowerCheckParentStateArmedForWakeNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerCheckParentStateArmedForWakeNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 3166 of file powerstatemachine.cpp.

3181{
3183 BOOLEAN parentOn;
3184
3185 status = This->PowerCheckParentOverload(&parentOn);
3186
3187 if (!NT_SUCCESS(status)) {
3189 }
3190 else if (parentOn) {
3192 }
3193 else {
3195 }
3196}
@ WdfDevStatePowerDxDisablingWakeAtBusNP
Definition: wdfdevice.h:155
@ WdfDevStatePowerUpFailedNP
Definition: wdfdevice.h:217
@ WdfDevStatePowerWaitForParentArmedForWakeNP
Definition: wdfdevice.h:172

◆ PowerCheckParentStateNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerCheckParentStateNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 1657 of file powerstatemachine.cpp.

1674{
1676 BOOLEAN parentOn;
1677
1678 status = This->PowerCheckParentOverload(&parentOn);
1679
1680 if (!NT_SUCCESS(status)) {
1682 }
1683 else if (parentOn) {
1685 }
1686 else {
1688 }
1689}
@ WdfDevStatePowerWaitForParentNP
Definition: wdfdevice.h:178
@ WdfDevStatePowerWakingNP
Definition: wdfdevice.h:182

◆ PowerCompletePendedWakeIrp()

VOID FxPkgPnp::PowerCompletePendedWakeIrp ( VOID  )
protected

Definition at line 4832 of file powerstatemachine.cpp.

4849{
4851 KIRQL irql;
4852
4854 COVERAGE_TRAP();
4855 return;
4856 }
4857
4858 //
4859 // Pop an irp off of the list
4860 //
4865
4867
4869
4871}
static MdIrp GetIrpFromListEntry(__in PLIST_ENTRY Ple)
Definition: fxirpum.cpp:1190
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
LIST_ENTRY m_WaitWakeIrpToBeProcessedList

Referenced by PowerCompleteWakeRequestFromWithinMachine(), and PowerProcessEventInner().

◆ PowerCompleteWakeRequestFromWithinMachine()

VOID FxPkgPnp::PowerCompleteWakeRequestFromWithinMachine ( __in NTSTATUS  Status)
protected

Definition at line 4874 of file powerstatemachine.cpp.

4892{
4895 }
4896}
VOID PowerCompletePendedWakeIrp(VOID)
BOOLEAN PowerMakeWakeRequestNonCancelable(__in NTSTATUS Status)
_Must_inspect_result_ _In_ WDFDEVICE _In_ NTSTATUS WaitWakeStatus
Definition: wdfdevice.h:3945

◆ PowerConnectInterruptFailed()

VOID FxPkgPnp::PowerConnectInterruptFailed ( VOID  )
protected

Definition at line 5283 of file powerstatemachine.cpp.

5302{
5304
5306
5307 if (!NT_SUCCESS(status)) {
5308 //
5309 // Report the error, but continue forward
5310 //
5313 "Interrupt(s) disconnect on WDFDEVICE %p failed, %!STATUS!",
5315 }
5316
5319
5320 if (!NT_SUCCESS(status)) {
5321 //
5322 // Report the error, but continue forward
5323 //
5326 "EvtDeviceD0Exit WDFDEVICE 0x%p !devobj 0x%p failed, %!STATUS!",
5329 }
5330
5332}
FxPnpDeviceD0Exit m_DeviceD0Exit
Definition: fxpkgpnp.hpp:4554
VOID PowerSetDevicePowerState(__in WDF_POWER_DEVICE_STATE State)
_Must_inspect_result_ NTSTATUS Invoke(__in WDFDEVICE Device, __in WDF_POWER_DEVICE_STATE TargetState)

◆ PowerD0ArmedForWake()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerD0ArmedForWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 1960 of file powerstatemachine.cpp.

1977{
1978 if ((This->m_Device->GetDeviceObjectFlags() & DO_POWER_PAGABLE) == 0) {
1979 //
1980 // We are non pageable, go to that state now
1981 //
1982 COVERAGE_TRAP();
1983
1985 }
1986
1987 return WdfDevStatePowerNull;
1988}
@ WdfDevStatePowerDecideD0State
Definition: wdfdevice.h:149

◆ PowerD0ArmedForWakeNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerD0ArmedForWakeNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 1991 of file powerstatemachine.cpp.

2008{
2009 if (This->m_Device->GetDeviceObjectFlags() & DO_POWER_PAGABLE) {
2010 //
2011 // We are pageable, go to that state now
2012 //
2013 COVERAGE_TRAP();
2014
2016 }
2017
2018 return WdfDevStatePowerNull;
2019}

◆ PowerD0BusWakeOwner()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerD0BusWakeOwner ( __inout FxPkgPnp This)
staticprotected

Definition at line 1888 of file powerstatemachine.cpp.

1906{
1907 if ((This->m_Device->GetDeviceObjectFlags() & DO_POWER_PAGABLE) == 0) {
1908 //
1909 // We are non pageable, go to that state now
1910 //
1911 COVERAGE_TRAP();
1912
1914 }
1915 else if (This->PowerIsWakeRequestPresent()) {
1917 }
1918 else {
1919 return WdfDevStatePowerNull;
1920 }
1921}
@ WdfDevStatePowerEnablingWakeAtBus
Definition: wdfdevice.h:135

◆ PowerD0BusWakeOwnerNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerD0BusWakeOwnerNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 1924 of file powerstatemachine.cpp.

1942{
1943 if (This->m_Device->GetDeviceObjectFlags() & DO_POWER_PAGABLE) {
1944 //
1945 // Pageable.
1946 //
1947 COVERAGE_TRAP();
1948
1950 }
1951 else if (This->PowerIsWakeRequestPresent()) {
1953 }
1954 else {
1955 return WdfDevStatePowerNull;
1956 }
1957}
@ WdfDevStatePowerEnablingWakeAtBusNP
Definition: wdfdevice.h:136

◆ PowerD0DisarmingWakeAtBus()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerD0DisarmingWakeAtBus ( __inout FxPkgPnp This)
staticprotected

Definition at line 2057 of file powerstatemachine.cpp.

2073{
2074 //
2075 // We should only get into this state when this devobj is not a PDO and a
2076 // power policy owner.
2077 //
2078 ASSERT((This->m_Device->IsPdo() &&
2079 This->IsPowerPolicyOwner()) == FALSE);
2080
2081 //
2082 // Disarm
2083 //
2084 This->PowerDisableWakeAtBusOverload();
2085 This->PowerCompletePendedWakeIrp();
2086
2087 //
2088 // Go back to normal unarmed D0 with bus wake ownership
2089 //
2091}
@ WdfDevStatePowerD0BusWakeOwner
Definition: wdfdevice.h:139

◆ PowerD0DisarmingWakeAtBusNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerD0DisarmingWakeAtBusNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 2094 of file powerstatemachine.cpp.

2110{
2111 //
2112 // We should only get into this state when this devobj is not a PDO and a
2113 // power policy owner.
2114 //
2115 ASSERT((This->m_Device->IsPdo() && This->IsPowerPolicyOwner()) == FALSE);
2116
2117 //
2118 // Disarm
2119 //
2120 This->PowerDisableWakeAtBusOverload();
2121 This->PowerCompletePendedWakeIrp();
2122
2123 //
2124 // Go back to normal unarmed D0 with bus wake ownership
2125 //
2127}
@ WdfDevStatePowerD0BusWakeOwnerNP
Definition: wdfdevice.h:140

◆ PowerD0NP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerD0NP ( __inout FxPkgPnp This)
staticprotected

Definition at line 1859 of file powerstatemachine.cpp.

1874{
1875 if (This->m_Device->GetDeviceObjectFlags() & DO_POWER_PAGABLE) {
1876 //
1877 // We are pageable, go to that state now
1878 //
1879 COVERAGE_TRAP();
1881 }
1882
1883 return WdfDevStatePowerNull;
1884}

◆ PowerD0Starting()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerD0Starting ( __inout FxPkgPnp This)
staticprotected

Definition at line 2130 of file powerstatemachine.cpp.

2146{
2148
2149 //
2150 // Call the driver to tell it to put the hardware into the working
2151 // state.
2152 //
2153 // m_DevicePowerState is the "old" state because we update it after the
2154 // D0Entry callback.
2155 //
2156 status = This->m_DeviceD0Entry.Invoke(
2157 This->m_Device->GetHandle(),
2158 (WDF_POWER_DEVICE_STATE) This->m_DevicePowerState);
2159
2160 if (!NT_SUCCESS(status)) {
2162 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
2163 "EvtDeviceD0Entry WDFDEVICE 0x%p !devobj 0x%p, old state "
2164 "%!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
2165 This->m_Device->GetHandle(),
2166 This->m_Device->GetDeviceObject(),
2167 This->m_DevicePowerState, status);
2168
2170 }
2171
2173}
enum _WDF_POWER_DEVICE_STATE WDF_POWER_DEVICE_STATE
@ WdfDevStatePowerInitialPowerUpFailedDerefParent
Definition: wdfdevice.h:198
@ WdfDevStatePowerD0StartingConnectInterrupt
Definition: wdfdevice.h:146

◆ PowerD0StartingConnectInterrupt()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerD0StartingConnectInterrupt ( __inout FxPkgPnp This)
staticprotected

Definition at line 2176 of file powerstatemachine.cpp.

2193{
2195
2196 //
2197 // Connect the interrupt and enable it
2198 //
2199 status = This->NotifyResourceObjectsD0(NotifyResourcesNoFlags);
2200 if (!NT_SUCCESS(status)) {
2201 //
2202 // NotifyResourceObjectsD0 has already logged the error, no need to
2203 // repeat any error messsages here
2204 //
2206 }
2207
2208 status = This->m_DeviceD0EntryPostInterruptsEnabled.Invoke(
2209 This->m_Device->GetHandle(),
2210 (WDF_POWER_DEVICE_STATE) This->m_DevicePowerState);
2211
2212 if (!NT_SUCCESS(status)) {
2213
2215 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
2216 "EvtDeviceD0EntryPostInterruptsEnabed WDFDEVICE 0x%p !devobj 0x%p, "
2217 "old state %!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
2218 This->m_Device->GetHandle(),
2219 This->m_Device->GetDeviceObject(),
2220 This->m_DevicePowerState, status);
2222 }
2223
2224 //
2225 // Last, figure out which state to drop into. This is the juncture
2226 // where we figure out if we're doing power in a pageable fashion.
2227 //
2229}
@ NotifyResourcesNoFlags
Definition: fxpkgpnp.hpp:207
@ WdfDevStatePowerD0StartingDmaEnable
Definition: wdfdevice.h:147
@ WdfDevStatePowerInitialConnectInterruptFailed
Definition: wdfdevice.h:195

◆ PowerD0StartingDmaEnable()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerD0StartingDmaEnable ( __inout FxPkgPnp This)
staticprotected

Definition at line 2232 of file powerstatemachine.cpp.

2248{
2249 if (This->PowerDmaEnableAndScan(TRUE) == FALSE) {
2251 }
2252
2254}
@ WdfDevStatePowerD0StartingStartSelfManagedIo
Definition: wdfdevice.h:148
@ WdfDevStatePowerInitialDmaEnableFailed
Definition: wdfdevice.h:196

◆ PowerD0StartingStartSelfManagedIo()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerD0StartingStartSelfManagedIo ( __inout FxPkgPnp This)
staticprotected

Definition at line 2257 of file powerstatemachine.cpp.

2273{
2274
2275
2276
2277
2278 This->m_Device->m_PkgIo->ResumeProcessingForPower();
2279
2280 if (This->m_SelfManagedIoMachine != NULL) {
2282
2283 status = This->m_SelfManagedIoMachine->Start();
2284
2285 if (!NT_SUCCESS(status)) {
2286 // return WdfDevStatePowerInitialSelfManagedIoFailed; __REACTOS__ : allow to fail
2287 }
2288 }
2289
2290 This->PowerSetDevicePowerState(WdfPowerDeviceD0);
2291
2292 //
2293 // Send the PowerUp event to both the PnP and the Power Policy state machines.
2294 //
2295 This->PowerSendPowerUpEvents();
2296
2298}
@ WdfPowerDeviceD0
Definition: wdfdevice.h:423

◆ PowerD0SurpriseRemoved()

static WDF_DEVICE_POWER_STATE FxPkgPnp::PowerD0SurpriseRemoved ( __inout FxPkgPnp This)
staticprotected

◆ PowerDecideD0State()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerDecideD0State ( __inout FxPkgPnp This)
staticprotected

Definition at line 2301 of file powerstatemachine.cpp.

2317{
2318 if (This->m_Device->GetDeviceObjectFlags() & DO_POWER_PAGABLE) {
2319 //
2320 // Pageable.
2321 //
2322 if (This->m_SharedPower.m_WaitWakeOwner) {
2324 }
2325 else {
2326 return WdfDevStatePowerD0;
2327 }
2328 }
2329 else {
2330 //
2331 // Non-pageable.
2332 //
2333 if (This->m_SharedPower.m_WaitWakeOwner) {
2335 }
2336 else {
2337 return WdfDevStatePowerD0NP;
2338 }
2339 }
2340}
@ WdfDevStatePowerD0
Definition: wdfdevice.h:137
@ WdfDevStatePowerD0NP
Definition: wdfdevice.h:138

◆ PowerDereference()

VOID __inline FxPkgPnp::PowerDereference ( __in_opt PVOID  Tag = NULL,
__in_opt LONG  Line = 0,
__in_opt PSTR  File = NULL 
)
inline

Definition at line 3498 of file fxpkgpnp.hpp.

3503 {
3505 }
Definition: File.h:16
VOID IoDecrement(__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 _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065

Referenced by PnpDeviceUsageNotification(), PnpPowerDereferenceSelf(), PowerPolicyChildPoweredDown(), and ResumeIdleWorker().

◆ PowerDisableWakeAtBusOverload()

virtual VOID FxPkgPnp::PowerDisableWakeAtBusOverload ( VOID  )
inlineprotectedvirtual

Reimplemented in FxPkgPdo.

Definition at line 1396 of file fxpkgpnp.hpp.

1399 {
1400 }

◆ PowerDmaEnableAndScan()

BOOLEAN FxPkgPnp::PowerDmaEnableAndScan ( __in BOOLEAN  ImplicitPowerUp)
protected

Definition at line 3666 of file powerstatemachine.cpp.

3669{
3671
3672 if (PowerDmaPowerUp() == FALSE) {
3673 return FALSE;
3674 }
3675
3676 if (m_EnumInfo != NULL) {
3677 //
3678 // Scan for children
3679 //
3681
3682 ple = NULL;
3684 ((FxChildList*) ple->GetTransactionedObject())->ScanForChildren();
3685 }
3686
3688 }
3689
3690 if (ImplicitPowerUp == FALSE) {
3692 }
3693
3694 return TRUE;
3695}
_Must_inspect_result_ BOOLEAN PowerDmaPowerUp(VOID)
@ PwrPolPowerUpHwStarted

◆ PowerDmaPowerDown()

BOOLEAN FxPkgPnp::PowerDmaPowerDown ( VOID  )
protected

Definition at line 83 of file powerstatemachinekm.cpp.

99{
100 // FxTransactionedEntry* ple;
101 // NTSTATUS status;
103
104 result = TRUE;
105
106 //
107 // Power up each dma enabler
108 //
109 // if (m_DmaEnablerList != NULL) {
110 // m_DmaEnablerList->LockForEnum(GetDriverGlobals());
111
112 // ple = NULL;
113 // while ((ple = m_DmaEnablerList->GetNextEntry(ple)) != NULL) {
114 // status = ((FxDmaEnabler*) ple->GetTransactionedObject())->PowerDown();
115
116 // if (!NT_SUCCESS(status)) {
117 // //
118 // // We do not break out of the loop on power down failure. We will
119 // // continue to power down each channel regardless of the previous
120 // // channel's power down status.
121 // //
122 // result = FALSE;
123 // }
124 // }
125
126 // m_DmaEnablerList->UnlockFromEnum(GetDriverGlobals());
127 // }
128
129 return result;
130}

Referenced by PowerGotoDxIoStopped(), and PowerGotoDxIoStoppedNP().

◆ PowerDmaPowerUp()

_Must_inspect_result_ BOOLEAN FxPkgPnp::PowerDmaPowerUp ( VOID  )
protected

Definition at line 36 of file powerstatemachinekm.cpp.

53{
54 // FxTransactionedEntry* ple;
55 // NTSTATUS status;
57
58 result = TRUE;
59
60 //
61 // Power up each dma enabler
62 //
63 // if (m_DmaEnablerList != NULL) {
64 // m_DmaEnablerList->LockForEnum(GetDriverGlobals());
65
66 // ple = NULL;
67 // while ((ple = m_DmaEnablerList->GetNextEntry(ple)) != NULL) {
68 // status = ((FxDmaEnabler*) ple->GetTransactionedObject())->PowerUp();
69
70 // if (!NT_SUCCESS(status)) {
71 // result = FALSE;
72 // break;
73 // }
74 // }
75
76 // m_DmaEnablerList->UnlockFromEnum(GetDriverGlobals());
77 // }
78
79 return result;
80}

Referenced by PowerDmaEnableAndScan().

◆ PowerDNotZeroNP()

static WDF_DEVICE_POWER_STATE FxPkgPnp::PowerDNotZeroNP ( __inout FxPkgPnp This)
staticprotected

◆ PowerDxDisablingWakeAtBus()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerDxDisablingWakeAtBus ( __inout FxPkgPnp This)
staticprotected

Definition at line 2552 of file powerstatemachine.cpp.

2567{
2568 //
2569 // We should only get into this state when this devobj is not a PDO and a
2570 // power policy owner.
2571 //
2572 ASSERT((This->m_Device->IsPdo() && This->IsPowerPolicyOwner()) == FALSE);
2573
2574 This->PowerDisableWakeAtBusOverload();
2575
2577}

◆ PowerDxDisablingWakeAtBusNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerDxDisablingWakeAtBusNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 2580 of file powerstatemachine.cpp.

2595{
2596 //
2597 // We should only get into this state when this devobj is not a PDO and a
2598 // power policy owner.
2599 //
2600 ASSERT((This->m_Device->IsPdo() && This->IsPowerPolicyOwner()) == FALSE);
2601
2602 This->PowerDisableWakeAtBusOverload();
2603
2605}

◆ PowerDxStoppedArmForWake()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerDxStoppedArmForWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 4314 of file powerstatemachine.cpp.

4332{
4334
4335 COVERAGE_TRAP();
4336
4337 //
4338 // We should only get into this state when this devobj is not a PDO and a
4339 // power policy owner.
4340 //
4341 ASSERT((This->m_Device->IsPdo() && This->IsPowerPolicyOwner()) == FALSE);
4342
4343 status = This->PowerEnableWakeAtBusOverload();
4344
4345 if (NT_SUCCESS(status)) {
4346 //
4347 // No matter of the irp status (canceled, pending, completed), we always
4348 // transition to the D0ArmedForWake state because that is where we
4349 // we handle the change in the irp's status.
4350 //
4351 COVERAGE_TRAP();
4353 }
4354 else {
4355 COVERAGE_TRAP();
4356 This->PowerCompleteWakeRequestFromWithinMachine(status);
4357 return WdfDevStatePowerDx;
4358 }
4359}
@ WdfDevStatePowerDxArmedForWake
Definition: wdfdevice.h:167
@ WdfDevStatePowerDx
Definition: wdfdevice.h:161

◆ PowerDxStoppedArmForWakeNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerDxStoppedArmForWakeNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4362 of file powerstatemachine.cpp.

4380{
4382
4383 COVERAGE_TRAP();
4384
4385 //
4386 // We should only get into this state when this devobj is not a PDO and a
4387 // power policy owner.
4388 //
4389 ASSERT((This->m_Device->IsPdo() && This->IsPowerPolicyOwner()) == FALSE);
4390
4391 status = This->PowerEnableWakeAtBusOverload();
4392
4393 if (NT_SUCCESS(status)) {
4394 //
4395 // No matter of the irp status (canceled, pending, completed), we always
4396 // transition to the D0ArmedForWake state because that is where we
4397 // we handle the change in the irp's status.
4398 //
4399 COVERAGE_TRAP();
4401 }
4402 else {
4403 COVERAGE_TRAP();
4404 This->PowerCompleteWakeRequestFromWithinMachine(status);
4405 return WdfDevStatePowerDxNP;
4406 }
4407}
@ WdfDevStatePowerDxNP
Definition: wdfdevice.h:162
@ WdfDevStatePowerDxArmedForWakeNP
Definition: wdfdevice.h:168

◆ PowerDxStoppedDecideDxState()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerDxStoppedDecideDxState ( __inout FxPkgPnp This)
staticprotected

Definition at line 4259 of file powerstatemachine.cpp.

4275{
4276 //
4277 // We should only get into this state when this devobj is not the power
4278 // policy owner.
4279 //
4280 ASSERT(This->IsPowerPolicyOwner() == FALSE);
4281
4282 //
4283 // Move power policy back into a working state
4284 //
4285 // While it seems odd to send a power up in a Dx state, the power up is
4286 // really an indication to the power policy state machine that the implicit
4287 // D0 has been successfully processed, basically, it is a status event more
4288 // then an indication of true power state.
4289 //
4290 This->PowerSendPowerUpEvents();
4291
4292 if (This->m_Device->GetDeviceObjectFlags() & DO_POWER_PAGABLE) {
4293 if (This->PowerIsWakeRequestPresent()) {
4294 COVERAGE_TRAP();
4296 }
4297 else {
4298 return WdfDevStatePowerDx;
4299 }
4300 }
4301 else {
4302 if (This->PowerIsWakeRequestPresent()) {
4303 COVERAGE_TRAP();
4305 }
4306 else {
4307 COVERAGE_TRAP();
4308 return WdfDevStatePowerDxNP;
4309 }
4310 }
4311}
@ WdfDevStatePowerDxStoppedArmForWakeNP
Definition: wdfdevice.h:209
@ WdfDevStatePowerDxStoppedArmForWake
Definition: wdfdevice.h:208

◆ PowerDxStoppedDisarmWake()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerDxStoppedDisarmWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 4097 of file powerstatemachine.cpp.

4113{
4114 //
4115 // We should only get into this state when this devobj is not a PDO and a
4116 // power policy owner.
4117 //
4118 ASSERT((This->m_Device->IsPdo() && This->IsPowerPolicyOwner()) == FALSE);
4119
4120 This->PowerDisableWakeAtBusOverload();
4121
4123}
@ WdfDevStatePowerGotoDxStoppedDisableInterrupt
Definition: wdfdevice.h:216

◆ PowerDxStoppedDisarmWakeNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerDxStoppedDisarmWakeNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4126 of file powerstatemachine.cpp.

4142{
4143 //
4144 // We should only get into this state when this devobj is not a PDO and a
4145 // power policy owner.
4146 //
4147 ASSERT((This->m_Device->IsPdo() && This->IsPowerPolicyOwner()) == FALSE);
4148
4149 This->PowerDisableWakeAtBusOverload();
4150
4152}
@ WdfDevStatePowerGotoDxStoppedDisableInterruptNP
Definition: wdfdevice.h:202

◆ PowerDxSurpriseRemovedPowerDown()

static WDF_DEVICE_POWER_STATE FxPkgPnp::PowerDxSurpriseRemovedPowerDown ( __inout FxPkgPnp This)
staticprotected

◆ PowerDxSurpriseRemovedPowerUp()

static WDF_DEVICE_POWER_STATE FxPkgPnp::PowerDxSurpriseRemovedPowerUp ( __inout FxPkgPnp This)
staticprotected

◆ PowerDZero()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerDZero ( __inout FxPkgPnp This)
staticprotected

Definition at line 1830 of file powerstatemachine.cpp.

1845{
1846 if ((This->m_Device->GetDeviceObjectFlags() & DO_POWER_PAGABLE) == 0) {
1847 //
1848 // We are non pageable, go to that state now
1849 //
1850 COVERAGE_TRAP();
1851
1853 }
1854
1855 return WdfDevStatePowerNull;
1856}

◆ PowerEnableWakeAtBusOverload()

virtual NTSTATUS FxPkgPnp::PowerEnableWakeAtBusOverload ( VOID  )
inlineprotectedvirtual

Reimplemented in FxPkgPdo.

Definition at line 1387 of file fxpkgpnp.hpp.

1390 {
1391 return STATUS_SUCCESS;
1392 }

◆ PowerEnablingWakeAtBus()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerEnablingWakeAtBus ( __inout FxPkgPnp This)
staticprotected

Definition at line 1736 of file powerstatemachine.cpp.

1751{
1753
1754 //
1755 // We should only get into this state when this devobj is not a PDO and a
1756 // power policy owner.
1757 //
1758 ASSERT((This->m_Device->IsPdo() && This->IsPowerPolicyOwner()) == FALSE);
1759
1760 status = This->PowerEnableWakeAtBusOverload();
1761
1763
1764 if (NT_SUCCESS(status)) {
1765 //
1766 // No matter of the irp status (canceled, pending, completed), we always
1767 // transition to the D0ArmedForWake state because that is where we
1768 // we handle the change in the irp's status.
1769 //
1771 }
1772 else {
1773 This->PowerCompleteWakeRequestFromWithinMachine(status);
1774
1776 }
1777}
@ WdfDevStatePowerD0ArmedForWake
Definition: wdfdevice.h:141

◆ PowerEnablingWakeAtBusNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerEnablingWakeAtBusNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 1780 of file powerstatemachine.cpp.

1795{
1797
1798 //
1799 // We should only get into this state when this devobj is not a PDO and a
1800 // power policy owner.
1801 //
1802 ASSERT((This->m_Device->IsPdo() &&
1803 This->IsPowerPolicyOwner()) == FALSE);
1804
1805 status = This->PowerEnableWakeAtBusOverload();
1806
1808
1809 if (NT_SUCCESS(status)) {
1810 //
1811 // No matter of the irp status (canceled, pending, completed), we always
1812 // transition to the D0ArmedForWake state because that is where we
1813 // we handle the change in the irp's status.
1814 //
1816 }
1817 else {
1818 //
1819 // Complete the irp with the error that callback indicated
1820 //
1821 COVERAGE_TRAP();
1822
1823 This->PowerCompleteWakeRequestFromWithinMachine(status);
1824
1826 }
1827}
@ WdfDevStatePowerD0ArmedForWakeNP
Definition: wdfdevice.h:142

◆ PowerEnterNewState()

VOID FxPkgPnp::PowerEnterNewState ( __in WDF_DEVICE_POWER_STATE  State)
protected

Definition at line 1511 of file powerstatemachine.cpp.

1528{
1530 WDF_DEVICE_POWER_STATE currentState, newState;
1532 FxWatchdog watchdog(this);
1533
1534 currentState = m_Device->GetDevicePowerState();
1535 newState = State;
1536
1537 while (newState != WdfDevStatePowerNull) {
1540 "WDFDEVICE 0x%p !devobj 0x%p entering Power State "
1541 "%!WDF_DEVICE_POWER_STATE! from %!WDF_DEVICE_POWER_STATE!",
1544 newState, currentState);
1545
1546 if (m_PowerStateCallbacks != NULL) {
1547 //
1548 // Callback for leaving the old state
1549 //
1550 RtlZeroMemory(&data, sizeof(data));
1551
1553 data.Data.LeaveState.CurrentState = currentState;
1554 data.Data.LeaveState.NewState = newState;
1555
1556 m_PowerStateCallbacks->Invoke(currentState,
1559 &data);
1560 }
1561
1563 (USHORT) newState;
1564
1565 if (m_PowerStateCallbacks != NULL) {
1566 //
1567 // Callback for entering the new state
1568 //
1569 RtlZeroMemory(&data, sizeof(data));
1570
1572 data.Data.EnterState.CurrentState = currentState;
1573 data.Data.EnterState.NewState = newState;
1574
1575 m_PowerStateCallbacks->Invoke(newState,
1578 &data);
1579 }
1580
1581 m_Device->SetDevicePowerState(newState);
1582 currentState = newState;
1583
1584 entry = GetPowerTableEntry(currentState);
1585
1586 //
1587 // And call the state handler, if there is one.
1588 //
1589 if (entry->StateFunc != NULL) {
1590 watchdog.StartTimer(currentState);
1591 newState = entry->StateFunc(this);
1592 watchdog.CancelTimer(currentState);
1593
1594 //
1595 // Validate the return value if FX_STATE_MACHINE_VERIFY is enabled
1596 //
1597 VALIDATE_POWER_STATE(currentState, newState);
1598
1599 }
1600 else {
1601 newState = WdfDevStatePowerNull;
1602 }
1603
1604 if (m_PowerStateCallbacks != NULL) {
1605 //
1606 // Callback for post processing the new state
1607 //
1608 RtlZeroMemory(&data, sizeof(data));
1609
1611 data.Data.PostProcessState.CurrentState = currentState;
1612
1613 m_PowerStateCallbacks->Invoke(currentState,
1616 &data);
1617 }
1618 }
1619}
__inline WDF_DEVICE_POWER_STATE GetDevicePowerState()
Definition: fxdevice.hpp:1157
__inline VOID SetDevicePowerState(__in WDF_DEVICE_POWER_STATE DeviceState)
Definition: fxdevice.hpp:1182
static CPPOWER_STATE_TABLE GetPowerTableEntry(__in WDF_DEVICE_POWER_STATE State)
Definition: fxpkgpnp.hpp:2862
#define VALIDATE_POWER_STATE(_CurrentState, _NewState)
VOID Invoke(__in WDF_DEVICE_POWER_STATE State, __in WDF_STATE_NOTIFICATION_TYPE Type, __in WDFDEVICE Device, __in PCWDF_DEVICE_POWER_NOTIFICATION_DATA NotificationData)
enum _WDF_DEVICE_POWER_STATE WDF_DEVICE_POWER_STATE

Referenced by PowerProcessEventInner().

◆ PowerFinalPowerDownFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerFinalPowerDownFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 4410 of file powerstatemachine.cpp.

4425{
4426 This->PowerSendPowerDownFailureEvent(FxPowerDownTypeImplicit);
4427
4428 //
4429 // If we are not the PPO for the stack we could receive a power irp
4430 // during the middle of an implicit power down so we cannot assume
4431 // that there will be no pended power irp during an implicit power down.
4432 //
4433 ASSERT(This->IsPowerPolicyOwner() ? This->m_PendingDevicePowerIrp == NULL : TRUE);
4434
4436}
@ FxPowerDownTypeImplicit
Definition: fxpkgpnp.hpp:219
@ WdfDevStatePowerStopped
Definition: wdfdevice.h:151

◆ PowerGotoD3Stopped()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoD3Stopped ( __inout FxPkgPnp This)
staticprotected

Definition at line 2343 of file powerstatemachine.cpp.

2359{
2361 BOOLEAN failed;
2362
2363 failed = FALSE;
2364
2365 //
2366 // We *must* call suspend here even though the pnp state machine called self
2367 // managed io stop. Consider the following:
2368 // 1 this device is a filter
2369 // 2 the power policy owner has idle enabled and the device stack is
2370 // currently idled out (in Dx)
2371 // 3 the query remove comes, this driver processes it and succeeds
2372 // self managed io stop
2373 // 4 before the PwrPolStop event is processed in this driver, the pwr policy
2374 // owner moves the stack into D0.
2375 // 5 now this driver processed the PwrPolStop and moves into this state. We
2376 // now need to make sure self managed i/o is in the stopped state before
2377 // doing anything else.
2378 //
2379
2380 //
2381 // The self managed io state machine can handle a suspend event when it is
2382 // already in the stopped state.
2383 //
2384 // Tell the driver to stop its self-managed I/O.
2385 //
2386 if (This->m_SelfManagedIoMachine != NULL) {
2387 status = This->m_SelfManagedIoMachine->Suspend();
2388
2389 if (!NT_SUCCESS(status)) {
2391 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
2392 "EvtDeviceSelfManagedIoStop failed %!STATUS!", status);
2393 failed = TRUE;
2394 }
2395 }
2396
2397
2398
2399
2400
2401 // Top-edge queue hold.
2402 This->m_Device->m_PkgIo->StopProcessingForPower(FxIoStopProcessingForPowerHold);
2403
2404 if (This->PowerDmaPowerDown() == FALSE) {
2405 failed = TRUE;
2406 }
2407
2408 status = This->m_DeviceD0ExitPreInterruptsDisabled.Invoke(
2409 This->m_Device->GetHandle(),
2411 );
2412
2413 if (!NT_SUCCESS(status)) {
2414 failed = TRUE;
2415
2417 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
2418 "EvtDeviceD0ExitPreInterruptsDisabled WDFDEVICE 0x%p !devobj 0x%p, "
2419 "new state %!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
2420 This->m_Device->GetHandle(),
2421 This->m_Device->GetDeviceObject(),
2423 }
2424
2425 //
2426 // Disconnect the interrupt.
2427 //
2428 status = This->NotifyResourceObjectsDx(NotifyResourcesForceDisconnect);
2429 if (!NT_SUCCESS(status)) {
2430 //
2431 // NotifyResourceObjectsDx already traced the error
2432 //
2433 failed = TRUE;
2434 }
2435
2436 //
2437 // Call the driver to tell it to put the hardware into a sleeping
2438 // state.
2439 //
2440 status = This->m_DeviceD0Exit.Invoke(This->m_Device->GetHandle(),
2442 if (!NT_SUCCESS(status)) {
2443 failed = TRUE;
2444
2446 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
2447 "EvtDeviceD0Exit WDFDEVICE 0x%p !devobj 0x%p, new state "
2448 "%!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
2449 This->m_Device->GetHandle(),
2450 This->m_Device->GetDeviceObject(),
2452 }
2453
2454 This->PowerSetDevicePowerState(WdfPowerDeviceD3Final);
2455
2456 //
2457 // If this is a child, release the power reference on the parent
2458 //
2459 This->PowerParentPowerDereference();
2460
2461 if (failed) {
2463 }
2464
2465 This->PowerSendPowerDownEvents(FxPowerDownTypeImplicit);
2466
2467 //
2468 // If we are not the PPO for the stack we could receive a power irp
2469 // during the middle of an implicit power down so we cannot assume
2470 // that there will be no pended power irp during an implicit power down.
2471 //
2472 ASSERT(This->IsPowerPolicyOwner() ? This->m_PendingDevicePowerIrp == NULL : TRUE);
2473
2475}
@ FxIoStopProcessingForPowerHold
@ WdfDevStatePowerFinalPowerDownFailed
Definition: wdfdevice.h:210

◆ PowerGotoDNotZero()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDNotZero ( __inout FxPkgPnp This)
staticprotected

Definition at line 2608 of file powerstatemachine.cpp.

2623{
2624 This->PowerGotoDx();
2625
2626 return WdfDevStatePowerNull;
2627}

◆ PowerGotoDNotZeroIoStopped()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDNotZeroIoStopped ( __inout FxPkgPnp This)
staticprotected

Definition at line 2652 of file powerstatemachine.cpp.

2655{
2656 if (This->PowerGotoDxIoStopped() == FALSE) {
2658 }
2659
2660 return WdfDevStatePowerDx;
2661}
@ WdfDevStatePowerGotoDxFailed
Definition: wdfdevice.h:215

◆ PowerGotoDNotZeroIoStoppedNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDNotZeroIoStoppedNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 2664 of file powerstatemachine.cpp.

2667{
2668 if (This->PowerGotoDxIoStoppedNP() == FALSE) {
2670 }
2671
2672 return WdfDevStatePowerDxNP;
2673}
@ WdfDevStatePowerGotoDxNPFailed
Definition: wdfdevice.h:160

◆ PowerGotoDNotZeroNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDNotZeroNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 2630 of file powerstatemachine.cpp.

2645{
2646 This->PowerGotoDx();
2647
2648 return WdfDevStatePowerNull;
2649}

◆ PowerGotoDx()

VOID FxPkgPnp::PowerGotoDx ( VOID  )
protected

Definition at line 2698 of file powerstatemachine.cpp.

2713{
2716
2717 //
2718 // Tell the driver to stop its self-managed I/O
2719 //
2721
2722 if (!NT_SUCCESS(status)) {
2725 "EvtDeviceSelfManagedIoStop failed %!STATUS!", status);
2726
2728 }
2729 }
2730
2731
2732
2733
2734
2735 // Top-edge queue hold
2737
2739}
_Must_inspect_result_ NTSTATUS Suspend(VOID)
@ PwrPolPowerDownIoStopped

◆ PowerGotoDxArmedForWake()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDxArmedForWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 3058 of file powerstatemachine.cpp.

3074{
3075 This->PowerGotoDx();
3076
3077 return WdfDevStatePowerNull;
3078}

◆ PowerGotoDxArmedForWakeNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDxArmedForWakeNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 3081 of file powerstatemachine.cpp.

3098{
3099 This->PowerGotoDx();
3100
3101 return WdfDevStatePowerNull;
3102}

◆ PowerGotoDxFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDxFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 4500 of file powerstatemachine.cpp.

4515{
4516 //
4517 // NotifyResourceObjectsDx will log any errors
4518 //
4519 (void) This->NotifyResourceObjectsDx(NotifyResourcesForceDisconnect |
4521
4523}
@ NotifyResourcesDisconnectInactive
Definition: fxpkgpnp.hpp:213
@ WdfDevStatePowerReportPowerDownFailed
Definition: wdfdevice.h:194

◆ PowerGotoDxIoStopped()

BOOLEAN FxPkgPnp::PowerGotoDxIoStopped ( VOID  )
protected

Definition at line 2742 of file powerstatemachine.cpp.

2759{
2762 BOOLEAN failed;
2763 FxIrp irp;
2764 ULONG notifyFlags;
2765
2766 failed = FALSE;
2767
2768 //
2769 // First determine the state that will be indicated to the driver
2770 //
2772
2778 break;
2779
2780 default:
2782 break;
2783 }
2784
2785 //
2786 // Can we even be a power pageable device and be in hibernation path?
2787 //
2790 COVERAGE_TRAP();
2791
2792 //
2793 // This device is in the hibernation path and the target system state is
2794 // S4. Tell the driver that it should do special handling.
2795 //
2797 }
2798
2799 if (PowerDmaPowerDown() == FALSE) {
2800 failed = TRUE;
2801 }
2802
2805 state
2806 );
2807
2808 if (!NT_SUCCESS(status)) {
2809 failed = TRUE;
2810
2813 "EvtDeviceD0ExitPreInterruptsDisabled WDFDEVICE 0x%p !devobj 0x%p, "
2814 "new state %!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
2817 }
2818
2819 //
2820 // interrupt disable & disconnect
2821 //
2822
2824
2825 //
2826 // In general, m_WaitWakeIrp is accessed through guarded InterlockedExchange
2827 // operations. However, following is a special case where we just want to know
2828 // the current value. It is possible that the value of m_WaitWakeIrp can
2829 // change right after we query it. Users of NotifyResourcesArmedForWake will
2830 // need to be aware of this fact.
2831 //
2832 // Note that relying on m_WaitWakeIrp to decide whether to disconnect the wake
2833 // interrupts or not is unreliable and may result in a race condition between
2834 // the device powering down and a wake interrupt firing:
2835 //
2836 // Thread A: Device is powering down and is going to disconnect wake interrupts
2837 // unless m_WaitWakeIrp is not NULL.
2838 // Thread B: Wake interrupt fires (holding the OS interrupt lock) which results
2839 // in completing the IRP_MN_WAIT_WAKE and setting m_WaitWakeIrp to NULL.
2840 // Thread then blocks waiting for the device to power up.
2841 // Thread A: m_WaitWakeIrp is NULL so we disconnect the wake interrupt, but are
2842 // blocked waiting to acquire the lock held by the ISR. The deadlock
2843 // results in bugcheck 0x9F since the Dx IRP is being blocked.
2844 //
2845 // The m_WakeInterruptsKeepConnected flag is set when we request a IRP_MN_WAIT_WAKE
2846 // in the device powering down path, and is cleared below once it is used.
2847 //
2849 notifyFlags |= NotifyResourcesArmedForWake;
2851 }
2852
2853 status = NotifyResourceObjectsDx(notifyFlags);
2854 if (!NT_SUCCESS(status)) {
2855 //
2856 // NotifyResourceObjectsDx already traced the error
2857 //
2858 failed = TRUE;
2859 }
2860
2861 //
2862 // Call the driver to tell it to put the hardware into a sleeping
2863 // state.
2864 //
2865
2867
2868 if (!NT_SUCCESS(status)) {
2871 "EvtDeviceD0Exit WDFEVICE 0x%p !devobj 0x%p, new state "
2872 "%!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
2875
2876 failed = TRUE;
2877 }
2878
2879 //
2880 // If this is a child, release the power reference on the parent
2881 //
2883
2884 //
2885 // Set our state no matter if power down failed or not
2886 //
2888
2889 //
2890 // Stopping self managed io previously failed, convert that failure into
2891 // a local failure here.
2892 //
2895 failed = TRUE;
2896 }
2897
2898 if (failed) {
2899 //
2900 // Power policy will use this property when it is processing the
2901 // completion of the Dx irp.
2902 //
2904
2905 //
2906 // This state will record that we encountered an internal error.
2907 //
2908 return FALSE;
2909 }
2910
2912
2914
2915 return TRUE;
2916}
POWER_ACTION GetParameterPowerShutdownType()
Definition: fxirpum.cpp:719
virtual VOID PowerParentPowerDereference(VOID)=0
VOID PowerSendPowerDownEvents(__in FxPowerDownType Type)
BOOLEAN PowerDmaPowerDown(VOID)
FxPnpDeviceD0ExitPreInterruptsDisabled m_DeviceD0ExitPreInterruptsDisabled
Definition: fxpkgpnp.hpp:4553
virtual VOID PowerReleasePendingDeviceIrp(BOOLEAN IrpMustBePresent=TRUE)=0
_Must_inspect_result_ NTSTATUS Invoke(__in WDFDEVICE Device, __in WDF_POWER_DEVICE_STATE TargetState)
@ NotifyResourcesExplicitPowerDown
Definition: fxpkgpnp.hpp:212
@ NotifyResourcesArmedForWake
Definition: fxpkgpnp.hpp:214
@ FxPowerDownTypeExplicit
Definition: fxpkgpnp.hpp:218
@ PowerSystemHibernate
Definition: ntpoapi.h:40
@ PowerActionShutdownOff
Definition: ntpoapi.h:129
@ PowerActionShutdown
Definition: ntpoapi.h:127
@ PowerActionShutdownReset
Definition: ntpoapi.h:128
@ WdfPowerDevicePrepareForHibernation
Definition: wdfdevice.h:428

◆ PowerGotoDxIoStoppedArmedForWake()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDxIoStoppedArmedForWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 3105 of file powerstatemachine.cpp.

3108{
3109 if (This->PowerGotoDxIoStopped() == FALSE) {
3111 }
3112
3114}

◆ PowerGotoDxIoStoppedArmedForWakeNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDxIoStoppedArmedForWakeNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 3117 of file powerstatemachine.cpp.

3120{
3121 if (This->PowerGotoDxIoStoppedNP() == FALSE) {
3123 }
3124
3126}

◆ PowerGotoDxIoStoppedNP()

BOOLEAN FxPkgPnp::PowerGotoDxIoStoppedNP ( VOID  )
protected

Definition at line 2919 of file powerstatemachine.cpp.

2934{
2937 BOOLEAN failed;
2938 FxIrp irp;
2939
2940 failed = FALSE;
2941
2942 //
2943 // First determine the state that will be indicated to the driver
2944 //
2946
2952 break;
2953
2954 default:
2956 break;
2957 }
2958
2961 //
2962 // This device is in the hibernation path and the target system state is
2963 // S4. Tell the driver that it should do special handling.
2964 //
2966 }
2967
2968 if (PowerDmaPowerDown() == FALSE) {
2969 failed = TRUE;
2970 }
2971
2974 state
2975 );
2976
2977 if (!NT_SUCCESS(status)) {
2978 failed = TRUE;
2979
2982 "EvtDeviceD0ExitPreInterruptsDisabled WDFDEVICE 0x%p !devobj 0x%p, "
2983 "new state %!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
2986 }
2987
2988 //
2989 // Interrupt disable (and NO disconnect)
2990 //
2992
2993 if (!NT_SUCCESS(status)) {
2994 //
2995 // NotifyResourceObjectsDx already traced the error
2996 //
2997 failed = TRUE;
2998 }
2999
3000 //
3001 // Call the driver to tell it to put the hardware into a sleeping
3002 // state.
3003 //
3004
3006
3007 if (!NT_SUCCESS(status)) {
3010 "EvtDeviceD0Exit WDFDEVICE 0x%p !devobj 0x%p, new state "
3011 "%!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
3014
3015 failed = TRUE;
3016 }
3017
3018 //
3019 // If this is a child, release the power reference on the parent
3020 //
3022
3023 //
3024 // Set our state no matter if power down failed or not
3025 //
3027
3028 //
3029 // Stopping self managed io previously failed, convert that failure into
3030 // a local failure here.
3031 //
3034 failed = TRUE;
3035 }
3036
3037 if (failed) {
3038 //
3039 // Power policy will use this property when it is processing the
3040 // completion of the Dx irp.
3041 //
3043
3044 //
3045 // This state will record that we encountered an internal error.
3046 //
3047 return FALSE;
3048 }
3049
3051
3053
3054 return TRUE;
3055}
@ NotifyResourcesNP
Definition: fxpkgpnp.hpp:208

◆ PowerGotoDxNPFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDxNPFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 2676 of file powerstatemachine.cpp.

2691{
2692 This->DisconnectInterruptNP();
2693
2695}

◆ PowerGotoDxStopped()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDxStopped ( __inout FxPkgPnp This)
staticprotected

Definition at line 4178 of file powerstatemachine.cpp.

4194{
4195 This->PowerSendPowerDownEvents(FxPowerDownTypeImplicit);
4196
4198}

◆ PowerGotoDxStoppedDisableInterrupt()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDxStoppedDisableInterrupt ( __inout FxPkgPnp This)
staticprotected

Definition at line 4526 of file powerstatemachine.cpp.

4541{
4542 //
4543 // NotifyResourceObjectsDx will log any errors
4544 //
4545 (void) This->NotifyResourceObjectsDx(NotifyResourcesForceDisconnect |
4547
4549}
@ WdfDevStatePowerGotoDxStopped
Definition: wdfdevice.h:203

◆ PowerGotoDxStoppedDisableInterruptNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoDxStoppedDisableInterruptNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4155 of file powerstatemachine.cpp.

4171{
4172 This->NotifyResourceObjectsDx(NotifyResourcesSurpriseRemoved);
4173
4175}
@ NotifyResourcesSurpriseRemoved
Definition: fxpkgpnp.hpp:209

◆ PowerGotoImplicitD3DisarmWakeAtBus()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoImplicitD3DisarmWakeAtBus ( __inout FxPkgPnp This)
staticprotected

Definition at line 2022 of file powerstatemachine.cpp.

2038{
2039 //
2040 // We should only get into this state when this devobj is a PDO and not a
2041 // power policy owner.
2042 //
2043 ASSERT((This->m_Device->IsPdo() &&
2044 This->IsPowerPolicyOwner()) == FALSE);
2045
2046 //
2047 // Disarm
2048 // No need to complete the pended ww irp. State machine will complete it
2049 // in PnpFailed handler, or upper driver will cancel it.
2050 //
2051 This->PowerDisableWakeAtBusOverload();
2052
2054}
@ WdfDevStatePowerGotoD3Stopped
Definition: wdfdevice.h:150

◆ PowerGotoStopped()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerGotoStopped ( __inout FxPkgPnp This)
staticprotected

Definition at line 4201 of file powerstatemachine.cpp.

4218{
4219 //
4220 // We should only get into this state when this devobj is not the power
4221 // policy owner.
4222 //
4223 ASSERT(This->IsPowerPolicyOwner() == FALSE);
4224
4225 This->PowerReleasePendingDeviceIrp();
4227}

◆ PowerIndicateWaitWakeStatus()

BOOLEAN FxPkgPnp::PowerIndicateWaitWakeStatus ( __in NTSTATUS  WaitWakeStatus)

Definition at line 4781 of file powerstatemachine.cpp.

4808{
4810 //
4811 // The power machine will eventually call PowerCompletePendedWakeIrp
4812 // to complete the request.
4813 //
4816 }
4817 else if (NT_SUCCESS(WaitWakeStatus)) {
4819 }
4820 else {
4822 }
4823
4824 return TRUE;
4825 }
4826 else {
4827 return FALSE;
4828 }
4829}
@ PowerWakeCanceled
@ PowerWakeSucceeded
@ PowerWakeFailed

Referenced by if(), PnpCleanupForRemove(), and PowerPolicyCancelWaitWake().

◆ PowerInitialConnectInterruptFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerInitialConnectInterruptFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 3953 of file powerstatemachine.cpp.

3970{
3971 This->PowerConnectInterruptFailed();
3972
3974}

◆ PowerInitialDmaEnableFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerInitialDmaEnableFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 3978 of file powerstatemachine.cpp.

3994{
3996
3997 (void) This->PowerDmaPowerDown();
3998
3999 status = This->m_DeviceD0ExitPreInterruptsDisabled.Invoke(
4000 This->m_Device->GetHandle(),
4002 );
4003
4004 if (!NT_SUCCESS(status)) {
4005 //
4006 // Report the error, but continue forward
4007 //
4009 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
4010 "EvtDeviceD0ExitPreInterruptsDisabled WDFDEVICE 0x%p !devobj 0x%p "
4011 "new state %!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
4012 This->m_Device->GetHandle(),
4013 This->m_Device->GetDeviceObject(),
4015 }
4016
4018}

◆ PowerInitialPowerUpFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerInitialPowerUpFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 4075 of file powerstatemachine.cpp.

4090{
4091 This->PowerSendPowerUpFailureEvent();
4092
4094}

◆ PowerInitialPowerUpFailedDerefParent()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerInitialPowerUpFailedDerefParent ( __inout FxPkgPnp This)
staticprotected

Definition at line 4049 of file powerstatemachine.cpp.

4064{
4065
4066 //
4067 // If this is a child, release the power reference on the parent
4068 //
4069 This->PowerParentPowerDereference();
4070
4072}
@ WdfDevStatePowerInitialPowerUpFailed
Definition: wdfdevice.h:199

◆ PowerInitialSelfManagedIoFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerInitialSelfManagedIoFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 4021 of file powerstatemachine.cpp.

4038{
4039
4040
4041
4042
4043 This->m_Device->m_PkgIo->StopProcessingForPower(FxIoStopProcessingForPowerHold);
4044
4046}

◆ PowerIsWakeRequestPresent()

BOOLEAN FxPkgPnp::PowerIsWakeRequestPresent ( VOID  )
inlineprotected

Definition at line 2672 of file fxpkgpnp.hpp.

2675 {
2676 //
2677 // We don't acquire the spinlock because when we transition to the state
2678 // which will attempt the arming of the device (at bus level), we will
2679 // gracefully handle the absence of the irp.
2680 //
2681 // On the other side if there is no irp and it is set immediately after
2682 // our check, the event posted by the irp's arrival will transition us
2683 // to the state which will attempt the arming.
2684 //
2686 }

◆ PowerMakeWakeRequestNonCancelable()

BOOLEAN FxPkgPnp::PowerMakeWakeRequestNonCancelable ( __in NTSTATUS  Status)
protected

Definition at line 4899 of file powerstatemachine.cpp.

4917{
4918 KIRQL irql;
4920
4921 //
4922 // Currently we assume that if we are the bus wait wake owner and that only
4923 // PDOs can be bus wake owners, so we must have a parent device.
4924 //
4927
4928 result = FALSE;
4929
4930 //
4931 // Attempt to retrieve the wait wake irp. We can safely dereference the
4932 // PIRP in while holding the lock as long as it is not NULL.
4933 //
4935
4937 MdCancelRoutine pOldCancelRoutine;
4938 FxIrp wwIrp;
4939
4941
4942 pOldCancelRoutine = wwIrp.SetCancelRoutine(NULL);
4943
4944 if (pOldCancelRoutine != NULL) {
4945 FxPkgPnp* pParentPkg;
4946
4947 pParentPkg = m_Device->m_ParentDevice->m_PkgPnp;
4948
4949 //
4950 // Propagate the successful wake status from the parent to this
4951 // child's WW IRP if the parent is the PPO for its stack.
4952 //
4954 pParentPkg->IsPowerPolicyOwner() &&
4956 //
4957 // The only way that m_SystemWakeSource can be TRUE is if
4958 // FxLibraryGlobals.PoGetSystemWake != NULL and if it is not
4959 // NULL, then FxLibraryGlobals.PoSetSystemWake cannot be NULL
4960 // either.
4961
4962
4963
4964
4965
4967
4968 //
4969 // If this PDO is the PPO for its stack, then we must mark this
4970 // device as the system wake source if we have any
4971 // enumerated PDOs off of this PDO so that we can propagate the
4972 // system wake source attribute to our children stacks.
4973 // (For a FDO which is the PPO, we do this in the WW completion
4974 // routine.)
4975 //
4976 if (IsPowerPolicyOwner()) {
4979 "WDFDEVICE 0x%p !devobj 0x%p WW !irp 0x%p is a source "
4980 "of wake", m_Device->GetHandle(),
4983
4985 }
4986 }
4987
4988 //
4989 // Set the status for the irp when it is completed later
4990 //
4992
4993 //
4994 // Queue the irp for completion later
4995 //
4997 wwIrp.ListEntry());
4998
4999 wwIrp.SetIrp(NULL);
5001 result = TRUE;
5002 }
5003 else {
5004 //
5005 // The irp is being canceled as we run here. As soon as the spin
5006 // lock is dropped, the cancel routine will run (or continue if it
5007 // is blocked on this lock). Do nothing here and let the cancel
5008 // routine run its course.
5009 //
5010 ASSERT(wwIrp.IsCanceled());
5011 DO_NOTHING();
5012 }
5013 }
5015
5016 return result;
5017}
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
MdCancelRoutine SetCancelRoutine(__in_opt MdCancelRoutine CancelRoutine)
Definition: fxirpum.cpp:124
PLIST_ENTRY ListEntry()
Definition: fxirpum.cpp:535
BOOLEAN IsCanceled()
Definition: fxirpum.cpp:484
BOOLEAN IsPowerPolicyOwner(VOID)
Definition: fxpkgpnp.hpp:3612
static VOID _PowerSetSystemWakeSource(__in FxIrp *Irp)

Referenced by PowerCompleteWakeRequestFromWithinMachine(), and PowerIndicateWaitWakeStatus().

◆ PowerNotifyingD0EntryToWakeInterrupts()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerNotifyingD0EntryToWakeInterrupts ( __inout FxPkgPnp This)
staticprotected

Definition at line 4604 of file powerstatemachine.cpp.

4621{
4622 if (This->m_WakeInterruptCount == 0) {
4624 }
4625
4626 This->SendEventToAllWakeInterrupts(WakeInterruptEventEnteringD0);
4627
4628 return WdfDevStatePowerNull;;
4629}
@ WakeInterruptEventEnteringD0
@ WdfDevStatePowerWakingConnectInterrupt
Definition: wdfdevice.h:183

◆ PowerNotifyingD0EntryToWakeInterruptsNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerNotifyingD0EntryToWakeInterruptsNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4681 of file powerstatemachine.cpp.

4698{
4699 if (This->m_WakeInterruptCount == 0) {
4701 }
4702
4703 This->SendEventToAllWakeInterrupts(WakeInterruptEventEnteringD0);
4704
4705 return WdfDevStatePowerNull;;
4706}
@ WdfDevStatePowerWakingConnectInterruptNP
Definition: wdfdevice.h:184

◆ PowerNotifyingD0ExitToWakeInterrupts()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerNotifyingD0ExitToWakeInterrupts ( __inout FxPkgPnp This)
staticprotected

Definition at line 4632 of file powerstatemachine.cpp.

4649{
4650 if (This->m_WakeInterruptCount == 0) {
4652 }
4653
4654 //
4655 // Indiciate to the wake interrupt state machine that the device is
4656 // leaving D0 and also whether the device is armed for wake. The wake
4657 // interrupt machine treats these differently as described below.
4658 //
4659 if (This->m_WakeInterruptsKeepConnected == TRUE ||
4660 This->m_SharedPower.m_WaitWakeIrp != NULL) {
4661 This->SendEventToAllWakeInterrupts(WakeInterruptEventLeavingD0);
4662 }
4663 else {
4664 //
4665 // When a wake interrupt is not armed for wake it will be disconnected
4666 // by the power state machine once the wake interrupt state machine
4667 // acknowledges the transition. If the interrupt fires between
4668 // the time this event is posted and it is disconnected, it needs to be
4669 // delivered to the driver or a deadlock could occur between PO state machine
4670 // trying to disconnect the interrupt and the wake interrupt machine
4671 // holding on to the ISR waiting for the device to return to D0 before
4672 // delivering the interrupt.
4673 //
4674 This->SendEventToAllWakeInterrupts(WakeInterruptEventLeavingD0NotArmedForWake);
4675 }
4676
4677 return WdfDevStatePowerNull;;
4678}
@ WakeInterruptEventLeavingD0
@ WakeInterruptEventLeavingD0NotArmedForWake
@ WdfDevStatePowerGotoDxIoStopped
Definition: wdfdevice.h:158

◆ PowerNotifyingD0ExitToWakeInterruptsNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerNotifyingD0ExitToWakeInterruptsNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4709 of file powerstatemachine.cpp.

4726{
4727 if (This->m_WakeInterruptCount == 0) {
4729 }
4730
4731 //
4732 // Indiciate to the wake interrupt state machine that the device is
4733 // leaving D0 and also whether the device is armed for wake. The wake
4734 // interrupt machine treats these differently as described below
4735 //
4736 if (This->m_WakeInterruptsKeepConnected == TRUE ||
4737 This->m_SharedPower.m_WaitWakeIrp != NULL) {
4738 This->SendEventToAllWakeInterrupts(WakeInterruptEventLeavingD0);
4739 }
4740 else {
4741 //
4742 // When a wake interrupt is not armed for wake it will be disconnected by
4743 // the power state machine once the wake interrupt state machine
4744 // acknowledges the transition. If the interrupt fires between
4745 // the time this event is posted and it is disconnected, it needs to be
4746 // delivered to the driver or a deadlock could occur between PO state machine
4747 // trying to disconnect the interrupt and the wake interrupt machine holding on
4748 // to the ISR waiting for the device to return to D0 before delivering the
4749 // interrupt.
4750 //
4751 This->SendEventToAllWakeInterrupts(WakeInterruptEventLeavingD0NotArmedForWake);
4752 }
4753
4754 return WdfDevStatePowerNull;;
4755}
@ WdfDevStatePowerGotoDxIoStoppedNP
Definition: wdfdevice.h:159

◆ PowerParentPowerDereference()

virtual VOID FxPkgPnp::PowerParentPowerDereference ( VOID  )
protectedpure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

Referenced by PowerGotoDxIoStopped(), and PowerGotoDxIoStoppedNP().

◆ PowerPolCancelingUsbSSForSystemSleep()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolCancelingUsbSSForSystemSleep ( __inout FxPkgPnp This)
staticprotected

Definition at line 8296 of file powerpolicystatemachine.cpp.

8312{
8314
8315 if (This->PowerPolicyCancelUsbSSIfCapable()) {
8316 //
8317 // Usbss completion event will move us from this state.
8318 //
8319 return WdfDevStatePwrPolNull;
8320 }
8321
8322 //
8323 // If usbss irp was there it has already been canceled, so march on.
8324 //
8326}
#define ASSERT_PWR_POL_STATE(_This, _State)
@ WdfDevStatePwrPolCancelingWakeForSystemSleep
Definition: wdfdevice.h:308
@ WdfDevStatePwrPolCancelingUsbSSForSystemSleep
Definition: wdfdevice.h:361

◆ PowerPolCancelingWakeForSystemSleep()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolCancelingWakeForSystemSleep ( __inout FxPkgPnp This)
staticprotected

Definition at line 6103 of file powerpolicystatemachine.cpp.

6106{
6108
6109 if (This->PowerPolicyCancelWaitWake() == FALSE &&
6110 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
6112 }
6113
6114 return WdfDevStatePwrPolNull;
6115}
@ WdfDevStatePwrPolCancelingWakeForSystemSleepWakeCanceled
Definition: wdfdevice.h:309

◆ PowerPolCancelingWakeForSystemSleepWakeCanceled()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolCancelingWakeForSystemSleepWakeCanceled ( __inout FxPkgPnp This)
staticprotected

Definition at line 6118 of file powerpolicystatemachine.cpp.

6121{
6123
6126
6127 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, NoRetry);
6128
6129 if (!NT_SUCCESS(status)) {
6130 COVERAGE_TRAP();
6132 }
6133
6134 return WdfDevStatePwrPolNull;
6135}
@ NoRetry
Definition: fxpkgpnp.hpp:202
@ WdfDevStatePwrPolPowerUpForSystemSleepNotSeen
Definition: wdfdevice.h:356

◆ PowerPolCancelUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolCancelUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 6845 of file powerpolicystatemachine.cpp.

6861{
6863
6864 //
6865 // We notified the device power requirement state machine that we are about
6866 // to power down, but eventually we didn't power down. So notify the device
6867 // power requirement state machine that the device should be considered
6868 // powered on.
6869 //
6870 This->m_PowerPolicyMachine.m_Owner->
6871 m_PoxInterface.DeviceIsPoweredOn();
6872
6873 This->m_PowerPolicyMachine.m_Owner->
6874 m_PoxInterface.RequestComponentActive();
6875
6876 if (This->PowerPolicyCancelUsbSSIfCapable() == FALSE) {
6877 //
6878 // UsbSS has already been canceled/completed
6879 //
6881 }
6882
6883 return WdfDevStatePwrPolNull;
6884}
@ WdfDevStatePwrPolStartedCancelTimer
Definition: wdfdevice.h:334
@ WdfDevStatePwrPolCancelUsbSS
Definition: wdfdevice.h:332

◆ PowerPolCheckPowerPageable()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolCheckPowerPageable ( __inout FxPkgPnp This)
staticprotected

Definition at line 4146 of file powerpolicystatemachine.cpp.

4162{
4163 ULONG flags;
4165
4167
4168 deviceObject.SetObject(This->m_Device->GetDeviceObject());
4170
4171 if (flags & DO_POWER_PAGABLE) {
4172 ASSERT((flags & DO_POWER_INRUSH) == 0);
4173
4175 }
4176 else {
4177 //
4178 // DO_POWER_INRUSH also gets us to this state, but since it is mutually
4179 // exclusive with DO_POWER_PAGABLE, we don't need to check for it
4180 //
4182 }
4183}
ULONG GetFlags(VOID)
GLbitfield flags
Definition: glext.h:7161
@ WdfDevStatePwrPolSleepingWakeWakeArrived
Definition: wdfdevice.h:249
@ WdfDevStatePwrPolSleepingWakeWakeArrivedNP
Definition: wdfdevice.h:258
@ WdfDevStatePwrPolCheckPowerPageable
Definition: wdfdevice.h:248
#define DO_POWER_INRUSH

◆ PowerPolDeviceD0PowerRequestFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolDeviceD0PowerRequestFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 7049 of file powerpolicystatemachine.cpp.

7064{
7065 COVERAGE_TRAP();
7066
7068
7069 This->SetInternalFailure();
7070
7071 if (FALSE == This->m_ReleaseHardwareAfterDescendantsOnFailure) {
7072 This->PnpProcessEvent(PnpEventPowerUpFailed);
7073 }
7074
7076}
@ PnpEventPowerUpFailed
@ WdfDevStatePwrPolDeviceD0PowerRequestFailed
Definition: wdfdevice.h:341
@ WdfDevStatePwrPolDevicePowerRequestFailed
Definition: wdfdevice.h:342

◆ PowerPolDeviceIdleReturnToActive()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolDeviceIdleReturnToActive ( __inout FxPkgPnp This)
staticprotected

Definition at line 3787 of file powerpolicystatemachine.cpp.

3802{
3804
3805 This->m_PowerPolicyMachine.m_Owner->
3806 m_PoxInterface.RequestComponentActive();
3807
3809}
@ WdfDevStatePwrPolDeviceIdleReturnToActive
Definition: wdfdevice.h:365

◆ PowerPolDeviceIdleSleeping()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolDeviceIdleSleeping ( __inout FxPkgPnp This)
staticprotected

Definition at line 3812 of file powerpolicystatemachine.cpp.

3827{
3829
3830 //
3831 // Normally we'd make the component active when we get the device-power-
3832 // required notification. But we've not yet processed the device-power-not-
3833 // required notification, so we will not be processing the device-power-
3834 // required notification either. So let's activate the component before we
3835 // process the Sx IRP.
3836 //
3837 This->m_PowerPolicyMachine.m_Owner->
3838 m_PoxInterface.RequestComponentActive();
3839
3841}
@ WdfDevStatePwrPolDeviceIdleSleeping
Definition: wdfdevice.h:366
@ WdfDevStatePwrPolStartedIdleCapableCancelTimerForSleep
Definition: wdfdevice.h:339

◆ PowerPolDeviceIdleStopping()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolDeviceIdleStopping ( __inout FxPkgPnp This)
staticprotected

Definition at line 3844 of file powerpolicystatemachine.cpp.

3859{
3861
3862 //
3863 // Normally we'd make the component active when we get the device-power-
3864 // required notification. But we've not yet processed the device-power-not-
3865 // required notification, so we will not be processing the device-power-
3866 // required notification either. So let's activate the component before we
3867 // process the stop/remove request.
3868 //
3869 This->m_PowerPolicyMachine.m_Owner->
3870 m_PoxInterface.RequestComponentActive();
3871
3873}
@ WdfDevStatePwrPolStoppingCancelTimer
Definition: wdfdevice.h:326
@ WdfDevStatePwrPolDeviceIdleStopping
Definition: wdfdevice.h:367

◆ PowerPolDevicePowerRequestFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolDevicePowerRequestFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 7079 of file powerpolicystatemachine.cpp.

7096{
7098
7099 //
7100 // In the failure path we still need to notify the children that they can
7101 // power up so that they will unblock.
7102 //
7103 This->PowerPolicyChildrenCanPowerUp();
7104
7105 This->m_PowerPolicyMachine.m_Owner->m_PowerFailed = TRUE;
7106
7107 //
7108 // Notify the device power requirement state machine that the device should
7109 // be considered powered on, although it may not be in reality. Doing this
7110 // will ensure that component activation before device removal will succeed.
7111 //
7112 This->m_PowerPolicyMachine.m_Owner->
7113 m_PoxInterface.DeviceIsPoweredOn();
7114
7115 return WdfDevStatePwrPolNull;
7116}

◆ PowerPolDisarmingWakeForSystemSleepCompletePowerUp()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolDisarmingWakeForSystemSleepCompletePowerUp ( __inout FxPkgPnp This)
staticprotected

Definition at line 6138 of file powerpolicystatemachine.cpp.

6155{
6158
6159 //
6160 // If the PDO is the Power Policy owner, then disable wake at bus, otherwise
6161 // the power state machine will disable wake at bus.
6162 //
6163 if (This->m_Device->IsPdo()) {
6164 This->PowerDisableWakeAtBusOverload();
6165 }
6166
6167 This->m_PowerPolicyMachine.m_Owner->m_DeviceDisarmWakeFromS0.Invoke(
6168 This->m_Device->GetHandle()
6169 );
6170
6171 This->PowerProcessEvent(PowerCompleteD0);
6172
6173 return WdfDevStatePwrPolNull;
6174}
@ WdfDevStatePwrPolDisarmingWakeForSystemSleepCompletePowerUp
Definition: wdfdevice.h:310

◆ PowerPolicyBlockChildrenPowerUp()

VOID FxPkgPnp::PowerPolicyBlockChildrenPowerUp ( VOID  )
inlineprivate

Definition at line 4017 of file fxpkgpnp.hpp.

4020 {
4021 if (m_EnumInfo != NULL) {
4022 m_EnumInfo->AcquireParentPowerStateLock(GetDriverGlobals());
4023 //
4024 // Setup a guard so that no children power up until we return to S0.
4025 //
4027 m_EnumInfo->ReleaseParentPowerStateLock(GetDriverGlobals());
4028 }
4029 }

Referenced by PowerPolicyPowerDownForSx().

◆ PowerPolicyCancelUsbSS()

VOID FxPkgPnp::PowerPolicyCancelUsbSS ( VOID  )
protected

Definition at line 197 of file powerpolicystatemachinekm.cpp.

Referenced by PowerPolicyCancelUsbSSIfCapable().

◆ PowerPolicyCancelUsbSSIfCapable()

BOOLEAN FxPkgPnp::PowerPolicyCancelUsbSSIfCapable ( VOID  )
protected

Definition at line 8361 of file powerpolicystatemachine.cpp.

8377{
8380 return FALSE;
8381 }
8382 else {
8384 return TRUE;
8385 }
8386}
VOID PowerPolicyCancelUsbSS(VOID)
BOOLEAN m_EventDropped

◆ PowerPolicyCancelWaitWake()

BOOLEAN FxPkgPnp::PowerPolicyCancelWaitWake ( VOID  )
protected

Definition at line 7724 of file powerpolicystatemachine.cpp.

7739{
7740 MdIrp wwIrp;
7741 BOOLEAN cancelled, result;
7742
7744 //
7745 // This will complete the irp and then post the appropriate events to
7746 // both the power and power policy state machines.
7747 //
7749 }
7750 else {
7753
7754 if (wwIrp != NULL) {
7755 FxIrp irp(wwIrp);
7756
7758 "Successfully got WaitWake irp %p for cancelling", wwIrp);
7759
7760 result = irp.Cancel();
7761
7763 "Cancel of irp %p returned %d", wwIrp, result);
7764
7765
7768 }
7769 else {
7770 //
7771 // Irp has been completed by the lower bus driver, that's OK
7772 // because the completion of the request will trigger the
7773 // same transition
7774 //
7775 DO_NOTHING();
7776 }
7777
7778 cancelled = TRUE;
7779 }
7780 else {
7782 "No WaitWake irp to cancel");
7783
7784 cancelled = FALSE;
7785 }
7786 }
7787
7788 return cancelled;
7789}
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45

◆ PowerPolicyCanChildPowerUp()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PowerPolicyCanChildPowerUp ( __out PBOOLEAN  PowerUp)
inline

Definition at line 3686 of file fxpkgpnp.hpp.

3689 {
3690 *PowerUp = FALSE;
3691
3692 if (IsPowerPolicyOwner()) {
3694
3695 //
3696 // By referencing the parent (this device) we make sure that if the
3697 // parent is in Dx, we force it back into D0 so that this child can
3698 // be in D0.
3699 //
3701
3702 if (!NT_SUCCESS(status)) {
3703 return status;
3704 }
3705
3706 //
3707 // m_EnumInfo is valid because the child device is calling into the
3708 // parent device and if there is a child, there is a m_EnumInfo.
3709 //
3710 m_EnumInfo->AcquireParentPowerStateLock(GetDriverGlobals());
3711
3712 //
3713 // The caller has added a power reference to this device, so this device
3714 // will remain in D0 until that power reference has been removed. This
3715 // count is separate from the power ref count b/c the power ref count
3716 // only controls when the idle timer will fire. This count handles the
3717 // race that can occur after we decide that the parent is idle and act
3718 // on it and the child powers up before this parent actually powers
3719 // down.
3720 //
3723
3724 m_EnumInfo->ReleaseParentPowerStateLock(GetDriverGlobals());
3725 }
3726 else {
3727 //
3728 // The parent (this device) is not the power policy owner. That
3729 // means we cannot poke the parent to come back to D0 and rely on
3730 // the parent being in D0. Our only recourse is to move into D0 and
3731 // ignore the parent's device power state.
3732 //
3733 // We will only get into this situation if the parent is not the
3734 // power policy owner of the stack. This usually means the parent
3735 // is a filter driver in the parent stack and is creating a virtual
3736 // child. Since the child is assumed virtual, it's D state is not
3737 // tied to real hardware and doesn't really matter.
3738 //
3739 *PowerUp = TRUE;
3740 }
3741
3742 return STATUS_SUCCESS;
3743 }

Referenced by FxPkgPdo::PowerCheckParentOverload().

◆ PowerPolicyCanIdlePowerDown()

BOOLEAN FxPkgPnp::PowerPolicyCanIdlePowerDown ( __in DEVICE_POWER_STATE  DxState)
private

Definition at line 7933 of file powerpolicystatemachine.cpp.

7954{
7955 BOOLEAN powerDown;
7956
7957 //
7958 // If we potentially have children, make sure that they are all in Dx before
7959 // the parent powers down.
7960 //
7961 if (m_EnumInfo != NULL) {
7962 m_EnumInfo->AcquireParentPowerStateLock(GetDriverGlobals());
7964 //
7965 // Setup a guard so that no children power up until we either fail
7966 // this power down or power all the way down and back up.
7967 //
7969 powerDown = TRUE;
7970 }
7971 else {
7974 "WDFDEVICE %p !devobj 0x%p not idling out because there are %d "
7975 "children who are powered up", m_Device->GetHandle(),
7978 powerDown = FALSE;
7979 }
7980 m_EnumInfo->ReleaseParentPowerStateLock(GetDriverGlobals());
7981 }
7982 else {
7983 powerDown = TRUE;
7984 }
7985
7986 if (powerDown) {
7988
7990
7991 if (!NT_SUCCESS(status)) {
7992 //
7993 // This will set m_ChildrenCanPowerUp to TRUE and send a
7994 // ParentMovesToD0 in case any children powered down in between
7995 // determining if the parent can go idle and failing to do so.
7996 //
7998
7999 powerDown = FALSE;
8000 }
8001 }
8002
8003 return powerDown;
8004}
_Must_inspect_result_ NTSTATUS PowerPolicySendDevicePowerRequest(__in DEVICE_POWER_STATE DeviceState, __in SendDeviceRequestAction Action)
VOID PowerPolicyChildrenCanPowerUp(VOID)

◆ PowerPolicyCanWakeFromSystemState()

BOOLEAN FxPkgPnp::PowerPolicyCanWakeFromSystemState ( __in SYSTEM_POWER_STATE  SystemState)
inlineprotected

Definition at line 2831 of file fxpkgpnp.hpp.

2834 {
2835 return SystemState <= PowerPolicyGetDeviceDeepestSystemWakeState();
2836 }
SYSTEM_POWER_STATE PowerPolicyGetDeviceDeepestSystemWakeState(VOID)
Definition: fxpkgpnp.hpp:2839

Referenced by PowerPolicyHandleSystemQueryPower().

◆ PowerPolicyCheckAssumptions()

VOID FxPkgPnp::PowerPolicyCheckAssumptions ( VOID  )
private

Definition at line 2052 of file powerpolicystatemachine.cpp.

2071{
2072 WDFCASSERT(sizeof(FxPwrPolStateInfo) == sizeof(ULONG));
2073
2075 ==
2077
2078 // we assume these are the same length when we update the history index
2080 sizeof(m_PowerPolicyMachine.m_Queue[0]))
2081 ==
2084}
FxPowerPolicyEvent m_Queue[FxPowerPolicyEventQueueDepth]

◆ PowerPolicyChildPoweredDown()

VOID FxPkgPnp::PowerPolicyChildPoweredDown ( VOID  )
inline

Definition at line 3746 of file fxpkgpnp.hpp.

3749 {
3750 //
3751 // If this parent is the power policy owner of the child's stack, release
3752 // the requirement this device to be in D0 while the child is in D0.
3753 //
3754 if (IsPowerPolicyOwner()) {
3755 //
3756 // Decrement the number of children who are powered on
3757 //
3758 m_EnumInfo->AcquireParentPowerStateLock(GetDriverGlobals());
3761 m_EnumInfo->ReleaseParentPowerStateLock(GetDriverGlobals());
3762
3764 }
3765 }

Referenced by FxPkgPdo::PowerParentPowerDereference().

◆ PowerPolicyChildrenCanPowerUp()

VOID FxPkgPnp::PowerPolicyChildrenCanPowerUp ( VOID  )
private

Definition at line 8040 of file powerpolicystatemachine.cpp.

8056{
8057 //
8058 // This can be called for any PPO so we must check first if we have any
8059 // possibility of children.
8060 //
8061 if (m_EnumInfo == NULL) {
8062 return;
8063 }
8064
8065 if (IsPowerPolicyOwner()) {
8066 m_EnumInfo->AcquireParentPowerStateLock(GetDriverGlobals());
8067
8068 //
8069 // When the child attempts to power up, m_ChildrenPoweredOnCount can
8070 // be incremented while the parent is in Dx. The important value
8071 // here is the guard value, m_ChildrenCanPowerUp which must be
8072 // FALSE.
8073 //
8074 // ASSERT (m_PowerPolicyMachine.m_Owner->m_ChildrenPoweredOnCount == 0);
8075
8076 //
8077 // In the USB SS case, we can return to StartingDecideS0Wake without
8078 // ever attempting to go into a Dx state state, so m_ChildrenCanPowerUp
8079 // can be TRUE.
8080 //
8081 // ASSERT(m_PowerPolicyMachine.m_Owner->m_ChildrenCanPowerUp == FALSE);
8082
8084 m_EnumInfo->ReleaseParentPowerStateLock(GetDriverGlobals());
8085
8086 //
8087 // Now that we have set the state of the parent, any child which checks
8088 // the power state after we have released the lock will be able to
8089 // power up immediately. We now need to unblock all children which
8090 // checked the parent state before this function was called by posting
8091 // a PowerParentToD0 event to each child (regardless of the PDO device
8092 // power state).
8093 //
8095 }
8096 else {
8097 //
8098 // Since we are not the power policy owner for the parent device,
8099 // we cannot make any guarantees about the child being in D0 while
8100 // the parent is in D0 so we do not call PowerPostParentToD0ToChildren().
8101 // Additionally in PowerPolicyCanChildPowerUp(), if the parent (this)
8102 // device is not the PPO, we don't even check the parent D state before
8103 // powering up the child.
8104 //
8105 DO_NOTHING();
8106 }
8107}
VOID PowerPolicyPostParentToD0ToChildren(VOID)

Referenced by PowerPolicyCanIdlePowerDown().

◆ PowerPolicyCompleteSystemPowerIrp()

VOID FxPkgPnp::PowerPolicyCompleteSystemPowerIrp ( VOID  )
protected

Definition at line 7700 of file powerpolicystatemachine.cpp.

7703{
7706
7708
7710
7713 "Completing system power irp %p (S%d), %!STATUS!",
7716 status);
7717
7719
7721}

Referenced by PowerPolicyProcessEventInner().

◆ PowerPolicyDisarmWakeFromSx()

VOID __inline FxPkgPnp::PowerPolicyDisarmWakeFromSx ( VOID  )
private

Definition at line 8111 of file powerpolicystatemachine.cpp.

8124{
8125 NTSTATUS wwStatus;
8127
8130 );
8131
8133
8134 if (wwStatus != STATUS_CANCELLED &&
8135 m_EnumInfo != NULL &&
8138
8139 ple = NULL;
8141 ((FxChildList*) ple->GetTransactionedObject())->
8142 IndicateWakeStatus(wwStatus);
8143 }
8144
8146 }
8147
8149
8150 //
8151 // Always set the wake source back to FALSE regardless of it previous value.
8152 //
8154}
BOOLEAN __inline PowerPolicyShouldPropagateWakeStatusToChildren(VOID)
Definition: fxpkgpnp.hpp:3407
VOID Invoke(__in WDFDEVICE Device)
FxPowerDeviceDisarmWakeFromSx m_DeviceDisarmWakeFromSx

◆ PowerPolicyEnterNewState()

VOID FxPkgPnp::PowerPolicyEnterNewState ( __in WDF_DEVICE_POWER_POLICY_STATE  State)
protected

Definition at line 3349 of file powerpolicystatemachine.cpp.

3365{
3367 WDF_DEVICE_POWER_POLICY_STATE currentState, newState;
3369 FxWatchdog watchdog(this);
3370
3371 currentState = m_Device->GetDevicePowerPolicyState();
3372 newState = NewState;
3373
3374 while (newState != WdfDevStatePwrPolNull) {
3377 "WDFDEVICE 0x%p !devobj 0x%p entering power policy state "
3378 "%!WDF_DEVICE_POWER_POLICY_STATE! from "
3379 "%!WDF_DEVICE_POWER_POLICY_STATE!", m_Device->GetHandle(),
3380 m_Device->GetDeviceObject(), newState, currentState);
3381
3383 //
3384 // Callback for leaving the old state
3385 //
3386 RtlZeroMemory(&data, sizeof(data));
3387
3389 data.Data.LeaveState.CurrentState = currentState;
3390 data.Data.LeaveState.NewState = newState;
3391
3392 m_PowerPolicyStateCallbacks->Invoke(currentState,
3395 &data);
3396 }
3397
3400
3402 //
3403 // Callback for entering the new state
3404 //
3405 RtlZeroMemory(&data, sizeof(data));
3406
3408 data.Data.EnterState.CurrentState = currentState;
3409 data.Data.EnterState.NewState = newState;
3410
3414 &data);
3415 }
3416
3418 currentState = newState;
3419
3420 entry = GetPowerPolicyTableEntry(currentState);
3421
3422 //
3423 // And call the state handler, if there is one.
3424 //
3425 if (entry->StateFunc != NULL) {
3426 watchdog.StartTimer(currentState);
3427 newState = entry->StateFunc(this);
3428 watchdog.CancelTimer(currentState);
3429
3430 //
3431 // Validate the return value if FX_STATE_MACHINE_VERIFY is enabled
3432 //
3433 VALIDATE_PWR_POL_STATE(currentState, newState);
3434
3435 }
3436 else {
3437 newState = WdfDevStatePwrPolNull;
3438 }
3439
3441 //
3442 // Callback for post processing the new state
3443 //
3444 RtlZeroMemory(&data, sizeof(data));
3445
3447 data.Data.PostProcessState.CurrentState = currentState;
3448
3449 m_PowerPolicyStateCallbacks->Invoke(currentState,
3452 &data);
3453 }
3454 }
3455}
static CPPOWER_POLICY_STATE_TABLE GetPowerPolicyTableEntry(__in WDF_DEVICE_POWER_POLICY_STATE State)
Definition: fxpkgpnp.hpp:2871
#define VALIDATE_PWR_POL_STATE(_CurrentState, _NewState)

Referenced by PowerPolicyProcessEventInner().

◆ PowerPolicyGetCurrentWakeReason()

ULONG FxPkgPnp::PowerPolicyGetCurrentWakeReason ( VOID  )

Definition at line 5782 of file fxpkgpnp.cpp.

5806{
5807 ULONG wakeReason;
5808
5809 wakeReason = 0x0;
5810
5813 //
5814 // Wake settings depends on children and one or more children are
5815 // armed for wake.
5816 //
5818 }
5819
5821 //
5822 // Wake settings is explicitly enabled.
5823 //
5825 }
5826
5827 return wakeReason;
5828}
@ FxPowerPolicySxWakeDeviceEnabledFlag
@ FxPowerPolicySxWakeChildrenArmedFlag

Referenced by PowerPolicyIsWakeEnabled().

◆ PowerPolicyGetDeviceDeepestDeviceWakeState()

DEVICE_POWER_STATE FxPkgPnp::PowerPolicyGetDeviceDeepestDeviceWakeState ( __in SYSTEM_POWER_STATE  SystemState)
protected

Definition at line 6440 of file fxpkgpnp.cpp.

6443{
6444 DEVICE_POWER_STATE dxState;
6445
6446 //
6447 // Earlier versions of WDF (pre-1.11) did not take into account SystemState
6448 // in figuring out the deepest wake state. So for compatibility we restrict
6449 // this to drivers compiled for 1.11 or newer. See comments in the
6450 // FxPkgPnp::QueryForCapabilities function for more information on
6451 // compatibility risk.
6452 //
6453 if (GetDriverGlobals()->IsVersionGreaterThanOrEqualTo(1,11)) {
6454 if ((SystemState < PowerSystemWorking) ||
6455 (SystemState > PowerSystemHibernate)) {
6456 dxState = PowerDeviceD0;
6457 } else {
6458 dxState = MapWakeDepthToDstate(
6460 );
6461 }
6462 }
6463 else {
6464 //
6465 // For pre-1.11 drivers, all of m_DeviceWake array is populated with
6466 // the same DeviceWake value obtained from device capabilities so we
6467 // just use the first one (index 0).
6468 //
6470 }
6471
6472 //
6473 // Per WDM docs DeviceWake and SystemWake must be non-zero to support
6474 // wake. We warn about the violation. Ideally, a verifier check would have
6475 // been better but we want to avoid that because some drivers may
6476 // intentionally call this DDI and do not treat the DDI failure as fatal (
6477 // because they are aware that DDI may succeed in some cases), and a verifier
6478 // breakpoint would force them to avoid the verifier failure by not enabling
6479 // verifier.
6480 //
6481 if (dxState == PowerDeviceUnspecified ||
6485 "SystemWake %!SYSTEM_POWER_STATE! and DeviceWake "
6486 "%!DEVICE_POWER_STATE! power state reported in device "
6487 "capabilities do not support wake. Both the SystemWake and "
6488 "DeviceWake members should be nonzero to support wake-up on "
6489 "this system.", m_SystemWake, dxState);
6490 }
6491
6492 return dxState;
6493}
BYTE m_SystemWake
Definition: fxpkgpnp.hpp:4188
BYTE m_DeviceWake[DeviceWakeStates]
Definition: fxpkgpnp.hpp:4185
@ PowerSystemUnspecified
Definition: ntpoapi.h:35
@ PowerDeviceUnspecified
Definition: ntpoapi.h:48
enum _DEVICE_WAKE_DEPTH DEVICE_WAKE_DEPTH
FORCEINLINE DEVICE_POWER_STATE MapWakeDepthToDstate(_In_ DEVICE_WAKE_DEPTH WakeDepth)
Definition: iotypes.h:7490

Referenced by PowerPolicySetS0IdleSettings(), and PowerPolicySetSxWakeSettings().

◆ PowerPolicyGetDeviceDeepestSystemWakeState()

SYSTEM_POWER_STATE FxPkgPnp::PowerPolicyGetDeviceDeepestSystemWakeState ( VOID  )
inlineprotected

Definition at line 2839 of file fxpkgpnp.hpp.

2842 {
2844 }
enum _SYSTEM_POWER_STATE SYSTEM_POWER_STATE

Referenced by PowerPolicyCanWakeFromSystemState().

◆ PowerPolicyGetPendingSystemState()

SYSTEM_POWER_STATE FxPkgPnp::PowerPolicyGetPendingSystemState ( VOID  )
inlineprotected

Definition at line 2808 of file fxpkgpnp.hpp.

2811 {
2813
2814 //
2815 // In a FastS4 situation, Parameters.Power.State.SystemState will be
2816 // PowerSystemHibernate, while TargetSystemState will indicate the
2817 // true Sx state the machine is moving into.
2818 //
2819 return (SYSTEM_POWER_STATE)
2821 TargetSystemState;
2822 }
SYSTEM_POWER_STATE_CONTEXT GetParameterPowerSystemPowerStateContext()
Definition: fxirpum.cpp:671

◆ PowerPolicyHandleSystemQueryPower()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PowerPolicyHandleSystemQueryPower ( __in SYSTEM_POWER_STATE  QueryState)
protected

Definition at line 3582 of file fxpkgpnp.cpp.

3670{
3671 PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
3673
3674 if (QueryState >= PowerSystemHibernate ||
3676 //
3677 // If the query is for the machine's minimum S state or we going into
3678 // hibernate or off, always succeed it.
3679 //
3681 }
3682 else {
3683
3684 //
3685 // On Windows Vista and above, its OK to return a failure status code
3686 // if the system is going into an S state at which the device cannot
3687 // wake the system.
3688 //
3690
3691 //
3692 // The S state the machine is going into is one where we can't
3693 // wake it up because our D state is too low for this S state.
3694 // Since this isn't the minimum S state the machine is capable
3695 // of, reject the current query.
3696 //
3698 FxDriverGlobals, TRACE_LEVEL_WARNING, TRACINGPNP,
3699 "failing system query power because the device cannot wake the "
3700 "machine from S%d",
3701 QueryState - 1);
3702
3704 }
3705
3706 return status;
3707}
BOOLEAN PowerPolicyCanWakeFromSystemState(__in SYSTEM_POWER_STATE SystemState)
Definition: fxpkgpnp.hpp:2831
RTL_OSVERSIONINFOEXW OsVersionInfo
Definition: fxglobals.h:770
ULONG dwMajorVersion
Definition: rtltypes.h:270

Referenced by FxPkgPdo::_DispatchQueryPower(), and FxPkgFdo::DispatchSystemQueryPower().

◆ PowerPolicyIsWakeEnabled()

BOOLEAN FxPkgPnp::PowerPolicyIsWakeEnabled ( VOID  )

Definition at line 5769 of file fxpkgpnp.cpp.

5772{
5774 return TRUE;
5775 }
5776 else {
5777 return FALSE;
5778 }
5779}
ULONG PowerPolicyGetCurrentWakeReason(VOID)
Definition: fxpkgpnp.cpp:5782

Referenced by FxPkgFdo::DispatchSystemQueryPower().

◆ PowerPolicyPostParentToD0ToChildren()

VOID FxPkgPnp::PowerPolicyPostParentToD0ToChildren ( VOID  )
private

Definition at line 8007 of file powerpolicystatemachine.cpp.

8022{
8024
8026
8027 if (m_EnumInfo != NULL) {
8029
8030 ple = NULL;
8032 ((FxChildList*) ple->GetTransactionedObject())->PostParentToD0();
8033 }
8034
8036 }
8037}

Referenced by PowerPolicyChildrenCanPowerUp().

◆ PowerPolicyPowerDownForSx()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PowerPolicyPowerDownForSx ( __in DEVICE_POWER_STATE  DxState,
__in SendDeviceRequestAction  Action 
)
inlineprivate

Definition at line 3996 of file fxpkgpnp.hpp.

4000 {
4001 //
4002 // The device is powering down because the system is moving into a lower
4003 // power state.
4004 //
4005 // If we have child devices, setup the guard so that they do not power
4006 // up while the parent is in low power. Note that in this case (an Sx
4007 // transition) we do not look at the count of powered up children
4008 // because the power policy owner for the child's stack should not be
4009 // powering up the device once it has processed the Sx irp for its stack.
4010 //
4012
4014 }
VOID PowerPolicyBlockChildrenPowerUp(VOID)
Definition: fxpkgpnp.hpp:4017
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510

◆ PowerPolicyProcessEvent()

VOID FxPkgPnp::PowerPolicyProcessEvent ( __in FxPowerPolicyEvent  Event,
__in BOOLEAN  ProcessEventOnDifferentThread = FALSE 
)

Definition at line 2886 of file powerpolicystatemachine.cpp.

2903{
2905 ULONG mask;
2906 KIRQL irql;
2907
2908 //
2909 // Take the lock, raising to DISPATCH_LEVEL.
2910 //
2912
2913 //
2914 // If the input Event is any of the events described by PowerSingularEventMask,
2915 // then check whether it is already queued up. If so, then dont enqueue this
2916 // Event.
2917 //
2921 }
2922 else {
2925 "WDFDEVICE 0x%p !devobj 0x%p current pwr pol state "
2926 "%!WDF_DEVICE_POWER_POLICY_STATE! dropping event "
2927 "%!FxPowerPolicyEvent! because the Event is already enqueued.",
2931
2932 m_PowerPolicyMachine.Unlock(irql);
2933 return;
2934 }
2935 }
2936
2938 //
2939 // The queue is full. Bail.
2940 //
2941 m_PowerPolicyMachine.Unlock(irql);
2942
2943 ASSERT(!"The Power queue is full. This shouldn't be able to happen.");
2944 return;
2945 }
2946
2950 "WDFDEVICE 0x%p !devobj 0x%p current pwr pol state "
2951 "%!WDF_DEVICE_POWER_POLICY_STATE! dropping event "
2952 "%!FxPowerPolicyEvent! because of a closed queue",
2956
2957 //
2958 // The queue is closed. Bail
2959 //
2960 m_PowerPolicyMachine.Unlock(irql);
2961
2962 return;
2963 }
2964
2965 //
2966 // Enqueue the event. Whether the event goes on the front
2967 // or the end of the queue depends on which event it is and if we are the
2968 // PPO or not.
2969 //
2970 // Yes, mask could be a member variable of m_PowerPolicyMachine, but why
2971 // waste 4 bytes when it is very easy to figure out?
2972 //
2975
2976 if (Event & mask) {
2977 //
2978 // Stick it on the front of the queue, making it the next event that
2979 // will be processed if, otherwise let these events go by.
2980 //
2982 }
2983 else {
2984 //
2985 // Stick it on the end of the queue.
2986 //
2988 }
2989
2990 //
2991 // Drop the lock.
2992 //
2993 m_PowerPolicyMachine.Unlock(irql);
2994
2995 //
2996 // Now, if we are running at PASSIVE_LEVEL, attempt to run the state
2997 // machine on this thread. If we can't do that, then queue a work item.
2998 //
3000 irql,
3001 ProcessOnDifferentThread
3002 )) {
3003
3004 LONGLONG timeout = 0;
3005
3008
3009 if (FxWaitLockInternal::IsLockAcquired(status)) {
3011
3012 //
3013 // We now hold the state machine lock. So call the function that
3014 // dispatches the next state.
3015 //
3017
3018 //
3019 // The pnp state machine should be the only one deleting the object
3020 //
3021 ASSERT(info.m_DeleteObject == FALSE);
3022
3025
3026 info.Evaluate(this);
3027
3028 return;
3029 }
3030 }
3031
3032 //
3033 // The tag added above will be released when the work item runs
3034 //
3035
3036 //
3037 // For one reason or another, we couldn't run the state machine on this
3038 // thread. So queue a work item to do it. If m_PnPWorkItemEnqueuing
3039 // is non-zero, that means that the work item is already being enqueued
3040 // on another thread. This is significant, since it means that we can't do
3041 // anything with the work item on this thread, but it's okay, since the
3042 // work item will pick up our work and do it.
3043 //
3045}
BOOLEAN ShouldProcessPowerPolicyEventOnDifferentThread(__in KIRQL CurrentIrql, __in BOOLEAN CallerSpecifiedProcessingOnDifferentThread)
VOID PowerPolicyProcessEventInner(__inout FxPostProcessInfo *Info)
@ PwrPolPriorityEventsMask
@ PowerPolSingularEventMask
@ PwrPolNotOwnerPriorityEventsMask
GLenum GLint GLuint mask
Definition: glext.h:6028

Referenced by __drv_maxIRQL(), FxPowerIdleMachine::DisablingTimerExpired(), FxPkgPdo::DispatchSystemSetPower(), DispatchWaitWake(), FxPowerIdleMachine::InDxIoIncrement(), PnpPowerPolicyRemove(), PnpPowerPolicyStart(), PnpPowerPolicyStop(), PnpPowerPolicySurpriseRemove(), PowerDmaEnableAndScan(), PowerGotoDx(), PowerPolicySetS0IdleState(), PowerSendPowerDownEvents(), PowerSendPowerDownFailureEvent(), PowerSendPowerUpEvents(), PowerSendPowerUpFailureEvent(), FxPowerIdleMachine::TimedOutIoIncrement(), and FxPowerIdleMachine::TimingOut().

◆ PowerPolicyProcessEventInner()

VOID FxPkgPnp::PowerPolicyProcessEventInner ( __inout FxPostProcessInfo Info)
protected

Definition at line 3084 of file powerpolicystatemachine.cpp.

3087{
3090 ULONG i;
3091 KIRQL irql;
3092
3093 if (IsPowerPolicyOwner()) {
3095
3096 //
3097 // Process as many events as we can.
3098 //
3099 for ( ; ; ) {
3101
3102 //
3103 // Get an event from the queue.
3104 //
3106
3109
3110 //
3111 // The queue is empty.
3112 //
3113 m_PowerPolicyMachine.Unlock(irql);
3114 return;
3115 }
3116
3118
3119 //
3120 // At this point, we need to determine whether we can process this
3121 // event.
3122 //
3124 //
3125 // These are always possible to handle.
3126 //
3127 DO_NOTHING();
3128 }
3129 else {
3130 //
3131 // Check to see if this state can handle new events, ie if this
3132 // is a green dot (queue open) or red dot (queue *not* open) state.
3133 //
3134 if (entry->StateInfo.Bits.QueueOpen == FALSE) {
3135 //
3136 // This state can't handle new events.
3137 //
3138 m_PowerPolicyMachine.Unlock(irql);
3139 return;
3140 }
3141 }
3142
3143 //
3144 // If the event obtained from the queue was a singular event, then
3145 // clear the flag to allow other similar events to be put into this
3146 // queue for processing.
3147 //
3150 }
3151
3153 m_PowerPolicyMachine.Unlock(irql);
3154
3155 //
3156 // Find the entry in the power policy state table that corresponds
3157 // to this event.
3158 //
3159 newState = WdfDevStatePwrPolNull;
3160
3161 if (entry->FirstTargetState.PowerPolicyEvent == event) {
3162 newState = entry->FirstTargetState.TargetState;
3163
3164 DO_EVENT_TRAP(&entry->FirstTargetState);
3165 }
3166 else if (entry->OtherTargetStates != NULL) {
3167 for (i = 0;
3168 entry->OtherTargetStates[i].PowerPolicyEvent != PwrPolNull;
3169 i++) {
3170 if (entry->OtherTargetStates[i].PowerPolicyEvent == event) {
3171 newState = entry->OtherTargetStates[i].TargetState;
3172 DO_EVENT_TRAP(&entry->OtherTargetStates[i]);
3173 break;
3174 }
3175 }
3176 }
3177
3178 if (newState == WdfDevStatePwrPolNull) {
3179 //
3180 // This state doesn't respond to the event. Just throw the event
3181 // away.
3182 //
3185 "WDFDEVICE 0x%p !devobj 0x%p current pwr pol state "
3186 "%!WDF_DEVICE_POWER_POLICY_STATE! dropping event "
3187 "%!FxPowerPolicyEvent!", m_Device->GetHandle(),
3190
3191 if ((entry->StateInfo.Bits.KnownDroppedEvents & event) == 0) {
3192 COVERAGE_TRAP();
3193
3196 "WDFDEVICE 0x%p !devobj 0x%p current state "
3197 "%!WDF_DEVICE_POWER_POLICY_STATE!, policy event "
3198 "%!FxPowerPolicyEvent! is not a known dropped "
3199 "event, known dropped events are %!FxPowerPolicyEvent!",
3202 event, entry->StateInfo.Bits.KnownDroppedEvents);
3203
3204
3205 }
3206
3207 //
3208 // Failsafes for events which have required processing in them.
3209 //
3210 switch (event) {
3211 case PwrPolSx:
3212 //
3213 // The Sx handling code expects that the state machine
3214 // complete the Sx irp. (S0 irps are never pended). Since
3215 // we don't have a state to transition to that will complete
3216 // the request, do so now.
3217 //
3218 // (This can legitimately happen if a PDO is disabled and
3219 // the machines moves into an Sx state.)
3220 //
3222 break;
3223
3225 //
3226 // This state did not handle the event and event got
3227 // dropped. However some state is definitely going to wait
3228 // for this event. That's why we need m_EventDropped flag.
3229 // If we didn't have this flag there will be no way to know
3230 // if the event got dropped and some state will end up
3231 // waiting for it indefinitely.
3232 //
3234 break;
3235
3238 break;
3239
3240 case PwrPolWakeSuccess:
3241 case PwrPolWakeFailed:
3242 //
3243 // This state did not handle the event and event got
3244 // dropped. However some state is definitely going to wait
3245 // for this event. That's why we need
3246 // m_WakeCompletionEventDropped flag. If we didn't have this
3247 // flag there will be no way to know if the event got
3248 // dropped and some state will end up waiting for it
3249 // indefinitely.
3250 //
3252 break;
3253
3254 default:
3255 DO_NOTHING();
3256 break;
3257 }
3258 }
3259 else {
3260 //
3261 // Now enter the new state.
3262 //
3263 PowerPolicyEnterNewState(newState);
3264 }
3265 }
3266 }
3267 else {
3268 //
3269 // Process as many events as we can.
3270 //
3271 for ( ; ; ) {
3273
3274#pragma prefast(suppress:__WARNING_DEREF_NULL_PTR, "The current power policy state will always be in the table so entry will never be NULL")
3277 );
3278
3279 //
3280 // Get an event from the queue.
3281 //
3283
3285 //
3286 // The queue is empty.
3287 //
3288 m_PowerPolicyMachine.Unlock(irql);
3289 return;
3290 }
3291
3293
3294 //
3295 // At this point, we need to determine whether we can process this
3296 // event.
3297 //
3299 //
3300 // These are always possible to handle.
3301 //
3302 DO_NOTHING();
3303 }
3304 else {
3305 //
3306 // Check to see if this state can handle new events, ie if this
3307 // is a green dot (queue open) or red dot (queue *not* open) state.
3308 //
3309 if (entry->QueueOpen == FALSE) {
3310 //
3311 // This state can't handle new events.
3312 //
3313 m_PowerPolicyMachine.Unlock(irql);
3314 return;
3315 }
3316 }
3317
3318 //
3319 // If the event obtained from the queue was a singular event, then
3320 // clear the flag to allow other similar events to be put into this
3321 // queue for processing.
3322 //
3325 }
3326
3328 m_PowerPolicyMachine.Unlock(irql);
3329
3330 if (entry != NULL && entry->TargetStatesCount > 0) {
3331 for (i = 0; i < entry->TargetStatesCount; i++) {
3332 if (event == entry->TargetStates[i].PowerPolicyEvent) {
3333 DO_EVENT_TRAP(&entry->TargetStates[i]);
3334
3335 //
3336 // Now enter the new state.
3337 //
3339 entry->TargetStates[i].TargetState);
3340 break;
3341 }
3342 }
3343 }
3344 }
3345 }
3346}
VOID PowerPolicyCompleteSystemPowerIrp(VOID)
VOID NotPowerPolicyOwnerEnterNewState(__in WDF_DEVICE_POWER_POLICY_STATE NewState)
VOID PowerPolicyEnterNewState(__in WDF_DEVICE_POWER_POLICY_STATE State)
@ PwrPolUsbSelectiveSuspendCompleted
@ PwrPolUsbSelectiveSuspendCallback

Referenced by PowerPolicyProcessEvent().

◆ PowerPolicySendDevicePowerRequest()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PowerPolicySendDevicePowerRequest ( __in DEVICE_POWER_STATE  DeviceState,
__in SendDeviceRequestAction  Action 
)
protected

Definition at line 7524 of file powerpolicystatemachine.cpp.

7561{
7562 MdRequestPowerComplete pCompletionRoutine;
7566 ULONG i;
7567
7569 interval.QuadPart = WDF_REL_TIMEOUT_IN_MS(500);
7570 state.DeviceState = DeviceState;
7571
7572 if (DeviceState == PowerDeviceD0) {
7573 //
7574 // We are powering up, we do not synchronize the completion of the D0 irp
7575 // with a potential S0 irp. However we need to ensure that if an upper filter
7576 // driver fails the power irp, we handle it gracefully rather than keep waiting
7577 // for the power irp to arrive.
7578 //
7579 pCompletionRoutine = _PowerPolDevicePowerUpComplete;
7580 }
7581 else {
7582 //
7583 // We are powering down, we synchronize the completion of the Dx irp
7584 // with a potential Sx irp. If there is no pending Sx irp, the state
7585 // machine takes care of it.
7586 //
7587 pCompletionRoutine = _PowerPolDevicePowerDownComplete;
7588 }
7589
7590 //
7591 // We track when we request power irps to catch someone other then ourselves
7592 // sending power irps to our own stack.
7593 //
7594 if (DeviceState == PowerDeviceD0) {
7596 }
7597 else {
7599 }
7600
7601 for (i = 0; i < 100; i++) {
7604 state,
7605 pCompletionRoutine,
7606 this);
7607
7608 //
7609 // If we are not retrying, we always break out
7610 //
7611 if (NT_SUCCESS(status) || Action == NoRetry) {
7612 break;
7613 }
7614
7616 }
7617
7618 if (!NT_SUCCESS(status)) {
7619 //
7620 // We are no longer requesting a power irp
7621 //
7622 if (DeviceState == PowerDeviceD0) {
7624 }
7625 else {
7627 }
7628
7629 if (Action == Retry) {
7630 COVERAGE_TRAP();
7631
7634 "Could not request D%d irp for device %p (WDFDEVICE %p), "
7635 "%!STATUS!", DeviceState-1,
7638 }
7639 }
7640
7642 "Requesting D%d irp, %!STATUS!",
7643 DeviceState-1, status);
7644
7645 return status;
7646}
static _Must_inspect_result_ NTSTATUS RequestPowerIrp(__in MdDeviceObject DeviceObject, __in UCHAR MinorFunction, __in POWER_STATE PowerState, __in MdRequestPowerComplete CompletionFunction, __in PVOID Context)
Definition: fxirpum.cpp:1047
static MdRequestPowerCompleteType _PowerPolDevicePowerDownComplete
Definition: fxpkgpnp.hpp:2755
static MdRequestPowerCompleteType _PowerPolDevicePowerUpComplete
Definition: fxpkgpnp.hpp:2759
static __inline VOID MxDelayExecutionThread(__in KPROCESSOR_MODE WaitMode, __in BOOLEAN Alertable, __in PLARGE_INTEGER Interval)
Definition: mxgeneralkm.h:209
@ Retry
Definition: fxpkgpnp.hpp:203
REQUEST_POWER_COMPLETE * MdRequestPowerComplete
Definition: mxum.h:162
FORCEINLINE LONGLONG WDF_REL_TIMEOUT_IN_MS(_In_ ULONGLONG Time)
Definition: wdfcore.h:80
_In_ WDFDEVICE _Out_ PWDF_DEVICE_STATE DeviceState
Definition: wdfdevice.h:1999

Referenced by PowerPolicyCanIdlePowerDown(), and PowerPolicyPowerDownForSx().

◆ PowerPolicySendWaitWakeRequest()

_Must_inspect_result_ NTSTATUS FxPkgPnp::PowerPolicySendWaitWakeRequest ( __in SYSTEM_POWER_STATE  SystemState)
protected

Definition at line 7650 of file powerpolicystatemachine.cpp.

7653{
7656
7657 state.SystemState = SystemState;
7658
7659 //
7660 // We track when we request power irps to catch someone other then ourselves
7661 // sending power irps to our own stack.
7662 //
7664
7665 //
7666 // Since we are sending a fresh wake, clear any state that was meant
7667 // for the last wake IRP
7668 //
7670
7671 //
7672 // we are requesting new ww irp so re-initialize dropped event tracker.
7673 //
7675
7677 "Requesting wait wake irp for S%d", SystemState-1);
7678
7681 state,
7683 this);
7684
7685 if (!NT_SUCCESS(status)) {
7687 "Requesting wait wake irp for S%d failed, %!STATUS!",
7688 SystemState-1, status);
7689
7690 //
7691 // We are no longer requesting a power irp
7692 //
7694 }
7695
7696 return status;
7697}
static MdRequestPowerCompleteType _PowerPolDeviceWaitWakeComplete
Definition: fxpkgpnp.hpp:2751

◆ PowerPolicySetS0IdleSettings()

NTSTATUS FxPkgPnp::PowerPolicySetS0IdleSettings ( __in PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS  Settings)

Definition at line 2778 of file fxpkgpnp.cpp.

2798{
2799 DEVICE_POWER_STATE dxState;
2800 ULONG idleTimeout;
2802 BOOLEAN enabled, s0Capable, overridable, firstTime;
2803 WDF_TRI_STATE powerUpOnSystemWake;
2804 const LONGLONG negliblySmallIdleTimeout = -1; // 100 nanoseconds
2805
2806 s0Capable = FALSE;
2807 dxState = PowerDeviceD3;
2808 overridable = FALSE;
2809 firstTime = TRUE;
2810
2811 if (Settings->Enabled == WdfTrue) {
2812 enabled = TRUE;
2813
2814 } else if (Settings->Enabled == WdfUseDefault) {
2815 enabled = TRUE;
2816
2819
2820 //
2821 // Read registry. If registry value is not found, the value of "enabled"
2822 // remains unchanged
2823 //
2824 ReadRegistryS0Idle(&valueName, &enabled);
2825 }
2826 else {
2829 "If registry value WdfDefaultIdleInWorkingState was present, "
2830 "it was not read because DDI WdfDeviceAssignS0IdleSettings "
2831 "was not called at PASSIVE_LEVEL");
2832 }
2833 }
2834 else {
2835 enabled = FALSE;
2836 }
2837
2839 firstTime = FALSE;
2840 }
2841
2844 if (!NT_SUCCESS(status)) {
2845 return status;
2846 }
2847
2848 //
2849 // Do not set m_CapsQueried to TRUE yet because we will do that once we
2850 // know the entire stack has been built we will do the query again.
2851 //
2852 }
2853
2854 switch (Settings->IdleCaps) {
2856 case IdleCanWakeFromS0:
2857 s0Capable = TRUE;
2858
2859 if (Settings->DxState == PowerDeviceMaximum) {
2861
2862 //
2863 // Some bus drivers
2864
2865 // incorrectly report DeviceWake=D0 to
2866 // indicate that it does not support wake instead of specifying
2867 // PowerDeviceUnspecified and KMDF ends up requesting
2868 // a D0 irp when going to Dx. The check prevents this bug.
2869 //
2870 if (dxState < PowerDeviceD1 ||
2871 dxState > PowerDeviceD3 ||
2872 (dxState > PowerDeviceD2 && Settings->IdleCaps == IdleUsbSelectiveSuspend)
2873 ) {
2875
2878 "DeviceWake power state reported in device capabilities "
2879 "%!DEVICE_POWER_STATE! indicates that device can not signal"
2880 " a wake event, %!STATUS!",
2881 dxState, status);
2882 return status;
2883 }
2884 }
2885 else {
2886 DEVICE_POWER_STATE dxDeepest;
2887
2888 dxState = Settings->DxState;
2890
2891 if (dxState > dxDeepest) {
2893
2896 "DxState specified by driver %!DEVICE_POWER_STATE! cannot "
2897 "be lighter than lightest available device wake state"
2898 " %!DEVICE_POWER_STATE!, %!STATUS!", dxState,
2899 dxDeepest, status);
2900 return status;
2901 }
2902
2903 //
2904 // Can only perform wait wake from D2 on a USB device
2905 //
2906 if (dxState > PowerDeviceD2 &&
2907 Settings->IdleCaps == IdleUsbSelectiveSuspend) {
2909
2912 "DxState specified by driver %!DEVICE_POWER_STATE! cannot "
2913 "be lighter than PowerDeviceD2 for USB selective suspend "
2914 "%!STATUS!",
2915 dxState, status);
2916 return status;
2917 }
2918 }
2919
2920 if (Settings->IdleCaps == IdleUsbSelectiveSuspend) {
2922
2923 if (!NT_SUCCESS(status)) {
2926 "Failed to initialize USB selective suspend %!STATUS!",
2927 status);
2928 return status;
2929 }
2930 }
2931
2932 break;
2933
2935 s0Capable = FALSE;
2936
2937 if (Settings->DxState == PowerDeviceMaximum) {
2938 dxState = PowerDeviceD3;
2939 }
2940 else {
2941 dxState = Settings->DxState;
2942 }
2943
2944 break;
2945
2946 default:
2947 ASSERT(FALSE);
2948 break;
2949 }
2950
2951 if (Settings->IdleTimeout == IdleTimeoutDefaultValue) {
2952 idleTimeout = FxPowerPolicyDefaultTimeout;
2953 }
2954 else {
2955 idleTimeout = Settings->IdleTimeout;
2956 }
2957
2958 if (Settings->UserControlOfIdleSettings == IdleAllowUserControl) {
2959
2960 // status = UpdateWmiInstanceForS0Idle(AddInstance);
2961 // if (!NT_SUCCESS(status)) {
2962 // return status;
2963 // } __REACTOS__
2964
2965 if (Settings->Enabled == WdfUseDefault) {
2966 //
2967 // Read the registry entry for idle enabled if it's the first time.
2968 //
2969 if (firstTime && Mx::MxGetCurrentIrql() == PASSIVE_LEVEL) {
2971
2972 //
2973 // Read registry. If registry value is not found, the value of
2974 // "enabled" remains unchanged
2975 //
2976 ReadRegistryS0Idle(&valueName, &enabled);
2977 }
2978 else {
2979 //
2980 // Use the saved value for idle enabled.
2981 //
2983 }
2984 }
2985
2986 overridable = TRUE;
2987 }
2988 else if (Settings->UserControlOfIdleSettings == IdleDoNotAllowUserControl) {
2989 //
2990 // No user control
2991 //
2992 overridable = FALSE;
2993
2994 // (void) UpdateWmiInstanceForS0Idle(RemoveInstance); __REACTOS__
2995 }
2996
2997 //
2998 // !!!! DO NOT INTRODUCE FAILURES BEYOND THIS POINT !!!!
2999 //
3000 // We should not introduce any failures that are not due to driver errors
3001 // beyond this point. This is because we are going to commit the driver's
3002 // S0-idle settings now and any failure in the midst of that could leave us
3003 // in a bad state. Therefore, all failable code where the failure is beyond
3004 // the driver's control should be placed above this point.
3005 //
3006 // For example, a driver may want wake-from-S0 support, but the device may
3007 // not support it. We already checked for that failure above, before we
3008 // started committing any of the driver's S0-idle settings.
3009 //
3010 // Any failures below this point should only be due to driver errors, i.e.
3011 // the driver incorrectly calling the AssignS0IdleSettings DDI.
3012 //
3013
3014 if (firstTime) {
3017 }
3018
3019 //
3020 // IdleTimeoutType is available only on > 1.9
3021 //
3022#ifndef __REACTOS__
3024 if (firstTime) {
3025 if ((SystemManagedIdleTimeout == Settings->IdleTimeoutType) ||
3027 Settings->IdleTimeoutType)) {
3028 //
3029 // This is the first time S0-idle policy is being specified and
3030 // the caller has asked for the idle timeout to be determined
3031 // by the power manager.
3032 //
3034 m_TimeoutMgmt.UseSystemManagedIdleTimeout(
3036 );
3037 if (!NT_SUCCESS(status)) {
3038 return status;
3039 }
3040 }
3041 } else {
3042 //
3043 // This is not the first time S0-idle policy is being specified.
3044 // Verify that the caller is not trying to change their mind about
3045 // whether the idle timeout is determined by the power manager.
3046 //
3047 BOOLEAN currentlyUsingSystemManagedIdleTimeout;
3048 BOOLEAN callerWantsSystemManagedIdleTimeout;
3049
3050 currentlyUsingSystemManagedIdleTimeout =
3052 UsingSystemManagedIdleTimeout();
3053 callerWantsSystemManagedIdleTimeout =
3054 ((SystemManagedIdleTimeout == Settings->IdleTimeoutType) ||
3055 (SystemManagedIdleTimeoutWithHint == Settings->IdleTimeoutType));
3056
3057 //
3058 // UMDF currently does not implement
3059 // IdleTimeoutManagement::_SystemManagedIdleTimeoutAvailable. So
3060 // that method must be called only as part of the second check in
3061 // the "if" statement below. Since UMDF currently does not support
3062 // system managed idle timeout, the first check will always evaluate
3063 // to 'FALSE', so the second check never gets executed for UMDF.
3064 //
3065 if ((callerWantsSystemManagedIdleTimeout !=
3066 currentlyUsingSystemManagedIdleTimeout)
3067 &&
3069 ) {
3070
3074 "A previous call to assign S0-idle policy specified that "
3075 "the idle timeout %s be determined by the power manager. "
3076 "This decision cannot be changed. %!STATUS!",
3077 currentlyUsingSystemManagedIdleTimeout ?
3078 "should" :
3079 "should not",
3080 status);
3082 return status;
3083 }
3084 }
3085 }
3086#endif
3087
3088 if (Settings->IdleCaps == IdleCannotWakeFromS0) {
3089 //
3090 // PowerUpIdleDeviceOnSystemWake field added after v1.7.
3091 // By default KMDF uses an optimization where the device is not powered
3092 // up when resuming from Sx if it is idle. The field
3093 // PowerUpIdleDeviceOnSystemWake is used to turn off this optimization and allow
3094 // device to power up when resuming from Sx. Note that this optimization
3095 // is applicable only for IdleCannotWakeFromS0. In other cases the
3096 // device is always powered up in order to arm for wake.
3097 //
3098 powerUpOnSystemWake =
3100 Settings->PowerUpIdleDeviceOnSystemWake :
3102
3103 switch(powerUpOnSystemWake) {
3104 case WdfTrue:
3108 "Driver turned off S0Idle optimization. Device will be "
3109 "powered up on resume from Sx even when it is idle");
3110 break;
3111 case WdfFalse:
3115 "Driver turned on S0Idle optimization. Device will remain "
3116 "powered off if idle when resuming from Sx");
3117 break;
3118 case WdfUseDefault:
3119 DO_NOTHING();
3120 break;
3121 default:
3122 break;
3123 }
3124 }
3125
3126 if (FALSE ==
3128 {
3129 if (Settings->IdleCaps == IdleUsbSelectiveSuspend) {
3132 m_IdleSettings.UsbSSCapabilityKnown = TRUE;
3133
3134 } else if (Settings->IdleCaps == IdleCanWakeFromS0) {
3135
3137 m_IdleSettings.UsbSSCapabilityKnown = TRUE;
3138 }
3139 }
3140
3141 //
3142 // Wake FromS0Capable is set every time because we want to allow the driver
3143 // to swap between idle wake capable and idle not wake capable. This should
3144 // be allowed so that a scenario similar to the following can be implemented:
3145 //
3146 // a) when the device has an outstanding open, the device should arm itself
3147 // for wake when idle
3148 //
3149 // b) when the device does not have an outstanding open, the device should
3150 // be off and not armed.
3151 //
3152 // The only way to be off is to assign S0 wake settings, so the
3153 // WakeFromS0Capable field must change on each DDI call. This is not a
3154 // problem for the power policy state machine because it evaluates
3155 // WakeFromS0Capable state before enabling of idle. If we are not
3156 // WakeFromS0Capable and USB SS capable (ie a have a torn/unsynchronized
3157 // state) in m_IdleSettings, we will recover from it when processing
3158 // PwrPolS0IdlePolicyChanged in the state machine (b/c this event causes
3159 // both fields to be reevaluated).
3160 //
3162
3164
3166 m_IdleSettings.m_TimeoutMgmt.UsingSystemManagedIdleTimeout()) {
3167 //
3168 // With system managed idle timeout, we don't want to apply an idle
3169 // timeout of our own on top of that. Effectively, our idle timeout is
3170 // 0.
3171 // But we apply a negligibly small timeout value as this allows us to
3172 // keep the same logic in the idle state machine, regardless of whether
3173 // we're using system-managed idle timeout or driver-managed idle
3174 // timeout.
3175 //
3176 if (firstTime) {
3178 m_PowerIdleMachine.m_PowerTimeout.QuadPart =
3179 negliblySmallIdleTimeout;
3180 }
3181
3182 if (SystemManagedIdleTimeoutWithHint == Settings->IdleTimeoutType) {
3183 //
3184 // We save the idle timeout hint, but we don't provide the hint to
3185 // the power framework immediately. This is because currently we may
3186 // or may not be registered with the power framework. Note that
3187 // WdfDeviceAssignS0IdleSettings might get called even when we are
3188 // not registered with the power framework.
3189 //
3190 // Therefore, we provide the hint to the power framework only when
3191 // we get to the WdfDevStatePwrPolStartingDecideS0Wake state. This
3192 // state is a good choice for providing the hint because:
3193 // 1. We know we would be registered with the power framework when
3194 // we are in this state.
3195 // 2. Any change in S0-idle settings causes us to go through this
3196 // state.
3197 //
3199 idleTimeout;
3200 }
3201
3202 } else {
3204 = WDF_REL_TIMEOUT_IN_MS(idleTimeout);
3205 }
3206
3207 //
3208 // If the driver is 1.11 or later, update the bus drivers with the client's
3209 // choice on the topic of D3hot or D3cold.
3210 //
3212 (Settings->ExcludeD3Cold != WdfUseDefault)) {
3214 BOOLEAN enableD3Cold;
3215
3217
3218 switch (Settings->ExcludeD3Cold) {
3219 case WdfFalse:
3220 enableD3Cold = TRUE;
3221 break;
3222 default:
3225 "Invalid tri-state value for ExcludeD3Cold %d",
3226 Settings->ExcludeD3Cold);
3228 case WdfTrue:
3229 enableD3Cold = FALSE;
3230 break;
3231 }
3232
3234 &deviceObject,
3236 enableD3Cold);
3237 }
3238
3240
3241 return STATUS_SUCCESS;
3242}
_Must_inspect_result_ NTSTATUS QueryForCapabilities(VOID)
Definition: fxpkgpnp.cpp:1675
DEVICE_POWER_STATE PowerPolicyGetDeviceDeepestDeviceWakeState(__in SYSTEM_POWER_STATE SystemState)
Definition: fxpkgpnp.cpp:6440
VOID ReadRegistryS0Idle(__in PCUNICODE_STRING ValueName, __out BOOLEAN *Enabled)
Definition: fxpkgpnpkm.cpp:376
static BOOLEAN _SystemManagedIdleTimeoutAvailable(VOID)
Definition: supportkm.cpp:211
@ FxPowerPolicyDefaultTimeout
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
@ PowerDeviceD1
Definition: ntpoapi.h:50
@ PowerDeviceD2
Definition: ntpoapi.h:51
@ PowerDeviceD3
Definition: ntpoapi.h:52
#define __fallthrough
Definition: sal_old.h:314
_Must_inspect_result_ NTSTATUS InitUsbSS(VOID)
DEVICE_POWER_STATE DxState
VOID SetD3ColdSupport(__in PFX_DRIVER_GLOBALS DriverGlobals, __in MxDeviceObject *DeviceInStack, __in PD3COLD_SUPPORT_INTERFACE D3ColdInterface, __in BOOLEAN UseD3Cold)
Definition: supportkm.cpp:172
struct _WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_V1_7 WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_V1_7
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
Definition: wdfdevice.h:2595
#define IdleTimeoutDefaultValue
Definition: wdfdevice.h:816
@ IdleDoNotAllowUserControl
Definition: wdfdevice.h:407
@ IdleAllowUserControl
Definition: wdfdevice.h:408
@ SystemManagedIdleTimeout
Definition: wdfdevice.h:1244
@ SystemManagedIdleTimeoutWithHint
Definition: wdfdevice.h:1245
#define WDF_S0_IDLE_ENABLED_VALUE_NAME
Definition: wdfdevice.h:490
@ IdleUsbSelectiveSuspend
Definition: wdfdevice.h:402
@ IdleCanWakeFromS0
Definition: wdfdevice.h:401
@ IdleCannotWakeFromS0
Definition: wdfdevice.h:400
#define WDF_S0_IDLE_DEFAULT_VALUE_NAME
Definition: wdfdevice.h:492
@ WdfTrue
Definition: wdftypes.h:88
@ WdfUseDefault
Definition: wdftypes.h:89
@ WdfFalse
Definition: wdftypes.h:87
enum _WDF_TRI_STATE WDF_TRI_STATE

◆ PowerPolicySetS0IdleState()

◆ PowerPolicySetSxWakeSettings()

NTSTATUS FxPkgPnp::PowerPolicySetSxWakeSettings ( __in PWDF_DEVICE_POWER_POLICY_WAKE_SETTINGS  Settings,
__in BOOLEAN  ArmForWakeIfChildrenAreArmedForWake,
__in BOOLEAN  IndicateChildWakeOnParentWake 
)

Definition at line 3245 of file fxpkgpnp.cpp.

3276{
3277 DEVICE_POWER_STATE dxState;
3279 BOOLEAN overridable, firstTime, enabled;
3280
3281 dxState = PowerDeviceD3;
3282 overridable = FALSE;
3283 firstTime = TRUE;
3284
3285 if (Settings->Enabled == WdfTrue) {
3286 enabled = TRUE;
3287
3288 }
3289 else if (Settings->Enabled == WdfUseDefault) {
3290 enabled = TRUE;
3291
3294
3295 //
3296 // Read registry. If registry value is not found, the value of "enabled"
3297 // remains unchanged
3298 //
3299 ReadRegistrySxWake(&valueName, &enabled);
3300 }
3301 else {
3304 "If registry value WdfDefaultWakeFromSleepState was present, "
3305 "it was not read because DDI WdfDeviceAssignSxWakeSettings "
3306 "was not called at PASSIVE_LEVEL");
3307 }
3308 }
3309 else {
3310 enabled = FALSE;
3311 }
3312
3314 firstTime = FALSE;
3315 }
3316
3319 if (!NT_SUCCESS(status)) {
3320 return status;
3321 }
3322
3323 //
3324 // Do not set m_CapsQueried to TRUE yet because we will do that once we
3325 // know the entire stack has been built we will do the query again.
3326 //
3327 }
3328
3329 if (Settings->DxState == PowerDeviceMaximum) {
3331
3332 //
3333 // Some bus drivers
3334
3335 // incorrectly report DeviceWake=D0 to
3336 // indicate that it does not support wake instead of specifying
3337 // PowerDeviceUnspecified and KMDF ends up requesting
3338 // a D0 irp when going to Dx. The check prevents this bug.
3339 //
3340 if (dxState < PowerDeviceD1 || dxState > PowerDeviceD3) {
3342
3345 "DeviceWake power state reported in device capabilities "
3346 "%!DEVICE_POWER_STATE! indicates that device can not signal a "
3347 "wake event, %!STATUS!",
3348 dxState, status);
3349 return status;
3350 }
3351 }
3352 else {
3353 DEVICE_POWER_STATE dxDeepest;
3354
3355 dxState = Settings->DxState;
3357
3358 if (dxState > dxDeepest) {
3362 "DxState specified by driver %!DEVICE_POWER_STATE! cannot be"
3363 " lighter than lightest available device wake state "
3364 "%!DEVICE_POWER_STATE!, %!STATUS!", dxState,
3365 dxDeepest, status);
3366 return status;
3367 }
3368 }
3369
3370 if (Settings->UserControlOfWakeSettings == WakeAllowUserControl) {
3371
3372 // status = UpdateWmiInstanceForSxWake(AddInstance); __REACTOS__
3373
3374 // if (!NT_SUCCESS(status)) {
3375 // return status;
3376 // }
3377
3378 if (Settings->Enabled == WdfUseDefault) {
3379 //
3380 // Read the registry entry for wake enabled if it's the first time.
3381 //
3382 if (firstTime && Mx::MxGetCurrentIrql() == PASSIVE_LEVEL) {
3384
3385 //
3386 // Read registry. If registry value is not found, the value of
3387 // "enabled" remains unchanged
3388 //
3389 ReadRegistrySxWake(&valueName, &enabled);
3390 }
3391 else {
3392 //
3393 // Use the saved value for wake enabled.
3394 //
3396 }
3397 }
3398
3399 overridable = TRUE;
3400 }
3401 else if (Settings->UserControlOfWakeSettings == WakeDoNotAllowUserControl) {
3402 //
3403 // No user control, just set to enabled
3404 //
3405 overridable = FALSE;
3406
3407 // (void) UpdateWmiInstanceForSxWake(RemoveInstance); __REACTOS__
3408 }
3409
3410 if (firstTime) {
3413
3414 //
3415 // If ArmForWakeIfChildrenAreArmedForWake setting is set to FALSE,
3416 // then we use the legacy framework behavior which did not depend
3417 // on the child device being capable of arming for wake or not.
3418 //
3420 ArmForWakeIfChildrenAreArmedForWake;
3421
3422 //
3423 // If IndicateChildWakeOnParentWake setting is set to FALSE, then
3424 // we use the legacy framework behavior wherein the wake status
3425 // is not propagated from the parent device to the child device.
3426 //
3428 IndicateChildWakeOnParentWake;
3429 }
3430
3432
3434
3435 return STATUS_SUCCESS;
3436}
VOID ReadRegistrySxWake(__in PCUNICODE_STRING ValueName, __out BOOLEAN *Enabled)
Definition: fxpkgpnpkm.cpp:469
@ WakeAllowUserControl
Definition: wdfdevice.h:418
@ WakeDoNotAllowUserControl
Definition: wdfdevice.h:417
#define WDF_SX_WAKE_ENABLED_VALUE_NAME
Definition: wdfdevice.h:491
#define WDF_SX_WAKE_DEFAULT_VALUE_NAME
Definition: wdfdevice.h:493

◆ PowerPolicySetSxWakeState()

VOID FxPkgPnp::PowerPolicySetSxWakeState ( __in BOOLEAN  State)

Definition at line 3720 of file fxpkgpnp.cpp.

3740{
3743
3744 //
3745 // Since we are not posting an event to the power policy state machine, try
3746 // to write out the value now, otherwise it will be written when we
3747 // transition
3748 //
3752
3753 timeout = 0;
3754
3755 //
3756 // If the lock is already acquired on this thread, this will fail, which
3757 // is OK.
3758 //
3761 &timeout
3762 );
3763
3764 if (FxWaitLockInternal::IsLockAcquired(status)) {
3765 SaveState(TRUE);
3766
3769 );
3770 }
3771 }
3772}

Referenced by _SxWakeSetInstance(), _SxWakeSetItem(), PowerPolicySetSxWakeSettings(), and FxDevice::ProcessWmiPowerQueryOrSetData().

◆ PowerPolicyShouldPropagateWakeStatusToChildren()

BOOLEAN __inline FxPkgPnp::PowerPolicyShouldPropagateWakeStatusToChildren ( VOID  )
inline

Definition at line 3407 of file fxpkgpnp.hpp.

Referenced by PowerPolicyDisarmWakeFromSx().

◆ PowerPolicySubmitUsbIdleNotification()

VOID FxPkgPnp::PowerPolicySubmitUsbIdleNotification ( VOID  )
protected

Definition at line 162 of file powerpolicystatemachinekm.cpp.

165{
166 // FxIrp* usbIdleIrp;
167
168 // //
169 // // This will be set to TRUE if USBSS completion event gets dropped.
170 // //
171 // m_PowerPolicyMachine.m_Owner->m_UsbIdle->m_EventDropped = FALSE;
172
173 // usbIdleIrp = &m_PowerPolicyMachine.m_Owner->m_UsbIdle->m_IdleIrp;
174
175 // usbIdleIrp->Reuse();
176
177 // usbIdleIrp->SetCompletionRoutineEx(
178 // m_Device->GetDeviceObject(),
179 // _PowerPolicyUsbSelectiveSuspendCompletionRoutine,
180 // this);
181
182 // usbIdleIrp->SetMajorFunction(IRP_MJ_INTERNAL_DEVICE_CONTROL);
183 // usbIdleIrp->SetParameterIoctlCode(
184 // IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION);
185 // usbIdleIrp->SetParameterIoctlInputBufferLength(
186 // sizeof(m_PowerPolicyMachine.m_Owner->m_UsbIdle->m_CallbackInfo));
187 // usbIdleIrp->SetParameterIoctlType3InputBuffer(
188 // (PVOID) &m_PowerPolicyMachine.m_Owner->m_UsbIdle->m_CallbackInfo);
189
190 // m_PowerPolicyMachine.m_Owner->m_UsbIdle->m_IdleIrp.CallDriver(
191 // m_Device->GetAttachedDevice()
192 // );
194}

◆ PowerPolicyUpdateSystemWakeSource()

VOID FxPkgPnp::PowerPolicyUpdateSystemWakeSource ( __in FxIrp Irp)
protected

Definition at line 35 of file powerpolicystatemachinekm.cpp.

50{
51 //
52 // Check to see if this device caused the machine to wake up
53 //
55 PoGetSystemWake(Irp->GetIrp());
56
60 "WDFDEVICE 0x%p !devobj 0x%p WW !irp 0x%p is a source of "
61 "wake",
64 Irp->GetIrp());
65 }
66}

◆ PowerPolIdleCapableDeviceIdle()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolIdleCapableDeviceIdle ( __inout FxPkgPnp This)
staticprotected

Definition at line 3752 of file powerpolicystatemachine.cpp.

3768{
3769 BOOLEAN canPowerDown;
3771
3772 canPowerDown = This->m_PowerPolicyMachine.m_Owner->
3773 m_PoxInterface.DeclareComponentIdle();
3774
3775 //
3776 // If we are using driver-managed idle timeout we can power down immediately
3777 // and so we jump to the next state (that initiates power down) immediately.
3778 // If we are using system-managed idle timeout, we wait in the current state
3779 // for device-power-not-required notification.
3780 //
3781 return (canPowerDown ?
3784}
@ WdfDevStatePwrPolIdleCapableDeviceIdle
Definition: wdfdevice.h:364
@ WdfDevStatePwrPolTimerExpiredNoWake
Definition: wdfdevice.h:238

◆ PowerPolIoPresentArmed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolIoPresentArmed ( __inout FxPkgPnp This)
staticprotected

Definition at line 5794 of file powerpolicystatemachine.cpp.

5797{
5799
5800 if (This->PowerPolicyCancelWaitWake() == FALSE &&
5801 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
5802 COVERAGE_TRAP();
5804 }
5805
5806 return WdfDevStatePwrPolNull;
5807}
@ WdfDevStatePwrPolIoPresentArmedWakeCanceled
Definition: wdfdevice.h:297
@ WdfDevStatePwrPolIoPresentArmed
Definition: wdfdevice.h:296

◆ PowerPolIoPresentArmedWakeCanceled()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolIoPresentArmedWakeCanceled ( __inout FxPkgPnp This)
staticprotected

Definition at line 5825 of file powerpolicystatemachine.cpp.

5828{
5830
5832
5833 This->m_PowerPolicyMachine.m_Owner->
5834 m_PoxInterface.RequestComponentActive();
5835
5836 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, Retry);
5837
5838 if (!NT_SUCCESS(status)) {
5839 COVERAGE_TRAP();
5841 }
5842
5843 return WdfDevStatePwrPolNull;
5844}

◆ PowerPolPowerUpForSystemSleepFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolPowerUpForSystemSleepFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 6177 of file powerpolicystatemachine.cpp.

6195{
6197
6198 This->PowerPolicyCompleteSystemPowerIrp();
6199
6201}
@ WdfDevStatePwrPolPowerUpForSystemSleepFailed
Definition: wdfdevice.h:311

◆ PowerPolPowerUpForSystemSleepNotSeen()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolPowerUpForSystemSleepNotSeen ( __inout FxPkgPnp This)
staticprotected

Definition at line 7301 of file powerpolicystatemachine.cpp.

7319{
7320 if (This->m_PendingSystemPowerIrp != NULL) {
7321 This->PowerPolicyCompleteSystemPowerIrp();
7322 }
7323
7325}

◆ PowerPolRemoved()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolRemoved ( __inout FxPkgPnp This)
staticprotected

Definition at line 6640 of file powerpolicystatemachine.cpp.

6656{
6657 KIRQL irql;
6658
6660
6661 //
6662 // We raise IRQL to dispatch level so that pnp is forced onto its own thread
6663 // to process the PwrPolRemoved event. If pnp is on the power thread when
6664 // it processes the event and it tries to delete the dedicated thread, it
6665 // will deadlock waiting for the thread it is on to exit.
6666 //
6667 Mx::MxRaiseIrql(DISPATCH_LEVEL, &irql);
6668 This->PnpProcessEvent(PnpEventPwrPolRemoved);
6669 Mx::MxLowerIrql(irql);
6670
6671 return WdfDevStatePwrPolNull;
6672}
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
@ WdfDevStatePwrPolRemoved
Definition: wdfdevice.h:374

◆ PowerPolRestarting()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolRestarting ( __inout FxPkgPnp This)
staticprotected

Definition at line 6675 of file powerpolicystatemachine.cpp.

6690{
6692
6693 This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.Start();
6694
6695 This->PowerProcessEvent(PowerImplicitD0);
6696
6697 //
6698 // Wait for the successful power up before starting any idle timers. If
6699 // the power up fails, we will not send a power policy stop from the pnp
6700 // engine.
6701 //
6702 return WdfDevStatePwrPolNull;
6703}
@ WdfDevStatePwrPolRestarting
Definition: wdfdevice.h:375

◆ PowerPolRestartingFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolRestartingFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 6706 of file powerpolicystatemachine.cpp.

6721{
6722 KIRQL irql;
6723
6725
6726 This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.Stop();
6727
6728 //
6729 // We raise IRQL to dispatch level so that pnp is forced onto its own thread
6730 // to process the PwrPolStartFailed event. If pnp is on the power thread
6731 // when it processes the event and it tries to delete the dedicated thread,
6732 // it will deadlock waiting for the thread it is on to exit.
6733 //
6734 Mx::MxRaiseIrql(DISPATCH_LEVEL, &irql);
6735 This->PnpProcessEvent(PnpEventPwrPolStartFailed);
6736 Mx::MxLowerIrql(irql);
6737
6739}
@ WdfDevStatePwrPolRestartingFailed
Definition: wdfdevice.h:376

◆ PowerPolS0NoWakeCompletePowerUp()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolS0NoWakeCompletePowerUp ( __inout FxPkgPnp This)
staticprotected

Definition at line 4001 of file powerpolicystatemachine.cpp.

4019{
4021
4022 This->m_PowerPolicyMachine.m_Owner->
4023 m_PoxInterface.DeviceIsPoweredOn();
4024
4025 This->PowerProcessEvent(PowerCompleteD0);
4026
4027 return WdfDevStatePwrPolNull;
4028}
@ WdfDevStatePwrPolS0NoWakeCompletePowerUp
Definition: wdfdevice.h:243

◆ PowerPolS0NoWakePowerUp()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolS0NoWakePowerUp ( __inout FxPkgPnp This)
staticprotected

Definition at line 3977 of file powerpolicystatemachine.cpp.

3980{
3982
3984
3985 //
3986 // Attempt to get back to the D0 state
3987 //
3988 This->m_PowerPolicyMachine.m_Owner->
3989 m_PoxInterface.RequestComponentActive();
3990 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, Retry);
3991
3992 if (!NT_SUCCESS(status)) {
3993 COVERAGE_TRAP();
3995 }
3996
3997 return WdfDevStatePwrPolNull;
3998}
@ WdfDevStatePwrPolS0NoWakePowerUp
Definition: wdfdevice.h:242

◆ PowerPolS0WakeCompletePowerUp()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolS0WakeCompletePowerUp ( __inout FxPkgPnp This)
staticprotected

Definition at line 5872 of file powerpolicystatemachine.cpp.

5889{
5891
5892 This->PowerProcessEvent(PowerCompleteD0);
5893
5894 return WdfDevStatePwrPolNull;
5895}
@ WdfDevStatePwrPolS0WakeCompletePowerUp
Definition: wdfdevice.h:299

◆ PowerPolS0WakeDisarm()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolS0WakeDisarm ( __inout FxPkgPnp This)
staticprotected

Definition at line 5847 of file powerpolicystatemachine.cpp.

5850{
5852
5853 This->m_PowerPolicyMachine.m_Owner->
5854 m_PoxInterface.DeviceIsPoweredOn();
5855
5856 //
5857 // If the PDO is the Power Policy owner, then disable wake at bus, otherwise
5858 // the power state machine will disable wake at bus.
5859 //
5860 if (This->m_Device->IsPdo()) {
5861 This->PowerDisableWakeAtBusOverload();
5862 }
5863
5864 This->m_PowerPolicyMachine.m_Owner->m_DeviceDisarmWakeFromS0.Invoke(
5865 This->m_Device->GetHandle()
5866 );
5867
5869}
@ WdfDevStatePwrPolS0WakeDisarm
Definition: wdfdevice.h:298

◆ PowerPolSleeping()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleeping ( __inout FxPkgPnp This)
staticprotected

Definition at line 4751 of file powerpolicystatemachine.cpp.

4768{
4769 NTSTATUS notifyPowerDownStatus;
4770 SYSTEM_POWER_STATE systemState;
4771
4773
4774 //
4775 // If the bus/PDO is not in the hibernate path, then verify that all the
4776 // children have powered down by now.
4777 //
4778 if (This->GetUsageCount(WdfSpecialFileHibernation) == 0 &&
4779 This->m_PowerPolicyMachine.m_Owner->m_ChildrenPoweredOnCount > 0) {
4781 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
4782 "WDFDEVICE %p powering down before child devices have powered down. "
4783 "This usually indicates a faulty child device that completed the Sx "
4784 "irp before sending the Dx irp",
4785 This->m_Device->GetHandle());
4786
4788 This->m_Device->GetDriverGlobals());
4789 }
4790
4791 //
4792 // Simulate a device-power-not-required notification from the power
4793 // framework. An Sx-IRP is essentially equivalent to a device-power-not-
4794 // required notification.
4795 //
4796 This->m_PowerPolicyMachine.m_Owner->
4797 m_PoxInterface.SimulateDevicePowerNotRequired();
4798
4799 //
4800 // Notify the device-power-requirement state machine that we are about to
4801 // power down
4802 //
4803 notifyPowerDownStatus = This->m_PowerPolicyMachine.m_Owner->
4804 m_PoxInterface.NotifyDevicePowerDown();
4805
4806 //
4807 // We simulated a device-power-not-required notification before we notified
4808 // the device-power-requirement state machine that we are powering down.
4809 // Therefore, our notification should have succeeded.
4810 //
4811 ASSERT(NT_SUCCESS(notifyPowerDownStatus));
4812 UNREFERENCED_PARAMETER(notifyPowerDownStatus);
4813
4814 systemState = This->PowerPolicyGetPendingSystemState();
4815
4816 if (This->PowerPolicyIsWakeEnabled() &&
4817 This->PowerPolicyCanWakeFromSystemState(systemState)) {
4819 }
4820 else {
4822 }
4823}
__inline VOID FxVerifierBreakOnDeviceStateError(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
Definition: fxverifier.h:101
@ WdfDevStatePwrPolSleepingNoWakePowerDown
Definition: wdfdevice.h:271
@ WdfDevStatePwrPolSleeping
Definition: wdfdevice.h:270
@ WdfDevStatePwrPolSleepingWakePowerDown
Definition: wdfdevice.h:274

◆ PowerPolSleepingNoWakeCompletePowerDown()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleepingNoWakeCompletePowerDown ( __inout FxPkgPnp This)
staticprotected

Definition at line 4885 of file powerpolicystatemachine.cpp.

4902{
4905
4906 This->PowerProcessEvent(PowerCompleteDx);
4907
4908 return WdfDevStatePwrPolNull;
4909}
@ WdfDevStatePwrPolSleepingNoWakeCompletePowerDown
Definition: wdfdevice.h:272

◆ PowerPolSleepingNoWakeDxRequestFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleepingNoWakeDxRequestFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 4912 of file powerpolicystatemachine.cpp.

4915{
4916 COVERAGE_TRAP();
4917
4919
4920 This->SetInternalFailure();
4921 This->PowerPolicyCompleteSystemPowerIrp();
4922
4923 if (FALSE == This->m_ReleaseHardwareAfterDescendantsOnFailure) {
4924 This->PnpProcessEvent(PnpEventPowerDownFailed);
4925 }
4926
4928}
@ PnpEventPowerDownFailed
@ WdfDevStatePwrPolSleepingNoWakeDxRequestFailed
Definition: wdfdevice.h:273

◆ PowerPolSleepingNoWakePowerDown()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleepingNoWakePowerDown ( __inout FxPkgPnp This)
staticprotected

Definition at line 4826 of file powerpolicystatemachine.cpp.

4842{
4844 DEVICE_POWER_STATE dxState;
4845
4847
4848 dxState = (DEVICE_POWER_STATE)
4849 This->m_PowerPolicyMachine.m_Owner->m_IdealDxStateForSx;
4850
4851 if (dxState != PowerDeviceD3) {
4852 DEVICE_POWER_STATE dxMappedState;
4853
4854 //
4855 // Get the lightest Dx state for this Sx state as reported by the
4856 // device capabilities of the stack.
4857 //
4858 dxMappedState = _GetPowerCapState(
4859 This->PowerPolicyGetPendingSystemState(),
4860 This->m_PowerPolicyMachine.m_Owner->m_SystemToDeviceStateMap
4861 );
4862
4863 //
4864 // If the ideal desired state is lighter than what the S->D mapping says
4865 // is the lightest supported D state, use the mapping value instead.
4866 //
4867 if (dxState < dxMappedState) {
4868 dxState = dxMappedState;
4869 }
4870 }
4871
4872 ASSERT(dxState >= PowerDeviceD1 && dxState <= PowerDeviceD3);
4873
4874 status = This->PowerPolicyPowerDownForSx(dxState, Retry);
4875
4876 if (!NT_SUCCESS(status)) {
4877 COVERAGE_TRAP();
4879 }
4880
4881 return WdfDevStatePwrPolNull;
4882}
static DEVICE_POWER_STATE _GetPowerCapState(__in ULONG Index, __in ULONG State)
Definition: fxpkgpnp.cpp:5657

◆ PowerPolSleepingPowerDownNotProcessed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleepingPowerDownNotProcessed ( __inout FxPkgPnp This)
staticprotected

Definition at line 7119 of file powerpolicystatemachine.cpp.

7136{
7138
7139 This->SetInternalFailure();
7140
7142}
@ WdfDevStatePwrPolSystemSleepPowerRequestFailed
Definition: wdfdevice.h:247
@ WdfDevStatePwrPolSleepingPowerDownNotProcessed
Definition: wdfdevice.h:349

◆ PowerPolSleepingSendWake()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleepingSendWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 4966 of file powerpolicystatemachine.cpp.

4983{
4984 SYSTEM_POWER_STATE systemState;
4986
4988
4989 //
4990 // We are in a wake-enabled path, keep wake interrupts connected.
4991 //
4992 This->m_WakeInterruptsKeepConnected = TRUE;
4993
4994 //
4995 // We use the deepest possible Sx state instead of the current Sx state so
4996 // that we can handle the FastS4 case where PowerPolicyGetPendingSystemState
4997 // would return, but we could possible goto S4. By using the deepest
4998 // possible state, we can arm for any possible Sx state that we are capable
4999 // of waking from.
5000 //
5001 systemState = This->PowerPolicyGetDeviceDeepestSystemWakeState();
5002
5003 status = This->PowerPolicySendWaitWakeRequest(systemState);
5004
5005 if (!NT_SUCCESS(status)) {
5007 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
5008 "Attempting to send wait wake request for EvtDeviceArmWakeFromSx() "
5009 "failed, %!STATUS!", status);
5010
5011 COVERAGE_TRAP();
5012
5014 }
5015
5016 return WdfDevStatePwrPolNull;
5017}
@ WdfDevStatePwrPolSleepingSendWake
Definition: wdfdevice.h:275

◆ PowerPolSleepingWakePowerDown()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleepingWakePowerDown ( __inout FxPkgPnp This)
staticprotected

Definition at line 4931 of file powerpolicystatemachine.cpp.

4948{
4950
4952
4953 status = This->PowerPolicyPowerDownForSx(
4954 This->m_PowerPolicyMachine.m_Owner->m_WakeSettings.DxState, NoRetry
4955 );
4956
4957 if (!NT_SUCCESS(status)) {
4958 COVERAGE_TRAP();
4960 }
4961
4962 return WdfDevStatePwrPolNull;
4963}

◆ PowerPolSleepingWakePowerDownFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleepingWakePowerDownFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 4521 of file powerpolicystatemachine.cpp.

4538{
4541
4542 if (This->PowerPolicyCancelWaitWake() == FALSE &&
4543 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
4545 }
4546
4547 return WdfDevStatePwrPolNull;
4548}
@ WdfDevStatePwrPolSleepingWakePowerDownFailed
Definition: wdfdevice.h:260
@ WdfDevStatePwrPolSleepingWakePowerDownFailedWakeCanceled
Definition: wdfdevice.h:261

◆ PowerPolSleepingWakePowerDownFailedWakeCanceled()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleepingWakePowerDownFailedWakeCanceled ( __inout FxPkgPnp This)
staticprotected

Definition at line 4551 of file powerpolicystatemachine.cpp.

4567{
4570
4571 This->PowerPolicyCompleteSystemPowerIrp();
4572
4574}

◆ PowerPolSleepingWakeRevertArmWake()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleepingWakeRevertArmWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 4251 of file powerpolicystatemachine.cpp.

4254{
4257
4259 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
4260 "reverting arm for wake from Sx due to failure to allocate wait wake "
4261 "request or wait wake request completed immeidately. Device will *NOT* "
4262 "be armed for wake from Sx");
4263
4264 //
4265 // Enable calls should be matched with Disable calls even in the failure
4266 // cases. However, for the Enable wake at bus failure, we do not call the
4267 // disable wake at bus method as we try to keep the failure behavior
4268 // consistent with the Power State machine. Only the Device Disarm wake
4269 // callback will be invoked here.
4270 //
4271 This->PowerPolicyDisarmWakeFromSx();
4272
4273 //
4274 // attempt to cancel ww
4275 //
4276 if (This->PowerPolicyCancelWaitWake() == FALSE &&
4277 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
4279 }
4280
4281 return WdfDevStatePwrPolNull;
4282}
@ WdfDevStatePwrPolSleepingWakeRevertArmWake
Definition: wdfdevice.h:250

◆ PowerPolSleepingWakeRevertArmWakeNP()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleepingWakeRevertArmWakeNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4487 of file powerpolicystatemachine.cpp.

4490{
4493
4495 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
4496 "reverting arm for wake from Sx due to failure to allocate wait wake "
4497 "request or wait wake request completed immeidately. Device will *NOT* "
4498 "be armed for wake from Sx");
4499
4500 //
4501 // Enable calls should be matched with Disable calls even in the failure
4502 // cases. However, for the Enable wake at bus failure, we do not call the
4503 // disable wake at bus method as we try to keep the failure behavior
4504 // consistent with the Power State machine. Only the Device Disarm wake
4505 // callback will be invoked here.
4506 //
4507 This->PowerPolicyDisarmWakeFromSx();
4508
4509 //
4510 // attempt to cancel ww
4511 //
4512 if (This->PowerPolicyCancelWaitWake() == FALSE &&
4513 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
4515 }
4516
4517 return WdfDevStatePwrPolNull;
4518}
@ WdfDevStatePwrPolSleepingWakeRevertArmWakeNP
Definition: wdfdevice.h:259

◆ PowerPolSleepingWakeWakeArrived()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleepingWakeWakeArrived ( __inout FxPkgPnp This)
staticprotected

Definition at line 4186 of file powerpolicystatemachine.cpp.

4202{
4204 ULONG wakeReason;
4205
4208
4209 ASSERT(This->PowerPolicyCanWakeFromSystemState(
4210 This->PowerPolicyGetPendingSystemState()
4211 ));
4212
4213 wakeReason = This->PowerPolicyGetCurrentWakeReason();
4214
4215 status = This->m_PowerPolicyMachine.m_Owner->m_DeviceArmWakeFromSx.Invoke(
4216 This->m_Device->GetHandle(),
4219 );
4220
4221 if (!NT_SUCCESS(status)) {
4223 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
4224 "WDFDEVICE %p Failed to arm for wake from Sx, %!STATUS!",
4225 This->m_Device->GetHandle(), status);
4226
4228 }
4229
4230 //
4231 // If the PDO is the Power Policy owner, then enable wake at bus, otherwise
4232 // the power state machine will enable wake at bus.
4233 //
4234 if (This->m_Device->IsPdo()) {
4235 status = This->PowerEnableWakeAtBusOverload();
4236 if (!NT_SUCCESS(status)) {
4238 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
4239 "WDFDEVICE %p Failed to Enable Wake at Bus, %!STATUS!",
4240 This->m_Device->GetHandle(), status);
4242 }
4243 }
4244
4245 This->PowerProcessEvent(PowerCompleteDx);
4246
4247 return WdfDevStatePwrPolNull;
4248}
#define FLAG_TO_BOOL(_Flags, _FlagMask)
Definition: fxobject.hpp:125

◆ PowerPolSleepingWakeWakeArrivedNP()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSleepingWakeWakeArrivedNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4421 of file powerpolicystatemachine.cpp.

4438{
4440 ULONG wakeReason;
4441
4444
4445 ASSERT(This->PowerPolicyCanWakeFromSystemState(
4446 This->PowerPolicyGetPendingSystemState()
4447 ));
4448
4449 wakeReason = This->PowerPolicyGetCurrentWakeReason();
4450
4451 status = This->m_PowerPolicyMachine.m_Owner->m_DeviceArmWakeFromSx.Invoke(
4452 This->m_Device->GetHandle(),
4455 );
4456
4457 if (!NT_SUCCESS(status)) {
4459 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
4460 "WDFDEVICE %p Failed to arm for wake from Sx, %!STATUS!",
4461 This->m_Device->GetHandle(), status);
4462
4464 }
4465
4466 //
4467 // If the PDO is the Power Policy owner, then enable wake at bus, otherwise
4468 // the power state machine will enable wake at bus.
4469 //
4470 if (This->m_Device->IsPdo()) {
4471 status = This->PowerEnableWakeAtBusOverload();
4472 if (!NT_SUCCESS(status)) {
4474 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
4475 "WDFDEVICE %p Failed to Enable Wake at Bus, %!STATUS!",
4476 This->m_Device->GetHandle(), status);
4478 }
4479 }
4480
4481 This->PowerProcessEvent(PowerCompleteDx);
4482
4483 return WdfDevStatePwrPolNull;
4484}

◆ PowerPolStarted()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStarted ( __inout FxPkgPnp This)
staticprotected

Definition at line 6887 of file powerpolicystatemachine.cpp.

6902{
6904
6905 //
6906 // We signal we are in D0 even though there is idling out in this state
6907 // because we could have just come from a state which *was* idled out.
6908 // For instance
6909 // 1) We are in WaitingArmed and an io present event moved us out of this state
6910 // 2) Immediately afterward, the s0 idle policy was changed
6911 // 3) When we enter StartingDecideS0Wake, we will move into this state without
6912 // first entering StartedWakeCapable.
6913 // 4) The source of the io present event, if waiting synchronously needs to
6914 // be unblocked.
6915 //
6916 This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer();
6917
6918 return WdfDevStatePwrPolNull;
6919}
@ WdfDevStatePwrPolStarted
Definition: wdfdevice.h:333

◆ PowerPolStartedCancelTimer()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStartedCancelTimer ( __inout FxPkgPnp This)
staticprotected

Definition at line 6922 of file powerpolicystatemachine.cpp.

6937{
6939
6940 if (This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer()) {
6942 }
6943 else {
6944 COVERAGE_TRAP();
6946 }
6947}
@ WdfDevStatePwrPolStartingDecideS0Wake
Definition: wdfdevice.h:236
@ WdfDevStatePwrPolStartedWaitForIdleTimeout
Definition: wdfdevice.h:335

◆ PowerPolStartedIdleCapable()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStartedIdleCapable ( __inout FxPkgPnp This)
staticprotected

Definition at line 3736 of file powerpolicystatemachine.cpp.

3739{
3741
3742 //
3743 // Enable the idle state machine. This will release any threads who are
3744 // waiting for the device to return to D0.
3745 //
3746 This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.EnableTimer();
3747
3748 return WdfDevStatePwrPolNull;
3749}
@ WdfDevStatePwrPolStartedIdleCapable
Definition: wdfdevice.h:237

◆ PowerPolStartedIdleCapableCancelTimerForSleep()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStartedIdleCapableCancelTimerForSleep ( __inout FxPkgPnp This)
staticprotected

Definition at line 7019 of file powerpolicystatemachine.cpp.

7035{
7038
7039 if (This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer()) {
7041 }
7042 else {
7043 COVERAGE_TRAP();
7045 }
7046}
@ WdfDevStatePwrPolStartedIdleCapableWaitForIdleTimeout
Definition: wdfdevice.h:340

◆ PowerPolStartedWakeCapable()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStartedWakeCapable ( __inout FxPkgPnp This)
staticprotected

Definition at line 5163 of file powerpolicystatemachine.cpp.

5166{
5168
5169 //
5170 // Enable the idle state machine. This will release any threads who are
5171 // waiting for the device to return to D0.
5172 //
5173 This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.EnableTimer();
5174
5175 return WdfDevStatePwrPolNull;
5176}
@ WdfDevStatePwrPolStartedWakeCapable
Definition: wdfdevice.h:281

◆ PowerPolStartedWakeCapableCancelTimerForSleep()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStartedWakeCapableCancelTimerForSleep ( __inout FxPkgPnp This)
staticprotected

Definition at line 6950 of file powerpolicystatemachine.cpp.

6966{
6969
6970 if (This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer()) {
6972 }
6973 else {
6974 COVERAGE_TRAP();
6976 }
6977}
@ WdfDevStatePwrPolStartedWakeCapableWaitForIdleTimeout
Definition: wdfdevice.h:337
@ WdfDevStatePwrPolStartedWakeCapableCancelTimerForSleep
Definition: wdfdevice.h:336

◆ PowerPolStartedWakeCapableSleepingUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStartedWakeCapableSleepingUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 6980 of file powerpolicystatemachine.cpp.

6997{
6999
7001
7002 result = This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer();
7003
7004 //
7005 // Since the power timeout expired, the disable should not return FALSE
7006 //
7007 ASSERT(result);
7009
7010 //
7011 // Cancel USBSS irp
7012 //
7013 This->PowerPolicyCancelUsbSS();
7014
7015 return WdfDevStatePwrPolNull;
7016}
@ WdfDevStatePwrPolStartedWakeCapableSleepingUsbSS
Definition: wdfdevice.h:338

◆ PowerPolStarting()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStarting ( __inout FxPkgPnp This)
staticprotected

Definition at line 3543 of file powerpolicystatemachine.cpp.

3546{
3548
3549 This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.Start();
3550
3551 This->PowerProcessEvent(PowerImplicitD0);
3552
3553 //
3554 // Wait for the successful power up before starting any idle timers. If
3555 // the power up fails, we will not send a power policy stop from the pnp
3556 // engine.
3557 //
3558 return WdfDevStatePwrPolNull;
3559}
@ WdfDevStatePwrPolStarting
Definition: wdfdevice.h:233

◆ PowerPolStartingDecideS0Wake()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStartingDecideS0Wake ( __inout FxPkgPnp This)
staticprotected

Definition at line 3698 of file powerpolicystatemachine.cpp.

3701{
3703
3704 This->PowerPolicyChildrenCanPowerUp();
3705
3706 //
3707 // Save idle state if it is dirty. We check when deciding the S0 state
3708 // because any change in the S0 idle settings will go through this state.
3709 //
3710 This->SaveState(TRUE);
3711
3712 //
3713 // If necessary update the idle timeout hint to the power framework
3714 //
3715 This->m_PowerPolicyMachine.m_Owner->m_PoxInterface.UpdateIdleTimeoutHint();
3716
3717 if (This->m_PowerPolicyMachine.m_Owner->m_IdleSettings.Enabled) {
3718 if (This->m_PowerPolicyMachine.m_Owner->m_IdleSettings.WakeFromS0Capable) {
3719 //
3720 // We can idle out and wake from S0
3721 //
3723 }
3724 else {
3725 //
3726 // We can idle out, but not wake from the idle state
3727 //
3729 }
3730 }
3731
3733}

◆ PowerPolStartingFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStartingFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 3661 of file powerpolicystatemachine.cpp.

3677{
3678 KIRQL irql;
3679
3681
3682 This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.Stop();
3683
3684 //
3685 // We raise IRQL to dispatch level so that pnp is forced onto its own thread
3686 // to process the PwrPolStartFailed event. If pnp is on the power thread when
3687 // it processes the event and it tries to delete the dedicated thread, it
3688 // will deadlock waiting for the thread its on to exit.
3689 //
3690 Mx::MxRaiseIrql(DISPATCH_LEVEL, &irql);
3691 This->PnpProcessEvent(PnpEventPwrPolStartFailed);
3692 Mx::MxLowerIrql(irql);
3693
3694 return WdfDevStatePwrPolNull;
3695}
@ WdfDevStatePwrPolStartingFailed
Definition: wdfdevice.h:235

◆ PowerPolStartingPoweredUp()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStartingPoweredUp ( __inout FxPkgPnp This)
staticprotected

Definition at line 3562 of file powerpolicystatemachine.cpp.

3585{
3588
3589 //
3590 // The decision regarding whether or not the power framework determines the
3591 // idle timeout is now "frozen" and cannot be changed unless the device is
3592 // stopped and restarted.
3593 //
3594 This->m_PowerPolicyMachine.m_Owner->
3595 m_IdleSettings.m_TimeoutMgmt.FreezeIdleTimeoutManagementStatus(
3596 This->GetDriverGlobals()
3597 );
3598
3599 status = This->m_PowerPolicyMachine.m_Owner->
3600 m_PoxInterface.InitializeComponents();
3601 if (FALSE == NT_SUCCESS(status)) {
3603 }
3604
3606}
@ WdfDevStatePwrPolStartingPoweredUpFailed
Definition: wdfdevice.h:377
@ WdfDevStatePwrPolStartingPoweredUp
Definition: wdfdevice.h:363

◆ PowerPolStartingPoweredUpFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStartingPoweredUpFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 3609 of file powerpolicystatemachine.cpp.

3626{
3628
3629 This->PowerProcessEvent(PowerImplicitD3);
3630
3631 return WdfDevStatePwrPolNull;
3632}

◆ PowerPolStartingSucceeded()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStartingSucceeded ( __inout FxPkgPnp This)
staticprotected

Definition at line 3635 of file powerpolicystatemachine.cpp.

◆ PowerPolStoppedRemoving()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppedRemoving ( __inout FxPkgPnp This)
staticprotected

Definition at line 6614 of file powerpolicystatemachine.cpp.

6630{
6632
6633 This->m_PowerPolicyMachine.m_Owner->
6634 m_PoxInterface.UninitializeComponents();
6635
6637}
@ WdfDevStatePwrPolStoppedRemoving
Definition: wdfdevice.h:373

◆ PowerPolStopping()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStopping ( __inout FxPkgPnp This)
staticprotected

Definition at line 6519 of file powerpolicystatemachine.cpp.

6522{
6524
6525 //
6526 // Prevent any children from powering up. Technically this is not necessary
6527 // because if we are getting to this point, all of our children have already
6528 // been implicitly stopped as well, but this keeps the child power up state
6529 // consistent with the power policy state.
6530 //
6531 This->PowerPolicyBlockChildrenPowerUp();
6532
6533 //
6534 // This power change event does not need to be synchronous
6535 //
6536 This->PowerProcessEvent(PowerImplicitD3);
6537
6538 return WdfDevStatePwrPolNull;
6539}
@ WdfDevStatePwrPolStopping
Definition: wdfdevice.h:323

◆ PowerPolStoppingCancelTimer()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingCancelTimer ( __inout FxPkgPnp This)
staticprotected

Definition at line 6742 of file powerpolicystatemachine.cpp.

6757{
6759
6760 if (This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer()) {
6762 }
6763 else {
6764 //
6765 // Timer was not canceled, move to the state where we wait for the
6766 // timeout event to be posted.
6767 //
6769 }
6770}
@ WdfDevStatePwrPolStoppingWaitForIdleTimeout
Definition: wdfdevice.h:327

◆ PowerPolStoppingCancelUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingCancelUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 6773 of file powerpolicystatemachine.cpp.

6788{
6790
6791 //
6792 // We notified the device power requirement state machine that we are about
6793 // to power down, but eventually we didn't power down. So notify the device
6794 // power requirement state machine that the device should be considered
6795 // powered on.
6796 //
6797 This->m_PowerPolicyMachine.m_Owner->
6798 m_PoxInterface.DeviceIsPoweredOn();
6799
6800 This->m_PowerPolicyMachine.m_Owner->
6801 m_PoxInterface.RequestComponentActive();
6802
6803 if (This->PowerPolicyCancelUsbSSIfCapable() == FALSE) {
6804 //
6805 // UsbSS already canceled/completed
6806 //
6808 }
6809
6811}
@ WdfDevStatePwrPolStoppingCancelUsbSS
Definition: wdfdevice.h:328
@ WdfDevStatePwrPolStoppingWaitForUsbSSCompletion
Definition: wdfdevice.h:329

◆ PowerPolStoppingCancelWake()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingCancelWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 6814 of file powerpolicystatemachine.cpp.

6831{
6833
6834 if (This->PowerPolicyCancelWaitWake() == FALSE &&
6835 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
6836 COVERAGE_TRAP();
6838 }
6839 else {
6840 return WdfDevStatePwrPolNull;
6841 }
6842}
@ WdfDevStatePwrPolStoppingCancelWake
Definition: wdfdevice.h:330

◆ PowerPolStoppingD0()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingD0 ( __inout FxPkgPnp This)
staticprotected

Definition at line 6407 of file powerpolicystatemachine.cpp.

6410{
6412
6414
6415 This->m_PowerPolicyMachine.m_Owner->
6416 m_PoxInterface.RequestComponentActive();
6417
6418 This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer();
6419
6420 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, Retry);
6421 if (!NT_SUCCESS(status)) {
6422 COVERAGE_TRAP();
6424 }
6425
6426 return WdfDevStatePwrPolNull;
6427}
@ WdfDevStatePwrPolStoppingD0
Definition: wdfdevice.h:318

◆ PowerPolStoppingD0CancelUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingD0CancelUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 8329 of file powerpolicystatemachine.cpp.

8344{
8346
8347 if (This->PowerPolicyCancelUsbSSIfCapable()) {
8348 //
8349 // Usbss completion event will move us from this state.
8350 //
8351 return WdfDevStatePwrPolNull;
8352 }
8353
8354 //
8355 // If usbss irp was there it has already been canceled, so march on.
8356 //
8358}
@ WdfDevStatePwrPolStoppingD0CancelUsbSS
Definition: wdfdevice.h:362

◆ PowerPolStoppingD0Failed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingD0Failed ( __inout FxPkgPnp This)
staticprotected

Definition at line 6430 of file powerpolicystatemachine.cpp.

6447{
6449
6450 This->m_PowerPolicyMachine.m_Owner->m_PowerFailed = TRUE;
6451
6452 //
6453 // Notify the device power requirement state machine that the device should
6454 // be considered powered on, although it is not. Doing this will ensure that
6455 // component activation before device removal will succeed.
6456 //
6457 This->m_PowerPolicyMachine.m_Owner->
6458 m_PoxInterface.DeviceIsPoweredOn();
6459
6461}
@ WdfDevStatePwrPolStoppingDisarmWakeCancelWake
Definition: wdfdevice.h:321
@ WdfDevStatePwrPolStoppingD0Failed
Definition: wdfdevice.h:319

◆ PowerPolStoppingDisarmWake()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingDisarmWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 6464 of file powerpolicystatemachine.cpp.

6467{
6469
6470 This->m_PowerPolicyMachine.m_Owner->
6471 m_PoxInterface.DeviceIsPoweredOn();
6472
6473 //
6474 // If the PDO is the Power Policy owner, then disable wake at bus, otherwise
6475 // the power state machine will disable wake at bus.
6476 //
6477 if (This->m_Device->IsPdo()) {
6478 This->PowerDisableWakeAtBusOverload();
6479 }
6480
6481 This->m_PowerPolicyMachine.m_Owner->m_DeviceDisarmWakeFromS0.Invoke(
6482 This->m_Device->GetHandle()
6483 );
6484
6485 This->PowerProcessEvent(PowerCompleteD0);
6486
6487 return WdfDevStatePwrPolNull;
6488
6489}
@ WdfDevStatePwrPolStoppingDisarmWake
Definition: wdfdevice.h:320

◆ PowerPolStoppingDisarmWakeCancelWake()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingDisarmWakeCancelWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 6492 of file powerpolicystatemachine.cpp.

6495{
6497
6498 if (This->PowerPolicyCancelWaitWake() == FALSE &&
6499 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
6501 }
6502
6503 return WdfDevStatePwrPolNull;
6504}
@ WdfDevStatePwrPolStoppingDisarmWakeWakeCanceled
Definition: wdfdevice.h:322

◆ PowerPolStoppingDisarmWakeWakeCanceled()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingDisarmWakeWakeCanceled ( __inout FxPkgPnp This)
staticprotected

◆ PowerPolStoppingFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 6542 of file powerpolicystatemachine.cpp.

6558{
6560
6561 This->m_PowerPolicyMachine.m_Owner->m_PowerFailed = TRUE;
6562
6564}
@ WdfDevStatePwrPolStoppingSendStatus
Definition: wdfdevice.h:325
@ WdfDevStatePwrPolStoppingFailed
Definition: wdfdevice.h:324

◆ PowerPolStoppingResetDevice()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingResetDevice ( __inout FxPkgPnp This)
staticprotected

Definition at line 6300 of file powerpolicystatemachine.cpp.

6317{
6320
6322
6323 This->m_PowerPolicyMachine.m_Owner->
6324 m_PoxInterface.RequestComponentActive();
6325
6326 result = This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer();
6327 ASSERT(result);
6329
6330 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, Retry);
6331
6332 if (!NT_SUCCESS(status)) {
6333 COVERAGE_TRAP();
6335 }
6336
6337 return WdfDevStatePwrPolNull;
6338}
@ WdfDevStatePwrPolStoppingResetDevice
Definition: wdfdevice.h:315

◆ PowerPolStoppingResetDeviceCompletePowerUp()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingResetDeviceCompletePowerUp ( __inout FxPkgPnp This)
staticprotected

Definition at line 6341 of file powerpolicystatemachine.cpp.

6359{
6362
6363 This->m_PowerPolicyMachine.m_Owner->
6364 m_PoxInterface.DeviceIsPoweredOn();
6365
6366 This->PowerProcessEvent(PowerCompleteD0);
6367
6368 return WdfDevStatePwrPolNull;
6369}
@ WdfDevStatePwrPolStoppingResetDeviceCompletePowerUp
Definition: wdfdevice.h:316

◆ PowerPolStoppingResetDeviceFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingResetDeviceFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 6372 of file powerpolicystatemachine.cpp.

6390{
6392
6393 This->m_PowerPolicyMachine.m_Owner->m_PowerFailed = TRUE;
6394
6395 //
6396 // Notify the device power requirement state machine that the device should
6397 // be considered powered on, although it is not. Doing this will ensure that
6398 // component activation before device removal will succeed.
6399 //
6400 This->m_PowerPolicyMachine.m_Owner->
6401 m_PoxInterface.DeviceIsPoweredOn();
6402
6404}
@ WdfDevStatePwrPolStoppingResetDeviceFailed
Definition: wdfdevice.h:317

◆ PowerPolStoppingSendStatus()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingSendStatus ( __inout FxPkgPnp This)
staticprotected

Definition at line 6567 of file powerpolicystatemachine.cpp.

6584{
6585 KIRQL irql;
6586
6588
6589 This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.Stop();
6590
6591 //
6592 // We raise IRQL to dispatch level so that pnp is forced onto its own thread
6593 // to process the PwrPolStopped event. If pnp is on the power thread when
6594 // it processes the event and it tries to delete the dedicated thread, it
6595 // will deadlock waiting for the thread its on to exit.
6596 //
6597 Mx::MxRaiseIrql(DISPATCH_LEVEL, &irql);
6598 This->PnpProcessEvent(
6599 This->m_PowerPolicyMachine.m_Owner->m_PowerFailed
6602 );
6603 Mx::MxLowerIrql(irql);
6604
6605 //
6606 // Reset back to a non failed state
6607 //
6608 This->m_PowerPolicyMachine.m_Owner->m_PowerFailed = FALSE;
6609
6611}

◆ PowerPolStoppingSucceeded()

static WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolStoppingSucceeded ( __inout FxPkgPnp This)
staticprotected

◆ PowerPolSystemAsleepNoWake()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemAsleepNoWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 5020 of file powerpolicystatemachine.cpp.

5023{
5025
5026 This->PowerPolicyCompleteSystemPowerIrp();
5027
5028 return WdfDevStatePwrPolNull;
5029}
@ WdfDevStatePwrPolSystemAsleepNoWake
Definition: wdfdevice.h:276

◆ PowerPolSystemAsleepWakeArmed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemAsleepWakeArmed ( __inout FxPkgPnp This)
staticprotected

Definition at line 4285 of file powerpolicystatemachine.cpp.

4288{
4290 This->PowerPolicyCompleteSystemPowerIrp();
4291
4292 return WdfDevStatePwrPolNull;
4293}
@ WdfDevStatePwrPolSystemAsleepWakeArmed
Definition: wdfdevice.h:251

◆ PowerPolSystemAsleepWakeArmedNP()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemAsleepWakeArmedNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4577 of file powerpolicystatemachine.cpp.

4580{
4582
4583 This->PowerPolicyCompleteSystemPowerIrp();
4584
4585 return WdfDevStatePwrPolNull;
4586}
@ WdfDevStatePwrPolSystemAsleepWakeArmedNP
Definition: wdfdevice.h:262

◆ PowerPolSystemSleepFromDeviceWaitingUnarmed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemSleepFromDeviceWaitingUnarmed ( __inout FxPkgPnp This)
staticprotected

Definition at line 4031 of file powerpolicystatemachine.cpp.

4034{
4035 SYSTEM_POWER_STATE systemState;
4036
4039
4040 systemState = This->PowerPolicyGetPendingSystemState();
4041
4042 if (This->PowerPolicyIsWakeEnabled() &&
4043 This->PowerPolicyCanWakeFromSystemState(systemState)) {
4045 }
4046 else {
4048 }
4049}
@ WdfDevStatePwrPolSystemSleepFromDeviceWaitingUnarmed
Definition: wdfdevice.h:244
@ WdfDevStatePwrPolSystemSleepNeedWake
Definition: wdfdevice.h:245

◆ PowerPolSystemSleepNeedWake()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemSleepNeedWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 4052 of file powerpolicystatemachine.cpp.

4055{
4058
4060
4061 result = This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer();
4062 ASSERT(result);
4064
4065 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, Retry);
4066
4067 //
4068 // We are currently in Dx and not armed for wake. While the current Dx
4069 // state may not be the same Dx state we would be for Sx, we can't get to
4070 // D0 to arm ourselves for Sx wake so just leave ourselves as is.
4071 //
4072 if (!NT_SUCCESS(status)) {
4074 This->GetDriverGlobals(), TRACE_LEVEL_WARNING, TRACINGPNP,
4075 "Failed to allocate D0 request to disarm from wake from S0 to allow "
4076 "arm for wake from Sx, %!STATUS!", status);
4077
4078 COVERAGE_TRAP();
4079
4080 //
4081 // If D0 IRP allocation fails, we don't treat that as an error. Instead,
4082 // we just let the device remain in Dx without arming it for
4083 // wake-from-Sx, even though the driver had enabled wake-from-Sx.
4084 //
4086 }
4087
4088 return WdfDevStatePwrPolNull;
4089}

◆ PowerPolSystemSleepNeedWakeCompletePowerUp()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemSleepNeedWakeCompletePowerUp ( __inout FxPkgPnp This)
staticprotected

Definition at line 4092 of file powerpolicystatemachine.cpp.

4110{
4113
4114 This->PowerProcessEvent(PowerCompleteD0);
4115
4116 return WdfDevStatePwrPolNull;
4117}
@ WdfDevStatePwrPolSystemSleepNeedWakeCompletePowerUp
Definition: wdfdevice.h:246

◆ PowerPolSystemSleepPowerRequestFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemSleepPowerRequestFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 4120 of file powerpolicystatemachine.cpp.

4137{
4139
4140 This->PowerPolicyCompleteSystemPowerIrp();
4141
4143}

◆ PowerPolSystemWakeDeviceToD0()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceToD0 ( __inout FxPkgPnp This)
staticprotected

Definition at line 5078 of file powerpolicystatemachine.cpp.

5081{
5083
5085
5086 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, Retry);
5087 if (!NT_SUCCESS(status)) {
5088 COVERAGE_TRAP();
5090 }
5091
5092 return WdfDevStatePwrPolNull;
5093}
@ WdfDevStatePwrPolSystemWakeDeviceToD0
Definition: wdfdevice.h:278

◆ PowerPolSystemWakeDeviceToD0CompletePowerUp()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceToD0CompletePowerUp ( __inout FxPkgPnp This)
staticprotected

Definition at line 5096 of file powerpolicystatemachine.cpp.

5114{
5117
5118 //
5119 // Simulate a device-power-not-required notification from the power
5120 // framework. An S0-IRP is essentially equivalent to a device-power-required
5121 // notification.
5122 //
5123 This->m_PowerPolicyMachine.m_Owner->
5124 m_PoxInterface.SimulateDevicePowerRequired();
5125
5126 //
5127 // Notify the device-power-requirement state machine that we are powered on
5128 //
5129 This->m_PowerPolicyMachine.m_Owner->
5130 m_PoxInterface.DeviceIsPoweredOn();
5131
5132 This->PowerProcessEvent(PowerCompleteD0);
5133
5134 return WdfDevStatePwrPolNull;
5135}
@ WdfDevStatePwrPolSystemWakeDeviceToD0CompletePowerUp
Definition: wdfdevice.h:279

◆ PowerPolSystemWakeDeviceWakeCompletePowerUp()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWakeCompletePowerUp ( __inout FxPkgPnp This)
staticprotected

Definition at line 4709 of file powerpolicystatemachine.cpp.

4727{
4730
4731 //
4732 // Simulate a device-power-required notification from the power framework.
4733 // An S0-IRP is essentially equivalent to a device-power-required
4734 // notification.
4735 //
4736 This->m_PowerPolicyMachine.m_Owner->
4737 m_PoxInterface.SimulateDevicePowerRequired();
4738
4739 //
4740 // Notify the device-power-requirement state machine that we are powered on
4741 //
4742 This->m_PowerPolicyMachine.m_Owner->
4743 m_PoxInterface.DeviceIsPoweredOn();
4744
4745 This->PowerProcessEvent(PowerCompleteD0);
4746
4747 return WdfDevStatePwrPolNull;
4748}
@ WdfDevStatePwrPolSystemWakeDeviceWakeCompletePowerUp
Definition: wdfdevice.h:269

◆ PowerPolSystemWakeDeviceWakeDisabled()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWakeDisabled ( __inout FxPkgPnp This)
staticprotected

Definition at line 5032 of file powerpolicystatemachine.cpp.

5049{
5051
5052 //
5053 // We do not attempt to let the device remain in Dx if we are using system-
5054 // managed idle timeout. This is because an S0 IRP is equivalent to a
5055 // device-power-required notification from the power framework. In response
5056 // to it, we need to power up the device and notify the power framework that
5057 // the device is powered on.
5058 //
5059 if ((This->m_PowerPolicyMachine.m_Owner->
5060 m_IdleSettings.m_TimeoutMgmt.UsingSystemManagedIdleTimeout() == FALSE)
5061 &&
5062 (This->m_PowerPolicyMachine.m_Owner->m_IdleSettings.Enabled)
5063 &&
5064 (This->m_PowerPolicyMachine.m_Owner->
5065 m_IdleSettings.WakeFromS0Capable == FALSE)
5066 &&
5067 (This->m_PowerPolicyMachine.m_Owner->
5068 m_IdleSettings.PowerUpIdleDeviceOnSystemWake == FALSE)) {
5069
5071 }
5072 else {
5074 }
5075}
@ WdfDevStatePwrPolSystemWakeQueryIdle
Definition: wdfdevice.h:280
@ WdfDevStatePwrPolSystemWakeDeviceWakeDisabled
Definition: wdfdevice.h:277

◆ PowerPolSystemWakeDeviceWakeDisarm()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWakeDisarm ( __inout FxPkgPnp This)
staticprotected

Definition at line 4355 of file powerpolicystatemachine.cpp.

4358{
4361
4362 //
4363 // If the PDO is the Power Policy owner, then disable wake at bus, otherwise
4364 // the power state machine will disable wake at bus.
4365 //
4366 if (This->m_Device->IsPdo()) {
4367 This->PowerDisableWakeAtBusOverload();
4368 }
4369
4370 This->PowerPolicyDisarmWakeFromSx();
4371
4373}
@ WdfDevStatePwrPolSystemWakeDeviceWakeDisarm
Definition: wdfdevice.h:254

◆ PowerPolSystemWakeDeviceWakeDisarmNP()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWakeDisarmNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4646 of file powerpolicystatemachine.cpp.

4649{
4651
4652 //
4653 // If the PDO is the Power Policy owner, then disable wake at bus, otherwise
4654 // the power state machine will disable wake at bus.
4655 //
4656 if (This->m_Device->IsPdo()) {
4657 This->PowerDisableWakeAtBusOverload();
4658 }
4659
4660 This->PowerPolicyDisarmWakeFromSx();
4661
4663}
@ WdfDevStatePwrPolSystemWakeDeviceWakeDisarmNP
Definition: wdfdevice.h:265

◆ PowerPolSystemWakeDeviceWakeEnabled()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWakeEnabled ( __inout FxPkgPnp This)
staticprotected

Definition at line 4296 of file powerpolicystatemachine.cpp.

4299{
4302
4303 if (This->PowerPolicyCancelWaitWake() == FALSE &&
4304 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
4306 }
4307
4308 return WdfDevStatePwrPolNull;
4309}
@ WdfDevStatePwrPolSystemWakeDeviceWakeEnabled
Definition: wdfdevice.h:252
@ WdfDevStatePwrPolSystemWakeDeviceWakeEnabledWakeCanceled
Definition: wdfdevice.h:253

◆ PowerPolSystemWakeDeviceWakeEnabledNP()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWakeEnabledNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4589 of file powerpolicystatemachine.cpp.

4592{
4594
4595 if (This->PowerPolicyCancelWaitWake() == FALSE &&
4596 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
4598 }
4599
4600 return WdfDevStatePwrPolNull;
4601}
@ WdfDevStatePwrPolSystemWakeDeviceWakeEnabledWakeCanceledNP
Definition: wdfdevice.h:264
@ WdfDevStatePwrPolSystemWakeDeviceWakeEnabledNP
Definition: wdfdevice.h:263

◆ PowerPolSystemWakeDeviceWakeEnabledWakeCanceled()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWakeEnabledWakeCanceled ( __inout FxPkgPnp This)
staticprotected

Definition at line 4335 of file powerpolicystatemachine.cpp.

4338{
4340
4343
4344 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, Retry);
4345
4346 if (!NT_SUCCESS(status)) {
4347 COVERAGE_TRAP();
4349 }
4350
4351 return WdfDevStatePwrPolNull;
4352}

◆ PowerPolSystemWakeDeviceWakeEnabledWakeCanceledNP()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWakeEnabledWakeCanceledNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4626 of file powerpolicystatemachine.cpp.

4629{
4631
4634
4635 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, Retry);
4636
4637 if (!NT_SUCCESS(status)) {
4638 COVERAGE_TRAP();
4640 }
4641
4642 return WdfDevStatePwrPolNull;
4643}

◆ PowerPolSystemWakeDeviceWakeInterruptFired()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWakeInterruptFired ( __inout FxPkgPnp This)
staticprotected

Definition at line 4312 of file powerpolicystatemachine.cpp.

4315{
4318
4319 //
4320 // Make a note of the fact that system was woken by
4321 // a wake interrupt of this device
4322 //
4323 This->m_SystemWokenByWakeInterrupt = TRUE;
4324
4325 if (This->PowerPolicyCancelWaitWake() == FALSE &&
4326 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
4327
4329 }
4330
4331 return WdfDevStatePwrPolNull;
4332}
@ WdfDevStatePwrPolSystemWakeDeviceWakeInterruptFired
Definition: wdfdevice.h:380
@ WdfDevStatePwrPolSystemWakeDeviceWakeTriggered
Definition: wdfdevice.h:255

◆ PowerPolSystemWakeDeviceWakeInterruptFiredNP()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWakeInterruptFiredNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4604 of file powerpolicystatemachine.cpp.

4607{
4610
4611 //
4612 // Make a notee of the fact that system was woken by
4613 // a wake interrupt of this device
4614 //
4615 This->m_SystemWokenByWakeInterrupt = TRUE;
4616
4617 if (This->PowerPolicyCancelWaitWake() == FALSE &&
4618 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
4620 }
4621
4622 return WdfDevStatePwrPolNull;
4623}
@ WdfDevStatePwrPolSystemWakeDeviceWakeTriggeredNP
Definition: wdfdevice.h:266
@ WdfDevStatePwrPolSystemWakeDeviceWakeInterruptFiredNP
Definition: wdfdevice.h:381

◆ PowerPolSystemWakeDeviceWakeTriggeredS0()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWakeTriggeredS0 ( __inout FxPkgPnp This)
staticprotected

Definition at line 4376 of file powerpolicystatemachine.cpp.

4379{
4381
4384
4385 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, Retry);
4386
4387 if (!NT_SUCCESS(status)) {
4388 COVERAGE_TRAP();
4390 }
4391
4392 return WdfDevStatePwrPolNull;
4393}
@ WdfDevStatePwrPolSystemWakeDeviceWakeTriggeredS0
Definition: wdfdevice.h:256

◆ PowerPolSystemWakeDeviceWakeTriggeredS0NP()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWakeTriggeredS0NP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4666 of file powerpolicystatemachine.cpp.

4669{
4671
4673
4674 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, Retry);
4675
4676 if (!NT_SUCCESS(status)) {
4677 COVERAGE_TRAP();
4679 }
4680
4681 return WdfDevStatePwrPolNull;
4682}
@ WdfDevStatePwrPolSystemWakeDeviceWakeTriggeredS0NP
Definition: wdfdevice.h:267

◆ PowerPolSystemWakeDeviceWokeDisarm()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWokeDisarm ( __inout FxPkgPnp This)
staticprotected

Definition at line 4396 of file powerpolicystatemachine.cpp.

4399{
4402
4403 //
4404 // If the PDO is the Power Policy owner, then disable wake at bus, otherwise
4405 // the power state machine will enable wake at bus.
4406 //
4407 if (This->m_Device->IsPdo()) {
4408 This->PowerDisableWakeAtBusOverload();
4409 }
4410
4411 This->m_PowerPolicyMachine.m_Owner->m_DeviceWakeFromSxTriggered.Invoke(
4412 This->m_Device->GetHandle()
4413 );
4414
4415 This->PowerPolicyDisarmWakeFromSx();
4416
4418}
@ WdfDevStatePwrPolSystemWakeDeviceWokeDisarm
Definition: wdfdevice.h:257

◆ PowerPolSystemWakeDeviceWokeDisarmNP()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeDeviceWokeDisarmNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4685 of file powerpolicystatemachine.cpp.

4688{
4690
4691 //
4692 // If the PDO is the Power Policy owner, then disable wake at bus, otherwise
4693 // the power state machine will disable wake at bus.
4694 //
4695 if (This->m_Device->IsPdo()) {
4696 This->PowerDisableWakeAtBusOverload();
4697 }
4698
4699 This->m_PowerPolicyMachine.m_Owner->m_DeviceWakeFromSxTriggered.Invoke(
4700 This->m_Device->GetHandle()
4701 );
4702
4703 This->PowerPolicyDisarmWakeFromSx();
4704
4706}
@ WdfDevStatePwrPolSystemWakeDeviceWokeDisarmNP
Definition: wdfdevice.h:268

◆ PowerPolSystemWakeQueryIdle()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolSystemWakeQueryIdle ( __inout FxPkgPnp This)
staticprotected

Definition at line 5138 of file powerpolicystatemachine.cpp.

5141{
5143
5144 //
5145 // This state can be reached only if we are using driver-managed idle
5146 // timeout.
5147 //
5148 ASSERT(
5149 This->m_PowerPolicyMachine.m_Owner->
5150 m_IdleSettings.m_TimeoutMgmt.UsingSystemManagedIdleTimeout() == FALSE
5151 );
5152
5153 if (This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.QueryReturnToIdle()) {
5155 }
5156 else {
5158 }
5159}
@ WdfDevStatePwrPolWaitingUnarmed
Definition: wdfdevice.h:240

◆ PowerPolTimerExpiredDecideUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredDecideUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 5215 of file powerpolicystatemachine.cpp.

5234{
5235 NTSTATUS notifyPowerDownStatus;
5236
5238
5239 //
5240 // Notify the device power requirement state machine that we are about to
5241 // power down.
5242 //
5243 notifyPowerDownStatus = This->m_PowerPolicyMachine.m_Owner->
5244 m_PoxInterface.NotifyDevicePowerDown();
5245 if (FALSE == NT_SUCCESS(notifyPowerDownStatus)) {
5246 //
5247 // We couldn't notify the device power requirement state machine that
5248 // we are about to power down, because the "device-power-required"
5249 // notification has already arrived. So we should not power down at this
5250 // time. Revert back to the started state.
5251 //
5253 }
5254
5255 if (This->m_PowerPolicyMachine.m_Owner->m_IdleSettings.UsbSSCapable) {
5257 }
5258 else {
5260 }
5261}
@ WdfDevStatePwrPolTimerExpiredWakeCapablePowerDown
Definition: wdfdevice.h:283
@ WdfDevStatePwrPolTimerExpiredWakeCapableUsbSS
Definition: wdfdevice.h:285
@ WdfDevStatePwrPolTimerExpiredDecideUsbSS
Definition: wdfdevice.h:282

◆ PowerPolTimerExpiredNoWake()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredNoWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 3876 of file powerpolicystatemachine.cpp.

3879{
3880 BOOLEAN poweredDown;
3881 NTSTATUS notifyPowerDownStatus;
3882
3884
3885 //
3886 // Notify the device power requirement state machine that we are about to
3887 // power down.
3888 //
3889 notifyPowerDownStatus = This->m_PowerPolicyMachine.m_Owner->
3890 m_PoxInterface.NotifyDevicePowerDown();
3891 if (FALSE == NT_SUCCESS(notifyPowerDownStatus)) {
3892 //
3893 // We couldn't notify the device power requirement state machine that
3894 // we are about to power down, because the "device-power-required"
3895 // notification has already arrived. So we should not power down at this
3896 // time. Revert back to the started state.
3897 //
3899 }
3900
3901 poweredDown = This->PowerPolicyCanIdlePowerDown(
3902 This->m_PowerPolicyMachine.m_Owner->m_IdleSettings.DxState
3903 );
3904
3905 if (poweredDown == FALSE) {
3906 //
3907 // Upon failure, revert back to the started state.
3908 //
3910 }
3911
3912 return WdfDevStatePwrPolNull;
3913}
@ WdfDevStatePwrPolTimerExpiredNoWakeUndoPowerDown
Definition: wdfdevice.h:368
@ WdfDevStatePwrPolTimerExpiredNoWakeReturnToActive
Definition: wdfdevice.h:378

◆ PowerPolTimerExpiredNoWakeCompletePowerDown()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredNoWakeCompletePowerDown ( __inout FxPkgPnp This)
staticprotected

Definition at line 3916 of file powerpolicystatemachine.cpp.

3933{
3936
3937 This->PowerProcessEvent(PowerCompleteDx);
3938
3939 return WdfDevStatePwrPolNull;
3940}
@ WdfDevStatePwrPolTimerExpiredNoWakeCompletePowerDown
Definition: wdfdevice.h:239

◆ PowerPolTimerExpiredNoWakePowerDownNotProcessed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredNoWakePowerDownNotProcessed ( __inout FxPkgPnp This)
staticprotected

Definition at line 7172 of file powerpolicystatemachine.cpp.

7189{
7192
7193 This->SetInternalFailure();
7194
7196}
@ WdfDevStatePwrPolTimerExpiredNoWakePowerDownNotProcessed
Definition: wdfdevice.h:351

◆ PowerPolTimerExpiredNoWakePoweredDownDisableIdleTimer()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredNoWakePoweredDownDisableIdleTimer ( __inout FxPkgPnp This)
staticprotected

Definition at line 7261 of file powerpolicystatemachine.cpp.

7279{
7281
7284
7285 //
7286 // Disable the timer so that when we move back into D0, the timer is not
7287 // automatically started. Since the timer has already fired, we should never
7288 // get FALSE back (which indicates we should wait for the timer to fire).
7289 //
7290 result = This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer();
7291 ASSERT(result);
7293
7294 //
7295 // Check to see if we should immediately power up
7296 //
7298}
@ WdfDevStatePwrPolTimerExpiredNoWakePoweredDownDisableIdleTimer
Definition: wdfdevice.h:352
@ WdfDevStatePwrPolWaitingUnarmedQueryIdle
Definition: wdfdevice.h:241

◆ PowerPolTimerExpiredNoWakeReturnToActive()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredNoWakeReturnToActive ( __inout FxPkgPnp This)
staticprotected

Definition at line 7232 of file powerpolicystatemachine.cpp.

7250{
7253
7254 This->m_PowerPolicyMachine.m_Owner->
7255 m_PoxInterface.RequestComponentActive();
7256
7258}

◆ PowerPolTimerExpiredNoWakeUndoPowerDown()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredNoWakeUndoPowerDown ( __inout FxPkgPnp This)
staticprotected

Definition at line 7199 of file powerpolicystatemachine.cpp.

7215{
7218
7219 //
7220 // We notified the device power requirement state machine that we are about
7221 // to power down, but eventually we didn't power down. So notify the device
7222 // power requirement state machine that the device should be considered
7223 // powered on.
7224 //
7225 This->m_PowerPolicyMachine.m_Owner->
7226 m_PoxInterface.DeviceIsPoweredOn();
7227
7229}

◆ PowerPolTimerExpiredWakeCapableCancelWake()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapableCancelWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 5447 of file powerpolicystatemachine.cpp.

5464{
5466
5467 if (This->PowerPolicyCancelWaitWake() == FALSE) {
5469 }
5470
5471 return WdfDevStatePwrPolNull;
5472}
@ WdfDevStatePwrPolTimerExpiredWakeCapableCancelWake
Definition: wdfdevice.h:287
@ WdfDevStatePwrPolTimerExpiredWakeCapableWakeCanceled
Definition: wdfdevice.h:288

◆ PowerPolTimerExpiredWakeCapableCleanup()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapableCleanup ( __inout FxPkgPnp This)
staticprotected

Definition at line 5500 of file powerpolicystatemachine.cpp.

5517{
5519
5520 if (This->m_PowerPolicyMachine.m_Owner->m_IdleSettings.UsbSSCapable) {
5521 COVERAGE_TRAP();
5522 This->m_PowerPolicyMachine.UsbSSCallbackProcessingComplete();
5523 }
5524
5525 //
5526 // Cancel UsbSS if present
5527 //
5528 if (This->PowerPolicyCancelUsbSSIfCapable()) {
5529 //
5530 // wait for Usbss completion event to move us from this state.
5531 //
5532 return WdfDevStatePwrPolNull;
5533 }
5534
5536}
@ WdfDevStatePwrPolTimerExpiredWakeCompletedPowerDown
Definition: wdfdevice.h:291
@ WdfDevStatePwrPolTimerExpiredWakeCapableCleanup
Definition: wdfdevice.h:289

◆ PowerPolTimerExpiredWakeCapableDxAllocFailed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapableDxAllocFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 5539 of file powerpolicystatemachine.cpp.

5556{
5559
5560 if (This->m_PowerPolicyMachine.m_Owner->m_IdleSettings.UsbSSCapable) {
5561 COVERAGE_TRAP();
5562 This->m_PowerPolicyMachine.UsbSSCallbackProcessingComplete();
5563 }
5564
5565 //
5566 // cancel USB SS irp if capable
5567 //
5568 if (This->PowerPolicyCancelUsbSSIfCapable()) {
5569 //
5570 // wait for Usbss completion event to move us from this state.
5571 //
5572 return WdfDevStatePwrPolNull;
5573 }
5574
5576}
@ WdfDevStatePwrPolTimerExpiredWakeCapableUndoPowerDown
Definition: wdfdevice.h:371
@ WdfDevStatePwrPolTimerExpiredWakeCapableDxAllocFailed
Definition: wdfdevice.h:290

◆ PowerPolTimerExpiredWakeCapablePowerDown()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapablePowerDown ( __inout FxPkgPnp This)
staticprotected

Definition at line 5264 of file powerpolicystatemachine.cpp.

5284{
5285 BOOLEAN poweredDown;
5286
5288
5289 poweredDown = This->PowerPolicyCanIdlePowerDown(
5290 This->m_PowerPolicyMachine.m_Owner->m_IdleSettings.DxState
5291 );
5292
5293 if (poweredDown == FALSE) {
5294 //
5295 // Upon failure, revert back to the started state.
5296 //
5298 }
5299
5300 return WdfDevStatePwrPolNull;
5301}

◆ PowerPolTimerExpiredWakeCapablePowerDownFailedCancelWake()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapablePowerDownFailedCancelWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 6010 of file powerpolicystatemachine.cpp.

6026{
6028 This,
6030
6031 if (This->PowerPolicyCancelWaitWake() == FALSE) {
6033 }
6034
6035 return WdfDevStatePwrPolNull;
6036}
@ WdfDevStatePwrPolTimerExpiredWakeCapablePowerDownFailedCancelWake
Definition: wdfdevice.h:305
@ WdfDevStatePwrPolTimerExpiredWakeCapablePowerDownFailedWakeCanceled
Definition: wdfdevice.h:306

◆ PowerPolTimerExpiredWakeCapablePowerDownFailedUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapablePowerDownFailedUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 6070 of file powerpolicystatemachine.cpp.

6085{
6087
6088 if (This->m_PowerPolicyMachine.m_Owner->m_IdleSettings.UsbSSCapable) {
6089 This->m_PowerPolicyMachine.UsbSSCallbackProcessingComplete();
6090 }
6091
6092 if (This->PowerPolicyCancelUsbSSIfCapable()) {
6093 //
6094 // wait for Usbss completion event to move us from this state.
6095 //
6096 return WdfDevStatePwrPolNull;
6097 }
6098
6100}
@ WdfDevStatePwrPolTimerExpiredWakeCapablePowerDownFailedUsbSS
Definition: wdfdevice.h:307

◆ PowerPolTimerExpiredWakeCapablePowerDownFailedWakeCanceled()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapablePowerDownFailedWakeCanceled ( __inout FxPkgPnp This)
staticprotected

◆ PowerPolTimerExpiredWakeCapablePowerDownNotProcessed()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapablePowerDownNotProcessed ( __inout FxPkgPnp This)
staticprotected

Definition at line 7145 of file powerpolicystatemachine.cpp.

7162{
7165
7166 This->SetInternalFailure();
7167
7169}
@ WdfDevStatePwrPolTimerExpiredWakeCapablePowerDownNotProcessed
Definition: wdfdevice.h:350

◆ PowerPolTimerExpiredWakeCapableSendWake()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapableSendWake ( __inout FxPkgPnp This)
staticprotected

Definition at line 5304 of file powerpolicystatemachine.cpp.

5307{
5309
5312
5313 //
5314 // We are in a wake-enabled path, keep wake interrupts connected.
5315 //
5316 This->m_WakeInterruptsKeepConnected = TRUE;
5317
5318 status = This->PowerPolicySendWaitWakeRequest(PowerSystemWorking);
5319
5320 if (!NT_SUCCESS(status)) {
5322 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
5323 "Could not allocate wake request for wake from S0, revert arming,"
5324 " %!STATUS!", status);
5325
5326 COVERAGE_TRAP();
5327
5329 }
5330
5331 return WdfDevStatePwrPolNull;
5332}
@ WdfDevStatePwrPolTimerExpiredWakeCapableSendWake
Definition: wdfdevice.h:284

◆ PowerPolTimerExpiredWakeCapableUndoPowerDown()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapableUndoPowerDown ( __inout FxPkgPnp This)
staticprotected

Definition at line 5579 of file powerpolicystatemachine.cpp.

5595{
5598
5599 //
5600 // We notified the device power requirement state machine that we are about
5601 // to power down, but eventually we didn't power down. So notify the device
5602 // power requirement state machine that the device should be considered
5603 // powered on.
5604 //
5605 This->m_PowerPolicyMachine.m_Owner->
5606 m_PoxInterface.DeviceIsPoweredOn();
5608}

◆ PowerPolTimerExpiredWakeCapableUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapableUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 5335 of file powerpolicystatemachine.cpp.

5350{
5352
5353 This->PowerPolicySubmitUsbIdleNotification();
5354
5355 return WdfDevStatePwrPolNull;
5356}

◆ PowerPolTimerExpiredWakeCapableWakeArrived()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapableWakeArrived ( __inout FxPkgPnp This)
staticprotected

Definition at line 5394 of file powerpolicystatemachine.cpp.

5411{
5413
5416
5417 status = This->m_PowerPolicyMachine.m_Owner->m_DeviceArmWakeFromS0.Invoke(
5418 This->m_Device->GetHandle()
5419 );
5420
5421 if (!NT_SUCCESS(status)) {
5423 }
5424
5425 //
5426 // If the PDO is the Power Policy owner, then enable wake at bus, otherwise
5427 // the power state machine will enable wake at bus.
5428 //
5429 if (This->m_Device->IsPdo()) {
5430 status = This->PowerEnableWakeAtBusOverload();
5431 if (!NT_SUCCESS(status)) {
5433 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
5434 "WDFDEVICE %p Failed to Enable Wake at Bus, %!STATUS!",
5435 This->m_Device->GetHandle(), status);
5436
5438 }
5439 }
5440
5441 This->PowerProcessEvent(PowerCompleteDx);
5442
5443 return WdfDevStatePwrPolNull;
5444}
@ WdfDevStatePwrPolTimerExpiredWakeCapableWakeArrived
Definition: wdfdevice.h:286

◆ PowerPolTimerExpiredWakeCapableWakeCanceled()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapableWakeCanceled ( __inout FxPkgPnp This)
staticprotected

◆ PowerPolTimerExpiredWakeCapableWakeInterruptArrived()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCapableWakeInterruptArrived ( __inout FxPkgPnp This)
staticprotected

Definition at line 8389 of file powerpolicystatemachine.cpp.

8392{
8394
8395 if (This->PowerPolicyCancelWaitWake() == FALSE &&
8396 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
8398 }
8399
8400 return WdfDevStatePwrPolNull;
8401}
@ WdfDevStatePwrPolTimerExpiredWakeCapableWakeInterruptArrived
Definition: wdfdevice.h:382
@ WdfDevStatePwrPolTimerExpiredWakeCapableWakeSucceeded
Definition: wdfdevice.h:302

◆ PowerPolTimerExpiredWakeCompletedDisarm()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCompletedDisarm ( __inout FxPkgPnp This)
staticprotected

Definition at line 5925 of file powerpolicystatemachine.cpp.

5942{
5944
5945 //
5946 // If the PDO is the Power Policy owner, then disable wake at bus, otherwise
5947 // the power state machine will disable wake at bus.
5948 //
5949 if (This->m_Device->IsPdo()) {
5950 This->PowerDisableWakeAtBusOverload();
5951 }
5952
5953 This->m_PowerPolicyMachine.m_Owner->m_DeviceDisarmWakeFromS0.Invoke(
5954 This->m_Device->GetHandle()
5955 );
5956
5958
5959}
@ WdfDevStatePwrPolTimerExpiredWakeCompletedDisarm
Definition: wdfdevice.h:301

◆ PowerPolTimerExpiredWakeCompletedHardwareStarted()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCompletedHardwareStarted ( __inout FxPkgPnp This)
staticprotected

Definition at line 5688 of file powerpolicystatemachine.cpp.

5706{
5709
5710 This->m_PowerPolicyMachine.m_Owner->
5711 m_PoxInterface.DeviceIsPoweredOn();
5712
5714}
@ WdfDevStatePwrPolTimerExpiredWakeCompletedHardwareStarted
Definition: wdfdevice.h:372

◆ PowerPolTimerExpiredWakeCompletedPowerDown()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCompletedPowerDown ( __inout FxPkgPnp This)
staticprotected

Definition at line 5611 of file powerpolicystatemachine.cpp.

5628{
5631
5632 This->PowerProcessEvent(PowerCompleteDx);
5633
5634 return WdfDevStatePwrPolNull;
5635}

◆ PowerPolTimerExpiredWakeCompletedPowerUp()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeCompletedPowerUp ( __inout FxPkgPnp This)
staticprotected

Definition at line 5638 of file powerpolicystatemachine.cpp.

5655{
5658
5661
5662 This->m_PowerPolicyMachine.m_Owner->
5663 m_PoxInterface.RequestComponentActive();
5664
5665 //
5666 // Disable the timer so that when we move back into D0, the timer is not
5667 // automatically started. Since the timer has already fired, we should never
5668 // get FALSE back (which indicates we should wait for the timer to fire).
5669 //
5670 result = This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer();
5671 ASSERT(result);
5673
5674 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, Retry);
5675
5676 if (!NT_SUCCESS(status)) {
5677 //
5678 // Couldn't allocate power irp, goto the failed state
5679 //
5680 COVERAGE_TRAP();
5682 }
5683
5684 return WdfDevStatePwrPolNull;
5685}
@ WdfDevStatePwrPolTimerExpiredWakeCompletedPowerUp
Definition: wdfdevice.h:292

◆ PowerPolTimerExpiredWakeSucceeded()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolTimerExpiredWakeSucceeded ( __inout FxPkgPnp This)
staticprotected

Definition at line 5898 of file powerpolicystatemachine.cpp.

5914{
5916
5917 This->m_PowerPolicyMachine.m_Owner->m_DeviceWakeFromS0Triggered.Invoke(
5918 This->m_Device->GetHandle()
5919 );
5920
5922}
@ WdfDevStatePwrPolTimerExpiredWakeSucceeded
Definition: wdfdevice.h:300

◆ PowerPolWaitingArmedIoPresentCancelUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWaitingArmedIoPresentCancelUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 8230 of file powerpolicystatemachine.cpp.

8246{
8248
8249 if (This->PowerPolicyCancelUsbSSIfCapable()) {
8250 //
8251 // Usbss completion event will move us from this state.
8252 //
8253 return WdfDevStatePwrPolNull;
8254 }
8255
8256 //
8257 // If usbss irp was there it has already been canceled, so march on.
8258 //
8260}
@ WdfDevStatePwrPolWaitingArmedIoPresentCancelUsbSS
Definition: wdfdevice.h:359

◆ PowerPolWaitingArmedQueryIdle()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWaitingArmedQueryIdle ( __inout FxPkgPnp This)
staticprotected

Definition at line 5761 of file powerpolicystatemachine.cpp.

5781{
5782 //
5783 // If QueryReturnToIdle returns TRUE, return to the waiting state
5784 //
5785 if (This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.QueryReturnToIdle()) {
5787 }
5788 else {
5790 }
5791}
@ WdfDevStatePwrPolWaitingArmed
Definition: wdfdevice.h:294

◆ PowerPolWaitingArmedStoppingCancelUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWaitingArmedStoppingCancelUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 8157 of file powerpolicystatemachine.cpp.

8173{
8175
8176 This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer();
8177
8178 //
8179 // Since we are in Dx and surprise removed, cancel the usb SS irp if it is
8180 // there. Otherwise, the USB PDO will call us back after we have processed
8181 // remove.
8182 //
8183 if (This->PowerPolicyCancelUsbSSIfCapable()) {
8184 //
8185 // Usbss completion event will move us from this state.
8186 //
8187 return WdfDevStatePwrPolNull;
8188 }
8189
8190 //
8191 // If usbss irp was there it has already been canceled, so march on.
8192 //
8194}
@ WdfDevStatePwrPolWaitingArmedStoppingCancelUsbSS
Definition: wdfdevice.h:357

◆ PowerPolWaitingArmedUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWaitingArmedUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 5717 of file powerpolicystatemachine.cpp.

5732{
5734
5736
5737 if (This->m_PowerPolicyMachine.m_Owner->m_IdleSettings.UsbSSCapable) {
5738 This->m_PowerPolicyMachine.UsbSSCallbackProcessingComplete();
5739 }
5740
5741 //
5742 // Disable the timer so that when we move back into D0, the timer is not
5743 // automatically started. Since the timer has already fired, we should never
5744 // get FALSE back (which indicates we should wait for the timer to fire).
5745 //
5746 result = This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer();
5747 ASSERT(result);
5749
5750 //
5751 // PwrPolIoPresent can be sent before PwrPolPowerTimeoutExpired in the idle
5752 // state machine if the idle s.m. attempts to cancel the timer after it has
5753 // started running. That means the PwrPolIoPresent meant to wake up the
5754 // device and resume from idle is lost. By first querying the idle s.m.
5755 // after moving into Dx we can recover from the lost event.
5756 //
5758}
@ WdfDevStatePwrPolWaitingArmedQueryIdle
Definition: wdfdevice.h:295
@ WdfDevStatePwrPolWaitingArmedUsbSS
Definition: wdfdevice.h:293

◆ PowerPolWaitingArmedWakeFailedCancelUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWaitingArmedWakeFailedCancelUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 8197 of file powerpolicystatemachine.cpp.

8213{
8215
8216 if (This->PowerPolicyCancelUsbSSIfCapable()) {
8217 //
8218 // Usbss completion event will move us from this state.
8219 //
8220 return WdfDevStatePwrPolNull;
8221 }
8222
8223 //
8224 // If usbss irp was there it has already been canceled, so march on.
8225 //
8227}
@ WdfDevStatePwrPolWaitingArmedWakeFailedCancelUsbSS
Definition: wdfdevice.h:358

◆ PowerPolWaitingArmedWakeInterruptFired()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWaitingArmedWakeInterruptFired ( __inout FxPkgPnp This)
staticprotected

Definition at line 5810 of file powerpolicystatemachine.cpp.

5813{
5815
5816 if (This->PowerPolicyCancelWaitWake() == FALSE &&
5817 This->m_PowerPolicyMachine.m_Owner->m_WakeCompletionEventDropped) {
5819 }
5820
5821 return WdfDevStatePwrPolNull;
5822}
@ WdfDevStatePwrPolWaitingArmedWakeInterruptFired
Definition: wdfdevice.h:379
@ WdfDevStatePwrPolWaitingArmedWakeSucceededCancelUsbSS
Definition: wdfdevice.h:360

◆ PowerPolWaitingArmedWakeSucceededCancelUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWaitingArmedWakeSucceededCancelUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 8263 of file powerpolicystatemachine.cpp.

8279{
8281
8282 if (This->PowerPolicyCancelUsbSSIfCapable()) {
8283 //
8284 // Usbss completion event will move us from this state.
8285 //
8286 return WdfDevStatePwrPolNull;
8287 }
8288
8289 //
8290 // If usbss irp was there it has already been canceled, so march on.
8291 //
8293}
@ WdfDevStatePwrPolWokeFromS0
Definition: wdfdevice.h:313

◆ PowerPolWaitingUnarmedQueryIdle()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWaitingUnarmedQueryIdle ( __inout FxPkgPnp This)
staticprotected

Definition at line 3943 of file powerpolicystatemachine.cpp.

3962{
3964
3965 //
3966 // If QueryReturnToIdle returns TRUE, return to the waiting state
3967 //
3968 if (This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.QueryReturnToIdle()) {
3970 }
3971 else {
3973 }
3974}

◆ PowerPolWakeCapableDeviceIdle()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWakeCapableDeviceIdle ( __inout FxPkgPnp This)
staticprotected

Definition at line 5179 of file powerpolicystatemachine.cpp.

5195{
5196 BOOLEAN canPowerDown;
5197
5199
5200 canPowerDown = This->m_PowerPolicyMachine.m_Owner->
5201 m_PoxInterface.DeclareComponentIdle();
5202
5203 //
5204 // If we are using driver-managed idle timeout we can power down immediately
5205 // and so we jump to the next state (that initiates power down) immediately.
5206 // If we are using system-managed idle timeout, we wait in the current state
5207 // for device-power-not-required notification.
5208 //
5209 return (canPowerDown ?
5212}
@ WdfDevStatePwrPolWakeCapableDeviceIdle
Definition: wdfdevice.h:369

◆ PowerPolWakeCapableUsbSSCompleted()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWakeCapableUsbSSCompleted ( __inout FxPkgPnp This)
staticprotected

Definition at line 5359 of file powerpolicystatemachine.cpp.

5375{
5377
5378 //
5379 // We notified the device power requirement state machine that we are about
5380 // to power down, but eventually we didn't power down. So notify the device
5381 // power requirement state machine that the device should be considered
5382 // powered on.
5383 //
5384 This->m_PowerPolicyMachine.m_Owner->
5385 m_PoxInterface.DeviceIsPoweredOn();
5386
5387 This->m_PowerPolicyMachine.m_Owner->
5388 m_PoxInterface.RequestComponentActive();
5389
5391}
@ WdfDevStatePwrPolWakeCapableUsbSSCompleted
Definition: wdfdevice.h:370

◆ PowerPolWakeFailedUsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWakeFailedUsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 5962 of file powerpolicystatemachine.cpp.

5978{
5980
5982
5983 if (This->m_PowerPolicyMachine.m_Owner->m_IdleSettings.UsbSSCapable) {
5984 This->m_PowerPolicyMachine.UsbSSCallbackProcessingComplete();
5985 }
5986
5987 //
5988 // Disable the timer so that when we move back into D0, the timer is not
5989 // automatically started. Since the timer has already fired, we should never
5990 // get FALSE back (which indicates we should wait for the timer to fire).
5991 //
5992 result = This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer();
5993 ASSERT(result);
5995
5996 //
5997 // cancel USB SS irp if capable
5998 //
5999 if (This->PowerPolicyCancelUsbSSIfCapable()) {
6000 //
6001 // wait for Usbss completion event to move us from this state.
6002 //
6003 return WdfDevStatePwrPolNull;
6004 }
6005
6007}
@ WdfDevStatePwrPolWakeFailedUsbSS
Definition: wdfdevice.h:304

◆ PowerPolWokeFromS0()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWokeFromS0 ( __inout FxPkgPnp This)
staticprotected

Definition at line 6252 of file powerpolicystatemachine.cpp.

6255{
6257
6259
6260 This->m_PowerPolicyMachine.m_Owner->
6261 m_PoxInterface.RequestComponentActive();
6262
6263 status = This->PowerPolicySendDevicePowerRequest(PowerDeviceD0, Retry);
6264 if (!NT_SUCCESS(status)) {
6265 COVERAGE_TRAP();
6267 }
6268
6269 return WdfDevStatePwrPolNull;
6270}

◆ PowerPolWokeFromS0NotifyDriver()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWokeFromS0NotifyDriver ( __inout FxPkgPnp This)
staticprotected

Definition at line 6273 of file powerpolicystatemachine.cpp.

6289{
6291
6292 This->m_PowerPolicyMachine.m_Owner->m_DeviceWakeFromS0Triggered.Invoke(
6293 This->m_Device->GetHandle()
6294 );
6295
6297}
@ WdfDevStatePwrPolWokeFromS0NotifyDriver
Definition: wdfdevice.h:314

◆ PowerPolWokeFromS0UsbSS()

WDF_DEVICE_POWER_POLICY_STATE FxPkgPnp::PowerPolWokeFromS0UsbSS ( __inout FxPkgPnp This)
staticprotected

Definition at line 6204 of file powerpolicystatemachine.cpp.

6220{
6222
6224
6225 if (This->m_PowerPolicyMachine.m_Owner->m_IdleSettings.UsbSSCapable) {
6226 This->m_PowerPolicyMachine.UsbSSCallbackProcessingComplete();
6227 }
6228
6229 //
6230 // Disable the timer so that when we move back into D0, the timer is not
6231 // automatically started. Since the timer has already fired, we should never
6232 // get FALSE back (which indicates we should wait for the timer to fire).
6233 //
6234 result = This->m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.DisableTimer();
6235 ASSERT(result);
6237
6238 //
6239 // Cancel USBSS irp if capable
6240 //
6241 if (This->PowerPolicyCancelUsbSSIfCapable()) {
6242 //
6243 // Usbss completion event will move us from this state.
6244 //
6245 return WdfDevStatePwrPolNull;
6246 }
6247
6249}
@ WdfDevStatePwrPolWokeFromS0UsbSS
Definition: wdfdevice.h:312

◆ PowerPowerFailedPowerDown()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerPowerFailedPowerDown ( __inout FxPkgPnp This)
staticprotected

Definition at line 3894 of file powerstatemachine.cpp.

3911{
3912 //
3913 // Even though we failed power up and never really powered down, record our
3914 // state as powered down, so that if we are restarted (can easily happen for
3915 // a PDO), we have the correct previous state.
3916 //
3917 This->PowerSetDevicePowerState(WdfPowerDeviceD3Final);
3918
3919 This->PowerSendPowerDownEvents(FxPowerDownTypeImplicit);
3920
3922}

◆ PowerProcessEvent()

VOID FxPkgPnp::PowerProcessEvent ( __in FxPowerEvent  Event,
__in BOOLEAN  ProcessEventOnDifferentThread = FALSE 
)

Definition at line 1156 of file powerstatemachine.cpp.

1176{
1178 KIRQL irql;
1179
1180 //
1181 // Take the lock, raising to DISPATCH_LEVEL.
1182 //
1183 m_PowerMachine.Lock(&irql);
1184
1185 //
1186 // If the input Event is any of the events described by PowerSingularEventMask,
1187 // then check whether it is already queued up. If so, then dont enqueue this
1188 // Event.
1189 //
1193 }
1194 else {
1197 "WDFDEVICE 0x%p !devobj 0x%p current pwr pol state "
1198 "%!WDF_DEVICE_POWER_STATE! dropping event %!FxPowerEvent! because "
1199 "the Event is already enqueued.", m_Device->GetHandle(),
1202 Event);
1203
1204 m_PowerMachine.Unlock(irql);
1205 return;
1206 }
1207 }
1208
1209 if (m_PowerMachine.IsFull()) {
1210 //
1211 // The queue is full. Bail.
1212 //
1213 m_PowerMachine.Unlock(irql);
1214
1215 ASSERT(!"The Power queue is full. This shouldn't be able to happen.");
1216 return;
1217 }
1218
1222 "WDFDEVICE 0x%p !devobj 0x%p current pwr pol state "
1223 "%!WDF_DEVICE_POWER_STATE! dropping event %!FxPowerEvent! because "
1224 "of a closed queue", m_Device->GetHandle(),
1227 Event);
1228
1229 //
1230 // The queue is closed. Bail
1231 //
1232 m_PowerMachine.Unlock(irql);
1233
1234 return;
1235 }
1236
1237 //
1238 // Enqueue the event. Whether the event goes on the front
1239 // or the end of the queue depends on which event it is.
1240 //
1242 //
1243 // Stick it on the front of the queue, making it the next
1244 // event that will be processed.
1245 //
1247 }
1248 else {
1249 //
1250 // Stick it on the end of the queue.
1251 //
1253 }
1254
1255 //
1256 // Drop the lock.
1257 //
1258 m_PowerMachine.Unlock(irql);
1259
1260 //
1261 // Now, if we are running at PASSIVE_LEVEL, attempt to run the state
1262 // machine on this thread. If we can't do that, then queue a work item.
1263 //
1264
1265 if (irql == PASSIVE_LEVEL &&
1266 FALSE == ProcessOnDifferentThread) {
1267 LONGLONG timeout = 0;
1268
1271
1272 if (FxWaitLockInternal::IsLockAcquired(status)) {
1274
1275 //
1276 // We now hold the state machine lock. So call the function that
1277 // dispatches the next state.
1278 //
1280
1281 //
1282 // The pnp state machine should be the only one deleting the object
1283 //
1284 ASSERT(info.m_DeleteObject == FALSE);
1285
1287
1288 info.Evaluate(this);
1289
1290 return;
1291 }
1292 }
1293
1294 //
1295 // The tag added above will be released when the work item runs
1296 //
1297
1298 // For one reason or another, we couldn't run the state machine on this
1299 // thread. So queue a work item to do it. If m_PnPWorkItemEnqueuing
1300 // is non-zero, that means that the work item is already being enqueued
1301 // on another thread. This is significant, since it means that we can't do
1302 // anything with the work item on this thread, but it's okay, since the
1303 // work item will pick up our work and do it.
1304 //
1306}
VOID PowerProcessEventInner(__inout FxPostProcessInfo *Info)
@ PowerPriorityEventsMask
@ PowerSingularEventMask

Referenced by AckPendingWakeInterruptOperation(), CommitUsageNotification(), FxPkgPdo::DispatchDeviceSetPower(), DispatchWaitWake(), FxPkgFdo::LowerDevicePower(), and PowerIndicateWaitWakeStatus().

◆ PowerProcessEventInner()

VOID FxPkgPnp::PowerProcessEventInner ( __inout FxPostProcessInfo Info)
protected

Definition at line 1345 of file powerstatemachine.cpp.

1355{
1356 WDF_DEVICE_POWER_STATE currentPowerState, newState;
1359 KIRQL oldIrql;
1360
1361 //
1362 // Process as many events as we can.
1363 //
1364 for (;;) {
1365
1366 newState = WdfDevStatePowerNull;
1367 currentPowerState = m_Device->GetDevicePowerState();
1368 entry = GetPowerTableEntry(currentPowerState);
1369
1370 //
1371 // Get an event from the queue.
1372 //
1373 m_PowerMachine.Lock(&oldIrql);
1374
1375 if (m_PowerMachine.IsEmpty()) {
1377
1378 //
1379 // The queue is empty.
1380 //
1381 m_PowerMachine.Unlock(oldIrql);
1382 return;
1383 }
1384
1386
1387 //
1388 // At this point, we need to determine whether we can process this
1389 // event.
1390 //
1392 //
1393 // These are always possible to handle.
1394 //
1395 DO_NOTHING();
1396 }
1397 else {
1398 //
1399 // Check to see if this state can handle new events.
1400 //
1401 if (entry->StateInfo.Bits.QueueOpen == FALSE) {
1402 //
1403 // This state can't handle new events.
1404 //
1405 m_PowerMachine.Unlock(oldIrql);
1406 return;
1407 }
1408 }
1409
1410 //
1411 // If the event obtained from the queue was a singular event, then
1412 // clear the flag to allow other similar events to be put into this
1413 // queue for processing.
1414 //
1417 }
1418
1420 m_PowerMachine.Unlock(oldIrql);
1421
1422 //
1423 // Find the entry in the power state table that corresponds to this event
1424 //
1425 if (entry->FirstTargetState.PowerEvent == event) {
1426 newState = entry->FirstTargetState.TargetState;
1427
1428 DO_EVENT_TRAP(&entry->FirstTargetState);
1429 }
1430 else if (entry->OtherTargetStates != NULL) {
1431 ULONG i = 0;
1432
1433 for (i = 0;
1434 entry->OtherTargetStates[i].PowerEvent != PowerEventMaximum;
1435 i++) {
1436 if (entry->OtherTargetStates[i].PowerEvent == event) {
1437 newState = entry->OtherTargetStates[i].TargetState;
1438 DO_EVENT_TRAP(&entry->OtherTargetStates[i]);
1439 break;
1440 }
1441 }
1442 }
1443
1444 if (newState == WdfDevStatePowerNull) {
1447 "WDFDEVICE 0x%p !devobj 0x%p current power state "
1448 "%!WDF_DEVICE_POWER_STATE! dropping event %!FxPowerEvent!",
1452
1453 //
1454 // This state doesn't respond to the Event. Potentially throw
1455 // the event away.
1456 //
1457 if ((entry->StateInfo.Bits.KnownDroppedEvents & event) == 0) {
1458 COVERAGE_TRAP();
1459
1462 "WDFDEVICE %p !devobj 0x%p current state "
1463 "%!WDF_DEVICE_POWER_STATE! event %!FxPowerEvent! is not a "
1464 "known dropped event, known dropped events are "
1465 "%!FxPowerEvent!", m_Device->GetHandle(),
1468 event, entry->StateInfo.Bits.KnownDroppedEvents);
1469
1470
1471 }
1472
1473 switch (event) {
1474 case PowerWakeSucceeded:
1475 case PowerWakeFailed:
1476 case PowerWakeCanceled:
1477 //
1478 // There are states where we don't care if the wake completed.
1479 // Since the completion/cancellation of the wake request posts
1480 // an event which it assumes will complete the request, we must
1481 // catch these events here and complete the request.
1482 //
1484 break;
1485
1486 case PowerD0:
1487 case PowerDx:
1488 //
1489 // There are some (non WDF) power policy owner implementations
1490 // which send Dx to Dx or D0 to D0 transitions to the stack.
1491 //
1492 // We don't explicitly handle them in the state machine.
1493 //
1494 // Instead, we complete the pended irp if are about to drop it
1495 // on the floor.
1496 //
1498 break;
1499 }
1500 }
1501 else {
1502 //
1503 // Now enter the new state.
1504 //
1505 PowerEnterNewState(newState);
1506 }
1507 }
1508}
VOID PowerEnterNewState(__in WDF_DEVICE_POWER_STATE State)
@ PowerEventMaximum

Referenced by PowerProcessEvent().

◆ PowerReference()

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

Definition at line 3486 of file fxpkgpnp.hpp.

3492 {
3494 }
_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_ _In_ WDFDEVICE _In_ BOOLEAN WaitForD0
Definition: wdfdevice.h:4006

Referenced by PnpDeviceUsageNotification(), PnpPowerReferenceSelf(), PowerPolicyCanChildPowerUp(), FxIoQueue::SetTransitionFromEmpty(), and StopIdleWorker().

◆ PowerReleasePendingDeviceIrp()

virtual VOID FxPkgPnp::PowerReleasePendingDeviceIrp ( BOOLEAN  IrpMustBePresent = TRUE)
protectedpure virtual

◆ PowerReportPowerDownFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerReportPowerDownFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 3925 of file powerstatemachine.cpp.

3941{
3942
3943
3944
3945
3946 This->PowerReleasePendingDeviceIrp();
3947 This->PowerSendPowerDownFailureEvent(FxPowerDownTypeExplicit);
3948
3949 return WdfDevStatePowerNull;
3950}

◆ PowerReportPowerUpFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerReportPowerUpFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 3868 of file powerstatemachine.cpp.

3884{
3885 This->m_SystemPowerAction = PowerActionNone;
3886
3887 This->PowerReleasePendingDeviceIrp();
3888 This->PowerSendPowerUpFailureEvent();
3889
3890 return WdfDevStatePowerNull;
3891}

◆ PowerReportPowerUpFailedDerefParent()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerReportPowerUpFailedDerefParent ( __inout FxPkgPnp This)
staticprotected

Definition at line 3842 of file powerstatemachine.cpp.

3858{
3859 //
3860 // If this is a child, release the power reference on the parent
3861 //
3862 This->PowerParentPowerDereference();
3863
3865}
@ WdfDevStatePowerReportPowerUpFailed
Definition: wdfdevice.h:192

◆ PowerSendIdlePowerEvent()

VOID FxPkgPnp::PowerSendIdlePowerEvent ( __in FxPowerIdleEvents  Event)
protected

◆ PowerSendPowerDownEvents()

VOID FxPkgPnp::PowerSendPowerDownEvents ( __in FxPowerDownType  Type)
protected

Definition at line 5030 of file powerstatemachine.cpp.

5045{
5046 //
5047 // If this is an implicit power type, there is completion routine on the
5048 // power irp and we must send these events in the power state machine
5049 // regardless if we are the PPO or not.
5050 //
5053
5054 //
5055 // If we are the power policy owner, there is no need to distinguish
5056 // between an implicit power down or an explicit power down since the
5057 // PPO controls all power irps in the stack and a power policy stop
5058 // (e.g. an implicit power down) will not be racing with a real power
5059 // irp.
5060 //
5061 // The non PPO state machine needs to distinguish between the 2 types
5062 // of power downs because both of them may occur simultaneously and we
5063 // don't want to interpret the power down event for the real Dx irp with
5064 // the power down event for the (final) implicit power down.
5065 //
5068 return;
5069 }
5070
5072
5073 //
5074 // If we are the PPO, then we will send PwrPolPowerDown in the completion
5075 // routine passed to PoRequestPowerIrp. If we are not the PPO, we must send
5076 // the event now because we have no such completion routine.
5077 //
5078 if (IsPowerPolicyOwner()) {
5079 //
5080 // Transition the idle state machine to off immediately.
5081 //
5084 );
5085 }
5086 else {
5087 //
5088 // If we are not the PPO, there is no idle state machine to send an
5089 // event to and there is no Po request completion routine to send this
5090 // event, so we send it now.
5091 //
5093 }
5094}
VOID PowerSendIdlePowerEvent(__in FxPowerIdleEvents Event)
@ PowerIdleEventPowerDown
@ PwrPolImplicitPowerDown

Referenced by PowerGotoDxIoStopped(), and PowerGotoDxIoStoppedNP().

◆ PowerSendPowerDownFailureEvent()

VOID FxPkgPnp::PowerSendPowerDownFailureEvent ( __in FxPowerDownType  Type)
protected

Definition at line 5124 of file powerstatemachine.cpp.

5140{
5142
5143 if (IsPowerPolicyOwner()) {
5144 //
5145 // If we are the PPO and this is an explicit power operation, then we
5146 // will send PwrPolPowerDownFailed in the completion routine passed to
5147 // PoRequestPowerIrp. Otherwise, if this is an implicit power operation
5148 // that failed, we need to send the event now because there is no
5149 // Po completion routine to send the event later.
5150 //
5152 //
5153 // Since there is no power irp to complete, we must send the event
5154 // now.
5155 //
5156 // We only send PwrPolImplicitPowerDownFailed if we are not the
5157 // PPO, so we can't share code with the !PPO path.
5158 //
5160 }
5161 else {
5163
5164 //
5165 // Process the state change immediately in the idle state machine.
5166 // We should do this only on an explicit power down since the PPO
5167 // will have disabled the idle state machine before attempting an
5168 // implicit power down.
5169 //
5172 );
5173 }
5174 }
5175 else {
5176 //
5177 // We are not the PPO, so we must send the event now because we have no
5178 // such completion routine. Decide which event to send to the
5179 // !PPO state machine.
5180 //
5184 );
5185
5186 //
5187 // Send the pnp event last becuase if we are in the middle of a Dx
5188 // transition during S0, there is no S irp to guard a pnp state change
5189 // from occurring immediately after sending this event. If we sent it
5190 // before sending the power policy message, power policy might not
5191 // transition to the failed state by the time pnp does creating a
5192 // mismatch.
5193 //
5196 }
5197 }
5198}
@ PowerIdleEventPowerDownFailed
@ PwrPolImplicitPowerDownFailed

◆ PowerSendPowerUpEvents()

VOID FxPkgPnp::PowerSendPowerUpEvents ( VOID  )
protected

Definition at line 5097 of file powerstatemachine.cpp.

5112{
5114
5115 //
5116 // This must be called *before* PowerPostParentToD0ToChildren so that we
5117 // clear the child power up guard variable in the power policy state machine
5118 // and then post an event which will unblock the child.
5119 //
5121}
@ PowerIdleEventPowerUpComplete

◆ PowerSendPowerUpFailureEvent()

VOID FxPkgPnp::PowerSendPowerUpFailureEvent ( VOID  )
protected

◆ PowerSetDevicePowerState()

VOID FxPkgPnp::PowerSetDevicePowerState ( __in WDF_POWER_DEVICE_STATE  State)
protected

Definition at line 5229 of file powerstatemachine.cpp.

5244{
5245 POWER_STATE powerState;
5246
5247 //
5248 // Remember our previous state
5249 //
5251
5252 //
5253 // Set our new state
5254 //
5255 ASSERT(State <= 0xFF);
5257
5258 //
5259 // Notify the system of the new power state.
5260 //
5261 switch (State) {
5264 powerState.DeviceState = PowerDeviceD3;
5265 break;
5266
5267 case WdfPowerDeviceD0:
5270
5271 default:
5272 powerState.DeviceState = (DEVICE_POWER_STATE) State;
5273 break;
5274 }
5275
5279 powerState);
5280}
POWER_STATE SetPowerState(__in POWER_STATE_TYPE Type, __in POWER_STATE State)
@ DevicePowerState
Definition: ntpoapi.h:63
DEVICE_POWER_STATE DeviceState
Definition: ntpoapi.h:58
unsigned char BYTE
Definition: xxhash.c:193

Referenced by PowerConnectInterruptFailed(), PowerGotoDxIoStopped(), and PowerGotoDxIoStoppedNP().

◆ PowerStartingCheckDeviceType()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerStartingCheckDeviceType ( __inout FxPkgPnp This)
staticprotected

Definition at line 2478 of file powerstatemachine.cpp.

2495{
2496 if (This->m_Device->IsPdo()) {
2498 }
2499 else {
2501 }
2502}
@ WdfDevStatePowerStartingChild
Definition: wdfdevice.h:153
@ WdfDevStatePowerD0Starting
Definition: wdfdevice.h:145

◆ PowerStartingChild()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerStartingChild ( __inout FxPkgPnp This)
staticprotected

Definition at line 2505 of file powerstatemachine.cpp.

2520{
2522 BOOLEAN parentOn;
2523
2524 status = This->PowerCheckParentOverload(&parentOn);
2525
2526 if (!NT_SUCCESS(status)) {
2528 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
2529 "PowerReference on parent WDFDEVICE %p for child WDFDEVICE %p "
2530 "failed, %!STATUS!", This->m_Device->m_ParentDevice->m_Device->GetHandle(),
2531 This->m_Device->GetHandle(),
2532 status);
2533
2535 }
2536 else if (parentOn) {
2537 //
2538 // Parent is powered on, start the power up sequence
2539 //
2541 }
2542 else {
2543 //
2544 // The call to PowerReference will bring the parent into D0 and
2545 // move us out of this state after we return.
2546 //
2547 return WdfDevStatePowerNull;
2548 }
2549}

◆ PowerStartSelfManagedIo()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerStartSelfManagedIo ( __inout FxPkgPnp This)
staticprotected

Definition at line 3199 of file powerstatemachine.cpp.

3217{
3218
3219
3220
3221
3222
3223 // Top-edge queue release
3224 This->m_Device->m_PkgIo->ResumeProcessingForPower();
3225
3226 if (This->m_SelfManagedIoMachine != NULL) {
3228
3229 status = This->m_SelfManagedIoMachine->Start();
3230
3231 if (!NT_SUCCESS(status)) {
3233 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
3234 "EvtDeviceSelfManagedIoRestart failed - %!STATUS!", status);
3235
3237 }
3238 }
3239
3240 This->PowerSetDevicePowerState(WdfPowerDeviceD0);
3241
3242 //
3243 // Send the PowerUp event to both the PnP and the Power Policy state
3244 // machines.
3245 //
3246 This->PowerSendPowerUpEvents();
3247
3248 This->PowerReleasePendingDeviceIrp();
3249
3250 if (This->m_SharedPower.m_WaitWakeOwner) {
3252 }
3253 else {
3254 return WdfDevStatePowerD0;
3255 }
3256}
@ WdfDevStatePowerStartSelfManagedIoFailed
Definition: wdfdevice.h:175

◆ PowerStartSelfManagedIoFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerStartSelfManagedIoFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 3318 of file powerstatemachine.cpp.

3334{
3335
3336
3337
3338
3339 This->m_Device->m_PkgIo->StopProcessingForPower(FxIoStopProcessingForPowerHold);
3340
3342}
@ WdfDevStatePowerWakingDmaEnableFailed
Definition: wdfdevice.h:189

◆ PowerStartSelfManagedIoFailedNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerStartSelfManagedIoFailedNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 3345 of file powerstatemachine.cpp.

3361{
3362
3363
3364
3365
3366 This->m_Device->m_PkgIo->StopProcessingForPower(FxIoStopProcessingForPowerHold);
3367
3369}
@ WdfDevStatePowerWakingDmaEnableFailedNP
Definition: wdfdevice.h:190

◆ PowerStartSelfManagedIoNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerStartSelfManagedIoNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 3259 of file powerstatemachine.cpp.

3277{
3278
3279
3280
3281
3282
3283 // Top-edge queue release
3284 This->m_Device->m_PkgIo->ResumeProcessingForPower();
3285
3286 if (This->m_SelfManagedIoMachine != NULL) {
3288
3289 status = This->m_SelfManagedIoMachine->Start();
3290
3291 if (!NT_SUCCESS(status)) {
3293 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
3294 "EvtDeviceSelfManagedIoRestart failed - %!STATUS!", status);
3295
3297 }
3298 }
3299
3300 This->PowerSetDevicePowerState(WdfPowerDeviceD0);
3301
3302 //
3303 // Send the PowerUp event to both the PnP and the Power Policy state machines.
3304 //
3305 This->PowerSendPowerUpEvents();
3306
3307 This->PowerReleasePendingDeviceIrp();
3308
3309 if (This->m_SharedPower.m_WaitWakeOwner) {
3311 }
3312 else {
3313 return WdfDevStatePowerD0NP;
3314 }
3315}
@ WdfDevStatePowerStartSelfManagedIoFailedNP
Definition: wdfdevice.h:176

◆ PowerStoppedCompleteDx()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerStoppedCompleteDx ( __inout FxPkgPnp This)
staticprotected

Definition at line 4230 of file powerstatemachine.cpp.

4247{
4248 //
4249 // We should only get into this state when this devobj is not the power
4250 // policy owner.
4251 //
4252 ASSERT(This->IsPowerPolicyOwner() == FALSE);
4253
4254 This->PowerReleasePendingDeviceIrp();
4256}
@ WdfDevStatePowerDxStopped
Definition: wdfdevice.h:204

◆ PowerSurpriseRemoved()

static WDF_DEVICE_POWER_STATE FxPkgPnp::PowerSurpriseRemoved ( __inout FxPkgPnp This)
staticprotected

◆ PowerUpFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerUpFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 4469 of file powerstatemachine.cpp.

4484{
4485 COVERAGE_TRAP();
4486 //
4487 // Notify the interrupt state machines that the power up failed
4488 //
4489 This->SendEventToAllWakeInterrupts(WakeInterruptEventD0EntryFailed);
4490 //
4491 // NotifyResourceObjectsDx will log any errors
4492 //
4493 (void) This->NotifyResourceObjectsDx(NotifyResourcesForceDisconnect |
4495
4497}
@ WakeInterruptEventD0EntryFailed

◆ PowerUpFailedDerefParent()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerUpFailedDerefParent ( __inout FxPkgPnp This)
staticprotected

Definition at line 4439 of file powerstatemachine.cpp.

4454{
4455 //
4456 // Notify the interrupt state machines that the power up failed
4457 //
4458 This->SendEventToAllWakeInterrupts(WakeInterruptEventD0EntryFailed);
4459 //
4460 // NotifyResourceObjectsDx will log any errors
4461 //
4462 (void) This->NotifyResourceObjectsDx(NotifyResourcesForceDisconnect |
4464
4466}
@ WdfDevStatePowerReportPowerUpFailedDerefParent
Definition: wdfdevice.h:191

◆ PowerUpFailedDerefParentNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerUpFailedDerefParentNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4552 of file powerstatemachine.cpp.

4567{
4568 //
4569 // Notify the interrupt state machines that the power up failed
4570 //
4571 This->SendEventToAllWakeInterrupts(WakeInterruptEventD0EntryFailed);
4572 This->DisconnectInterruptNP();
4573
4575}

◆ PowerUpFailedNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerUpFailedNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 4578 of file powerstatemachine.cpp.

4593{
4594 //
4595 // Notify the interrupt state machines that the power up failed
4596 //
4597 This->SendEventToAllWakeInterrupts(WakeInterruptEventD0EntryFailed);
4598 This->DisconnectInterruptNP();
4599
4601}

◆ PowerWakePending()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerWakePending ( __inout FxPkgPnp This)
staticprotected

Definition at line 3373 of file powerstatemachine.cpp.

3391{
3392 This->PowerCompletePendedWakeIrp();
3393 return WdfDevStatePowerNull;
3394}

◆ PowerWakePendingNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerWakePendingNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 3397 of file powerstatemachine.cpp.

3415{
3416 This->PowerCompletePendedWakeIrp();
3417 return WdfDevStatePowerNull;
3418}

◆ PowerWaking()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerWaking ( __inout FxPkgPnp This)
staticprotected

Definition at line 3421 of file powerstatemachine.cpp.

3439{
3441
3442 //
3443 // m_DevicePowerState is the "old" state because we update it after the
3444 // D0Entry callback in SelfManagedIo or PowerPolicyStopped
3445 //
3446 status = This->m_DeviceD0Entry.Invoke(
3447 This->m_Device->GetHandle(),
3448 (WDF_POWER_DEVICE_STATE) This->m_DevicePowerState);
3449
3450 if (!NT_SUCCESS(status)) {
3452 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
3453 "EvtDeviceD0Entry WDFDEVICE 0x%p !devobj 0x%p, old state "
3454 "%!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
3455 This->m_Device->GetHandle(),
3456 This->m_Device->GetDeviceObject(),
3457 This->m_DevicePowerState, status);
3458
3460 }
3461
3463}
@ WdfDevStatePowerUpFailedDerefParent
Definition: wdfdevice.h:214
@ WdfDevStatePowerNotifyingD0EntryToWakeInterrupts
Definition: wdfdevice.h:220

◆ PowerWakingConnectInterrupt()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerWakingConnectInterrupt ( __inout FxPkgPnp This)
staticprotected

Definition at line 3511 of file powerstatemachine.cpp.

3528{
3530
3531 //
3532 // interrupt connect and enable
3533 //
3534 status = This->NotifyResourceObjectsD0(NotifyResourcesExplicitPowerup);
3535
3536 if (!NT_SUCCESS(status)) {
3538 }
3539
3540 status = This->m_DeviceD0EntryPostInterruptsEnabled.Invoke(
3541 This->m_Device->GetHandle(),
3542 (WDF_POWER_DEVICE_STATE) This->m_DevicePowerState);
3543
3544 if (!NT_SUCCESS(status)) {
3546 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
3547 "EvtDeviceD0EntryPostInterruptsEnabed WDFDEVICE 0x%p !devobj 0x%p, "
3548 "old state %!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
3549 This->m_Device->GetHandle(),
3550 This->m_Device->GetDeviceObject(),
3551 This->m_DevicePowerState, status);
3553 }
3554
3556}
@ NotifyResourcesExplicitPowerup
Definition: fxpkgpnp.hpp:211
@ WdfDevStatePowerWakingConnectInterruptFailed
Definition: wdfdevice.h:185
@ WdfDevStatePowerWakingDmaEnable
Definition: wdfdevice.h:187

◆ PowerWakingConnectInterruptFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerWakingConnectInterruptFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 3608 of file powerstatemachine.cpp.

3624{
3625 This->PowerConnectInterruptFailed();
3626
3628}

◆ PowerWakingConnectInterruptFailedNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerWakingConnectInterruptFailedNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 3631 of file powerstatemachine.cpp.

3647{
3648 //
3649 // PowerConnectInterruptFailed will call IoDisconnectInterrupt. Since we
3650 // are in the NP path, this may cause a deadlock between this thread and
3651 // paging I/O. Log something to the IFR so that if the watchdog timer kicks
3652 // in, at least we have context as to why we died.
3653 //
3655 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
3656 "Force disconnecting interupts on !devobj %p, WDFDEVICE %p",
3657 This->m_Device->GetDeviceObject(),
3658 This->m_Device->GetHandle());
3659
3660 This->PowerConnectInterruptFailed();
3661
3663}

◆ PowerWakingConnectInterruptNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerWakingConnectInterruptNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 3559 of file powerstatemachine.cpp.

3576{
3578
3579 //
3580 // interrupt enable (already connected b/c they were never disconnected
3581 // during the Dx transition).
3582 //
3583 status = This->NotifyResourceObjectsD0(NotifyResourcesNP);
3584
3585 if (!NT_SUCCESS(status)) {
3587 }
3588
3589 status = This->m_DeviceD0EntryPostInterruptsEnabled.Invoke(
3590 This->m_Device->GetHandle(),
3591 (WDF_POWER_DEVICE_STATE) This->m_DevicePowerState);
3592
3593 if (!NT_SUCCESS(status)) {
3595 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
3596 "EvtDeviceD0EntryPostInterruptsEnabed WDFDEVICE 0x%p !devobj 0x%p, "
3597 "old state %!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
3598 This->m_Device->GetHandle(),
3599 This->m_Device->GetDeviceObject(),
3600 This->m_DevicePowerState, status);
3602 }
3603
3605}
@ WdfDevStatePowerWakingConnectInterruptFailedNP
Definition: wdfdevice.h:186
@ WdfDevStatePowerWakingDmaEnableNP
Definition: wdfdevice.h:188

◆ PowerWakingDmaEnable()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerWakingDmaEnable ( __inout FxPkgPnp This)
staticprotected

Definition at line 3698 of file powerstatemachine.cpp.

3714{
3715 if (This->PowerDmaEnableAndScan(FALSE) == FALSE) {
3717 }
3718
3719 //
3720 // Return the state that we should drop into next.
3721 //
3722 return WdfDevStatePowerNull;
3723}

◆ PowerWakingDmaEnableFailed()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerWakingDmaEnableFailed ( __inout FxPkgPnp This)
staticprotected

Definition at line 3754 of file powerstatemachine.cpp.

3770{
3772
3773 (void) This->PowerDmaPowerDown();
3774
3775 status = This->m_DeviceD0ExitPreInterruptsDisabled.Invoke(
3776 This->m_Device->GetHandle(),
3778 );
3779
3780 if (!NT_SUCCESS(status)) {
3781 //
3782 // Report the error, but continue forward
3783 //
3785 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
3786 "EvtDeviceD0ExitPreInterruptsDisabled WDFDEVICE 0x%p !devobj 0x%p "
3787 "new state %!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
3788 This->m_Device->GetHandle(),
3789 This->m_Device->GetDeviceObject(),
3791 }
3792
3794}

◆ PowerWakingDmaEnableFailedNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerWakingDmaEnableFailedNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 3797 of file powerstatemachine.cpp.

3813{
3815
3816 COVERAGE_TRAP();
3817
3818 (void) This->PowerDmaPowerDown();
3819
3820 status = This->m_DeviceD0ExitPreInterruptsDisabled.Invoke(
3821 This->m_Device->GetHandle(),
3823 );
3824
3825 if (!NT_SUCCESS(status)) {
3826 //
3827 // Report the error, but continue forward
3828 //
3830 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
3831 "EvtDeviceD0ExitPreInterruptsDisabled WDFDEVICE 0x%p !devobj 0x%p "
3832 "new state %!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
3833 This->m_Device->GetHandle(),
3834 This->m_Device->GetDeviceObject(),
3836 }
3837
3839}

◆ PowerWakingDmaEnableNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerWakingDmaEnableNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 3726 of file powerstatemachine.cpp.

3742{
3743 if (This->PowerDmaEnableAndScan(FALSE) == FALSE) {
3745 }
3746
3747 //
3748 // Return the state that we should drop into next.
3749 //
3750 return WdfDevStatePowerNull;
3751}

◆ PowerWakingNP()

WDF_DEVICE_POWER_STATE FxPkgPnp::PowerWakingNP ( __inout FxPkgPnp This)
staticprotected

Definition at line 3467 of file powerstatemachine.cpp.

3484{
3486
3487 //
3488 // m_DevicePowerState is the "old" state because we update it after the
3489 // D0Entry callback in SelfManagedIoNP or PowerPolicyStopped
3490 //
3491 status = This->m_DeviceD0Entry.Invoke(
3492 This->m_Device->GetHandle(),
3493 (WDF_POWER_DEVICE_STATE) This->m_DevicePowerState);
3494
3495 if (!NT_SUCCESS(status)) {
3497 This->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
3498 "EvtDeviceD0Entry WDFDEVICE 0x%p !devobj 0x%p, old state "
3499 "%!WDF_POWER_DEVICE_STATE! failed, %!STATUS!",
3500 This->m_Device->GetHandle(),
3501 This->m_Device->GetDeviceObject(),
3502 This->m_DevicePowerState, status);
3503
3505 }
3506
3508}
@ WdfDevStatePowerNotifyingD0EntryToWakeInterruptsNP
Definition: wdfdevice.h:222
@ WdfDevStatePowerUpFailedDerefParentNP
Definition: wdfdevice.h:218

◆ ProcessDelayedDeletion()

VOID FxPkgPnp::ProcessDelayedDeletion ( VOID  )

Definition at line 1293 of file fxpkgpnp.cpp.

1296{
1299 "WDFDEVICE %p, !devobj %p processing delayed deletion from pnp state "
1300 "machine", m_Device->GetHandle(), m_Device->GetDeviceObject());
1301
1303 DeleteDevice();
1304}
VOID CleanupStateMachines(__in BOOLEAN ClenaupPnp)
Definition: fxpkgpnp.cpp:2066
VOID DeleteDevice(VOID)
Definition: fxpkgpnp.cpp:2249

◆ ProcessRemoveDeviceOverload()

virtual NTSTATUS FxPkgPnp::ProcessRemoveDeviceOverload ( FxIrp Irp)
privatepure virtual

◆ QueryForCapabilities()

_Must_inspect_result_ NTSTATUS FxPkgPnp::QueryForCapabilities ( VOID  )
protected

Definition at line 1675 of file fxpkgpnp.cpp.

1678{
1681
1683
1685
1687 &deviceObject,
1689 &caps);
1690
1691 if (NT_SUCCESS(status)) {
1692 ULONG states, i;
1693
1694 ASSERT(caps.DeviceCaps.DeviceWake <= 0xFF && caps.DeviceCaps.SystemWake <= 0xFF);
1695
1696 m_SystemWake = (BYTE) caps.DeviceCaps.SystemWake;
1697
1698 //
1699 // Initialize the array of wakeable D-states to say that all system
1700 // states down to the one identified in the caps can generate wake.
1701 // This will be overridden below if the BIOS supplied more information.
1702 //
1703 // Compatibility Note: Non-ACPI bus drivers (root-enumerated drivers)
1704 // or other bus drivers that haven't set the power settings correctly
1705 // for their PDO may end up with a valid value for DeviceWake in the
1706 // device capabilities but a value of PowerSystemUnspecified for
1707 // SystemWake, in which case a call to WdfDeviceAssignS0IdleSettings or
1708 // WdfDeviceAssignSxWakeSettings DDIs will fail on 1.11+ resulting in
1709 // device compat issues. The failure is expected and right thing to do
1710 // but has compatibility implications - drivers that worked earlier now
1711 // fail on 1.11. Note that earlier versions of WDF did not have
1712 // m_DeviceWake as an array and stored just the capabilities->DeviceWake
1713 // value without regard to the SystemWake but the current implementation
1714 // introduces dependency on systemWake value). So for compat reasons,
1715 // for pre-1.11 compiled drivers we initilaize the array with DeviceWake
1716 // value ignoring SystemWake, removing any dependency of DeviceWake
1717 // on SystemWake value and thus preserving previous behavior for
1718 // pre-1.11 compiled drivers.
1719 //
1721
1723
1724 for (i = PowerSystemWorking; i <= m_SystemWake; i++) {
1725
1726 //
1727 // Note that this cast is hiding a conversion between two slightly
1728 // incompatible types. DeviceWake is in terms of DEVICE_POWER_STATE
1729 // which is defined this way:
1730 //
1731 // typedef enum _DEVICE_POWER_STATE {
1732 // PowerDeviceUnspecified = 0,
1733 // PowerDeviceD0,
1734 // PowerDeviceD1,
1735 // PowerDeviceD2,
1736 // PowerDeviceD3,
1737 // PowerDeviceMaximum
1738 // } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
1739 //
1740 // m_DeviceWake is defined in terms of DEVICE_WAKE_DEPTH which is
1741 // defined this way:
1742 //
1743 // typedef enum _DEVICE_WAKE_DEPTH {
1744 // DeviceWakeDepthNotWakeable = 0,
1745 // DeviceWakeDepthD0,
1746 // DeviceWakeDepthD1,
1747 // DeviceWakeDepthD2,
1748 // DeviceWakeDepthD3hot,
1749 // DeviceWakeDepthD3cold,
1750 // DeviceWakeDepthMaximum
1751 // } DEVICE_WAKE_DEPTH, *PDEVICE_WAKE_DEPTH;
1752 //
1753 // The result is that the conversion below will map D3 onto D3hot,
1754 // which is a safe assumption to start with, one which may be
1755 // overridden later.
1756 //
1758 m_DeviceWake[i - PowerSystemWorking] = (BYTE) caps.DeviceCaps.DeviceWake;
1759 }
1760 }
1761 else {
1762 //
1763 // See comments above for information on mapping of device power
1764 // state to device wake depth.
1765 //
1768 (BYTE) caps.DeviceCaps.DeviceWake);
1769 }
1770
1771 //
1772 // Capture the S -> D state mapping table as a ULONG for use in the
1773 // power policy owner state machine when the machine moves into Sx and
1774 // the device is not armed for wake and has set an IdealDxStateForSx
1775 // value
1776 //
1777 states = 0x0;
1778
1779 for (i = 0; i < ARRAY_SIZE(caps.DeviceCaps.DeviceState); i++) {
1780 _SetPowerCapState(i, caps.DeviceCaps.DeviceState[i], &states);
1781 }
1782
1784
1785 //
1786 // Query for the D3cold support interface. If present, it will tell
1787 // us specifically which D-states will work for generating wake signals
1788 // from specific S-states.
1789 //
1790 // Earlier versions of WDF didn't make this query, so for compatibility,
1791 // we only make it now if the driver was built against WDF 1.11 or
1792 // later. In truth, this just shifts the failure from initialization
1793 // time to run time, because the information that we're presumably
1794 // getting from the BIOS with this interrogation is saying that the
1795 // code in earlier verisions of WDF would have blindly enabled a device
1796 // for wake which simply wasn't capable of generating its wake signal
1797 // from the chosen D-state. Thus the device would have been put into
1798 // a low power state and then failed to resume in response to its wake
1799 // signal.
1800 //
1801
1802 if (GetDriverGlobals()->IsVersionGreaterThanOrEqualTo(1,11)) {
1803
1804 //
1805 // Cycle through all the system states that this device can wake
1806 // from. There's no need to look at deeper sleep states than
1807 // m_SystemWake because the driver will not arm for wake in
1808 // those states.
1809 //
1810 for (i = PowerSystemWorking; i <= m_SystemWake; i++) {
1813 }
1814 }
1815 }
1816 }
1817
1818 return status;
1819}
#define ARRAY_SIZE(A)
Definition: main.h:20
const UCHAR DeviceWakeStates
Definition: fxpkgpnp.hpp:199
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
#define C_ASSERT(e)
Definition: intsafe.h:73
_Must_inspect_result_ BOOLEAN IsVersionGreaterThanOrEqualTo(__in ULONG Major, __in ULONG Minor)
Definition: globalskm.cpp:92
DEVICE_CAPABILITIES DeviceCaps
Definition: device_common.h:30
DEVICE_WAKE_DEPTH DeepestWakeableDstate[PowerSystemHibernate+1]
Definition: device_common.h:37
_Must_inspect_result_ NTSTATUS GetStackCapabilities(__in PFX_DRIVER_GLOBALS DriverGlobals, __in MxDeviceObject *DeviceInStack, __in_opt PD3COLD_SUPPORT_INTERFACE D3ColdInterface, __out PSTACK_DEVICE_CAPABILITIES Capabilities)
Definition: supportkm.cpp:48
@ DeviceWakeDepthMaximum
Definition: iotypes.h:7485
@ DeviceWakeDepthD0
Definition: iotypes.h:7480
@ DeviceWakeDepthNotWakeable
Definition: iotypes.h:7479

Referenced by PowerPolicySetS0IdleSettings(), and PowerPolicySetSxWakeSettings().

◆ QueryForD3ColdInterface()

VOID FxPkgPnp::QueryForD3ColdInterface ( VOID  )

Definition at line 538 of file fxpkgpnpkm.cpp.

541{
543 PDEVICE_OBJECT topOfStack;
544 PDEVICE_OBJECT pdo;
547
548 //
549 // This function can be invoked multiple times, particularly if filters
550 // send IRP_MN_QUERY_CAPABILITIES. So bail out if the interface has already
551 // been acquired.
552 //
553
557 return;
558 }
559
561
562 if (pdo == NULL) {
563 return;
564 }
565
566 //
567 // Get the top of stack device object, even though normal filters and the
568 // FDO may not have been added to the stack yet to ensure that this
569 // query-interface is seen by bus filters. Specifically, in a PCI device
570 // which is soldered to the motherboard, ACPI will be on the stack and it
571 // needs to see this IRP.
572 //
573 topOfStack = IoGetAttachedDeviceReference(pdo);
574 deviceObject.SetObject(topOfStack);
575 if (deviceObject.GetObject() != NULL) {
577 if (irp.GetIrp() == NULL) {
578
581 "Failed to allocate IRP to get D3COLD_SUPPORT_INTERFACE from !devobj %p",
582 pdo);
583 } else {
584
585 //
586 // Initialize the Irp
587 //
589
593 irp.SetParameterQueryInterfaceType(&GUID_D3COLD_SUPPORT_INTERFACE);
598
600
601 if (!NT_SUCCESS(status)) {
604 "!devobj %p declined to supply D3COLD_SUPPORT_INTERFACE",
605 pdo);
606
608 }
609 }
610 }
611 ObDereferenceObject(topOfStack);
612}
VOID SetParameterQueryInterfaceSize(__in USHORT Size)
Definition: fxirpkm.hpp:1082
CHECK_RETURN_IF_USER_MODE NTSTATUS SendIrpSynchronously(__in MdDeviceObject DeviceObject)
Definition: fxirpum.cpp:151
VOID SetMinorFunction(__in UCHAR MinorFunction)
Definition: fxirpum.cpp:967
VOID ClearNextStack(VOID)
Definition: fxirpum.cpp:1183
VOID SetParameterQueryInterfaceType(__in const GUID *InterfaceType)
Definition: fxirpkm.hpp:1063
VOID SetMajorFunction(__in UCHAR MajorFunction)
Definition: fxirpum.cpp:905
VOID SetParameterQueryInterfaceInterface(__in PINTERFACE Interface)
Definition: fxirpkm.hpp:1053
VOID SetParameterQueryInterfaceInterfaceSpecificData(__in PVOID InterfaceSpecificData)
Definition: fxirpkm.hpp:1091
VOID SetParameterQueryInterfaceVersion(__in USHORT Version)
Definition: fxirpkm.hpp:1073
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
PSET_D3COLD_SUPPORT SetD3ColdSupport
Definition: iotypes.h:7558
PGET_IDLE_WAKE_INFO GetIdleWakeInfo
Definition: iotypes.h:7559
#define IRP_MN_QUERY_INTERFACE
#define D3COLD_SUPPORT_INTERFACE_VERSION
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by Initialize().

◆ QueryForPowerThread()

virtual NTSTATUS FxPkgPnp::QueryForPowerThread ( VOID  )
privatepure virtual

◆ QueryForReenumerationInterface()

virtual VOID FxPkgPnp::QueryForReenumerationInterface ( VOID  )
privatepure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

◆ QueueToPowerThread()

VOID FxPkgPnp::QueueToPowerThread ( __in PWORK_QUEUE_ITEM  WorkItem)
inline

◆ ReadRegistryS0Idle()

VOID FxPkgPnp::ReadRegistryS0Idle ( __in PCUNICODE_STRING  ValueName,
__out BOOLEAN Enabled 
)
private

Definition at line 376 of file fxpkgpnpkm.cpp.

380{
383
385
386 //
387 // Modify the value of Enabled only if success
388 //
389 if (NT_SUCCESS(status)) {
390 ULONG value;
391
392 status = FxRegKey::_QueryULong(
394
395 if (NT_SUCCESS(status)) {
396 //
397 // Normalize the ULONG value into a BOOLEAN
398 //
399 *Enabled = (value == FALSE) ? FALSE : TRUE;
400 }
401 }
402}
FxAutoRegKey hKey
@ Enabled
Definition: mountmgr.h:179
#define STANDARD_RIGHTS_READ
Definition: nt_native.h:65
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243

Referenced by PowerPolicySetS0IdleSettings().

◆ ReadRegistrySxWake()

VOID FxPkgPnp::ReadRegistrySxWake ( __in PCUNICODE_STRING  ValueName,
__out BOOLEAN Enabled 
)
private

Definition at line 469 of file fxpkgpnpkm.cpp.

473{
476
478
479 //
480 // Modify the value of Enabled only if success
481 //
482 if (NT_SUCCESS(status)) {
483 ULONG value;
484
485 status = FxRegKey::_QueryULong(
487
488 if (NT_SUCCESS(status)) {
489 //
490 // Normalize the ULONG value into a BOOLEAN
491 //
492 *Enabled = (value == FALSE) ? FALSE : TRUE;
493 }
494 }
495}

Referenced by PowerPolicySetSxWakeSettings().

◆ ReadStateFromRegistry()

NTSTATUS FxPkgPnp::ReadStateFromRegistry ( _In_ PCUNICODE_STRING  ValueName,
_Out_ PULONG  Value 
)
private

Definition at line 105 of file fxpkgpnpum.cpp.

109{
110 DWORD err;
112 DWORD data;
114 HKEY pwrPolKey = NULL;
115 IWudfDeviceStack* devStack;
116
117 ASSERT(NULL != Value);
118 ASSERT(ValueName != NULL &&
119 ValueName->Length != 0 &&
120 ValueName->Buffer != NULL);
121
122 *Value = 0;
123 devStack = m_Device->GetDeviceStack();
124
125 err = RegOpenKeyEx(devStack->GetDeviceRegistryKey(),
127 0,
128 KEY_READ,
129 &pwrPolKey);
130 if (ERROR_SUCCESS != err) {
134 "RegOpenKeyEx returned error %d",
135 err);
136 goto Clean;
137 }
138
139 dataSize = sizeof(data);
140 err = RegQueryValueEx(pwrPolKey,
141 ValueName->Buffer,
142 NULL,
143 NULL,
144 (BYTE*) &data,
145 &dataSize);
146 if (ERROR_SUCCESS != err) {
150 "failed to read registry, "
151 "RegQueryValueEx returned error %d",
152 err);
153 goto Clean;
154 }
155
156 *Value = data;
158
159Clean:
160 if (NULL != pwrPolKey) {
161 RegCloseKey(pwrPolKey);
162 }
163
164 if (ERROR_SUCCESS == err) {
166 }
167 else {
168 PUMDF_VERSION_DATA driverVersion = devStack->GetMinDriverVersion();
169 BOOL preserveCompat =
170 devStack->ShouldPreserveIrpCompletionStatusCompatibility();
171
172 status = CHostFxUtil::NtStatusFromHr(HRESULT_FROM_WIN32(err),
173 driverVersion->MajorNumber,
174 driverVersion->MinorNumber,
175 preserveCompat);
176 }
177
178 return status;
179}
#define RegCloseKey(hKey)
Definition: registry.h:49
IWudfDeviceStack * GetDeviceStack(VOID)
Definition: fxdeviceum.hpp:435
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WUDF_POWER_POLICY_SETTINGS
Definition: device_common.h:45
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum GLsizei dataSize
Definition: glext.h:11123
#define KEY_READ
Definition: nt_native.h:1023
#define err(...)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegQueryValueEx
Definition: winreg.h:524

◆ RegisterCallbacks()

_Must_inspect_result_ NTSTATUS FxPkgPnp::RegisterCallbacks ( __in PWDF_PNPPOWER_EVENT_CALLBACKS  DispatchTable)

Definition at line 2667 of file fxpkgpnp.cpp.

2670{
2672
2673 //
2674 // Update the callback table.
2675 //
2676 m_DeviceD0Entry.m_Method = DispatchTable->EvtDeviceD0Entry;
2678 DispatchTable->EvtDeviceD0EntryPostInterruptsEnabled;
2680 DispatchTable->EvtDeviceD0ExitPreInterruptsDisabled;
2681 m_DeviceD0Exit.m_Method = DispatchTable->EvtDeviceD0Exit;
2682
2683 m_DevicePrepareHardware.m_Method = DispatchTable->EvtDevicePrepareHardware;
2684 m_DeviceReleaseHardware.m_Method = DispatchTable->EvtDeviceReleaseHardware;
2685
2686 m_DeviceQueryStop.m_Method = DispatchTable->EvtDeviceQueryStop;
2687 m_DeviceQueryRemove.m_Method = DispatchTable->EvtDeviceQueryRemove;
2688
2689 m_DeviceSurpriseRemoval.m_Method = DispatchTable->EvtDeviceSurpriseRemoval;
2690
2691 m_DeviceUsageNotification.m_Method = DispatchTable->EvtDeviceUsageNotification;
2692 m_DeviceUsageNotificationEx.m_Method = DispatchTable->EvtDeviceUsageNotificationEx;
2693 m_DeviceRelationsQuery.m_Method = DispatchTable->EvtDeviceRelationsQuery;
2694
2695 if (DispatchTable->EvtDeviceSelfManagedIoCleanup != NULL ||
2696 DispatchTable->EvtDeviceSelfManagedIoFlush != NULL ||
2697 DispatchTable->EvtDeviceSelfManagedIoInit != NULL ||
2698 DispatchTable->EvtDeviceSelfManagedIoSuspend != NULL ||
2699 DispatchTable->EvtDeviceSelfManagedIoRestart != NULL) {
2700
2702 this);
2703
2704 if (!NT_SUCCESS(status)) {
2705 return status;
2706 }
2707
2709 }
2710
2711 return STATUS_SUCCESS;
2712}
FxPnpDeviceQueryRemove m_DeviceQueryRemove
Definition: fxpkgpnp.hpp:4560
FxPnpDeviceD0Entry m_DeviceD0Entry
Definition: fxpkgpnp.hpp:4551
FxPnpDeviceQueryStop m_DeviceQueryStop
Definition: fxpkgpnp.hpp:4559
FxPnpDevicePrepareHardware m_DevicePrepareHardware
Definition: fxpkgpnp.hpp:4556
FxPnpDeviceSurpriseRemoval m_DeviceSurpriseRemoval
Definition: fxpkgpnp.hpp:4561
FxPnpDeviceD0EntryPostInterruptsEnabled m_DeviceD0EntryPostInterruptsEnabled
Definition: fxpkgpnp.hpp:4552
PFN_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED m_Method
PFN_WDF_DEVICE_D0_ENTRY m_Method
PFN_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DISABLED m_Method
PFN_WDF_DEVICE_D0_EXIT m_Method
PFN_WDF_DEVICE_PREPARE_HARDWARE m_Method
PFN_WDF_DEVICE_QUERY_REMOVE m_Method
PFN_WDF_DEVICE_QUERY_STOP m_Method
PFN_WDF_DEVICE_RELATIONS_QUERY m_Method
PFN_WDF_DEVICE_RELEASE_HARDWARE m_Method
PFN_WDF_DEVICE_SURPRISE_REMOVAL m_Method
PFN_WDF_DEVICE_USAGE_NOTIFICATION_EX m_Method
PFN_WDF_DEVICE_USAGE_NOTIFICATION m_Method
VOID InitializeMachine(__in PWDF_PNPPOWER_EVENT_CALLBACKS Callbacks)
static NTSTATUS _CreateAndInit(__deref_out FxSelfManagedIoMachine **SelfManagedIoMachine, __in FxPkgPnp *PkgPnp)
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:248

Referenced by Initialize().

◆ RegisterPowerPolicyCallbacks()

VOID FxPkgPnp::RegisterPowerPolicyCallbacks ( __in PWDF_POWER_POLICY_EVENT_CALLBACKS  Callbacks)

Definition at line 2715 of file fxpkgpnp.cpp.

2718{
2720 Callbacks->EvtDeviceArmWakeFromS0;
2722 Callbacks->EvtDeviceArmWakeFromSx;
2724 Callbacks->EvtDeviceArmWakeFromSxWithReason;
2725
2727 Callbacks->EvtDeviceDisarmWakeFromS0;
2729 Callbacks->EvtDeviceDisarmWakeFromSx;
2730
2732 Callbacks->EvtDeviceWakeFromS0Triggered;
2734 Callbacks->EvtDeviceWakeFromSxTriggered;
2735}
const struct winhelp_callbacks Callbacks
Definition: callback.c:161
PFN_WDF_DEVICE_ARM_WAKE_FROM_S0 m_Method
PFN_WDF_DEVICE_ARM_WAKE_FROM_SX m_Method
PFN_WDF_DEVICE_ARM_WAKE_FROM_SX_WITH_REASON m_MethodWithReason
PFN_WDF_DEVICE_DISARM_WAKE_FROM_S0 m_Method
PFN_WDF_DEVICE_DISARM_WAKE_FROM_SX m_Method
PFN_WDF_DEVICE_WAKE_FROM_S0_TRIGGERED m_Method
PFN_WDF_DEVICE_WAKE_FROM_SX_TRIGGERED m_Method
FxPowerDeviceArmWakeFromSx m_DeviceArmWakeFromSx
FxPowerDeviceWakeFromSxTriggered m_DeviceWakeFromSxTriggered
FxPowerDeviceArmWakeFromS0 m_DeviceArmWakeFromS0
FxPowerDeviceDisarmWakeFromS0 m_DeviceDisarmWakeFromS0
FxPowerDeviceWakeFromS0Triggered m_DeviceWakeFromS0Triggered

Referenced by Initialize().

◆ RegisterPowerPolicyWmiInstance()

NTSTATUS FxPkgPnp::RegisterPowerPolicyWmiInstance ( __in const GUID Guid,
__in FxWmiInstanceInternalCallbacks Callbacks,
__out FxWmiInstanceInternal **  Instance 
)

Definition at line 2738 of file fxpkgpnp.cpp.

2743{
2744 // WDF_WMI_PROVIDER_CONFIG config;
2745 // NTSTATUS status;
2746
2747 // WDF_WMI_PROVIDER_CONFIG_INIT(&config, Guid);
2748
2749 // //
2750 // // We are assuming we are registering either for the wait wake or device
2751 // // timeout GUIDs which both operate on BOOLEANs. If we expand this API in
2752 // // the future, have the caller pass in a config structure for the provider
2753 // // GUID.
2754 // //
2755 // config.MinInstanceBufferSize = sizeof(BOOLEAN);
2756
2757 // status = m_Device->m_PkgWmi->AddPowerPolicyProviderAndInstance(
2758 // &config,
2759 // Callbacks,
2760 // Instance);
2761
2762 // if (status == STATUS_OBJECT_NAME_COLLISION) {
2763 // status = STATUS_SUCCESS;
2764 // }
2765
2766 // if (!NT_SUCCESS(status)) {
2767 // DoTraceLevelMessage(
2768 // GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGPNP,
2769 // "Failed to register WMI power GUID %!STATUS!", status);
2770 // }
2771 //
2772 // return status;
2774 return STATUS_SUCCESS;
2775}

◆ ReleasePowerThread()

VOID FxPkgPnp::ReleasePowerThread ( VOID  )
private

Definition at line 5180 of file fxpkgpnp.cpp.

5197{
5198 BOOLEAN hadThread;
5199
5200 hadThread = m_HasPowerThread;
5201
5202 //
5203 // Set to FALSE before cleaning up the reference or thread itself in case
5204 // there is some other context trying to enqueue. The only way that could
5205 // be happening is if the power policy owner is not WDF and sends power irps
5206 // after query remove or surprise remove.
5207 //
5209
5210 //
5211 // Check for ownership
5212 //
5213 if (m_PowerThread != NULL) {
5214
5216
5217 //
5218 // Event on stack is used, which is fine since this code is invoked
5219 // only in KM. Verify this assumption.
5220 //
5221 // If this code is ever needed for UM, m_PowerThreadEvent should be
5222 // pre-initialized (simlar to the way m_RemoveEventUm is used)
5223 //
5225
5228
5230 //
5231 // Wait for all references to go away before exitting the thread.
5232 // A reference will be taken for every device in the stack above this
5233 // one which queried for the interface.
5234 //
5235 event.EnterCRAndWaitAndLeave();
5236 }
5237
5239
5240 //
5241 // Wait for the thread to exit and then delete it. Since we have
5242 // turned off the power policy state machine, we can safely do this here.
5243 // Any upper level clients will have also turned off their power policy
5244 // state machines.
5245 //
5248
5250 }
5251 else if (hadThread) {
5252 //
5253 // Release our reference
5254 //
5257 );
5258 }
5259}
virtual VOID DeleteObject(VOID)
BOOLEAN ExitThread(VOID)
#define WDF_VERIFY_KM_ONLY_CODE()
Definition: fxmacros.hpp:298
NTSTATUS EnterCRAndWaitAndLeave(VOID)
Definition: fxwaitlock.hpp:87

Referenced by CleanupStateMachines().

◆ ReleaseReenumerationInterface()

virtual VOID FxPkgPnp::ReleaseReenumerationInterface ( VOID  )
privatepure virtual

Implemented in FxPkgFdo, and FxPkgPdo.

Referenced by CleanupStateMachines().

◆ RemoveChildList()

VOID FxPkgPnp::RemoveChildList ( __in FxChildList List)

Definition at line 4983 of file fxpkgpnp.cpp.

4986{
4988 "Removing FxChildList %p, WDFCHILDLIST %p", List,
4989 List->GetHandle());
4990
4991 m_EnumInfo->m_ChildListList.Remove(GetDriverGlobals(), &List->m_TransactionLink);
4992
4993 //
4994
4995 //
4996}
VOID Remove(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxTransactionedEntry *Entry)

Referenced by FxDevice::RemoveChildList().

◆ RemoveDmaEnabler()

VOID FxPkgPnp::RemoveDmaEnabler ( __in FxDmaEnabler Enabler)

Definition at line 289 of file fxpkgpnpkm.cpp.

292{
294 "Removing DmaEnabler %p, WDFDMAENABLER %p",
295 Enabler, Enabler->GetObjectHandle());
296
297 m_DmaEnablerList->Remove(GetDriverGlobals(), &Enabler->m_TransactionLink);
298}

Referenced by FxDevice::RemoveDmaEnabler().

◆ RemoveInterruptObject()

VOID FxPkgPnp::RemoveInterruptObject ( __in FxInterrupt Interrupt)
protected

Definition at line 5965 of file fxpkgpnp.cpp.

5984{
5986 RemoveEntryList(&Interrupt->m_PnpList);
5987}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986

Referenced by FxInterrupt::DeleteObject().

◆ RemoveRemovalDevice()

VOID FxPkgPnp::RemoveRemovalDevice ( __in MdDeviceObject  DependentDevice)

Definition at line 4816 of file fxpkgpnp.cpp.

4819{
4820 if (m_RemovalDeviceList != NULL) {
4822 }
4823
4824 //
4825 // RemovalRelations are queried automatically by PnP when the device is
4826 // going to be query removed. No need to tell pnp that the list changed
4827 // until it needs to query for it.
4828 //
4829}

◆ RemoveUsageDevice()

VOID FxPkgPnp::RemoveUsageDevice ( __in MdDeviceObject  DependentDevice)

Definition at line 4742 of file fxpkgpnp.cpp.

◆ RevertUsageNotificationFlags()

VOID FxPkgPnp::RevertUsageNotificationFlags ( __in DEVICE_USAGE_NOTIFICATION_TYPE  Type,
__in BOOLEAN  InPath,
__in ULONG  OldFlags 
)
protected

Definition at line 4578 of file fxpkgpnp.cpp.

4600{
4601 //
4602 // Re-adjust our "special file count".
4603 //
4604 InPath = !InPath;
4605 AdjustUsageCount(Type, InPath);
4606
4607 //
4608 // Restore the flags on the device object.
4609 //
4611}
VOID __inline SetDeviceObjectFlags(_In_ ULONG Flags)
Definition: fxdevice.hpp:201
LONG AdjustUsageCount(__in DEVICE_USAGE_NOTIFICATION_TYPE Usage, __in BOOLEAN Add)
Definition: fxpkgpnp.hpp:3147

Referenced by PnpDeviceUsageNotification().

◆ RevokeDmaEnablerResources()

VOID FxPkgPnp::RevokeDmaEnablerResources ( __in FxDmaEnabler Enabler)

Definition at line 529 of file fxpkgpnpkm.cpp.

532{
533 // DmaEnabler->RevokeResources();
535}

Referenced by NotifyResourceobjectsToReleaseResources().

◆ SaveState()

VOID FxPkgPnp::SaveState ( __in BOOLEAN  UseCanSaveState)
protected

Definition at line 5831 of file fxpkgpnp.cpp.

5847{
5851 ULONG value;
5852
5853 //
5854 // We only have settings to save if we are the power policy owner
5855 //
5856 if (IsPowerPolicyOwner() == FALSE) {
5857 return;
5858 }
5859
5860 if (UseCanSaveState &&
5864 "Not saving wake settings for WDFDEVICE %p due to system power "
5865 "transition", m_Device->GetHandle());
5866 return;
5867 }
5868
5869 //
5870 // Check to see if there is anything to write out
5871 //
5874 return;
5875 }
5876
5877 //
5878 // No need to write out if user control is not enabled
5879 //
5882 return;
5883 }
5884
5885 //
5886 // If the device is in paging path we should not be touching registry during
5887 // power up because it may incur page fault which won't be satisfied if the
5888 // device is still not powered up, blocking power Irp. User control state
5889 // change will not get written if any at this time but will be flushed out
5890 // to registry during device disable/remove in the remove path.
5891 //
5893 return;
5894 }
5895
5896#if ((FX_CORE_MODE)==(FX_CORE_KERNEL_MODE))
5897
5899 if (!NT_SUCCESS(status)) {
5900 return;
5901 }
5902#else
5904#endif
5905
5910
5912
5914 }
5915
5920
5922
5924 }
5925}
BOOLEAN IsDevicePowerUpIrpPending(VOID)
Definition: fxpkgpnp.hpp:3113
VOID WriteStateToRegistry(__in HANDLE RegKey, __in PUNICODE_STRING ValueName, __in ULONG Value)
Definition: fxpkgpnpkm.cpp:301
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STANDARD_RIGHTS_WRITE
Definition: nt_native.h:66
Definition: name.c:39

◆ SendEventToAllWakeInterrupts()

VOID FxPkgPnp::SendEventToAllWakeInterrupts ( __in enum FxWakeInterruptEvents  WakeInterruptEvent)

Definition at line 6164 of file fxpkgpnp.cpp.

6182{
6183 FxInterrupt* pInterrupt;
6185
6186 if (m_WakeInterruptCount == 0) {
6187 return;
6188 }
6189
6190 //
6191 // Initialize the pending count to the wake interrupt count
6192 // If the event needs an acknowledgement, this variable will
6193 // be decremented as the interrupt machines ack.
6194 //
6196
6199 ple = ple->Flink) {
6200
6201 pInterrupt = CONTAINING_RECORD(ple, FxInterrupt, m_PnpList);
6202
6203 if (pInterrupt->IsWakeCapable()) {
6204 pInterrupt->ProcessWakeInterruptEvent(WakeInterruptEvent);
6205 }
6206
6207 }
6208}
__inline BOOLEAN IsWakeCapable(VOID)
VOID ProcessWakeInterruptEvent(__in FxWakeInterruptEvents Event)

◆ SendIrpSynchronously()

virtual NTSTATUS FxPkgPnp::SendIrpSynchronously ( FxIrp Irp)
protectedpure virtual

◆ SetChildBusInformation()

VOID FxPkgPnp::SetChildBusInformation ( __in PPNP_BUS_INFORMATION  BusInformation)
inline

Definition at line 3468 of file fxpkgpnp.hpp.

3471 {
3474 sizeof(PNP_BUS_INFORMATION));
3475 }
_In_ WDFDEVICE _In_ PPNP_BUS_INFORMATION BusInformation
Definition: wdfdevice.h:3915

◆ SetDeviceFailed()

VOID FxPkgPnp::SetDeviceFailed ( __in WDF_DEVICE_FAILED_ACTION  FailedAction)

Definition at line 3775 of file fxpkgpnp.cpp.

3796{
3798 MdDeviceObject pdo;
3799
3800#if (FX_CORE_MODE == FX_CORE_USER_MODE)
3801 if (GetDriverGlobals()->IsVersionGreaterThanOrEqualTo(2, 15) == FALSE &&
3803
3807 "WdfDeviceFailedAttemptRestart is only available for UMDF 2.15 "
3808 "and later drivers. Reverting to WdfDeviceFailedNoRestart.");
3809 }
3810#endif
3811
3813
3814 //
3815 // This will cause the PnP manager to tear down this stack, even if
3816 // the PDO can't be surprise-removed.
3817 //
3818 m_Failed = TRUE;
3819
3821 //
3822 // Attempt to get the PDO surprise-removed.
3823 //
3825
3826 if (NT_SUCCESS(status)) {
3827 return;
3828 }
3829 }
3830
3831#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
3832 //
3833 // In between creating a PDO WDFDEVICE and it starting, if this DDI is called,
3834 // we will not have a valid PDO. Make sure it is valid before we proceed.
3835 //
3837
3838 if (pdo != NULL) {
3839 //
3840 // Now tell the PnP manager to re-query us for our state.
3841 //
3842 MxDeviceObject physicalDeviceObject(pdo);
3843
3844 physicalDeviceObject.InvalidateDeviceState(
3846 );
3847 }
3848#else // USER_MODE
3852#endif
3853}
__inline MxDeviceObject * GetMxDeviceObject(VOID)
Definition: fxdevice.hpp:183
MdDeviceObject __inline GetSafePhysicalDevice(VOID)
Definition: fxdevice.hpp:1005
virtual NTSTATUS AskParentToRemoveAndReenumerate(VOID)=0
VOID InvalidateDeviceState(__in MdDeviceObject Fdo)
#define TRACINGDEVICE
Definition: dbgtrace.h:58
@ WdfDeviceFailedNoRestart
Definition: wdfdevice.h:470
_In_ WDFDEVICE _In_ WDF_DEVICE_FAILED_ACTION FailedAction
Definition: wdfdevice.h:3975

◆ SetInternalFailure()

VOID FxPkgPnp::SetInternalFailure ( VOID  )
protected

Definition at line 4856 of file fxpkgpnp.cpp.

4871{
4873
4874 MxDeviceObject physicalDeviceObject(
4876 );
4877 physicalDeviceObject.InvalidateDeviceState(
4879 );
4880}

Referenced by __drv_when(), CreatePowerThreadIfNeeded(), PnpEnableInterfacesAndRegisterWmi(), PowerSendPowerDownFailureEvent(), and PowerSendPowerUpFailureEvent().

◆ SetPendingDevicePowerIrp()

VOID FxPkgPnp::SetPendingDevicePowerIrp ( __inout FxIrp Irp)
inlineprotected

Definition at line 3050 of file fxpkgpnp.hpp.

3053 {
3055
3056 Irp->MarkIrpPending();
3057 m_PendingDevicePowerIrp = Irp->GetIrp();
3058
3059 if (Irp->GetParameterPowerStateDeviceState() > PowerDeviceD0) {
3060 //
3061 // We are powering down, capture the current power action. We will
3062 // reset it to PowerActionNone once we have powered up.
3063 //
3064 m_SystemPowerAction = (UCHAR) Irp->GetParameterPowerShutdownType();
3065 }
3066 }

Referenced by FxPkgPdo::DispatchDeviceSetPower(), and FxPkgFdo::LowerDevicePower().

◆ SetPendingPnpIrp()

VOID FxPkgPnp::SetPendingPnpIrp ( __inout FxIrp Irp,
__in BOOLEAN  MarkIrpPending = TRUE 
)
protected

Definition at line 4883 of file fxpkgpnp.cpp.

4887{
4888 if (m_PendingPnPIrp != NULL ) {
4889 FxIrp pendingIrp(m_PendingPnPIrp);
4890
4891 //
4892 // A state changing pnp irp is already pended. If we don't bugcheck
4893 // the pended pnp irp will be overwritten with new pnp irp and the old
4894 // one may never get completed, which may have drastic implications (
4895 // unresponsive system, power manager not sending Sx Irp etc.)
4896 //
4898 "A new state changing pnp irp %!pnpmn! IRP %p arrived while another "
4899 "pnp irp %!pnpmn! IRP %p is still pending WDFDEVICE %p\n",
4900 Irp->GetMinorFunction(), Irp->GetIrp(),
4901 pendingIrp.GetMinorFunction(),pendingIrp.GetIrp(),
4902 m_Device->GetHandle());
4903
4905 WDF_PNP_FATAL_ERROR, // specific type
4906 (ULONG_PTR)m_Device->GetHandle(), //parm 2
4907 (ULONG_PTR)Irp->GetIrp()); // parm 3
4908
4909 /* NOTREACHED */
4910 return;
4911 }
4912 if (MarkIrpPending) {
4913 Irp->MarkIrpPending();
4914 }
4915 m_PendingPnPIrp = Irp->GetIrp();
4916}
@ WDF_PNP_FATAL_ERROR
Definition: wdfbugcodes.h:69

Referenced by FxPkgPdo::_PnpEject(), FxPkgFdo::_PnpStartDeviceCompletionRoutine(), and PnpSurpriseRemoval().

◆ SetPendingPnpIrpStatus()

◆ SetPendingSystemPowerIrp()

VOID FxPkgPnp::SetPendingSystemPowerIrp ( __inout FxIrp Irp)
inlineprotected

Definition at line 3082 of file fxpkgpnp.hpp.

3085 {
3087 Irp->MarkIrpPending();
3088 m_PendingSystemPowerIrp = Irp->GetIrp();
3089 }

Referenced by FxPkgFdo::DispatchSystemSetPower(), and FxPkgPdo::DispatchSystemSetPower().

◆ SetPnpCaps()

VOID FxPkgPnp::SetPnpCaps ( __in PWDF_DEVICE_PNP_CAPABILITIES  PnpCapabilities)

Definition at line 5496 of file fxpkgpnp.cpp.

5512{
5513 LONG pnpCaps;
5514 KIRQL irql;
5515
5516 pnpCaps = 0;
5517 pnpCaps |= GET_PNP_CAP_BITS_FROM_STRUCT(PnpCapabilities, LockSupported);
5518 pnpCaps |= GET_PNP_CAP_BITS_FROM_STRUCT(PnpCapabilities, EjectSupported);
5520 pnpCaps |= GET_PNP_CAP_BITS_FROM_STRUCT(PnpCapabilities, DockDevice);
5521 pnpCaps |= GET_PNP_CAP_BITS_FROM_STRUCT(PnpCapabilities, UniqueID);
5522 pnpCaps |= GET_PNP_CAP_BITS_FROM_STRUCT(PnpCapabilities, SilentInstall);
5523 pnpCaps |= GET_PNP_CAP_BITS_FROM_STRUCT(PnpCapabilities, SurpriseRemovalOK);
5524 pnpCaps |= GET_PNP_CAP_BITS_FROM_STRUCT(PnpCapabilities, HardwareDisabled);
5525 pnpCaps |= GET_PNP_CAP_BITS_FROM_STRUCT(PnpCapabilities, NoDisplayInUI);
5526
5527 //
5528 // Since the caller of IRP_MN_QUERY_CAPABILITIES sets these 2 values to -1,
5529 // we can reuse the -1 as the default/no override value since the associated
5530 // PDEVICE_CAPAPBILITIES structure will have been predisposed to these values
5531 //
5532 if (PnpCapabilities->Address != (ULONG) -1) {
5534 }
5535 if (PnpCapabilities->UINumber != (ULONG) -1) {
5537 }
5538
5539 //
5540 // Use the FxPnpStateMask to keep the state mask while applying the new
5541 // pnp capabilities.
5542 //
5543 Lock(&irql);
5545 Unlock(irql);
5546}
#define GET_PNP_CAP_BITS_FROM_STRUCT(S, FieldName)
Definition: pnppriv.hpp:226
@ Removable
Definition: arc.h:81
_In_ WDFDEVICE _In_ PWDF_DEVICE_PNP_CAPABILITIES PnpCapabilities
Definition: wdfdevice.h:3857

◆ SetPnpState()

VOID FxPkgPnp::SetPnpState ( __in PWDF_DEVICE_STATE  State)

Definition at line 5579 of file fxpkgpnp.cpp.

5594{
5595 LONG pnpState;
5596 KIRQL irql;
5597
5598 pnpState = 0x0;
5600 pnpState |= GET_PNP_STATE_BITS_FROM_STRUCT(State, DontDisplayInUI);
5602 pnpState |= GET_PNP_STATE_BITS_FROM_STRUCT(State, NotDisableable);
5604 pnpState |= GET_PNP_STATE_BITS_FROM_STRUCT(State, ResourcesChanged);
5605
5606 //
5607 // Mask off FxPnpCapMask to keep the capabilities part of the bitfield
5608 // the same while change the pnp state.
5609 //
5610 Lock(&irql);
5612 Unlock(irql);
5613}
#define GET_PNP_STATE_BITS_FROM_STRUCT(S, FieldName)
Definition: pnppriv.hpp:221

◆ SetPowerCaps()

VOID FxPkgPnp::SetPowerCaps ( __in PWDF_DEVICE_POWER_CAPABILITIES  PowerCapabilities)

Definition at line 5683 of file fxpkgpnp.cpp.

5700{
5701 ULONG states, i;
5702 USHORT powerCaps;
5703
5704 states = 0x0;
5705
5706 //
5707 // Build up the device power state encoding into a temp var so that if we are
5708 // retrieving the encoding in another thread, we don't get a partial view
5709 //
5710 for (i = 0; i < ARRAY_SIZE(PowerCapabilities->DeviceState); i++) {
5711 _SetPowerCapState(i, PowerCapabilities->DeviceState[i], &states);
5712 }
5713
5714 m_PowerCaps.States = states;
5715
5716 //
5717 // Same idea. Build up the caps locally first so that when we assign them
5718 // into the object, it is assigned as a whole.
5719 //
5720 powerCaps = 0x0;
5721 powerCaps |= GET_POWER_CAP_BITS_FROM_STRUCT(PowerCapabilities, DeviceD1);
5722 powerCaps |= GET_POWER_CAP_BITS_FROM_STRUCT(PowerCapabilities, DeviceD2);
5723 powerCaps |= GET_POWER_CAP_BITS_FROM_STRUCT(PowerCapabilities, WakeFromD0);
5724 powerCaps |= GET_POWER_CAP_BITS_FROM_STRUCT(PowerCapabilities, WakeFromD1);
5725 powerCaps |= GET_POWER_CAP_BITS_FROM_STRUCT(PowerCapabilities, WakeFromD2);
5726 powerCaps |= GET_POWER_CAP_BITS_FROM_STRUCT(PowerCapabilities, WakeFromD3);
5727
5728 m_PowerCaps.Caps = powerCaps;
5729
5730 if (PowerCapabilities->DeviceWake != PowerDeviceMaximum) {
5732 }
5733 if (PowerCapabilities->SystemWake != PowerSystemMaximum) {
5735 }
5736
5740
5741 if (PowerCapabilities->IdealDxStateForSx != PowerDeviceMaximum) {
5742 //
5743 // Caller has already validated that IdealDxStateForSx is only set if
5744 // they device is the power policy owner.
5745 //
5747 PowerCapabilities->IdealDxStateForSx;
5748 }
5749}
#define GET_POWER_CAP_BITS_FROM_STRUCT(S, FieldName)
Definition: pnppriv.hpp:231
_In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_CAPABILITIES PowerCapabilities
Definition: wdfdevice.h:3886

◆ SetSpecialFileSupport()

VOID FxPkgPnp::SetSpecialFileSupport ( __in WDF_SPECIAL_FILE_TYPE  FileType,
__in BOOLEAN  Supported 
)

Definition at line 1307 of file fxpkgpnp.cpp.

1334{
1335 switch (FileType) {
1338 case WdfSpecialFileDump:
1339 case WdfSpecialFileBoot:
1341 break;
1342
1343 default:
1345 "Invalid special file type %x", FileType);
1346 }
1347}
VOID SetUsageSupport(__in DEVICE_USAGE_NOTIFICATION_TYPE Usage, __in BOOLEAN Supported)
Definition: fxpkgpnp.hpp:3138
@ Supported
Definition: classpnp.h:733
_In_ WDFDEVICE _In_ WDF_SPECIAL_FILE_TYPE FileType
Definition: wdfdevice.h:2741

◆ SetUsageNotificationFlags()

ULONG FxPkgPnp::SetUsageNotificationFlags ( __in DEVICE_USAGE_NOTIFICATION_TYPE  Type,
__in BOOLEAN  InPath 
)
protected

Definition at line 4497 of file fxpkgpnp.cpp.

4520{
4521 PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
4522 ULONG oldFlags, newFlags;
4523
4524 oldFlags = m_Device->GetDeviceObjectFlags();
4525
4526 //
4527
4528 //
4530 FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP,
4531 "Before: type %d, in path %d, special count %d, flags 0x%x, "
4532 "device %p (WDFDEVICE %p), is pageable capable %d",
4533 Type, InPath, GetUsageCount(Type), oldFlags,
4536
4537 //
4538 // Adjust our "special file count".
4539 //
4540 AdjustUsageCount(Type, InPath);
4541
4542 //
4543 // Boot notification doesn't require updating device flags.
4544 //
4546 return oldFlags;
4547 }
4548
4549 if (m_Device->IsFilter()) {
4550 //
4551 // Clear the previous flags and reset them to the attached
4552 // device's flags
4553 //
4554 newFlags = oldFlags & ~(DO_POWER_PAGABLE | DO_POWER_INRUSH);
4555 newFlags |= m_Device->GetAttachedDeviceObjectFlags() &
4557 m_Device->SetDeviceObjectFlags(newFlags);
4558 }
4559 else {
4560 if (InPath) {
4562 m_Device->GetDeviceObjectFlags() & ~DO_POWER_PAGABLE
4563 );
4564 }
4565 else {
4569 );
4570 }
4571 }
4572 }
4573
4574 return oldFlags;
4575}
ULONG __inline GetAttachedDeviceObjectFlags(VOID)
Definition: fxdevice.hpp:219
__inline BOOLEAN IsPowerPageableCapable(VOID)
Definition: fxdevice.hpp:1421

Referenced by PnpDeviceUsageNotification().

◆ SetUsageSupport()

VOID FxPkgPnp::SetUsageSupport ( __in DEVICE_USAGE_NOTIFICATION_TYPE  Usage,
__in BOOLEAN  Supported 
)
inlineprotected

Definition at line 3138 of file fxpkgpnp.hpp.

3142 {
3144 }

Referenced by SetSpecialFileSupport().

◆ ShouldProcessPnpEventOnDifferentThread()

BOOLEAN FxPkgPnp::ShouldProcessPnpEventOnDifferentThread ( __in KIRQL  CurrentIrql,
__in BOOLEAN  CallerSpecifiedProcessingOnDifferentThread 
)

Definition at line 88 of file pnpstatemachinekm.cpp.

142{
143 //
144 // For KMDF, we ignore what the caller of PnpProcessEvent specified (which
145 // should always be FALSE, BTW) and base our decision on the current IRQL.
146 // If we are running at PASSIVE_LEVEL, we process on the same thread else
147 // we queue a work item.
148 //
149 UNREFERENCED_PARAMETER(CallerSpecifiedProcessingOnDifferentThread);
150
151 ASSERT(FALSE == CallerSpecifiedProcessingOnDifferentThread);
152
153 return (CurrentIrql == PASSIVE_LEVEL) ? FALSE : TRUE;
154}

Referenced by PnpProcessEvent().

◆ ShouldProcessPowerPolicyEventOnDifferentThread()

BOOLEAN FxPkgPnp::ShouldProcessPowerPolicyEventOnDifferentThread ( __in KIRQL  CurrentIrql,
__in BOOLEAN  CallerSpecifiedProcessingOnDifferentThread 
)

Definition at line 69 of file powerpolicystatemachinekm.cpp.

125{
126 //
127 // For KMDF, we ignore what the caller of PowerPolicyProcessEvent specified
128 // (which should always be FALSE, BTW) and base our decision on the current
129 // IRQL. If we are running at PASSIVE_LEVEL, we process on the same thread
130 // else we queue a work item.
131 //
132 UNREFERENCED_PARAMETER(CallerSpecifiedProcessingOnDifferentThread);
133
134 ASSERT(FALSE == CallerSpecifiedProcessingOnDifferentThread);
135
136 return (CurrentIrql == PASSIVE_LEVEL) ? FALSE : TRUE;
137}

Referenced by PowerPolicyProcessEvent().

◆ SignalDeviceRemovedEvent()

VOID FxPkgPnp::SignalDeviceRemovedEvent ( VOID  )
inline

Definition at line 3782 of file fxpkgpnp.hpp.

3785 {
3787 }
__inline VOID Set()
Definition: mxeventkm.h:91

◆ SupportsWakeInterrupt()

BOOLEAN FxPkgPnp::SupportsWakeInterrupt ( VOID  )
inline

Definition at line 3620 of file fxpkgpnp.hpp.

3623 {
3624 if (m_WakeInterruptCount > 0) {
3625 return TRUE;
3626 } else {
3627 return FALSE;
3628 }
3629 }

Referenced by FxPkgFdo::HandleQueryCapabilities().

◆ UpdateWmiInstance()

NTSTATUS FxPkgPnp::UpdateWmiInstance ( _In_ FxWmiInstanceAction  Action,
_In_ BOOLEAN  ForS0Idle 
)
private

Definition at line 56 of file fxpkgpnpum.cpp.

60{
61 HRESULT hr;
63 IWudfDeviceStack* devStack;
64 WmiIdleWakeInstanceUpdate updateType;
65
66 devStack = m_Device->GetDeviceStack();
67
68 ASSERT(Action != InstanceActionInvalid);
69
70 if (Action == AddInstance) {
71 updateType = ForS0Idle ? AddS0IdleInstance : AddSxWakeInstance;
72 } else {
73 updateType = ForS0Idle ? RemoveS0IdleInstance : RemoveSxWakeInstance;
74 }
75
76 hr = devStack->UpdateIdleWakeWmiInstance(updateType);
77 if (S_OK == hr) {
79 }
80 else {
81 PUMDF_VERSION_DATA driverVersion = devStack->GetMinDriverVersion();
82 BOOL preserveCompat =
83 devStack->ShouldPreserveIrpCompletionStatusCompatibility();
84
85 status = CHostFxUtil::NtStatusFromHr(hr,
86 driverVersion->MajorNumber,
87 driverVersion->MinorNumber,
88 preserveCompat);
89 }
90
91 if (!NT_SUCCESS(status)) {
95 "failed to send ioctl to update %s WMI instance "
96 "%!STATUS!",
97 ForS0Idle ? "S0Idle" : "SxWake",
98 status);
99 }
100
101 return status;
102}
@ AddInstance
Definition: fxpkgpnp.hpp:429
#define S_OK
Definition: intsafe.h:52
HRESULT hr
Definition: shlfolder.c:183

Referenced by UpdateWmiInstanceForS0Idle(), and UpdateWmiInstanceForSxWake().

◆ UpdateWmiInstanceForS0Idle()

NTSTATUS FxPkgPnp::UpdateWmiInstanceForS0Idle ( __in FxWmiInstanceAction  Action)
private

Definition at line 243 of file fxpkgpnpum.cpp.

246{
248
249 //
250 // Send an IOCTL to redirector
251 // to add/remove S0Idle WMI instance.
252 //
254
255 return status;
256}
NTSTATUS UpdateWmiInstance(_In_ FxWmiInstanceAction Action, _In_ BOOLEAN ForS0Idle)
Definition: fxpkgpnpum.cpp:56

◆ UpdateWmiInstanceForSxWake()

NTSTATUS FxPkgPnp::UpdateWmiInstanceForSxWake ( __in FxWmiInstanceAction  Action)
private

Definition at line 281 of file fxpkgpnpum.cpp.

284{
286
287 //
288 // Send an IOCTL to redirector
289 // to add/remove SxWake WMI instance.
290 //
292
293 return status;
294}

◆ ValidateCmResource()

_Must_inspect_result_ NTSTATUS FxPkgPnp::ValidateCmResource ( __inout PCM_PARTIAL_RESOURCE_DESCRIPTOR CmResourceRaw,
__inout PCM_PARTIAL_RESOURCE_DESCRIPTOR CmResource 
)

Definition at line 4223 of file pnpstatemachine.cpp.

4241{
4244 FxCollectionEntry* curRaw;
4246 FxResourceCm* resRaw;
4248
4251
4252 res = NULL;
4253 resRaw = NULL;
4254
4256
4257 //
4258 // Find the resource in our list.
4259 //
4260 for (cur = m_Resources->Start(), curRaw = m_ResourcesRaw->Start();
4261 cur != m_Resources->End();
4262 cur = cur->Next(), curRaw = curRaw->Next()) {
4263
4265 resRaw = (FxResourceCm*) curRaw->m_Object;
4266
4267 if (&res->m_DescriptorClone == *CmResource) {
4268 break;
4269 }
4270 }
4271
4272 //
4273 // Error out if not found.
4274 //
4275 if (cur == m_Resources->End()) {
4279 "The translated PCM_PARTIAL_RESOURCE_DESCRIPTOR 0x%p is not valid, "
4280 "WDFDEVICE 0x%p, %!STATUS!",
4281 *CmResource, m_Device->GetHandle(), status);
4283 goto Done;
4284 }
4285
4286 //
4287 // Error out if the associated raw resource is not the same.
4288 //
4289 if (&resRaw->m_DescriptorClone != *CmResourceRaw) {
4293 "The raw PCM_PARTIAL_RESOURCE_DESCRIPTOR 0x%p is not valid, "
4294 "WDFDEVICE 0x%p, %!STATUS!",
4295 *CmResourceRaw, m_Device->GetHandle(), status);
4297 goto Done;
4298 }
4299
4300 //
4301 // Make sure driver didn't change any of the PnP settings.
4302 //
4303 if (sizeof(res->m_Descriptor) !=
4304 RtlCompareMemory(&res->m_DescriptorClone,
4305 &res->m_Descriptor,
4306 sizeof(res->m_Descriptor))) {
4310 "The translated PCM_PARTIAL_RESOURCE_DESCRIPTOR 0x%p is not valid, "
4311 "driver cannot change the assigned PnP resources, WDFDEVICE 0x%p, "
4312 "%!STATUS!",
4313 *CmResource, m_Device->GetHandle(), status);
4315 goto Done;
4316 }
4317
4318 if (sizeof(resRaw->m_Descriptor) !=
4320 &resRaw->m_Descriptor,
4321 sizeof(resRaw->m_Descriptor))) {
4325 "The raw PCM_PARTIAL_RESOURCE_DESCRIPTOR 0x%p is not valid, "
4326 "driver cannot change the assigned PnP resources, WDFDEVICE 0x%p, "
4327 "%!STATUS!",
4328 *CmResourceRaw, m_Device->GetHandle(), status);
4330 goto Done;
4331 }
4332
4333 //
4334 // Return the real descriptor.
4335 //
4336 ASSERT(res != NULL && resRaw != NULL);
4337 *CmResource = &res->m_Descriptor;
4338 *CmResourceRaw = &resRaw->m_Descriptor;
4339
4341
4342Done:
4343 return status;
4344}
CM_PARTIAL_RESOURCE_DESCRIPTOR m_DescriptorClone
Definition: fxresource.hpp:259
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
PFX_DRIVER_GLOBALS fxDriverGlobals
FxCollectionEntry * cur
GLuint res
Definition: glext.h:9613
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by ValidateInterruptResourceCm().

◆ ValidateInterruptResourceCm()

_Must_inspect_result_ NTSTATUS FxPkgPnp::ValidateInterruptResourceCm ( __in PCM_PARTIAL_RESOURCE_DESCRIPTOR  CmIntResourceRaw,
__in PCM_PARTIAL_RESOURCE_DESCRIPTOR  CmIntResource,
__in PWDF_INTERRUPT_CONFIG  Configuration 
)

Definition at line 4348 of file pnpstatemachine.cpp.

4367{
4369 PLIST_ENTRY le;
4370 FxInterrupt* interrupt;
4371 ULONG messageCount;
4373 PCM_PARTIAL_RESOURCE_DESCRIPTOR cmIntResourceRaw;
4374 PCM_PARTIAL_RESOURCE_DESCRIPTOR cmIntResource;
4375
4376 cmIntResourceRaw = CmIntResourceRaw;
4377 cmIntResource = CmIntResource;
4379
4380 //
4381 // Get the real descriptor not the copy.
4382 //
4383 status = ValidateCmResource(&cmIntResourceRaw, &cmIntResource);
4384 if (!NT_SUCCESS(status)) {
4385 goto Done;
4386 }
4387
4388 //
4389 // Make sure this is an interrupt resource.
4390 //
4391 if (cmIntResourceRaw->Type != CmResourceTypeInterrupt) {
4395 "The raw PCM_PARTIAL_RESOURCE_DESCRIPTOR 0x%p is not an "
4396 "interrupt resource, WDFDEVICE 0x%p, %!STATUS!",
4397 CmIntResourceRaw, m_Device->GetHandle(), status);
4399 goto Done;
4400 }
4401
4402 if (cmIntResource->Type != CmResourceTypeInterrupt) {
4406 "The translated PCM_PARTIAL_RESOURCE_DESCRIPTOR 0x%p is not an "
4407 "interrupt resource, WDFDEVICE 0x%p, %!STATUS!",
4408 CmIntResource, m_Device->GetHandle(), status);
4410 goto Done;
4411 }
4412
4413 //
4414 // Make sure resource was not claimed by another interrupt.
4415 // Multi-message MSI 2.2 interrupts: allowed to reuse claimed resources.
4416 // Driver must create them sequentially.
4417 // Line-based interrupts: allowed to reuse claimed resources.
4418 // Driver can create them out-of-order.
4419 // Other MSI: not allowed to reuse claimed resources.
4420 //
4421 messageCount = 0;
4422
4423 for (le = m_InterruptListHead.Flink;
4424 le != &m_InterruptListHead;
4425 le = le->Flink) {
4426
4427 interrupt = CONTAINING_RECORD(le, FxInterrupt, m_PnpList);
4428
4429 if (cmIntResource != interrupt->GetResources()) {
4430 //
4431 // Multi-message MSI 2.2 interrupts must be sequential.
4432 //
4433 if (messageCount != 0) {
4437 "Multi-message MSI 2.2 interrupts must be created "
4438 "sequentially, WDFDEVICE 0x%p, %!STATUS!",
4441 goto Done;
4442 }
4443
4444 continue;
4445 }
4446
4447 if (interrupt->IsWakeCapable() &&
4448 Configuration->PassiveHandling) {
4451 "The PCM_PARTIAL_RESOURCE_DESCRIPTOR 0x%p was already used "
4452 "to create a wakable interrupt 0x%p, WDFDEVICE 0x%p and "
4453 "any functional interrupt being shared with wakable interrupt "
4454 "can not use passive level handling",
4455 CmIntResource, interrupt->GetHandle(),
4456 m_Device->GetHandle());
4458 goto Done;
4459 }
4460
4461 if (interrupt->IsPassiveHandling() &&
4462 Configuration->CanWakeDevice) {
4465 "The PCM_PARTIAL_RESOURCE_DESCRIPTOR 0x%p was already used "
4466 "to create a passive level interrupt 0x%p, WDFDEVICE 0x%p and "
4467 "is now being used to create a wakable interrupt. A functional "
4468 "passive level interrupt can not be shared with wakable interrupt",
4469 CmIntResource, interrupt->GetHandle(),
4470 m_Device->GetHandle());
4472 goto Done;
4473 }
4474
4475 //
4476 // Check for multi-message MSI 2.2 interrupts. These are allowed
4477 // to use the same resource.
4478 // We allow line based interrupts to reuse claimed resources.
4479 //
4480 if (FxInterrupt::_IsMessageInterrupt(cmIntResource->Flags) == FALSE) {
4483 "The PCM_PARTIAL_RESOURCE_DESCRIPTOR 0x%p was already used "
4484 "to create interrupt 0x%p, WDFDEVICE 0x%p",
4485 CmIntResource, interrupt->GetHandle(),
4486 m_Device->GetHandle());
4487 continue;
4488 }
4489
4490 //
4491 // Only allow the correct # of messages.
4492 //
4493 messageCount++;
4494 if (messageCount >
4495 cmIntResourceRaw->u.MessageInterrupt.Raw.MessageCount) {
4496
4500 "All the MSI 2.2 interrupts for "
4501 "PCM_PARTIAL_RESOURCE_DESCRIPTOR 0x%p are already created, "
4502 "WDFDEVICE 0x%p, %!STATUS!",
4503 CmIntResource, m_Device->GetHandle(), status);
4505 goto Done;
4506 }
4507 }
4508
4510
4511Done:
4512 return status;
4513}
__inline BOOLEAN IsPassiveHandling(VOID)
PCM_PARTIAL_RESOURCE_DESCRIPTOR GetResources(VOID)
_Must_inspect_result_ NTSTATUS ValidateCmResource(__inout PCM_PARTIAL_RESOURCE_DESCRIPTOR *CmResourceRaw, __inout PCM_PARTIAL_RESOURCE_DESCRIPTOR *CmResource)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG Configuration
Definition: wdfinterrupt.h:374

◆ WakeInterruptCreated()

VOID FxPkgPnp::WakeInterruptCreated ( VOID  )
inline

Definition at line 4074 of file fxpkgpnp.hpp.

4077 {
4079
4081 }

Referenced by FxInterrupt::CreateWakeInterruptMachine().

◆ WriteStateToRegistry()

VOID FxPkgPnp::WriteStateToRegistry ( __in HANDLE  RegKey,
__in PUNICODE_STRING  ValueName,
__in ULONG  Value 
)
private

Definition at line 301 of file fxpkgpnpkm.cpp.

306{
307 ZwSetValueKey(RegKey, ValueName, 0, REG_DWORD, &Value, sizeof(Value));
308}

Referenced by SaveState().

Member Data Documentation

◆ _PowerPolDevicePowerDownComplete

__drv_sameIRQL VOID FxPkgPnp::_PowerPolDevicePowerDownComplete
staticprotected

Definition at line 2755 of file fxpkgpnp.hpp.

Referenced by PowerPolicySendDevicePowerRequest().

◆ _PowerPolDevicePowerUpComplete

__drv_sameIRQL VOID FxPkgPnp::_PowerPolDevicePowerUpComplete
staticprotected

Definition at line 2759 of file fxpkgpnp.hpp.

Referenced by PowerPolicySendDevicePowerRequest().

◆ _PowerPolDeviceWaitWakeComplete

__drv_sameIRQL VOID FxPkgPnp::_PowerPolDeviceWaitWakeComplete
staticprotected

Definition at line 2751 of file fxpkgpnp.hpp.

Referenced by PowerPolicySendWaitWakeRequest().

◆ _PowerPolicyUsbSelectiveSuspendCompletionRoutine

__drv_sameIRQL NTSTATUS FxPkgPnp::_PowerPolicyUsbSelectiveSuspendCompletionRoutine
staticprotected

Definition at line 2805 of file fxpkgpnp.hpp.

◆ _PowerPolicyWaitWakeCompletionRoutine

__drv_sameIRQL NTSTATUS FxPkgPnp::_PowerPolicyWaitWakeCompletionRoutine
staticprotected

Definition at line 2801 of file fxpkgpnp.hpp.

Referenced by DispatchWaitWake().

◆ _PowerWaitWakeCancelRoutine

VOID FxPkgPnp::_PowerWaitWakeCancelRoutine
staticprotected

Definition at line 2736 of file fxpkgpnp.hpp.

Referenced by DispatchWaitWake().

◆ FxInterrupt

friend FxPkgPnp::FxInterrupt
private

Definition at line 494 of file fxpkgpnp.hpp.

◆ FxPnpMachine

friend FxPkgPnp::FxPnpMachine
private

Definition at line 490 of file fxpkgpnp.hpp.

◆ FxPowerMachine

friend FxPkgPnp::FxPowerMachine
private

Definition at line 491 of file fxpkgpnp.hpp.

◆ FxPowerPolicyMachine

friend FxPkgPnp::FxPowerPolicyMachine
private

Definition at line 492 of file fxpkgpnp.hpp.

◆ FxPowerPolicyOwnerSettings

friend FxPkgPnp::FxPowerPolicyOwnerSettings
private

Definition at line 493 of file fxpkgpnp.hpp.

Referenced by Initialize().

◆ GUID_POWER_THREAD_INTERFACE

const GUID FxPkgPnp::GUID_POWER_THREAD_INTERFACE
staticprotected
Initial value:
= {
0xdc7a8e51, 0x49b3, 0x4a3a, { 0x9e, 0x81, 0x62, 0x52, 0x05, 0xe7, 0xd7, 0x29 }
}

Definition at line 4282 of file fxpkgpnp.hpp.

Referenced by HandleQueryInterface(), and FxPkgFdo::QueryForPowerThread().

◆ m_AchievedStart

BOOLEAN FxPkgPnp::m_AchievedStart
private

Definition at line 4344 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), and PnpIncrementRestartCountLogic().

◆ m_BusEnumRetries

UCHAR FxPkgPnp::m_BusEnumRetries
protected

Definition at line 4237 of file fxpkgpnp.hpp.

Referenced by FxPkgFdo::FxPkgFdo().

◆ m_BusInformation

PNP_BUS_INFORMATION FxPkgPnp::m_BusInformation
protected

◆ m_CapsQueried

BOOLEAN FxPkgPnp::m_CapsQueried
protected

◆ m_CleanupEventUm

FxCREvent FxPkgPnp::m_CleanupEventUm
private

Definition at line 4304 of file fxpkgpnp.hpp.

Referenced by CleanupStateMachines(), and Initialize().

◆ m_D3ColdInterface

◆ m_DeviceD0Entry

FxPnpDeviceD0Entry FxPkgPnp::m_DeviceD0Entry

Definition at line 4551 of file fxpkgpnp.hpp.

Referenced by RegisterCallbacks().

◆ m_DeviceD0EntryPostInterruptsEnabled

FxPnpDeviceD0EntryPostInterruptsEnabled FxPkgPnp::m_DeviceD0EntryPostInterruptsEnabled

Definition at line 4552 of file fxpkgpnp.hpp.

Referenced by RegisterCallbacks().

◆ m_DeviceD0Exit

◆ m_DeviceD0ExitPreInterruptsDisabled

FxPnpDeviceD0ExitPreInterruptsDisabled FxPkgPnp::m_DeviceD0ExitPreInterruptsDisabled

Definition at line 4553 of file fxpkgpnp.hpp.

Referenced by PowerGotoDxIoStopped(), PowerGotoDxIoStoppedNP(), and RegisterCallbacks().

◆ m_DeviceInterfaceHead

◆ m_DeviceInterfaceLock

◆ m_DeviceInterfacesCanBeEnabled

BOOLEAN FxPkgPnp::m_DeviceInterfacesCanBeEnabled

◆ m_DevicePowerState

BYTE FxPkgPnp::m_DevicePowerState

Definition at line 4105 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), and PowerSetDevicePowerState().

◆ m_DevicePowerStateOld

BYTE FxPkgPnp::m_DevicePowerStateOld

Definition at line 4108 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), and PowerSetDevicePowerState().

◆ m_DevicePrepareHardware

FxPnpDevicePrepareHardware FxPkgPnp::m_DevicePrepareHardware

Definition at line 4556 of file fxpkgpnp.hpp.

Referenced by __drv_when(), and RegisterCallbacks().

◆ m_DeviceQueryRemove

FxPnpDeviceQueryRemove FxPkgPnp::m_DeviceQueryRemove

Definition at line 4560 of file fxpkgpnp.hpp.

Referenced by RegisterCallbacks().

◆ m_DeviceQueryStop

FxPnpDeviceQueryStop FxPkgPnp::m_DeviceQueryStop

Definition at line 4559 of file fxpkgpnp.hpp.

Referenced by RegisterCallbacks().

◆ m_DeviceRelationsQuery

FxPnpDeviceRelationsQuery FxPkgPnp::m_DeviceRelationsQuery

◆ m_DeviceReleaseHardware

FxPnpDeviceReleaseHardware FxPkgPnp::m_DeviceReleaseHardware

Definition at line 4557 of file fxpkgpnp.hpp.

Referenced by PnpReleaseHardware(), and RegisterCallbacks().

◆ m_DeviceRemoveProcessed

MxEvent* FxPkgPnp::m_DeviceRemoveProcessed
protected

◆ m_DeviceStopCount

ULONG FxPkgPnp::m_DeviceStopCount

Definition at line 4146 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), and if().

◆ m_DeviceSurpriseRemoval

FxPnpDeviceSurpriseRemoval FxPkgPnp::m_DeviceSurpriseRemoval

Definition at line 4561 of file fxpkgpnp.hpp.

Referenced by RegisterCallbacks().

◆ m_DeviceUsageNotification

FxPnpDeviceUsageNotification FxPkgPnp::m_DeviceUsageNotification

Definition at line 4547 of file fxpkgpnp.hpp.

Referenced by PnpDeviceUsageNotification(), and RegisterCallbacks().

◆ m_DeviceUsageNotificationEx

FxPnpDeviceUsageNotificationEx FxPkgPnp::m_DeviceUsageNotificationEx

Definition at line 4548 of file fxpkgpnp.hpp.

Referenced by PnpDeviceUsageNotification(), and RegisterCallbacks().

◆ m_DeviceWake

BYTE FxPkgPnp::m_DeviceWake[DeviceWakeStates]
protected

◆ m_DmaEnablerList

◆ m_DxArmedForWakeNPOtherStates

◆ m_DxArmedForWakeOtherStates

◆ m_DxSurpriseRemovedOtherStates

const POWER_EVENT_TARGET_STATE FxPkgPnp::m_DxSurpriseRemovedOtherStates[]
staticprivate

Definition at line 4420 of file fxpkgpnp.hpp.

◆ m_EnumInfo

◆ m_Failed

BOOLEAN FxPkgPnp::m_Failed

Definition at line 4095 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), HandleQueryPnpDeviceState(), and SetDeviceFailed().

◆ m_FailedAction

BYTE FxPkgPnp::m_FailedAction
protected

Definition at line 4191 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), and SetDeviceFailed().

◆ m_HasPowerThread

BOOLEAN FxPkgPnp::m_HasPowerThread
protected

◆ m_InternalFailure

BOOLEAN FxPkgPnp::m_InternalFailure
protected

Definition at line 4249 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), HandleQueryPnpDeviceState(), and SetInternalFailure().

◆ m_InterruptListHead

◆ m_InterruptObjectCount

ULONG FxPkgPnp::m_InterruptObjectCount
private

◆ m_IoConnectInterruptEx

PFN_IO_CONNECT_INTERRUPT_EX FxPkgPnp::m_IoConnectInterruptEx
protected

Definition at line 4288 of file fxpkgpnp.hpp.

Referenced by FxInterrupt::ConnectInternal(), and FxPkgPnp().

◆ m_IoDisconnectInterruptEx

PFN_IO_DISCONNECT_INTERRUPT_EX FxPkgPnp::m_IoDisconnectInterruptEx
protected

Definition at line 4289 of file fxpkgpnp.hpp.

Referenced by FxInterrupt::DisconnectInternal(), and FxPkgPnp().

◆ m_IoReportInterruptActive

PFN_IO_REPORT_INTERRUPT_ACTIVE FxPkgPnp::m_IoReportInterruptActive
protected

Definition at line 4293 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), and FxInterrupt::ReportActive().

◆ m_IoReportInterruptInactive

PFN_IO_REPORT_INTERRUPT_INACTIVE FxPkgPnp::m_IoReportInterruptInactive
protected

Definition at line 4294 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), and FxInterrupt::ReportInactive().

◆ m_NotPowerPolOwnerDxStates

◆ m_NotPowerPolOwnerGotoD0InD0States

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_NotPowerPolOwnerGotoD0InD0States
staticprivate

◆ m_NotPowerPolOwnerGotoD0States

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_NotPowerPolOwnerGotoD0States
staticprivate

◆ m_NotPowerPolOwnerGotoDxInDxStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_NotPowerPolOwnerGotoDxInDxStates
staticprivate
Initial value:

Definition at line 4498 of file fxpkgpnp.hpp.

◆ m_NotPowerPolOwnerGotoDxStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_NotPowerPolOwnerGotoDxStates
staticprivate

◆ m_NotPowerPolOwnerObjectCreatedStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_NotPowerPolOwnerObjectCreatedStates
staticprivate

◆ m_NotPowerPolOwnerRemovedStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_NotPowerPolOwnerRemovedStates
staticprivate

◆ m_NotPowerPolOwnerStartingFailedStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_NotPowerPolOwnerStartingFailedStates
staticprivate
Initial value:

Definition at line 4496 of file fxpkgpnp.hpp.

◆ m_NotPowerPolOwnerStartingStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_NotPowerPolOwnerStartingStates
staticprivate

◆ m_NotPowerPolOwnerStartingSucceededStates

◆ m_NotPowerPolOwnerStoppedStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_NotPowerPolOwnerStoppedStates
staticprivate

◆ m_NotPowerPolOwnerStoppingPoweringDownStates

◆ m_NotPowerPolOwnerStoppingPoweringUpStates

◆ m_NotPowerPolOwnerStoppingWaitForImplicitPowerDownStates

◆ m_PendingChildCount

LONG FxPkgPnp::m_PendingChildCount
protected

Definition at line 4178 of file fxpkgpnp.hpp.

Referenced by ChildRemoved(), FinishInitialize(), FxPkgPnp(), and ~FxPkgPnp().

◆ m_PendingDevicePowerIrp

◆ m_PendingPnPIrp

◆ m_PendingSystemPowerIrp

◆ m_PnpCapsAddress

ULONG FxPkgPnp::m_PnpCapsAddress

◆ m_PnpCapsUINumber

ULONG FxPkgPnp::m_PnpCapsUINumber

◆ m_PnpEjectFailedOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpEjectFailedOtherStates
staticprivate
Initial value:

Definition at line 4399 of file fxpkgpnp.hpp.

◆ m_PnpFailedIoStartingOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpFailedIoStartingOtherStates
staticprivate

◆ m_PnpFailedPowerDownOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpFailedPowerDownOtherStates
staticprivate

◆ m_PnpFailedWaitForRemoveOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpFailedWaitForRemoveOtherStates
staticprivate

◆ m_PnpHardwareAvailableOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpHardwareAvailableOtherStates
staticprivate
Initial value:

Definition at line 4387 of file fxpkgpnp.hpp.

◆ m_PnpInitOtherStates

◆ m_PnpInitQueryRemoveOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpInitQueryRemoveOtherStates
staticprivate
Initial value:

Definition at line 4394 of file fxpkgpnp.hpp.

◆ m_PnpInitStartingOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpInitStartingOtherStates
staticprivate
Initial value:

Definition at line 4386 of file fxpkgpnp.hpp.

◆ m_PnpMachine

◆ m_PnpQueriedRemovingOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpQueriedRemovingOtherStates
staticprivate
Initial value:

Definition at line 4393 of file fxpkgpnp.hpp.

◆ m_PnpQueryRemovePendingOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpQueryRemovePendingOtherStates
staticprivate

◆ m_PnpQueryStopPendingOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpQueryStopPendingOtherStates
staticprivate

◆ m_PnpRemovedPdoWaitOtherStates

◆ m_PnpRestartHardwareAvailableOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpRestartHardwareAvailableOtherStates
staticprivate

◆ m_PnpRestartingOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpRestartingOtherStates
staticprivate

◆ m_PnpRestartOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpRestartOtherStates
staticprivate

◆ m_PnpRestartReleaseHardware

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpRestartReleaseHardware
staticprivate

◆ m_PnpStartedOtherStates

◆ m_PnpStartedRemovingOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpStartedRemovingOtherStates
staticprivate

◆ m_PnpStartedStoppingFailedOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpStartedStoppingFailedOtherStates
staticprivate

◆ m_PnpStartedStoppingOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpStartedStoppingOtherStates
staticprivate

◆ m_PnpStateAndCaps

◆ m_PnpStateCallbacks

FxPnpStateCallback* FxPkgPnp::m_PnpStateCallbacks
private

Definition at line 4374 of file fxpkgpnp.hpp.

Referenced by FinishInitialize(), FxPkgPnp(), PnpEnterNewState(), and ~FxPkgPnp().

◆ m_PnpStoppedOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpStoppedOtherStates
staticprivate

◆ m_PnpStoppedWaitForStartCompletionOtherStates

const PNP_EVENT_TARGET_STATE FxPkgPnp::m_PnpStoppedWaitForStartCompletionOtherStates
staticprivate

◆ m_PowerCaps

◆ m_PowerD0ArmedForWakeNPOtherStates

◆ m_PowerD0ArmedForWakeOtherStates

◆ m_PowerD0BusWakeOwnerNPOtherStates

◆ m_PowerD0BusWakeOwnerOtherStates

◆ m_PowerD0NPOtherStates

◆ m_PowerD0OtherStates

◆ m_PowerDNotZeroNPOtherStates

const POWER_EVENT_TARGET_STATE FxPkgPnp::m_PowerDNotZeroNPOtherStates
staticprivate

◆ m_PowerDNotZeroOtherStates

const POWER_EVENT_TARGET_STATE FxPkgPnp::m_PowerDNotZeroOtherStates
staticprivate

◆ m_PowerDxStoppedOtherStates

const POWER_EVENT_TARGET_STATE FxPkgPnp::m_PowerDxStoppedOtherStates
staticprivate
Initial value:

Definition at line 4422 of file fxpkgpnp.hpp.

◆ m_PowerMachine

◆ m_PowerPolCancelingWakeForSystemSleepOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolCancelingWakeForSystemSleepOtherStates
staticprivate

◆ m_PowerPolCancelingWakeForSystemSleepWakeCanceledOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolCancelingWakeForSystemSleepWakeCanceledOtherStates
staticprivate

◆ m_PowerPolCancelUsbSSOtherStates

◆ m_PowerPolDevicePowerRequestFailedOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolDevicePowerRequestFailedOtherStates
staticprivate

◆ m_PowerPolDisarmingWakeForSystemSleepCompletePowerUpOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolDisarmingWakeForSystemSleepCompletePowerUpOtherStates
staticprivate

◆ m_PowerPolicyMachine

FxPowerPolicyMachine FxPkgPnp::m_PowerPolicyMachine

Definition at line 4153 of file fxpkgpnp.hpp.

Referenced by __drv_maxIRQL(), FxPkgFdo::_Create(), _S0IdleQueryInstance(), _SxWakeQueryInstance(), CleanupStateMachines(), FxPkgFdo::DispatchDeviceSetPower(), FxPkgPdo::DispatchDeviceSetPower(), DispatchWaitWake(), if(), Initialize(), IsPowerPolicyOwner(), IsS0IdleSystemManaged(), IsS0IdleUsbSSEnabled(), IsS0IdleWakeFromS0Enabled(), IsSxWakeEnabled(), NotPowerPolicyOwnerEnterNewState(), PnpPowerReferenceDuringQueryPnp(), FxDevice::PoFxDevicePowerNotRequired(), FxDevice::PoFxDevicePowerRequired(), PostCreateDeviceInitialize(), PowerDereference(), PowerMakeWakeRequestNonCancelable(), FxPkgPdo::PowerNotifyParentChildWakeArmed(), FxPkgPdo::PowerNotifyParentChildWakeDisarmed(), PowerPolicyBlockChildrenPowerUp(), PowerPolicyCancelUsbSS(), PowerPolicyCancelUsbSSIfCapable(), PowerPolicyCancelWaitWake(), PowerPolicyCanChildPowerUp(), PowerPolicyCanIdlePowerDown(), PowerPolicyCheckAssumptions(), PowerPolicyChildPoweredDown(), PowerPolicyChildrenCanPowerUp(), PowerPolicyDisarmWakeFromSx(), PowerPolicyEnterNewState(), PowerPolicyGetCurrentWakeReason(), PowerPolicyProcessEvent(), PowerPolicyProcessEventInner(), PowerPolicySendDevicePowerRequest(), PowerPolicySendWaitWakeRequest(), PowerPolicySetS0IdleSettings(), PowerPolicySetS0IdleState(), PowerPolicySetSxWakeSettings(), PowerPolicySetSxWakeState(), PowerPolicyShouldPropagateWakeStatusToChildren(), PowerPolicyUpdateSystemWakeSource(), PowerReference(), PowerSendIdlePowerEvent(), PowerSendPowerDownEvents(), PowerSendPowerDownFailureEvent(), FxDevice::ProcessWmiPowerQueryOrSetData(), QueryForCapabilities(), RegisterPowerPolicyCallbacks(), SaveState(), and SetPowerCaps().

◆ m_PowerPolicyStateCallbacks

FxPowerPolicyStateCallback* FxPkgPnp::m_PowerPolicyStateCallbacks
private

◆ m_PowerPolIdleCapableDeviceIdleOtherStates

◆ m_PowerPolIoPresentArmedOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolIoPresentArmedOtherStates
staticprivate

◆ m_PowerPolIoPresentArmedWakeCanceledOtherStates

◆ m_PowerPolObjectCreatedOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolObjectCreatedOtherStates
staticprivate
Initial value:

Definition at line 4424 of file fxpkgpnp.hpp.

◆ m_PowerPolRemovedOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolRemovedOtherStates
staticprivate
Initial value:

Definition at line 4488 of file fxpkgpnp.hpp.

◆ m_PowerPolRestartingOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolRestartingOtherStates
staticprivate

◆ m_PowerPolS0NoWakeCompletePowerUpOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolS0NoWakeCompletePowerUpOtherStates
staticprivate

◆ m_PowerPolS0NoWakePowerUpOtherStates

◆ m_PowerPolS0WakeCompletePowerUpOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolS0WakeCompletePowerUpOtherStates
staticprivate

◆ m_PowerPolSleepingNoWakeCompletePowerDownOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSleepingNoWakeCompletePowerDownOtherStates
staticprivate

◆ m_PowerPolSleepingNoWakePowerDownOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSleepingNoWakePowerDownOtherStates
staticprivate

◆ m_PowerPolSleepingSendWakeOtherStates

◆ m_PowerPolSleepingWakePowerDownFailedOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSleepingWakePowerDownFailedOtherStates
staticprivate

◆ m_PowerPolSleepingWakePowerDownOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSleepingWakePowerDownOtherStates
staticprivate

◆ m_PowerPolSleepingWakeRevertArmWakeNPOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSleepingWakeRevertArmWakeNPOtherStates
staticprivate

◆ m_PowerPolSleepingWakeRevertArmWakeOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSleepingWakeRevertArmWakeOtherStates
staticprivate

◆ m_PowerPolSleepingWakeWakeArrivedNPOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSleepingWakeWakeArrivedNPOtherStates
staticprivate

◆ m_PowerPolSleepingWakeWakeArrivedOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSleepingWakeWakeArrivedOtherStates
staticprivate

◆ m_PowerPolStartedIdleCapableOtherStates

◆ m_PowerPolStartedOtherStates

◆ m_PowerPolStartedWaitForIdleTimeoutOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolStartedWaitForIdleTimeoutOtherStates
staticprivate

◆ m_PowerPolStartedWakeCapableOtherStates

◆ m_PowerPolStartingOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolStartingOtherStates
staticprivate

◆ m_PowerPolStoppedOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolStoppedOtherStates
staticprivate

◆ m_PowerPolStoppingCancelWakeOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolStoppingCancelWakeOtherStates
staticprivate

◆ m_PowerPolStoppingD0OtherStates

◆ m_PowerPolStoppingDisarmWakeCancelWakeOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolStoppingDisarmWakeCancelWakeOtherStates
staticprivate

◆ m_PowerPolStoppingDisarmWakeOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolStoppingDisarmWakeOtherStates
staticprivate

◆ m_PowerPolStoppingOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolStoppingOtherStates
staticprivate

◆ m_PowerPolStoppingResetDeviceCompletePowerUpOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolStoppingResetDeviceCompletePowerUpOtherStates
staticprivate

◆ m_PowerPolStoppingResetDeviceOtherStates

◆ m_PowerPolSystemAsleepWakeArmedNPOtherStates

◆ m_PowerPolSystemAsleepWakeArmedOtherStates

◆ m_PowerPolSystemSleepNeedWakeCompletePowerUpOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSystemSleepNeedWakeCompletePowerUpOtherStates
staticprivate

◆ m_PowerPolSystemSleepNeedWakeOtherStates

◆ m_PowerPolSystemWakeDeviceToD0CompletePowerUpOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSystemWakeDeviceToD0CompletePowerUpOtherStates
staticprivate

◆ m_PowerPolSystemWakeDeviceToD0OtherStates

◆ m_PowerPolSystemWakeDeviceWakeCompletePowerUpOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSystemWakeDeviceWakeCompletePowerUpOtherStates
staticprivate

◆ m_PowerPolSystemWakeDeviceWakeEnabledNPOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSystemWakeDeviceWakeEnabledNPOtherStates
staticprivate

◆ m_PowerPolSystemWakeDeviceWakeEnabledOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSystemWakeDeviceWakeEnabledOtherStates
staticprivate

◆ m_PowerPolSystemWakeDeviceWakeEnabledWakeCanceledNPOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSystemWakeDeviceWakeEnabledWakeCanceledNPOtherStates
staticprivate

◆ m_PowerPolSystemWakeDeviceWakeEnabledWakeCanceledOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSystemWakeDeviceWakeEnabledWakeCanceledOtherStates
staticprivate

◆ m_PowerPolSystemWakeDeviceWakeInterruptFiredNPOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSystemWakeDeviceWakeInterruptFiredNPOtherStates
staticprivate

◆ m_PowerPolSystemWakeDeviceWakeInterruptFiredOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSystemWakeDeviceWakeInterruptFiredOtherStates
staticprivate

◆ m_PowerPolSystemWakeDeviceWakeTriggeredS0NPOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSystemWakeDeviceWakeTriggeredS0NPOtherStates
staticprivate

◆ m_PowerPolSystemWakeDeviceWakeTriggeredS0OtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolSystemWakeDeviceWakeTriggeredS0OtherStates
staticprivate

◆ m_PowerPolTimerExpiredNoWakeCompletePowerDownOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolTimerExpiredNoWakeCompletePowerDownOtherStates
staticprivate

◆ m_PowerPolTimerExpiredNoWakeOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolTimerExpiredNoWakeOtherStates
staticprivate

◆ m_PowerPolTimerExpiredWakeCapableCancelWakeOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolTimerExpiredWakeCapableCancelWakeOtherStates
staticprivate

◆ m_PowerPolTimerExpiredWakeCapablePowerDownFailedCancelWakeOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolTimerExpiredWakeCapablePowerDownFailedCancelWakeOtherStates
staticprivate

◆ m_PowerPolTimerExpiredWakeCapablePowerDownFailedWakeInterruptArrivedOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolTimerExpiredWakeCapablePowerDownFailedWakeInterruptArrivedOtherStates
staticprivate

◆ m_PowerPolTimerExpiredWakeCapablePowerDownOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolTimerExpiredWakeCapablePowerDownOtherStates
staticprivate

◆ m_PowerPolTimerExpiredWakeCapableSendWakeOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolTimerExpiredWakeCapableSendWakeOtherStates
staticprivate

◆ m_PowerPolTimerExpiredWakeCapableUsbSSOtherStates

◆ m_PowerPolTimerExpiredWakeCapableWakeArrivedOtherStates

◆ m_PowerPolTimerExpiredWakeCapableWakeFailedOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolTimerExpiredWakeCapableWakeFailedOtherStates
staticprivate

◆ m_PowerPolTimerExpiredWakeCapableWakeInterruptArrivedOtherStates

◆ m_PowerPolTimerExpiredWakeCapableWakeSucceededOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolTimerExpiredWakeCapableWakeSucceededOtherStates
staticprivate

◆ m_PowerPolTimerExpiredWakeCompletedPowerDownOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolTimerExpiredWakeCompletedPowerDownOtherStates
staticprivate

◆ m_PowerPolTimerExpiredWakeCompletedPowerUpOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolTimerExpiredWakeCompletedPowerUpOtherStates
staticprivate

◆ m_PowerPolWaitingArmedOtherStates

◆ m_PowerPolWaitingArmedWakeInterruptFiredDuringPowerDownOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolWaitingArmedWakeInterruptFiredDuringPowerDownOtherStates
staticprivate

◆ m_PowerPolWaitingArmedWakeInterruptFiredOtherStates

const POWER_POLICY_EVENT_TARGET_STATE FxPkgPnp::m_PowerPolWaitingArmedWakeInterruptFiredOtherStates
staticprivate

◆ m_PowerPolWaitingUnarmedOtherStates

◆ m_PowerPolWakeCapableDeviceIdleOtherStates

◆ m_PowerPolWokeFromS0OtherStates

◆ m_PowerStateCallbacks

FxPowerStateCallback* FxPkgPnp::m_PowerStateCallbacks
private

Definition at line 4376 of file fxpkgpnp.hpp.

Referenced by FinishInitialize(), FxPkgPnp(), PowerEnterNewState(), and ~FxPkgPnp().

◆ m_PowerStoppedOtherStates

const POWER_EVENT_TARGET_STATE FxPkgPnp::m_PowerStoppedOtherStates
staticprivate
Initial value:

Definition at line 4421 of file fxpkgpnp.hpp.

◆ m_PowerThread

FxSystemThread* FxPkgPnp::m_PowerThread
private

Definition at line 4350 of file fxpkgpnp.hpp.

Referenced by CreatePowerThread(), FxPkgPnp(), and ReleasePowerThread().

◆ m_PowerThreadEvent

FxCREvent* FxPkgPnp::m_PowerThreadEvent
private

Definition at line 4354 of file fxpkgpnp.hpp.

Referenced by _PowerThreadInterfaceDereference(), FxPkgPnp(), and ReleasePowerThread().

◆ m_PowerThreadInterface

◆ m_PowerThreadInterfaceReferenceCount

LONG FxPkgPnp::m_PowerThreadInterfaceReferenceCount
private

◆ m_QueryInterfaceHead

SINGLE_LIST_ENTRY FxPkgPnp::m_QueryInterfaceHead

Definition at line 4122 of file fxpkgpnp.hpp.

Referenced by AddQueryInterface(), Dispose(), FxPkgPnp(), and HandleQueryInterface().

◆ m_QueryInterfaceLock

FxWaitLockInternal FxPkgPnp::m_QueryInterfaceLock

Definition at line 4120 of file fxpkgpnp.hpp.

Referenced by AddQueryInterface(), Dispose(), HandleQueryInterface(), and Initialize().

◆ m_ReleaseHardwareAfterDescendantsOnFailure

BOOLEAN FxPkgPnp::m_ReleaseHardwareAfterDescendantsOnFailure
protected

◆ m_RemovalDeviceList

◆ m_RemoveEventUm

MxEvent FxPkgPnp::m_RemoveEventUm
private

Definition at line 4305 of file fxpkgpnp.hpp.

Referenced by Initialize().

◆ m_Resources

◆ m_ResourcesRaw

◆ m_RestartCountMaximum

const ULONG FxPkgPnp::m_RestartCountMaximum = 5
staticprivate

Definition at line 4539 of file fxpkgpnp.hpp.

Referenced by PnpIncrementRestartCountLogic().

◆ m_RestartCountName

const PWCHAR FxPkgPnp::m_RestartCountName = RESTART_COUNT_NAME
staticprivate

Definition at line 4527 of file fxpkgpnp.hpp.

◆ m_RestartStartAchievedName

const PWCHAR FxPkgPnp::m_RestartStartAchievedName = RESTART_START_ACHIEVED_NAME
staticprivate

Definition at line 4525 of file fxpkgpnp.hpp.

◆ m_RestartStartTimeName

const PWCHAR FxPkgPnp::m_RestartStartTimeName = RESTART_START_TIME_NAME
staticprivate

Definition at line 4526 of file fxpkgpnp.hpp.

◆ m_RestartTimePeriodMaximum

const ULONG FxPkgPnp::m_RestartTimePeriodMaximum = 60
staticprivate

Definition at line 4533 of file fxpkgpnp.hpp.

Referenced by PnpIncrementRestartCountLogic().

◆ m_SelfManagedIoMachine

FxSelfManagedIoMachine* FxPkgPnp::m_SelfManagedIoMachine

◆ m_SetDeviceRemoveProcessed

BYTE FxPkgPnp::m_SetDeviceRemoveProcessed
protected

Definition at line 4198 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), and PnpProcessEventInner().

◆ m_SharedPower

◆ m_SpecialFileCount

LONG FxPkgPnp::m_SpecialFileCount[WdfSpecialFileMax-1]

Definition at line 4139 of file fxpkgpnp.hpp.

Referenced by AdjustUsageCount(), FxPkgPnp(), and GetUsageCount().

◆ m_SpecialSupport

BOOLEAN FxPkgPnp::m_SpecialSupport[WdfSpecialFileMax-1]

Definition at line 4133 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), IsUsageSupported(), and SetUsageSupport().

◆ m_SystemPowerAction

UCHAR FxPkgPnp::m_SystemPowerAction
protected

◆ m_SystemPowerState

◆ m_SystemWake

◆ m_SystemWokenByWakeInterrupt

BOOLEAN FxPkgPnp::m_SystemWokenByWakeInterrupt
private

Definition at line 4330 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), and PowerPolicySendWaitWakeRequest().

◆ m_UsageDependentDeviceList

FxRelatedDeviceList* FxPkgPnp::m_UsageDependentDeviceList

◆ m_WakeInterruptCount

ULONG FxPkgPnp::m_WakeInterruptCount
private

◆ m_WakeInterruptPendingAckCount

ULONG FxPkgPnp::m_WakeInterruptPendingAckCount
private

◆ m_WakeInterruptsKeepConnected

BOOLEAN FxPkgPnp::m_WakeInterruptsKeepConnected
private

Definition at line 4339 of file fxpkgpnp.hpp.

Referenced by FxPkgPnp(), and PowerGotoDxIoStopped().

◆ m_WakePendingNPOtherStates

const POWER_EVENT_TARGET_STATE FxPkgPnp::m_WakePendingNPOtherStates
staticprivate

◆ m_WakePendingOtherStates

const POWER_EVENT_TARGET_STATE FxPkgPnp::m_WakePendingOtherStates
staticprivate

◆ m_WdfNotPowerPolicyOwnerStates

const NOT_POWER_POLICY_OWNER_STATE_TABLE FxPkgPnp::m_WdfNotPowerPolicyOwnerStates
staticprivate

Definition at line 4383 of file fxpkgpnp.hpp.

Referenced by GetNotPowerPolicyOwnerTableEntry().

◆ m_WdfPnpStates

const PNP_STATE_TABLE FxPkgPnp::m_WdfPnpStates
staticprivate

Definition at line 4380 of file fxpkgpnp.hpp.

Referenced by GetPnpTableEntry(), and PnpCheckAssumptions().

◆ m_WdfPowerPolicyStates

const POWER_POLICY_STATE_TABLE FxPkgPnp::m_WdfPowerPolicyStates
staticprivate

Definition at line 4382 of file fxpkgpnp.hpp.

Referenced by GetPowerPolicyTableEntry(), and PowerPolicyCheckAssumptions().

◆ m_WdfPowerStates

const POWER_STATE_TABLE FxPkgPnp::m_WdfPowerStates
staticprivate

Definition at line 4381 of file fxpkgpnp.hpp.

Referenced by GetPowerTableEntry(), and PowerCheckAssumptions().


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