1 /*++ 2 3 Copyright (c) Microsoft. All rights reserved. 4 5 Module Name: 6 7 FxPkgPnp.hpp 8 9 Abstract: 10 11 This module implements the pnp package for the driver frameworks. 12 13 Author: 14 15 16 17 Environment: 18 19 Both kernel and user mode 20 21 Revision History: 22 23 --*/ 24 25 #ifndef _FXPKGPNP_H_ 26 #define _FXPKGPNP_H_ 27 28 // 29 // These are all magical numbers based on inspection. If the queue overflows, 30 // it is OK to increase these numbers without fear of either dependencies or 31 // weird side effects. 32 // 33 const UCHAR PnpEventQueueDepth = 8; 34 const UCHAR PowerEventQueueDepth = 8; 35 const UCHAR FxPowerPolicyEventQueueDepth = 8; 36 37 // @@SMVERIFY_SPLIT_BEGIN 38 39 // 40 // DEBUGGED_EVENT is a TRUE value rather then a FALSE value (and having the field 41 // name be TrapOnEvent) so that the initializer for the entry in the table has 42 // to explicitly set this value, otherwise, if left out, the compiler will zero 43 // out the field, which would lead to mistakenly saying the event was debugged 44 // if DEBUGGED_EVENT is FALSE. 45 // 46 // Basically, we are catching folks who update the table but forget to specify 47 // TRAP_ON_EVENT when they add the new entry. 48 // 49 #if FX_SUPER_DBG 50 #define DEBUGGED_EVENT , TRUE 51 #define TRAP_ON_EVENT , FALSE 52 53 #define DO_EVENT_TRAP(x) if ((x)->EventDebugged == FALSE) { COVERAGE_TRAP(); } 54 55 #define EVENT_TRAP_FIELD BOOLEAN EventDebugged; 56 57 #else // FX_SUPER_DBG 58 59 #define DEBUGGED_EVENT 60 #define TRAP_ON_EVENT 61 #define DO_EVENT_TRAP(x) (0) 62 63 // intentionally blank 64 #define EVENT_TRAP_FIELD 65 66 #endif // FX_SUPER_DBG 67 68 #if FX_STATE_MACHINE_VERIFY 69 enum FxStateMachineDeviceType { 70 FxSmDeviceTypeInvalid = 0, 71 FxSmDeviceTypePnp, 72 FxSmDeviceTypePnpFdo, 73 FxSmDeviceTypePnpPdo, 74 }; 75 #endif // FX_STATE_MACHINE_VERIFY 76 77 // @@SMVERIFY_SPLIT_END 78 79 #include "fxpnpcallbacks.hpp" 80 81 #include "fxeventqueue.hpp" 82 83 // 84 // Bit-flags for tracking which callback is currently executing. 85 // 86 enum FxDeviceCallbackFlags { 87 // Prepare hardware callback is running. 88 FXDEVICE_CALLBACK_IN_PREPARE_HARDWARE = 0x01, 89 }; 90 91 typedef 92 VOID 93 (*PFN_POWER_THREAD_ENQUEUE)( 94 __in PVOID Context, 95 __in PWORK_QUEUE_ITEM WorkItem 96 ); 97 98 // 99 // workaround overloaded definition (rpc generated headers all define INTERFACE 100 // to match the class name). 101 // 102 #undef INTERFACE 103 104 typedef struct _POWER_THREAD_INTERFACE { 105 // 106 // generic interface header 107 // 108 INTERFACE Interface; 109 110 PFN_POWER_THREAD_ENQUEUE PowerThreadEnqueue; 111 112 } POWER_THREAD_INTERFACE, *PPOWER_THREAD_INTERFACE; 113 114 // 115 // What follows here is a series of structures that define three state 116 // machines. The first is the PnP state machine, followed by the 117 // Power state machine, followed by the Power Policy state machine. 118 // The first two will be instantiated in every driver. The third will 119 // be instantiated only in drivers which are the power policy owners 120 // for their device stacks, which usually amounts to the being the FDO. 121 // 122 #include "fxpnpstatemachine.hpp" 123 #include "fxpowerstatemachine.hpp" 124 #include "fxpowerpolicystatemachine.hpp" 125 126 #include "fxselfmanagediostatemachine.hpp" 127 128 // 129 // Group these here instead of in the individual headers because, for some reason, 130 // tracewpp.exe, can't handle such an arrangement. 131 // 132 // begin_wpp config 133 // CUSTOM_TYPE(FxPnpEvent, ItemEnum(FxPnpEvent)); 134 // CUSTOM_TYPE(FxPowerEvent, ItemEnum(FxPowerEvent)); 135 // CUSTOM_TYPE(FxPowerPolicyEvent, ItemEnum(FxPowerPolicyEvent)); 136 // CUSTOM_TYPE(FxPowerIdleFlags, ItemEnum(FxPowerIdleFlags)); 137 // CUSTOM_TYPE(FxPowerIdleStates, ItemEnum(FxPowerIdleStates)); 138 // CUSTOM_TYPE(FxPowerIdleEvents, ItemEnum(FxPowerIdleEvents)); 139 // CUSTOM_TYPE(FxDevicePwrRequirementEvents, ItemEnum(FxDevicePwrRequirementEvents)); 140 // CUSTOM_TYPE(FxDevicePwrRequirementStates, ItemEnum(FxDevicePwrRequirementStates)); 141 // CUSTOM_TYPE(FxWakeInterruptEvents, ItemEnum(FxWakeInterruptEvents)); 142 // CUSTOM_TYPE(FxWakeInterruptStates, ItemEnum(FxWakeInterruptStates)); 143 144 // CUSTOM_TYPE(FxSelfManagedIoEvents, ItemEnum(FxSelfManagedIoEvents)); 145 // CUSTOM_TYPE(FxSelfManagedIoStates, ItemEnum(FxSelfManagedIoStates)); 146 // end_wpp 147 148 // 149 // These are defined in ntddk.h so its wpp custom type should be 150 // added to a common header along with other public enums. Howeever until that 151 // is done, define custom type here. 152 // 153 // begin_wpp config 154 // CUSTOM_TYPE(DEVICE_POWER_STATE, ItemEnum(_DEVICE_POWER_STATE)); 155 // CUSTOM_TYPE(SYSTEM_POWER_STATE, ItemEnum(_SYSTEM_POWER_STATE)); 156 // CUSTOM_TYPE(BUS_QUERY_ID_TYPE, ItemEnum(BUS_QUERY_ID_TYPE)); 157 // CUSTOM_TYPE(DEVICE_RELATION_TYPE, ItemEnum(_DEVICE_RELATION_TYPE)); 158 // CUSTOM_TYPE(pwrmn, ItemListByte(IRP_MN_WAIT_WAKE,IRP_MN_POWER_SEQUENCE,IRP_MN_SET_POWER,IRP_MN_QUERY_POWER)); 159 // end_wpp 160 161 // 162 // Information shared between the power and power policy state machines. 163 // 164 struct SharedPowerData { 165 // 166 // Current wait wake irp in this device object. Access to this field is 167 // determined by m_WaitWakeOwner. 168 // 169 // m_WaitWakeOwner == TRUE, access is guarded by 170 // FxPowerMachine::m_WaitWakeLock 171 // 172 // 173 // m_WaitWakeOwner == FALSE, access is guarded InterlockedExchange operations 174 // and the ability to cancel the request is guarded through 175 // FxPowerPolicyMachine::m_WaitWakeCancelCompletionOwnership 176 // 177 // Any devobj can be both the power policy owner and the wait wake owner, 178 // but usually this dual role would only be for raw PDOs. 179 // 180 MdIrp m_WaitWakeIrp; 181 182 // 183 // Indication whether this power machine owns wait wake irps (and calls 184 // (dis)arm at bus level callbacks and handles cancellation logic. 185 // 186 BOOLEAN m_WaitWakeOwner; 187 188 // 189 // If TRUE the watchdog timer should be extended to a very long period of 190 // time during debugging for a NP power operation. 191 // 192 // NOTE: nowhere in the code do we set this value to TRUE. The debugger 193 // extension !wdfextendwatchdog will set it to TRUE, so the field must 194 // stay. If moved, the extension must obviously be updated as well. 195 // 196 BOOLEAN m_ExtendWatchDogTimer; 197 }; 198 199 const UCHAR DeviceWakeStates = PowerSystemHibernate - PowerSystemWorking + 1; 200 201 enum SendDeviceRequestAction { 202 NoRetry = 0, 203 Retry, 204 }; 205 206 enum NotifyResourcesFlags { 207 NotifyResourcesNoFlags = 0x00, 208 NotifyResourcesNP = 0x01, 209 NotifyResourcesSurpriseRemoved = 0x02, 210 NotifyResourcesForceDisconnect = 0x04, 211 NotifyResourcesExplicitPowerup = 0x08, 212 NotifyResourcesExplicitPowerDown = 0x10, 213 NotifyResourcesDisconnectInactive = 0x20, 214 NotifyResourcesArmedForWake = 0x40, 215 }; 216 217 enum FxPowerDownType { 218 FxPowerDownTypeExplicit = 0, 219 FxPowerDownTypeImplicit, 220 }; 221 222 typedef 223 _Must_inspect_result_ 224 NTSTATUS 225 (*PFN_PNP_POWER_CALLBACK)( 226 __inout FxPkgPnp* This, 227 __inout FxIrp* Irp 228 ); 229 230 // 231 // The naming of these values is very important. The following macros rely on 232 // it: 233 // 234 // (state related:) 235 // SET_PNP_DEVICE_STATE_BIT 236 // SET_TRI_STATE_FROM_STATE_BITS 237 // GET_PNP_STATE_BITS_FROM_STRUCT 238 // 239 // (caps related:) 240 // GET_PNP_CAP_BITS_FROM_STRUCT 241 // SET_PNP_CAP_IF_TRUE 242 // SET_PNP_CAP_IF_FALSE 243 // SET_PNP_CAP 244 // 245 // They using the naming convention to generically map the field name in 246 // WDF_DEVICE_PNP_CAPABILITIES and WDF_DEVICE_STATE to the appropriate bit 247 // values. 248 // 249 enum FxPnpStateAndCapValues { 250 FxPnpStateDisabledFalse = 0x00000000, 251 FxPnpStateDisabledTrue = 0x00000001, 252 FxPnpStateDisabledUseDefault = 0x00000002, 253 FxPnpStateDisabledMask = 0x00000003, 254 255 FxPnpStateDontDisplayInUIFalse = 0x00000000, 256 FxPnpStateDontDisplayInUITrue = 0x00000004, 257 FxPnpStateDontDisplayInUIUseDefault = 0x00000008, 258 FxPnpStateDontDisplayInUIMask = 0x0000000C, 259 260 FxPnpStateFailedFalse = 0x00000000, 261 FxPnpStateFailedTrue = 0x00000010, 262 FxPnpStateFailedUseDefault = 0x00000020, 263 FxPnpStateFailedMask = 0x00000030, 264 265 FxPnpStateNotDisableableFalse = 0x00000000, 266 FxPnpStateNotDisableableTrue = 0x00000040, 267 FxPnpStateNotDisableableUseDefault = 0x00000080, 268 FxPnpStateNotDisableableMask = 0x000000C0, 269 270 FxPnpStateRemovedFalse = 0x00000000, 271 FxPnpStateRemovedTrue = 0x00000100, 272 FxPnpStateRemovedUseDefault = 0x00000200, 273 FxPnpStateRemovedMask = 0x00000300, 274 275 FxPnpStateResourcesChangedFalse = 0x00000000, 276 FxPnpStateResourcesChangedTrue = 0x00000400, 277 FxPnpStateResourcesChangedUseDefault= 0x00000800, 278 FxPnpStateResourcesChangedMask = 0x00000C00, 279 280 FxPnpStateMask = 0x00000FFF, 281 282 FxPnpCapLockSupportedFalse = 0x00000000, 283 FxPnpCapLockSupportedTrue = 0x00001000, 284 FxPnpCapLockSupportedUseDefault = 0x00002000, 285 FxPnpCapLockSupportedMask = 0x00003000, 286 287 FxPnpCapEjectSupportedFalse = 0x00000000, 288 FxPnpCapEjectSupportedTrue = 0x00004000, 289 FxPnpCapEjectSupportedUseDefault = 0x00008000, 290 FxPnpCapEjectSupportedMask = 0x0000C000, 291 292 FxPnpCapRemovableFalse = 0x00000000, 293 FxPnpCapRemovableTrue = 0x00010000, 294 FxPnpCapRemovableUseDefault = 0x00020000, 295 FxPnpCapRemovableMask = 0x00030000, 296 297 FxPnpCapDockDeviceFalse = 0x00000000, 298 FxPnpCapDockDeviceTrue = 0x00040000, 299 FxPnpCapDockDeviceUseDefault = 0x00080000, 300 FxPnpCapDockDeviceMask = 0x000C0000, 301 302 FxPnpCapUniqueIDFalse = 0x00000000, 303 FxPnpCapUniqueIDTrue = 0x00100000, 304 FxPnpCapUniqueIDUseDefault = 0x00200000, 305 FxPnpCapUniqueIDMask = 0x00300000, 306 307 FxPnpCapSilentInstallFalse = 0x00000000, 308 FxPnpCapSilentInstallTrue = 0x00400000, 309 FxPnpCapSilentInstallUseDefault = 0x00800000, 310 FxPnpCapSilentInstallMask = 0x00C00000, 311 312 FxPnpCapSurpriseRemovalOKFalse = 0x00000000, 313 FxPnpCapSurpriseRemovalOKTrue = 0x01000000, 314 FxPnpCapSurpriseRemovalOKUseDefault = 0x02000000, 315 FxPnpCapSurpriseRemovalOKMask = 0x03000000, 316 317 FxPnpCapHardwareDisabledFalse = 0x00000000, 318 FxPnpCapHardwareDisabledTrue = 0x04000000, 319 FxPnpCapHardwareDisabledUseDefault = 0x08000000, 320 FxPnpCapHardwareDisabledMask = 0x0C000000, 321 322 FxPnpCapNoDisplayInUIFalse = 0x00000000, 323 FxPnpCapNoDisplayInUITrue = 0x10000000, 324 FxPnpCapNoDisplayInUIUseDefault = 0x20000000, 325 FxPnpCapNoDisplayInUIMask = 0x30000000, 326 327 FxPnpCapMask = 0x3FFFF000, 328 }; 329 330 union FxPnpStateAndCaps { 331 struct { 332 // States 333 WDF_TRI_STATE Disabled : 2; 334 WDF_TRI_STATE DontDisplayInUI : 2; 335 WDF_TRI_STATE Failed : 2; 336 WDF_TRI_STATE NotDisableable : 2; 337 WDF_TRI_STATE Removed : 2; 338 WDF_TRI_STATE ResourcesChanged : 2; 339 340 // Caps 341 WDF_TRI_STATE LockSupported : 2; 342 WDF_TRI_STATE EjectSupported : 2; 343 WDF_TRI_STATE Removable : 2; 344 WDF_TRI_STATE DockDevice : 2; 345 WDF_TRI_STATE UniqueID : 2; 346 WDF_TRI_STATE SilentInstall : 2; 347 WDF_TRI_STATE SurpriseRemovalOK : 2; 348 WDF_TRI_STATE HardwareDisabled : 2; 349 WDF_TRI_STATE NoDisplayInUI : 2; 350 } ByEnum; 351 352 // 353 // The bottom 3 nibbles (0xFFF) are the pnp state tri state values encoded 354 // down to 2 bits each. 355 // 356 // The remaining portion (0x3FFFF000) are the pnp caps tri state values 357 // encoded down to 2 bits each as well. 358 // 359 LONG Value; 360 }; 361 362 // 363 // The naming of these values is very important. The following macros rely on it: 364 // GET_POWER_CAP_BITS_FROM_STRUCT 365 // SET_POWER_CAP 366 // 367 // They using the naming convention to generically map the field name in 368 // WDF_DEVICE_POWER_CAPABILITIES to the appropriate bit values. 369 // 370 enum FxPowerCapValues { 371 FxPowerCapDeviceD1False = 0x0000, 372 FxPowerCapDeviceD1True = 0x0001, 373 FxPowerCapDeviceD1UseDefault = 0x0002, 374 FxPowerCapDeviceD1Mask = 0x0003, 375 376 FxPowerCapDeviceD2False = 0x0000, 377 FxPowerCapDeviceD2True = 0x0004, 378 FxPowerCapDeviceD2UseDefault = 0x0008, 379 FxPowerCapDeviceD2Mask = 0x000C, 380 381 FxPowerCapWakeFromD0False = 0x0000, 382 FxPowerCapWakeFromD0True = 0x0010, 383 FxPowerCapWakeFromD0UseDefault= 0x0020, 384 FxPowerCapWakeFromD0Mask = 0x0030, 385 386 FxPowerCapWakeFromD1False = 0x0000, 387 FxPowerCapWakeFromD1True = 0x0040, 388 FxPowerCapWakeFromD1UseDefault= 0x0080, 389 FxPowerCapWakeFromD1Mask = 0x00C0, 390 391 FxPowerCapWakeFromD2False = 0x0000, 392 FxPowerCapWakeFromD2True = 0x0100, 393 FxPowerCapWakeFromD2UseDefault= 0x0200, 394 FxPowerCapWakeFromD2Mask = 0x0300, 395 396 FxPowerCapWakeFromD3False = 0x0000, 397 FxPowerCapWakeFromD3True = 0x0400, 398 FxPowerCapWakeFromD3UseDefault= 0x0800, 399 FxPowerCapWakeFromD3Mask = 0x0C00, 400 }; 401 402 struct FxPowerCaps { 403 // 404 // Encoded with FxPowerCapValues, which encodes the WDF_TRI_STATE values 405 // 406 USHORT Caps; 407 408 // 409 // Default value PowerDeviceMaximum, PowerSystemMaximum indicates not to 410 // set this value. 411 // 412 BYTE DeviceWake; // DEVICE_POWER_STATE 413 BYTE SystemWake; // SYSTEM_POWER_STATE 414 415 // 416 // Each state is encoded in a nibble in a byte 417 // 418 ULONG States; 419 420 // 421 // Default values of -1 indicate not to set this value 422 // 423 ULONG D1Latency; 424 ULONG D2Latency; 425 ULONG D3Latency; 426 }; 427 428 enum FxWmiInstanceAction : UINT32 { 429 AddInstance, 430 RemoveInstance 431 }; 432 433 struct FxEnumerationInfo : public FxStump { 434 public: 435 FxEnumerationInfo( 436 __in PFX_DRIVER_GLOBALS FxDriverGlobals 437 ) : m_ChildListList(FxDriverGlobals) 438 { 439 } 440 441 NTSTATUS 442 Initialize( 443 VOID 444 ) 445 { 446 NTSTATUS status; 447 448 status = m_PowerStateLock.Initialize(); 449 if (!NT_SUCCESS(status)) { 450 return status; 451 } 452 453 status = m_ChildListList.Initialize(); 454 if (!NT_SUCCESS(status)) { 455 return status; 456 } 457 458 return STATUS_SUCCESS; 459 } 460 461 _Acquires_lock_(_Global_critical_region_) 462 VOID 463 AcquireParentPowerStateLock( 464 __in PFX_DRIVER_GLOBALS FxDriverGlobals 465 ) 466 { 467 (VOID) m_PowerStateLock.AcquireLock(FxDriverGlobals); 468 } 469 470 _Releases_lock_(_Global_critical_region_) 471 VOID 472 ReleaseParentPowerStateLock( 473 __in PFX_DRIVER_GLOBALS FxDriverGlobals 474 ) 475 { 476 m_PowerStateLock.ReleaseLock(FxDriverGlobals); 477 } 478 479 public: 480 FxWaitLockInternal m_PowerStateLock; 481 482 // 483 // List of FxChildList objects which contain enumerated children 484 // 485 FxWaitLockTransactionedList m_ChildListList; 486 }; 487 488 class FxPkgPnp : public FxPackage { 489 490 friend FxPnpMachine; 491 friend FxPowerMachine; 492 friend FxPowerPolicyMachine; 493 friend FxPowerPolicyOwnerSettings; 494 friend FxInterrupt; 495 496 protected: 497 FxPkgPnp( 498 __in PFX_DRIVER_GLOBALS FxDriverGlobals, 499 __in CfxDevice* Device, 500 __in WDFTYPE Type 501 ); 502 503 ~FxPkgPnp(); 504 505 virtual 506 BOOLEAN 507 Dispose( 508 VOID 509 ); 510 511 _Must_inspect_result_ 512 virtual 513 NTSTATUS 514 Dispatch( 515 __in MdIrp Irp 516 ); 517 518 virtual 519 const PFN_PNP_POWER_CALLBACK* 520 GetDispatchPnp( 521 VOID 522 ) =0; 523 524 virtual 525 const PFN_PNP_POWER_CALLBACK* 526 GetDispatchPower( 527 VOID 528 ) =0; 529 530 VOID 531 DeleteDevice( 532 VOID 533 ); 534 535 VOID 536 SetInternalFailure( 537 VOID 538 ); 539 540 NTSTATUS 541 CompletePowerRequest( 542 __inout FxIrp* Irp, 543 __in NTSTATUS Status 544 ); 545 546 NTSTATUS 547 CompletePnpRequest( 548 __inout FxIrp* Irp, 549 __in NTSTATUS Status 550 ); 551 552 PNP_DEVICE_STATE 553 HandleQueryPnpDeviceState( 554 __in PNP_DEVICE_STATE PnpDeviceState 555 ); 556 557 _Must_inspect_result_ 558 NTSTATUS 559 HandleQueryBusRelations( 560 __inout FxIrp* Irp 561 ); 562 563 _Must_inspect_result_ 564 NTSTATUS 565 HandleQueryDeviceRelations( 566 __inout FxIrp* Irp, 567 __inout FxRelatedDeviceList* List 568 ); 569 570 _Must_inspect_result_ 571 NTSTATUS 572 HandleQueryInterface( 573 __inout FxIrp* Irp, 574 __out PBOOLEAN CompleteRequest 575 ); 576 577 _Must_inspect_result_ 578 NTSTATUS 579 QueryForCapabilities( 580 VOID 581 ); 582 583 VOID 584 PnpAssignInterruptsSyncIrql( 585 VOID 586 ); 587 588 _Must_inspect_result_ 589 NTSTATUS 590 PnpMatchResources( 591 VOID 592 ); 593 594 __drv_when(!NT_SUCCESS(return), __drv_arg(ResourcesMatched, _Must_inspect_result_)) 595 NTSTATUS 596 PnpPrepareHardware( 597 __out PBOOLEAN ResourcesMatched 598 ); 599 600 _Must_inspect_result_ 601 NTSTATUS 602 PnpPrepareHardwareInternal( 603 VOID 604 ); 605 606 _Must_inspect_result_ 607 NTSTATUS 608 PnpReleaseHardware( 609 VOID 610 ); 611 612 _Must_inspect_result_ 613 NTSTATUS 614 PnpEnableInterfacesAndRegisterWmi( 615 VOID 616 ); 617 618 _Must_inspect_result_ 619 static 620 NTSTATUS 621 _PnpStartDevice( 622 __inout FxPkgPnp* This, 623 __inout FxIrp* Irp 624 ); 625 626 _Must_inspect_result_ 627 static 628 NTSTATUS 629 _PnpQueryStopDevice( 630 __inout FxPkgPnp* This, 631 __inout FxIrp* Irp 632 ); 633 634 _Must_inspect_result_ 635 static 636 NTSTATUS 637 _PnpCancelStopDevice( 638 __inout FxPkgPnp* This, 639 __inout FxIrp* Irp 640 ); 641 642 _Must_inspect_result_ 643 static 644 NTSTATUS 645 _PnpStopDevice( 646 __inout FxPkgPnp* This, 647 __inout FxIrp* Irp 648 ); 649 650 _Must_inspect_result_ 651 static 652 NTSTATUS 653 _PnpQueryRemoveDevice( 654 __inout FxPkgPnp* This, 655 __inout FxIrp* Irp 656 ); 657 658 _Must_inspect_result_ 659 static 660 NTSTATUS 661 _PnpCancelRemoveDevice( 662 __inout FxPkgPnp* This, 663 __inout FxIrp* Irp 664 ); 665 666 _Must_inspect_result_ 667 static 668 NTSTATUS 669 _PnpRemoveDevice( 670 __inout FxPkgPnp* This, 671 __inout FxIrp* Irp 672 ); 673 674 _Must_inspect_result_ 675 NTSTATUS 676 PnpSurpriseRemoval( 677 __inout FxIrp* Irp 678 ); 679 680 NTSTATUS 681 FilterResourceRequirements( 682 __in IO_RESOURCE_REQUIREMENTS_LIST **IoList 683 ); 684 685 virtual 686 VOID 687 PowerReleasePendingDeviceIrp( 688 BOOLEAN IrpMustBePresent = TRUE 689 ) =0; 690 691 VOID 692 AddInterruptObject( 693 __in FxInterrupt* Interrupt 694 ); 695 696 VOID 697 RemoveInterruptObject( 698 __in FxInterrupt* Interrupt 699 ); 700 701 VOID 702 PnpProcessEventInner( 703 __inout FxPostProcessInfo* Info 704 ); 705 706 VOID 707 PowerProcessEventInner( 708 __inout FxPostProcessInfo* Info 709 ); 710 711 VOID 712 PowerPolicyProcessEventInner( 713 __inout FxPostProcessInfo* Info 714 ); 715 716 static 717 VOID 718 _PnpProcessEventInner( 719 __inout FxPkgPnp* This, 720 __inout FxPostProcessInfo* Info, 721 __in PVOID WorkerContext 722 ); 723 724 static 725 VOID 726 _PowerProcessEventInner( 727 __in FxPkgPnp* This, 728 __in FxPostProcessInfo* Info, 729 __in PVOID WorkerContext 730 ); 731 732 static 733 VOID 734 _PowerPolicyProcessEventInner( 735 __inout FxPkgPnp* This, 736 __inout FxPostProcessInfo* Info, 737 __in PVOID WorkerContext 738 ); 739 740 VOID 741 PnpEnterNewState( 742 __in WDF_DEVICE_PNP_STATE State 743 ); 744 745 VOID 746 PowerEnterNewState( 747 __in WDF_DEVICE_POWER_STATE State 748 ); 749 750 VOID 751 PowerPolicyEnterNewState( 752 __in WDF_DEVICE_POWER_POLICY_STATE State 753 ); 754 755 VOID 756 NotPowerPolicyOwnerEnterNewState( 757 __in WDF_DEVICE_POWER_POLICY_STATE NewState 758 ); 759 760 _Must_inspect_result_ 761 static 762 NTSTATUS 763 _DispatchWaitWake( 764 __inout FxPkgPnp* This, 765 __inout FxIrp* Irp 766 ); 767 768 _Must_inspect_result_ 769 NTSTATUS 770 DispatchWaitWake( 771 __inout FxIrp* Irp 772 ); 773 774 VOID 775 SaveState( 776 __in BOOLEAN UseCanSaveState 777 ); 778 779 _Must_inspect_result_ 780 static 781 NTSTATUS 782 _PnpDeviceUsageNotification( 783 __inout FxPkgPnp* This, 784 __inout FxIrp* Irp 785 ); 786 787 _Must_inspect_result_ 788 NTSTATUS 789 PnpDeviceUsageNotification( 790 __inout FxIrp* Irp 791 ); 792 793 794 LONG 795 GetPnpStateInternal( 796 VOID 797 ); 798 799 LONG 800 GetPnpCapsInternal( 801 VOID 802 ); 803 804 static 805 VOID 806 _SetPowerCapState( 807 __in ULONG Index, 808 __in DEVICE_POWER_STATE State, 809 __out PULONG Result 810 ); 811 812 static 813 DEVICE_POWER_STATE 814 _GetPowerCapState( 815 __in ULONG Index, 816 __in ULONG State 817 ); 818 819 // begin pnp state machine table based callbacks 820 static 821 WDF_DEVICE_PNP_STATE 822 PnpEventCheckForDevicePresence( 823 __inout FxPkgPnp* This 824 ); 825 826 virtual 827 BOOLEAN 828 PnpSendStartDeviceDownTheStackOverload( 829 VOID 830 ) =0; 831 832 virtual 833 WDF_DEVICE_PNP_STATE 834 PnpEventCheckForDevicePresenceOverload( 835 VOID 836 ) = 0; 837 838 static 839 WDF_DEVICE_PNP_STATE 840 PnpEventEjectHardware( 841 __inout FxPkgPnp* This 842 ); 843 844 virtual 845 WDF_DEVICE_PNP_STATE 846 PnpEventEjectHardwareOverload( 847 VOID 848 ) = 0; 849 850 static 851 WDF_DEVICE_PNP_STATE 852 PnpEventInitStarting( 853 __inout FxPkgPnp* This 854 ); 855 856 static 857 WDF_DEVICE_PNP_STATE 858 PnpEventInitSurpriseRemoved( 859 __inout FxPkgPnp* This 860 ); 861 862 static 863 WDF_DEVICE_PNP_STATE 864 PnpEventHardwareAvailable( 865 __inout FxPkgPnp* This 866 ); 867 868 static 869 WDF_DEVICE_PNP_STATE 870 PnpEventEnableInterfaces( 871 __inout FxPkgPnp* This 872 ); 873 874 static 875 WDF_DEVICE_PNP_STATE 876 PnpEventHardwareAvailablePowerPolicyFailed( 877 __inout FxPkgPnp* This 878 ); 879 880 static 881 WDF_DEVICE_PNP_STATE 882 PnpEventQueryRemoveAskDriver( 883 __inout FxPkgPnp* This 884 ); 885 886 static 887 WDF_DEVICE_PNP_STATE 888 PnpEventQueryRemoveEnsureDeviceAwake( 889 __inout FxPkgPnp* This 890 ); 891 892 static 893 WDF_DEVICE_PNP_STATE 894 PnpEventQueryRemovePending( 895 __inout FxPkgPnp* This 896 ); 897 898 static 899 WDF_DEVICE_PNP_STATE 900 PnpEventQueryRemoveStaticCheck( 901 __inout FxPkgPnp* This 902 ); 903 904 static 905 WDF_DEVICE_PNP_STATE 906 PnpEventQueriedRemoving( 907 __inout FxPkgPnp* This 908 ); 909 910 static 911 WDF_DEVICE_PNP_STATE 912 PnpEventQueryStopAskDriver( 913 __inout FxPkgPnp* This 914 ); 915 916 static 917 WDF_DEVICE_PNP_STATE 918 PnpEventQueryStopEnsureDeviceAwake( 919 __inout FxPkgPnp* This 920 ); 921 922 static 923 WDF_DEVICE_PNP_STATE 924 PnpEventQueryStopPending( 925 __inout FxPkgPnp* This 926 ); 927 928 static 929 WDF_DEVICE_PNP_STATE 930 PnpEventQueryStopStaticCheck( 931 __inout FxPkgPnp* This 932 ); 933 934 static 935 WDF_DEVICE_PNP_STATE 936 PnpEventQueryCanceled( 937 __inout FxPkgPnp* This 938 ); 939 940 static 941 WDF_DEVICE_PNP_STATE 942 PnpEventRemoved( 943 __inout FxPkgPnp* This 944 ); 945 946 virtual 947 WDF_DEVICE_PNP_STATE 948 PnpGetPostRemoveState( 949 VOID 950 ) =0; 951 952 static 953 WDF_DEVICE_PNP_STATE 954 PnpEventPdoRemoved( 955 __inout FxPkgPnp* This 956 ); 957 958 static 959 WDF_DEVICE_PNP_STATE 960 PnpEventRemovedPdoWait( 961 __inout FxPkgPnp* This 962 ); 963 964 static 965 WDF_DEVICE_PNP_STATE 966 PnpEventRemovedPdoSurpriseRemoved( 967 __inout FxPkgPnp* This 968 ); 969 970 virtual 971 WDF_DEVICE_PNP_STATE 972 PnpEventPdoRemovedOverload( 973 VOID 974 ) =0; 975 976 virtual 977 WDF_DEVICE_PNP_STATE 978 PnpEventFdoRemovedOverload( 979 VOID 980 ) =0; 981 982 virtual 983 VOID 984 PnpEventSurpriseRemovePendingOverload( 985 VOID 986 ); 987 988 VOID 989 PnpEventRemovedCommonCode( 990 VOID 991 ); 992 993 static 994 WDF_DEVICE_PNP_STATE 995 PnpEventRemovingDisableInterfaces( 996 __inout FxPkgPnp* This 997 ); 998 999 static 1000 WDF_DEVICE_PNP_STATE 1001 PnpEventRestarting( 1002 __inout FxPkgPnp* This 1003 ); 1004 1005 static 1006 WDF_DEVICE_PNP_STATE 1007 PnpEventStarted( 1008 __inout FxPkgPnp* This 1009 ); 1010 1011 static 1012 WDF_DEVICE_PNP_STATE 1013 PnpEventStartedCancelStop( 1014 __inout FxPkgPnp* This 1015 ); 1016 1017 static 1018 WDF_DEVICE_PNP_STATE 1019 PnpEventStartedCancelRemove( 1020 __inout FxPkgPnp* This 1021 ); 1022 1023 static 1024 WDF_DEVICE_PNP_STATE 1025 PnpEventStartedRemoving( 1026 __inout FxPkgPnp* This 1027 ); 1028 1029 static 1030 WDF_DEVICE_PNP_STATE 1031 PnpEventStartingFromStopped( 1032 __inout FxPkgPnp* This 1033 ); 1034 1035 static 1036 WDF_DEVICE_PNP_STATE 1037 PnpEventStopped( 1038 __inout FxPkgPnp* This 1039 ); 1040 1041 static 1042 WDF_DEVICE_PNP_STATE 1043 PnpEventStoppedWaitForStartCompletion( 1044 __inout FxPkgPnp* This 1045 ); 1046 1047 static 1048 WDF_DEVICE_PNP_STATE 1049 PnpEventStartedStopping( 1050 __inout FxPkgPnp* This 1051 ); 1052 1053 static 1054 WDF_DEVICE_PNP_STATE 1055 PnpEventSurpriseRemoved( 1056 __inout FxPkgPnp* This 1057 ); 1058 1059 static 1060 WDF_DEVICE_PNP_STATE 1061 PnpEventInitQueryRemove( 1062 __inout FxPkgPnp* This 1063 ); 1064 1065 static 1066 WDF_DEVICE_PNP_STATE 1067 PnpEventInitQueryRemoveCanceled( 1068 __inout FxPkgPnp* This 1069 ); 1070 1071 static 1072 WDF_DEVICE_PNP_STATE 1073 PnpEventFdoRemoved( 1074 __inout FxPkgPnp* This 1075 ); 1076 1077 static 1078 WDF_DEVICE_PNP_STATE 1079 PnpEventQueriedSurpriseRemove( 1080 __inout FxPkgPnp* This 1081 ); 1082 1083 static 1084 WDF_DEVICE_PNP_STATE 1085 PnpEventSurpriseRemoveIoStarted( 1086 __inout FxPkgPnp* This 1087 ); 1088 1089 static 1090 WDF_DEVICE_PNP_STATE 1091 PnpEventFailedPowerDown( 1092 __inout FxPkgPnp* This 1093 ); 1094 1095 static 1096 WDF_DEVICE_PNP_STATE 1097 PnpEventFailedIoStarting( 1098 __inout FxPkgPnp* This 1099 ); 1100 1101 static 1102 WDF_DEVICE_PNP_STATE 1103 PnpEventFailedOwnHardware( 1104 __inout FxPkgPnp* This 1105 ); 1106 1107 static 1108 WDF_DEVICE_PNP_STATE 1109 PnpEventFailed( 1110 __inout FxPkgPnp* This 1111 ); 1112 1113 static 1114 WDF_DEVICE_PNP_STATE 1115 PnpEventFailedPowerPolicyRemoved( 1116 __inout FxPkgPnp* This 1117 ); 1118 1119 static 1120 WDF_DEVICE_PNP_STATE 1121 PnpEventFailedSurpriseRemoved( 1122 __inout FxPkgPnp* This 1123 ); 1124 1125 static 1126 WDF_DEVICE_PNP_STATE 1127 PnpEventFailedStarted( 1128 __inout FxPkgPnp* This 1129 ); 1130 1131 static 1132 WDF_DEVICE_PNP_STATE 1133 PnpEventFailedInit( 1134 __inout FxPkgPnp* This 1135 ); 1136 1137 static 1138 WDF_DEVICE_PNP_STATE 1139 PnpEventPdoInitFailed( 1140 __inout FxPkgPnp* This 1141 ); 1142 1143 static 1144 WDF_DEVICE_PNP_STATE 1145 PnpEventRestart( 1146 __inout FxPkgPnp* This 1147 ); 1148 1149 static 1150 WDF_DEVICE_PNP_STATE 1151 PnpEventRestartReleaseHardware( 1152 __inout FxPkgPnp* This 1153 ); 1154 1155 static 1156 WDF_DEVICE_PNP_STATE 1157 PnpEventRestartHardwareAvailable( 1158 __inout FxPkgPnp* This 1159 ); 1160 1161 static 1162 WDF_DEVICE_PNP_STATE 1163 PnpEventPdoRestart( 1164 __inout FxPkgPnp* This 1165 ); 1166 1167 static 1168 WDF_DEVICE_PNP_STATE 1169 PnpEventRemovedChildrenRemoved( 1170 __inout FxPkgPnp* This 1171 ); 1172 1173 static 1174 WDF_DEVICE_PNP_STATE 1175 PnpEventFinal( 1176 __inout FxPkgPnp* This 1177 ); 1178 // end pnp state machine table based callbacks 1179 1180 VOID 1181 PnpPowerPolicyStart( 1182 VOID 1183 ); 1184 1185 VOID 1186 PnpPowerPolicyStop( 1187 VOID 1188 ); 1189 1190 VOID 1191 PnpPowerPolicySurpriseRemove( 1192 VOID 1193 ); 1194 1195 VOID 1196 PnpPowerPolicyRemove( 1197 VOID 1198 ); 1199 1200 VOID 1201 PnpFinishProcessingIrp( 1202 __in BOOLEAN IrpMustBePresent = TRUE 1203 ); 1204 1205 VOID 1206 PnpDisableInterfaces( 1207 VOID 1208 ); 1209 1210 virtual 1211 NTSTATUS 1212 SendIrpSynchronously( 1213 FxIrp* Irp 1214 ) =0; 1215 1216 // begin power state machine table based callbacks 1217 static 1218 WDF_DEVICE_POWER_STATE 1219 PowerCheckDeviceType( 1220 __inout FxPkgPnp* This 1221 ); 1222 1223 virtual 1224 WDF_DEVICE_POWER_STATE 1225 PowerCheckDeviceTypeOverload( 1226 VOID 1227 ) =0; 1228 1229 static 1230 WDF_DEVICE_POWER_STATE 1231 PowerCheckDeviceTypeNP( 1232 __inout FxPkgPnp* This 1233 ); 1234 1235 virtual 1236 WDF_DEVICE_POWER_STATE 1237 PowerCheckDeviceTypeNPOverload( 1238 VOID 1239 ) =0; 1240 1241 static 1242 WDF_DEVICE_POWER_STATE 1243 PowerEnablingWakeAtBus( 1244 __inout FxPkgPnp* This 1245 ); 1246 1247 static 1248 WDF_DEVICE_POWER_STATE 1249 PowerEnablingWakeAtBusNP( 1250 __inout FxPkgPnp* This 1251 ); 1252 1253 static 1254 WDF_DEVICE_POWER_STATE 1255 PowerCheckParentState( 1256 __inout FxPkgPnp* This 1257 ); 1258 1259 virtual 1260 NTSTATUS 1261 PowerCheckParentOverload( 1262 BOOLEAN* ParentOn 1263 ) =0; 1264 1265 static 1266 WDF_DEVICE_POWER_STATE 1267 PowerCheckParentStateNP( 1268 __inout FxPkgPnp* This 1269 ); 1270 1271 static 1272 WDF_DEVICE_POWER_STATE 1273 PowerDZero( 1274 __inout FxPkgPnp* This 1275 ); 1276 1277 static 1278 WDF_DEVICE_POWER_STATE 1279 PowerD0NP( 1280 __inout FxPkgPnp* This 1281 ); 1282 1283 static 1284 WDF_DEVICE_POWER_STATE 1285 PowerD0BusWakeOwner( 1286 __inout FxPkgPnp* This 1287 ); 1288 1289 static 1290 WDF_DEVICE_POWER_STATE 1291 PowerD0BusWakeOwnerNP( 1292 __inout FxPkgPnp* This 1293 ); 1294 1295 static 1296 WDF_DEVICE_POWER_STATE 1297 PowerD0ArmedForWake( 1298 __inout FxPkgPnp* This 1299 ); 1300 1301 static 1302 WDF_DEVICE_POWER_STATE 1303 PowerD0ArmedForWakeNP( 1304 __inout FxPkgPnp* This 1305 ); 1306 1307 static 1308 WDF_DEVICE_POWER_STATE 1309 PowerGotoImplicitD3DisarmWakeAtBus( 1310 __inout FxPkgPnp* This 1311 ); 1312 1313 static 1314 WDF_DEVICE_POWER_STATE 1315 PowerD0DisarmingWakeAtBus( 1316 __inout FxPkgPnp* This 1317 ); 1318 1319 static 1320 WDF_DEVICE_POWER_STATE 1321 PowerD0DisarmingWakeAtBusNP( 1322 __inout FxPkgPnp* This 1323 ); 1324 1325 static 1326 WDF_DEVICE_POWER_STATE 1327 PowerD0Starting( 1328 __inout FxPkgPnp* This 1329 ); 1330 1331 static 1332 WDF_DEVICE_POWER_STATE 1333 PowerD0StartingConnectInterrupt( 1334 __inout FxPkgPnp* This 1335 ); 1336 1337 static 1338 WDF_DEVICE_POWER_STATE 1339 PowerD0StartingDmaEnable( 1340 __inout FxPkgPnp* This 1341 ); 1342 1343 static 1344 WDF_DEVICE_POWER_STATE 1345 PowerD0StartingStartSelfManagedIo( 1346 __inout FxPkgPnp* This 1347 ); 1348 1349 static 1350 WDF_DEVICE_POWER_STATE 1351 PowerDecideD0State( 1352 __inout FxPkgPnp* This 1353 ); 1354 1355 static 1356 WDF_DEVICE_POWER_STATE 1357 PowerGotoD3Stopped( 1358 __inout FxPkgPnp* This 1359 ); 1360 1361 static 1362 WDF_DEVICE_POWER_STATE 1363 PowerStartingCheckDeviceType( 1364 __inout FxPkgPnp* This 1365 ); 1366 1367 static 1368 WDF_DEVICE_POWER_STATE 1369 PowerStartingChild( 1370 __inout FxPkgPnp* This 1371 ); 1372 1373 static 1374 WDF_DEVICE_POWER_STATE 1375 PowerDxDisablingWakeAtBus( 1376 __inout FxPkgPnp* This 1377 ); 1378 1379 static 1380 WDF_DEVICE_POWER_STATE 1381 PowerDxDisablingWakeAtBusNP( 1382 __inout FxPkgPnp* This 1383 ); 1384 1385 virtual 1386 NTSTATUS 1387 PowerEnableWakeAtBusOverload( 1388 VOID 1389 ) 1390 { 1391 return STATUS_SUCCESS; 1392 } 1393 1394 virtual 1395 VOID 1396 PowerDisableWakeAtBusOverload( 1397 VOID 1398 ) 1399 { 1400 } 1401 1402 virtual 1403 VOID 1404 PowerParentPowerDereference( 1405 VOID 1406 ) =0; 1407 1408 static 1409 WDF_DEVICE_POWER_STATE 1410 PowerGotoDNotZero( 1411 __inout FxPkgPnp* This 1412 ); 1413 1414 static 1415 WDF_DEVICE_POWER_STATE 1416 PowerGotoDNotZeroNP( 1417 __inout FxPkgPnp* This 1418 ); 1419 1420 static 1421 WDF_DEVICE_POWER_STATE 1422 PowerGotoDNotZeroIoStopped( 1423 __inout FxPkgPnp* This 1424 ); 1425 1426 static 1427 WDF_DEVICE_POWER_STATE 1428 PowerGotoDNotZeroIoStoppedNP( 1429 __inout FxPkgPnp* This 1430 ); 1431 1432 static 1433 WDF_DEVICE_POWER_STATE 1434 PowerGotoDxNPFailed( 1435 __inout FxPkgPnp* This 1436 ); 1437 1438 static 1439 WDF_DEVICE_POWER_STATE 1440 PowerGotoDxArmedForWake( 1441 __inout FxPkgPnp* This 1442 ); 1443 1444 static 1445 WDF_DEVICE_POWER_STATE 1446 PowerGotoDxArmedForWakeNP( 1447 __inout FxPkgPnp* This 1448 ); 1449 1450 static 1451 WDF_DEVICE_POWER_STATE 1452 PowerDNotZeroNP( 1453 __inout FxPkgPnp* This 1454 ); 1455 1456 static 1457 WDF_DEVICE_POWER_STATE 1458 PowerGotoDxIoStoppedArmedForWake( 1459 __inout FxPkgPnp* This 1460 ); 1461 1462 static 1463 WDF_DEVICE_POWER_STATE 1464 PowerGotoDxIoStoppedArmedForWakeNP( 1465 __inout FxPkgPnp* This 1466 ); 1467 1468 static 1469 WDF_DEVICE_POWER_STATE 1470 PowerCheckParentStateArmedForWake( 1471 __inout FxPkgPnp* This 1472 ); 1473 1474 static 1475 WDF_DEVICE_POWER_STATE 1476 PowerCheckParentStateArmedForWakeNP( 1477 __inout FxPkgPnp* This 1478 ); 1479 1480 static 1481 WDF_DEVICE_POWER_STATE 1482 PowerStartSelfManagedIo( 1483 __inout FxPkgPnp* This 1484 ); 1485 1486 static 1487 WDF_DEVICE_POWER_STATE 1488 PowerStartSelfManagedIoNP( 1489 __inout FxPkgPnp* This 1490 ); 1491 1492 static 1493 WDF_DEVICE_POWER_STATE 1494 PowerStartSelfManagedIoFailed( 1495 __inout FxPkgPnp* This 1496 ); 1497 1498 static 1499 WDF_DEVICE_POWER_STATE 1500 PowerStartSelfManagedIoFailedNP( 1501 __inout FxPkgPnp* This 1502 ); 1503 1504 static 1505 WDF_DEVICE_POWER_STATE 1506 PowerWakePending( 1507 __inout FxPkgPnp* This 1508 ); 1509 1510 static 1511 WDF_DEVICE_POWER_STATE 1512 PowerWakePendingNP( 1513 __inout FxPkgPnp* This 1514 ); 1515 1516 static 1517 WDF_DEVICE_POWER_STATE 1518 PowerWaking( 1519 __inout FxPkgPnp* This 1520 ); 1521 1522 static 1523 WDF_DEVICE_POWER_STATE 1524 PowerWakingNP( 1525 __inout FxPkgPnp* This 1526 ); 1527 1528 static 1529 WDF_DEVICE_POWER_STATE 1530 PowerWakingConnectInterrupt( 1531 __inout FxPkgPnp* This 1532 ); 1533 1534 static 1535 WDF_DEVICE_POWER_STATE 1536 PowerWakingConnectInterruptNP( 1537 __inout FxPkgPnp* This 1538 ); 1539 1540 static 1541 WDF_DEVICE_POWER_STATE 1542 PowerWakingConnectInterruptFailed( 1543 __inout FxPkgPnp* This 1544 ); 1545 1546 static 1547 WDF_DEVICE_POWER_STATE 1548 PowerWakingConnectInterruptFailedNP( 1549 __inout FxPkgPnp* This 1550 ); 1551 1552 static 1553 WDF_DEVICE_POWER_STATE 1554 PowerWakingDmaEnable( 1555 __inout FxPkgPnp* This 1556 ); 1557 1558 static 1559 WDF_DEVICE_POWER_STATE 1560 PowerWakingDmaEnableNP( 1561 __inout FxPkgPnp* This 1562 ); 1563 1564 static 1565 WDF_DEVICE_POWER_STATE 1566 PowerWakingDmaEnableFailed( 1567 __inout FxPkgPnp* This 1568 ); 1569 1570 static 1571 WDF_DEVICE_POWER_STATE 1572 PowerWakingDmaEnableFailedNP( 1573 __inout FxPkgPnp* This 1574 ); 1575 1576 static 1577 WDF_DEVICE_POWER_STATE 1578 PowerReportPowerUpFailedDerefParent( 1579 __inout FxPkgPnp* This 1580 ); 1581 1582 static 1583 WDF_DEVICE_POWER_STATE 1584 PowerReportPowerUpFailed( 1585 __inout FxPkgPnp* This 1586 ); 1587 1588 static 1589 WDF_DEVICE_POWER_STATE 1590 PowerPowerFailedPowerDown( 1591 __inout FxPkgPnp* This 1592 ); 1593 1594 static 1595 WDF_DEVICE_POWER_STATE 1596 PowerReportPowerDownFailed( 1597 __inout FxPkgPnp* This 1598 ); 1599 1600 static 1601 WDF_DEVICE_POWER_STATE 1602 PowerInitialConnectInterruptFailed( 1603 __inout FxPkgPnp* This 1604 ); 1605 1606 static 1607 WDF_DEVICE_POWER_STATE 1608 PowerInitialDmaEnableFailed( 1609 __inout FxPkgPnp* This 1610 ); 1611 1612 static 1613 WDF_DEVICE_POWER_STATE 1614 PowerInitialSelfManagedIoFailed( 1615 __inout FxPkgPnp* This 1616 ); 1617 1618 static 1619 WDF_DEVICE_POWER_STATE 1620 PowerInitialPowerUpFailedDerefParent( 1621 __inout FxPkgPnp* This 1622 ); 1623 1624 static 1625 WDF_DEVICE_POWER_STATE 1626 PowerInitialPowerUpFailed( 1627 __inout FxPkgPnp* This 1628 ); 1629 1630 static 1631 WDF_DEVICE_POWER_STATE 1632 PowerDxSurpriseRemovedPowerDown( 1633 __inout FxPkgPnp* This 1634 ); 1635 1636 static 1637 WDF_DEVICE_POWER_STATE 1638 PowerDxSurpriseRemovedPowerUp( 1639 __inout FxPkgPnp* This 1640 ); 1641 1642 static 1643 WDF_DEVICE_POWER_STATE 1644 PowerDxStoppedDisarmWake( 1645 __inout FxPkgPnp* This 1646 ); 1647 1648 static 1649 WDF_DEVICE_POWER_STATE 1650 PowerDxStoppedDisarmWakeNP( 1651 __inout FxPkgPnp* This 1652 ); 1653 1654 static 1655 WDF_DEVICE_POWER_STATE 1656 PowerGotoDxStoppedDisableInterruptNP( 1657 __inout FxPkgPnp* This 1658 ); 1659 1660 static 1661 WDF_DEVICE_POWER_STATE 1662 PowerGotoDxStopped( 1663 __inout FxPkgPnp* This 1664 ); 1665 1666 static 1667 WDF_DEVICE_POWER_STATE 1668 PowerGotoStopped( 1669 __inout FxPkgPnp* This 1670 ); 1671 1672 static 1673 WDF_DEVICE_POWER_STATE 1674 PowerStoppedCompleteDx( 1675 __inout FxPkgPnp* This 1676 ); 1677 1678 static 1679 WDF_DEVICE_POWER_STATE 1680 PowerDxStoppedDecideDxState( 1681 __inout FxPkgPnp* This 1682 ); 1683 1684 static 1685 WDF_DEVICE_POWER_STATE 1686 PowerDxStoppedArmForWake( 1687 __inout FxPkgPnp* This 1688 ); 1689 1690 static 1691 WDF_DEVICE_POWER_STATE 1692 PowerDxStoppedArmForWakeNP( 1693 __inout FxPkgPnp* This 1694 ); 1695 1696 static 1697 WDF_DEVICE_POWER_STATE 1698 PowerFinalPowerDownFailed( 1699 __inout FxPkgPnp* This 1700 ); 1701 1702 static 1703 WDF_DEVICE_POWER_STATE 1704 PowerD0SurpriseRemoved( 1705 __inout FxPkgPnp* This 1706 ); 1707 1708 static 1709 WDF_DEVICE_POWER_STATE 1710 PowerSurpriseRemoved( 1711 __inout FxPkgPnp* This 1712 ); 1713 1714 static 1715 WDF_DEVICE_POWER_STATE 1716 PowerUpFailedDerefParent( 1717 __inout FxPkgPnp* This 1718 ); 1719 1720 static 1721 WDF_DEVICE_POWER_STATE 1722 PowerUpFailed( 1723 __inout FxPkgPnp* This 1724 ); 1725 1726 static 1727 WDF_DEVICE_POWER_STATE 1728 PowerGotoDxFailed( 1729 __inout FxPkgPnp* This 1730 ); 1731 1732 static 1733 WDF_DEVICE_POWER_STATE 1734 PowerGotoDxStoppedDisableInterrupt( 1735 __inout FxPkgPnp* This 1736 ); 1737 1738 static 1739 WDF_DEVICE_POWER_STATE 1740 PowerUpFailedDerefParentNP( 1741 __inout FxPkgPnp* This 1742 ); 1743 1744 static 1745 WDF_DEVICE_POWER_STATE 1746 PowerUpFailedNP( 1747 __inout FxPkgPnp* This 1748 ); 1749 1750 static 1751 WDF_DEVICE_POWER_STATE 1752 PowerNotifyingD0ExitToWakeInterrupts( 1753 __inout FxPkgPnp* This 1754 ); 1755 1756 static 1757 WDF_DEVICE_POWER_STATE 1758 PowerNotifyingD0EntryToWakeInterrupts( 1759 __inout FxPkgPnp* This 1760 ); 1761 1762 static 1763 WDF_DEVICE_POWER_STATE 1764 PowerNotifyingD0ExitToWakeInterruptsNP( 1765 __inout FxPkgPnp* This 1766 ); 1767 1768 static 1769 WDF_DEVICE_POWER_STATE 1770 PowerNotifyingD0EntryToWakeInterruptsNP( 1771 __inout FxPkgPnp* This 1772 ); 1773 1774 // end power state machine table based callbacks 1775 1776 // begin power policy state machine table based callbacks 1777 static 1778 WDF_DEVICE_POWER_POLICY_STATE 1779 PowerPolStarting( 1780 __inout FxPkgPnp* This 1781 ); 1782 1783 static 1784 WDF_DEVICE_POWER_POLICY_STATE 1785 PowerPolStartingPoweredUp( 1786 __inout FxPkgPnp* This 1787 ); 1788 1789 static 1790 WDF_DEVICE_POWER_POLICY_STATE 1791 PowerPolStartingPoweredUpFailed( 1792 __inout FxPkgPnp* This 1793 ); 1794 1795 static 1796 WDF_DEVICE_POWER_POLICY_STATE 1797 PowerPolStartingSucceeded( 1798 __inout FxPkgPnp* This 1799 ); 1800 1801 static 1802 WDF_DEVICE_POWER_POLICY_STATE 1803 PowerPolStartingFailed( 1804 __inout FxPkgPnp* This 1805 ); 1806 1807 static 1808 WDF_DEVICE_POWER_POLICY_STATE 1809 PowerPolStartingDecideS0Wake( 1810 __inout FxPkgPnp* This 1811 ); 1812 1813 static 1814 WDF_DEVICE_POWER_POLICY_STATE 1815 PowerPolStartedIdleCapable( 1816 __inout FxPkgPnp* This 1817 ); 1818 1819 static 1820 WDF_DEVICE_POWER_POLICY_STATE 1821 PowerPolIdleCapableDeviceIdle( 1822 __inout FxPkgPnp* This 1823 ); 1824 1825 static 1826 WDF_DEVICE_POWER_POLICY_STATE 1827 PowerPolDeviceIdleReturnToActive( 1828 __inout FxPkgPnp* This 1829 ); 1830 1831 static 1832 WDF_DEVICE_POWER_POLICY_STATE 1833 PowerPolDeviceIdleSleeping( 1834 __inout FxPkgPnp* This 1835 ); 1836 1837 static 1838 WDF_DEVICE_POWER_POLICY_STATE 1839 PowerPolDeviceIdleStopping( 1840 __inout FxPkgPnp* This 1841 ); 1842 1843 static 1844 WDF_DEVICE_POWER_POLICY_STATE 1845 PowerPolTimerExpiredNoWake( 1846 __inout FxPkgPnp* This 1847 ); 1848 1849 static 1850 WDF_DEVICE_POWER_POLICY_STATE 1851 PowerPolTimerExpiredNoWakeCompletePowerDown( 1852 __inout FxPkgPnp* This 1853 ); 1854 1855 static 1856 WDF_DEVICE_POWER_POLICY_STATE 1857 PowerPolWaitingUnarmedQueryIdle( 1858 __inout FxPkgPnp* This 1859 ); 1860 1861 static 1862 WDF_DEVICE_POWER_POLICY_STATE 1863 PowerPolS0NoWakePowerUp( 1864 __inout FxPkgPnp* This 1865 ); 1866 1867 static 1868 WDF_DEVICE_POWER_POLICY_STATE 1869 PowerPolS0NoWakeCompletePowerUp( 1870 __inout FxPkgPnp* This 1871 ); 1872 1873 static 1874 WDF_DEVICE_POWER_POLICY_STATE 1875 PowerPolSystemSleepFromDeviceWaitingUnarmed( 1876 __inout FxPkgPnp* This 1877 ); 1878 1879 static 1880 WDF_DEVICE_POWER_POLICY_STATE 1881 PowerPolSystemSleepNeedWake( 1882 __inout FxPkgPnp* This 1883 ); 1884 1885 static 1886 WDF_DEVICE_POWER_POLICY_STATE 1887 PowerPolSystemSleepNeedWakeCompletePowerUp( 1888 __inout FxPkgPnp* This 1889 ); 1890 1891 static 1892 WDF_DEVICE_POWER_POLICY_STATE 1893 PowerPolSystemSleepPowerRequestFailed( 1894 __inout FxPkgPnp* This 1895 ); 1896 1897 static 1898 WDF_DEVICE_POWER_POLICY_STATE 1899 PowerPolCheckPowerPageable( 1900 __inout FxPkgPnp* This 1901 ); 1902 1903 static 1904 WDF_DEVICE_POWER_POLICY_STATE 1905 PowerPolSleepingWakeWakeArrived( 1906 __inout FxPkgPnp* This 1907 ); 1908 1909 static 1910 WDF_DEVICE_POWER_POLICY_STATE 1911 PowerPolSleepingWakeRevertArmWake( 1912 __inout FxPkgPnp* This 1913 ); 1914 1915 static 1916 WDF_DEVICE_POWER_POLICY_STATE 1917 PowerPolSystemAsleepWakeArmed( 1918 __inout FxPkgPnp* This 1919 ); 1920 1921 static 1922 WDF_DEVICE_POWER_POLICY_STATE 1923 PowerPolSystemWakeDeviceWakeEnabled( 1924 __inout FxPkgPnp* This 1925 ); 1926 1927 static 1928 WDF_DEVICE_POWER_POLICY_STATE 1929 PowerPolSystemWakeDeviceWakeEnabledWakeCanceled( 1930 __inout FxPkgPnp* This 1931 ); 1932 1933 static 1934 WDF_DEVICE_POWER_POLICY_STATE 1935 PowerPolSystemWakeDeviceWakeDisarm( 1936 __inout FxPkgPnp* This 1937 ); 1938 1939 static 1940 WDF_DEVICE_POWER_POLICY_STATE 1941 PowerPolSystemWakeDeviceWakeTriggeredS0( 1942 __inout FxPkgPnp* This 1943 ); 1944 1945 static 1946 WDF_DEVICE_POWER_POLICY_STATE 1947 PowerPolSystemWakeDeviceWokeDisarm( 1948 __inout FxPkgPnp* This 1949 ); 1950 1951 static 1952 WDF_DEVICE_POWER_POLICY_STATE 1953 PowerPolSleepingWakeWakeArrivedNP( 1954 __inout FxPkgPnp* This 1955 ); 1956 1957 static 1958 WDF_DEVICE_POWER_POLICY_STATE 1959 PowerPolSleepingWakeRevertArmWakeNP( 1960 __inout FxPkgPnp* This 1961 ); 1962 1963 static 1964 WDF_DEVICE_POWER_POLICY_STATE 1965 PowerPolSleepingWakePowerDownFailed( 1966 __inout FxPkgPnp* This 1967 ); 1968 1969 static 1970 WDF_DEVICE_POWER_POLICY_STATE 1971 PowerPolSleepingWakePowerDownFailedWakeCanceled( 1972 __inout FxPkgPnp* This 1973 ); 1974 1975 static 1976 WDF_DEVICE_POWER_POLICY_STATE 1977 PowerPolSystemAsleepWakeArmedNP( 1978 __inout FxPkgPnp* This 1979 ); 1980 1981 static 1982 WDF_DEVICE_POWER_POLICY_STATE 1983 PowerPolSystemWakeDeviceWakeEnabledNP( 1984 __inout FxPkgPnp* This 1985 ); 1986 1987 static 1988 WDF_DEVICE_POWER_POLICY_STATE 1989 PowerPolSystemWakeDeviceWakeEnabledWakeCanceledNP( 1990 __inout FxPkgPnp* This 1991 ); 1992 1993 static 1994 WDF_DEVICE_POWER_POLICY_STATE 1995 PowerPolSystemWakeDeviceWakeDisarmNP( 1996 __inout FxPkgPnp* This 1997 ); 1998 1999 static 2000 WDF_DEVICE_POWER_POLICY_STATE 2001 PowerPolSystemWakeDeviceWakeTriggeredS0NP( 2002 __inout FxPkgPnp* This 2003 ); 2004 2005 static 2006 WDF_DEVICE_POWER_POLICY_STATE 2007 PowerPolSystemWakeDeviceWokeDisarmNP( 2008 __inout FxPkgPnp* This 2009 ); 2010 2011 static 2012 WDF_DEVICE_POWER_POLICY_STATE 2013 PowerPolSystemWakeDeviceWakeCompletePowerUp( 2014 __inout FxPkgPnp* This 2015 ); 2016 2017 static 2018 WDF_DEVICE_POWER_POLICY_STATE 2019 PowerPolSleeping( 2020 __inout FxPkgPnp* This 2021 ); 2022 2023 static 2024 WDF_DEVICE_POWER_POLICY_STATE 2025 PowerPolSleepingNoWakePowerDown( 2026 __inout FxPkgPnp* This 2027 ); 2028 2029 static 2030 WDF_DEVICE_POWER_POLICY_STATE 2031 PowerPolSleepingNoWakeCompletePowerDown( 2032 __inout FxPkgPnp* This 2033 ); 2034 2035 static 2036 WDF_DEVICE_POWER_POLICY_STATE 2037 PowerPolSleepingNoWakeDxRequestFailed( 2038 __inout FxPkgPnp* This 2039 ); 2040 2041 static 2042 WDF_DEVICE_POWER_POLICY_STATE 2043 PowerPolSleepingWakePowerDown( 2044 __inout FxPkgPnp* This 2045 ); 2046 2047 static 2048 WDF_DEVICE_POWER_POLICY_STATE 2049 PowerPolSleepingSendWake( 2050 __inout FxPkgPnp* This 2051 ); 2052 2053 static 2054 WDF_DEVICE_POWER_POLICY_STATE 2055 PowerPolSystemAsleepNoWake( 2056 __inout FxPkgPnp* This 2057 ); 2058 2059 static 2060 WDF_DEVICE_POWER_POLICY_STATE 2061 PowerPolSystemWakeDeviceWakeDisabled( 2062 __inout FxPkgPnp* This 2063 ); 2064 2065 static 2066 WDF_DEVICE_POWER_POLICY_STATE 2067 PowerPolSystemWakeDeviceToD0( 2068 __inout FxPkgPnp* This 2069 ); 2070 2071 static 2072 WDF_DEVICE_POWER_POLICY_STATE 2073 PowerPolSystemWakeDeviceToD0CompletePowerUp( 2074 __inout FxPkgPnp* This 2075 ); 2076 2077 static 2078 WDF_DEVICE_POWER_POLICY_STATE 2079 PowerPolSystemWakeQueryIdle( 2080 __inout FxPkgPnp* This 2081 ); 2082 2083 static 2084 WDF_DEVICE_POWER_POLICY_STATE 2085 PowerPolStartedWakeCapable( 2086 __inout FxPkgPnp* This 2087 ); 2088 2089 static 2090 WDF_DEVICE_POWER_POLICY_STATE 2091 PowerPolWakeCapableDeviceIdle( 2092 __inout FxPkgPnp* This 2093 ); 2094 2095 static 2096 WDF_DEVICE_POWER_POLICY_STATE 2097 PowerPolWakeCapableUsbSSCompleted( 2098 __inout FxPkgPnp* This 2099 ); 2100 2101 static 2102 WDF_DEVICE_POWER_POLICY_STATE 2103 PowerPolTimerExpiredDecideUsbSS( 2104 __inout FxPkgPnp* This 2105 ); 2106 2107 static 2108 WDF_DEVICE_POWER_POLICY_STATE 2109 PowerPolTimerExpiredWakeCapablePowerDown( 2110 __inout FxPkgPnp* This 2111 ); 2112 2113 static 2114 WDF_DEVICE_POWER_POLICY_STATE 2115 PowerPolTimerExpiredWakeCapableSendWake( 2116 __inout FxPkgPnp* This 2117 ); 2118 2119 static 2120 WDF_DEVICE_POWER_POLICY_STATE 2121 PowerPolTimerExpiredWakeCapableUsbSS( 2122 __inout FxPkgPnp* This 2123 ); 2124 2125 static 2126 WDF_DEVICE_POWER_POLICY_STATE 2127 PowerPolTimerExpiredWakeCapableWakeArrived( 2128 __inout FxPkgPnp* This 2129 ); 2130 2131 static 2132 WDF_DEVICE_POWER_POLICY_STATE 2133 PowerPolTimerExpiredWakeCapableCancelWake( 2134 __inout FxPkgPnp* This 2135 ); 2136 2137 static 2138 WDF_DEVICE_POWER_POLICY_STATE 2139 PowerPolTimerExpiredWakeCapableWakeCanceled( 2140 __inout FxPkgPnp* This 2141 ); 2142 2143 static 2144 WDF_DEVICE_POWER_POLICY_STATE 2145 PowerPolTimerExpiredWakeCapableCleanup( 2146 __inout FxPkgPnp* This 2147 ); 2148 2149 static 2150 WDF_DEVICE_POWER_POLICY_STATE 2151 PowerPolTimerExpiredWakeCapableDxAllocFailed( 2152 __inout FxPkgPnp* This 2153 ); 2154 2155 static 2156 WDF_DEVICE_POWER_POLICY_STATE 2157 PowerPolTimerExpiredWakeCapableUndoPowerDown( 2158 __inout FxPkgPnp* This 2159 ); 2160 2161 static 2162 WDF_DEVICE_POWER_POLICY_STATE 2163 PowerPolTimerExpiredWakeCompletedPowerDown( 2164 __inout FxPkgPnp* This 2165 ); 2166 2167 static 2168 WDF_DEVICE_POWER_POLICY_STATE 2169 PowerPolTimerExpiredWakeCompletedPowerUp( 2170 __inout FxPkgPnp* This 2171 ); 2172 2173 static 2174 WDF_DEVICE_POWER_POLICY_STATE 2175 PowerPolTimerExpiredWakeCompletedHardwareStarted( 2176 __inout FxPkgPnp* This 2177 ); 2178 2179 static 2180 WDF_DEVICE_POWER_POLICY_STATE 2181 PowerPolWaitingArmedUsbSS( 2182 __inout FxPkgPnp* This 2183 ); 2184 2185 static 2186 WDF_DEVICE_POWER_POLICY_STATE 2187 PowerPolWaitingArmedQueryIdle( 2188 __inout FxPkgPnp* This 2189 ); 2190 2191 static 2192 WDF_DEVICE_POWER_POLICY_STATE 2193 PowerPolIoPresentArmed( 2194 __inout FxPkgPnp* This 2195 ); 2196 2197 static 2198 WDF_DEVICE_POWER_POLICY_STATE 2199 PowerPolIoPresentArmedWakeCanceled( 2200 __inout FxPkgPnp* This 2201 ); 2202 2203 static 2204 WDF_DEVICE_POWER_POLICY_STATE 2205 PowerPolS0WakeDisarm( 2206 __inout FxPkgPnp* This 2207 ); 2208 2209 static 2210 WDF_DEVICE_POWER_POLICY_STATE 2211 PowerPolS0WakeCompletePowerUp( 2212 __inout FxPkgPnp* This 2213 ); 2214 2215 static 2216 WDF_DEVICE_POWER_POLICY_STATE 2217 PowerPolTimerExpiredWakeSucceeded( 2218 __inout FxPkgPnp* This 2219 ); 2220 2221 static 2222 WDF_DEVICE_POWER_POLICY_STATE 2223 PowerPolTimerExpiredWakeCompletedDisarm( 2224 __inout FxPkgPnp* This 2225 ); 2226 2227 static 2228 WDF_DEVICE_POWER_POLICY_STATE 2229 PowerPolWakeFailedUsbSS( 2230 __inout FxPkgPnp* This 2231 ); 2232 2233 static 2234 WDF_DEVICE_POWER_POLICY_STATE 2235 PowerPolTimerExpiredWakeCapablePowerDownFailedCancelWake( 2236 __inout FxPkgPnp* This 2237 ); 2238 2239 static 2240 WDF_DEVICE_POWER_POLICY_STATE 2241 PowerPolTimerExpiredWakeCapablePowerDownFailedWakeCanceled( 2242 __inout FxPkgPnp* This 2243 ); 2244 2245 static 2246 WDF_DEVICE_POWER_POLICY_STATE 2247 PowerPolTimerExpiredWakeCapablePowerDownFailedUsbSS( 2248 __inout FxPkgPnp* This 2249 ); 2250 2251 static 2252 WDF_DEVICE_POWER_POLICY_STATE 2253 PowerPolCancelingWakeForSystemSleep( 2254 __inout FxPkgPnp* This 2255 ); 2256 2257 static 2258 WDF_DEVICE_POWER_POLICY_STATE 2259 PowerPolCancelingWakeForSystemSleepWakeCanceled( 2260 __inout FxPkgPnp* This 2261 ); 2262 2263 static 2264 WDF_DEVICE_POWER_POLICY_STATE 2265 PowerPolDisarmingWakeForSystemSleepCompletePowerUp( 2266 __inout FxPkgPnp* This 2267 ); 2268 2269 static 2270 WDF_DEVICE_POWER_POLICY_STATE 2271 PowerPolPowerUpForSystemSleepFailed( 2272 __inout FxPkgPnp* This 2273 ); 2274 2275 static 2276 WDF_DEVICE_POWER_POLICY_STATE 2277 PowerPolWokeFromS0UsbSS( 2278 __inout FxPkgPnp* This 2279 ); 2280 2281 static 2282 WDF_DEVICE_POWER_POLICY_STATE 2283 PowerPolWokeFromS0( 2284 __inout FxPkgPnp* This 2285 ); 2286 2287 static 2288 WDF_DEVICE_POWER_POLICY_STATE 2289 PowerPolWokeFromS0NotifyDriver( 2290 __inout FxPkgPnp* This 2291 ); 2292 2293 static 2294 WDF_DEVICE_POWER_POLICY_STATE 2295 PowerPolStoppingResetDevice( 2296 __inout FxPkgPnp* This 2297 ); 2298 2299 static 2300 WDF_DEVICE_POWER_POLICY_STATE 2301 PowerPolStoppingResetDeviceCompletePowerUp( 2302 __inout FxPkgPnp* This 2303 ); 2304 2305 static 2306 WDF_DEVICE_POWER_POLICY_STATE 2307 PowerPolStoppingResetDeviceFailed( 2308 __inout FxPkgPnp* This 2309 ); 2310 2311 static 2312 WDF_DEVICE_POWER_POLICY_STATE 2313 PowerPolStoppingD0( 2314 __inout FxPkgPnp* This 2315 ); 2316 2317 static 2318 WDF_DEVICE_POWER_POLICY_STATE 2319 PowerPolStoppingD0Failed( 2320 __inout FxPkgPnp* This 2321 ); 2322 2323 static 2324 WDF_DEVICE_POWER_POLICY_STATE 2325 PowerPolStoppingDisarmWake( 2326 __inout FxPkgPnp* This 2327 ); 2328 2329 static 2330 WDF_DEVICE_POWER_POLICY_STATE 2331 PowerPolStoppingDisarmWakeCancelWake( 2332 __inout FxPkgPnp* This 2333 ); 2334 2335 static 2336 WDF_DEVICE_POWER_POLICY_STATE 2337 PowerPolStoppingDisarmWakeWakeCanceled( 2338 __inout FxPkgPnp* This 2339 ); 2340 2341 static 2342 WDF_DEVICE_POWER_POLICY_STATE 2343 PowerPolStopping( 2344 __inout FxPkgPnp* This 2345 ); 2346 2347 static 2348 WDF_DEVICE_POWER_POLICY_STATE 2349 PowerPolStoppingSucceeded( 2350 __inout FxPkgPnp* This 2351 ); 2352 2353 static 2354 WDF_DEVICE_POWER_POLICY_STATE 2355 PowerPolStoppingFailed( 2356 __inout FxPkgPnp* This 2357 ); 2358 2359 static 2360 WDF_DEVICE_POWER_POLICY_STATE 2361 PowerPolStoppingSendStatus( 2362 __inout FxPkgPnp* This 2363 ); 2364 2365 static 2366 WDF_DEVICE_POWER_POLICY_STATE 2367 PowerPolStoppedRemoving( 2368 __inout FxPkgPnp* This 2369 ); 2370 2371 static 2372 WDF_DEVICE_POWER_POLICY_STATE 2373 PowerPolRemoved( 2374 __inout FxPkgPnp* This 2375 ); 2376 2377 static 2378 WDF_DEVICE_POWER_POLICY_STATE 2379 PowerPolRestarting( 2380 __inout FxPkgPnp* This 2381 ); 2382 2383 static 2384 WDF_DEVICE_POWER_POLICY_STATE 2385 PowerPolRestartingFailed( 2386 __inout FxPkgPnp* This 2387 ); 2388 2389 static 2390 WDF_DEVICE_POWER_POLICY_STATE 2391 PowerPolStoppingCancelTimer( 2392 __inout FxPkgPnp* This 2393 ); 2394 2395 static 2396 WDF_DEVICE_POWER_POLICY_STATE 2397 PowerPolStoppingCancelUsbSS( 2398 __inout FxPkgPnp* This 2399 ); 2400 2401 static 2402 WDF_DEVICE_POWER_POLICY_STATE 2403 PowerPolStoppingCancelWake( 2404 __inout FxPkgPnp* This 2405 ); 2406 2407 static 2408 WDF_DEVICE_POWER_POLICY_STATE 2409 PowerPolCancelUsbSS( 2410 __inout FxPkgPnp* This 2411 ); 2412 2413 static 2414 WDF_DEVICE_POWER_POLICY_STATE 2415 PowerPolStarted( 2416 __inout FxPkgPnp* This 2417 ); 2418 2419 static 2420 WDF_DEVICE_POWER_POLICY_STATE 2421 PowerPolStartedCancelTimer( 2422 __inout FxPkgPnp* This 2423 ); 2424 2425 static 2426 WDF_DEVICE_POWER_POLICY_STATE 2427 PowerPolStartedWakeCapableCancelTimerForSleep( 2428 __inout FxPkgPnp* This 2429 ); 2430 2431 static 2432 WDF_DEVICE_POWER_POLICY_STATE 2433 PowerPolStartedWakeCapableSleepingUsbSS( 2434 __inout FxPkgPnp* This 2435 ); 2436 2437 static 2438 WDF_DEVICE_POWER_POLICY_STATE 2439 PowerPolStartedIdleCapableCancelTimerForSleep( 2440 __inout FxPkgPnp* This 2441 ); 2442 2443 static 2444 WDF_DEVICE_POWER_POLICY_STATE 2445 PowerPolDeviceD0PowerRequestFailed( 2446 __inout FxPkgPnp* This 2447 ); 2448 2449 static 2450 WDF_DEVICE_POWER_POLICY_STATE 2451 PowerPolDevicePowerRequestFailed( 2452 __inout FxPkgPnp* This 2453 ); 2454 2455 static 2456 WDF_DEVICE_POWER_POLICY_STATE 2457 PowerPolSleepingPowerDownNotProcessed( 2458 __inout FxPkgPnp* This 2459 ); 2460 2461 static 2462 WDF_DEVICE_POWER_POLICY_STATE 2463 PowerPolTimerExpiredWakeCapablePowerDownNotProcessed( 2464 __inout FxPkgPnp* This 2465 ); 2466 2467 static 2468 WDF_DEVICE_POWER_POLICY_STATE 2469 PowerPolTimerExpiredNoWakePowerDownNotProcessed( 2470 __inout FxPkgPnp* This 2471 ); 2472 2473 static 2474 WDF_DEVICE_POWER_POLICY_STATE 2475 PowerPolTimerExpiredNoWakeUndoPowerDown( 2476 __inout FxPkgPnp* This 2477 ); 2478 2479 static 2480 WDF_DEVICE_POWER_POLICY_STATE 2481 PowerPolTimerExpiredNoWakeReturnToActive( 2482 __inout FxPkgPnp* This 2483 ); 2484 2485 static 2486 WDF_DEVICE_POWER_POLICY_STATE 2487 PowerPolTimerExpiredNoWakePoweredDownDisableIdleTimer( 2488 __inout FxPkgPnp* This 2489 ); 2490 2491 static 2492 WDF_DEVICE_POWER_POLICY_STATE 2493 PowerPolPowerUpForSystemSleepNotSeen( 2494 __inout FxPkgPnp* This 2495 ); 2496 2497 static 2498 WDF_DEVICE_POWER_POLICY_STATE 2499 PowerPolWaitingArmedStoppingCancelUsbSS( 2500 __inout FxPkgPnp* This 2501 ); 2502 2503 static 2504 WDF_DEVICE_POWER_POLICY_STATE 2505 PowerPolWaitingArmedWakeFailedCancelUsbSS( 2506 __inout FxPkgPnp* This 2507 ); 2508 2509 static 2510 WDF_DEVICE_POWER_POLICY_STATE 2511 PowerPolWaitingArmedIoPresentCancelUsbSS( 2512 __inout FxPkgPnp* This 2513 ); 2514 2515 static 2516 WDF_DEVICE_POWER_POLICY_STATE 2517 PowerPolWaitingArmedWakeSucceededCancelUsbSS( 2518 __inout FxPkgPnp* This 2519 ); 2520 static 2521 WDF_DEVICE_POWER_POLICY_STATE 2522 PowerPolCancelingUsbSSForSystemSleep( 2523 __inout FxPkgPnp* This 2524 ); 2525 2526 static 2527 WDF_DEVICE_POWER_POLICY_STATE 2528 PowerPolStoppingD0CancelUsbSS( 2529 __inout FxPkgPnp* This 2530 ); 2531 2532 static 2533 WDF_DEVICE_POWER_POLICY_STATE 2534 PowerPolWaitingArmedWakeInterruptFired( 2535 __inout FxPkgPnp* This 2536 ); 2537 2538 static 2539 WDF_DEVICE_POWER_POLICY_STATE 2540 PowerPolSystemWakeDeviceWakeInterruptFired( 2541 __inout FxPkgPnp* This 2542 ); 2543 2544 static 2545 WDF_DEVICE_POWER_POLICY_STATE 2546 PowerPolSystemWakeDeviceWakeInterruptFiredNP( 2547 __inout FxPkgPnp* This 2548 ); 2549 2550 static 2551 WDF_DEVICE_POWER_POLICY_STATE 2552 PowerPolTimerExpiredWakeCapableWakeInterruptArrived( 2553 __inout FxPkgPnp* This 2554 ); 2555 2556 static 2557 WDF_DEVICE_POWER_POLICY_STATE 2558 NotPowerPolOwnerStarting( 2559 __inout FxPkgPnp* This 2560 ); 2561 2562 static 2563 WDF_DEVICE_POWER_POLICY_STATE 2564 NotPowerPolOwnerStarted( 2565 __inout FxPkgPnp* This 2566 ); 2567 2568 static 2569 WDF_DEVICE_POWER_POLICY_STATE 2570 NotPowerPolOwnerGotoDx( 2571 __inout FxPkgPnp* This 2572 ); 2573 2574 static 2575 WDF_DEVICE_POWER_POLICY_STATE 2576 NotPowerPolOwnerGotoDxInDx( 2577 __inout FxPkgPnp* This 2578 ); 2579 2580 static 2581 WDF_DEVICE_POWER_POLICY_STATE 2582 NotPowerPolOwnerGotoD0( 2583 __inout FxPkgPnp* This 2584 ); 2585 2586 static 2587 WDF_DEVICE_POWER_POLICY_STATE 2588 NotPowerPolOwnerGotoD0InD0( 2589 __inout FxPkgPnp* This 2590 ); 2591 2592 static 2593 WDF_DEVICE_POWER_POLICY_STATE 2594 NotPowerPolOwnerStopping( 2595 __inout FxPkgPnp* This 2596 ); 2597 2598 static 2599 WDF_DEVICE_POWER_POLICY_STATE 2600 NotPowerPolOwnerStoppingSendStatus( 2601 __inout FxPkgPnp* This 2602 ); 2603 2604 static 2605 WDF_DEVICE_POWER_POLICY_STATE 2606 NotPowerPolOwnerStartingFailed( 2607 __inout FxPkgPnp* This 2608 ); 2609 2610 static 2611 WDF_DEVICE_POWER_POLICY_STATE 2612 NotPowerPolOwnerStoppingFailed( 2613 __inout FxPkgPnp* This 2614 ); 2615 2616 static 2617 WDF_DEVICE_POWER_POLICY_STATE 2618 NotPowerPolOwnerStoppingPoweringUp( 2619 __inout FxPkgPnp* This 2620 ); 2621 2622 static 2623 WDF_DEVICE_POWER_POLICY_STATE 2624 NotPowerPolOwnerStoppingPoweringDown( 2625 __inout FxPkgPnp* This 2626 ); 2627 2628 static 2629 WDF_DEVICE_POWER_POLICY_STATE 2630 NotPowerPolOwnerRemoved( 2631 __inout FxPkgPnp* This 2632 ); 2633 2634 // end power policy state machine table based callbacks 2635 2636 VOID 2637 PowerGotoDx( 2638 VOID 2639 ); 2640 2641 BOOLEAN 2642 PowerGotoDxIoStopped( 2643 VOID 2644 ); 2645 2646 BOOLEAN 2647 PowerGotoDxIoStoppedNP( 2648 VOID 2649 ); 2650 2651 BOOLEAN 2652 PowerDmaEnableAndScan( 2653 __in BOOLEAN ImplicitPowerUp 2654 ); 2655 2656 VOID 2657 PowerCompletePendedWakeIrp( 2658 VOID 2659 ); 2660 2661 VOID 2662 PowerCompleteWakeRequestFromWithinMachine( 2663 __in NTSTATUS Status 2664 ); 2665 2666 BOOLEAN 2667 PowerMakeWakeRequestNonCancelable( 2668 __in NTSTATUS Status 2669 ); 2670 2671 BOOLEAN 2672 PowerIsWakeRequestPresent( 2673 VOID 2674 ) 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 // 2685 return m_SharedPower.m_WaitWakeIrp != NULL ? TRUE : FALSE; 2686 } 2687 2688 VOID 2689 PowerSendIdlePowerEvent( 2690 __in FxPowerIdleEvents Event 2691 ); 2692 2693 VOID 2694 PowerSendPowerDownEvents( 2695 __in FxPowerDownType Type 2696 ); 2697 2698 VOID 2699 PowerSendPowerUpEvents( 2700 VOID 2701 ); 2702 2703 VOID 2704 PowerSendPowerDownFailureEvent( 2705 __in FxPowerDownType Type 2706 ); 2707 2708 VOID 2709 PowerSendPowerUpFailureEvent( 2710 VOID 2711 ); 2712 2713 VOID 2714 PowerSetDevicePowerState( 2715 __in WDF_POWER_DEVICE_STATE State 2716 ); 2717 2718 _Must_inspect_result_ 2719 BOOLEAN 2720 PowerDmaPowerUp( 2721 VOID 2722 ); 2723 2724 BOOLEAN 2725 PowerDmaPowerDown( 2726 VOID 2727 ); 2728 2729 VOID 2730 PowerConnectInterruptFailed( 2731 VOID 2732 ); 2733 2734 static 2735 MdCancelRoutineType 2736 _PowerWaitWakeCancelRoutine; 2737 2738 VOID 2739 PowerPolicyUpdateSystemWakeSource( 2740 __in FxIrp* Irp 2741 ); 2742 2743 static 2744 VOID 2745 _PowerSetSystemWakeSource( 2746 __in FxIrp* Irp 2747 ); 2748 2749 static 2750 MdRequestPowerCompleteType 2751 _PowerPolDeviceWaitWakeComplete; 2752 2753 static 2754 MdRequestPowerCompleteType 2755 _PowerPolDevicePowerDownComplete; 2756 2757 static 2758 MdRequestPowerCompleteType 2759 _PowerPolDevicePowerUpComplete; 2760 2761 _Must_inspect_result_ 2762 NTSTATUS 2763 PowerPolicySendDevicePowerRequest( 2764 __in DEVICE_POWER_STATE DeviceState, 2765 __in SendDeviceRequestAction Action 2766 ); 2767 2768 _Must_inspect_result_ 2769 NTSTATUS 2770 PowerPolicySendWaitWakeRequest( 2771 __in SYSTEM_POWER_STATE SystemState 2772 ); 2773 2774 VOID 2775 PowerPolicyCompleteSystemPowerIrp( 2776 VOID 2777 ); 2778 2779 BOOLEAN 2780 PowerPolicyCancelWaitWake( 2781 VOID 2782 ); 2783 2784 VOID 2785 PowerPolicySubmitUsbIdleNotification( 2786 VOID 2787 ); 2788 2789 BOOLEAN 2790 PowerPolicyCancelUsbSSIfCapable( 2791 VOID 2792 ); 2793 2794 VOID 2795 PowerPolicyCancelUsbSS( 2796 VOID 2797 ); 2798 2799 static 2800 MdCompletionRoutineType 2801 _PowerPolicyWaitWakeCompletionRoutine; 2802 2803 static 2804 MdCompletionRoutineType 2805 _PowerPolicyUsbSelectiveSuspendCompletionRoutine; 2806 2807 SYSTEM_POWER_STATE 2808 PowerPolicyGetPendingSystemState( 2809 VOID 2810 ) 2811 { 2812 FxIrp irp(m_PendingSystemPowerIrp); 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) 2820 (irp.GetParameterPowerSystemPowerStateContext()). 2821 TargetSystemState; 2822 } 2823 2824 _Must_inspect_result_ 2825 NTSTATUS 2826 PowerPolicyHandleSystemQueryPower( 2827 __in SYSTEM_POWER_STATE QueryState 2828 ); 2829 2830 BOOLEAN 2831 PowerPolicyCanWakeFromSystemState( 2832 __in SYSTEM_POWER_STATE SystemState 2833 ) 2834 { 2835 return SystemState <= PowerPolicyGetDeviceDeepestSystemWakeState(); 2836 } 2837 2838 SYSTEM_POWER_STATE 2839 PowerPolicyGetDeviceDeepestSystemWakeState( 2840 VOID 2841 ) 2842 { 2843 return (SYSTEM_POWER_STATE) m_SystemWake; 2844 } 2845 2846 DEVICE_POWER_STATE 2847 PowerPolicyGetDeviceDeepestDeviceWakeState( 2848 __in SYSTEM_POWER_STATE SystemState 2849 ); 2850 2851 static 2852 CPPNP_STATE_TABLE 2853 GetPnpTableEntry( 2854 __in WDF_DEVICE_PNP_STATE State 2855 ) 2856 { 2857 return &m_WdfPnpStates[WdfDevStateNormalize(State) - WdfDevStatePnpObjectCreated]; 2858 } 2859 2860 static 2861 CPPOWER_STATE_TABLE 2862 GetPowerTableEntry( 2863 __in WDF_DEVICE_POWER_STATE State 2864 ) 2865 { 2866 return &m_WdfPowerStates[WdfDevStateNormalize(State) - WdfDevStatePowerObjectCreated]; 2867 } 2868 2869 static 2870 CPPOWER_POLICY_STATE_TABLE 2871 GetPowerPolicyTableEntry( 2872 __in WDF_DEVICE_POWER_POLICY_STATE State 2873 ) 2874 { 2875 return &m_WdfPowerPolicyStates[WdfDevStateNormalize(State) - WdfDevStatePwrPolObjectCreated]; 2876 } 2877 2878 #if FX_STATE_MACHINE_VERIFY 2879 static 2880 CPPNP_STATE_ENTRY_FN_RETURN_STATE_TABLE 2881 GetPnpStateEntryFunctionReturnStatesTableEntry( 2882 __in WDF_DEVICE_PNP_STATE State 2883 ) 2884 { 2885 return &m_WdfPnpStateEntryFunctionReturnStates[WdfDevStateNormalize(State) - WdfDevStatePnpObjectCreated]; 2886 } 2887 2888 static 2889 CPPOWER_STATE_ENTRY_FN_RETURN_STATE_TABLE 2890 GetPowerStateEntryFunctionReturnStatesTableEntry( 2891 __in WDF_DEVICE_POWER_STATE State 2892 ) 2893 { 2894 return &m_WdfPowerStateEntryFunctionReturnStates[WdfDevStateNormalize(State) - WdfDevStatePowerObjectCreated]; 2895 } 2896 2897 static 2898 CPPWR_POL_STATE_ENTRY_FN_RETURN_STATE_TABLE 2899 GetPwrPolStateEntryFunctionReturnStatesTableEntry( 2900 __in WDF_DEVICE_POWER_POLICY_STATE State 2901 ) 2902 { 2903 return &m_WdfPwrPolStateEntryFunctionReturnStates[WdfDevStateNormalize(State) - WdfDevStatePwrPolObjectCreated]; 2904 } 2905 2906 VOID 2907 ValidatePnpStateEntryFunctionReturnValue( 2908 WDF_DEVICE_PNP_STATE CurrentState, 2909 WDF_DEVICE_PNP_STATE NewState 2910 ); 2911 2912 VOID 2913 ValidatePowerStateEntryFunctionReturnValue( 2914 WDF_DEVICE_POWER_STATE CurrentState, 2915 WDF_DEVICE_POWER_STATE NewState 2916 ); 2917 2918 VOID 2919 ValidatePwrPolStateEntryFunctionReturnValue( 2920 WDF_DEVICE_POWER_POLICY_STATE CurrentState, 2921 WDF_DEVICE_POWER_POLICY_STATE NewState 2922 ); 2923 #endif //FX_STATE_MACHINE_VERIFY 2924 2925 _Must_inspect_result_ 2926 static 2927 CPNOT_POWER_POLICY_OWNER_STATE_TABLE 2928 GetNotPowerPolicyOwnerTableEntry( 2929 __in WDF_DEVICE_POWER_POLICY_STATE State 2930 ) 2931 { 2932 ULONG i; 2933 2934 for (i = 0; 2935 m_WdfNotPowerPolicyOwnerStates[i].CurrentTargetState != WdfDevStatePwrPolNull; 2936 i++) { 2937 if (m_WdfNotPowerPolicyOwnerStates[i].CurrentTargetState == State) { 2938 return &m_WdfNotPowerPolicyOwnerStates[i]; 2939 } 2940 } 2941 2942 return NULL; 2943 } 2944 2945 static 2946 NTSTATUS 2947 _S0IdleQueryInstance( 2948 __in CfxDevice* Device, 2949 __in FxWmiInstanceInternal* Instance, 2950 __in ULONG OutBufferSize, 2951 __out PVOID OutBuffer, 2952 __out PULONG BufferUsed 2953 ); 2954 2955 static 2956 NTSTATUS 2957 _S0IdleSetInstance( 2958 __in CfxDevice* Device, 2959 __in FxWmiInstanceInternal* Instance, 2960 __in ULONG InBufferSize, 2961 __in PVOID InBuffer 2962 ); 2963 2964 static 2965 NTSTATUS 2966 _S0IdleSetItem( 2967 __in CfxDevice* Device, 2968 __in FxWmiInstanceInternal* Instance, 2969 __in ULONG DataItemId, 2970 __in ULONG InBufferSize, 2971 __in PVOID InBuffer 2972 ); 2973 2974 static 2975 NTSTATUS 2976 _SxWakeQueryInstance( 2977 __in CfxDevice* Device, 2978 __in FxWmiInstanceInternal* Instaace, 2979 __in ULONG OutBufferSize, 2980 __out PVOID OutBuffer, 2981 __out PULONG BufferUsed 2982 ); 2983 2984 static 2985 NTSTATUS 2986 _SxWakeSetInstance( 2987 __in CfxDevice* Device, 2988 __in FxWmiInstanceInternal* Instance, 2989 __in ULONG InBufferSize, 2990 __in PVOID InBuffer 2991 ); 2992 2993 static 2994 NTSTATUS 2995 _SxWakeSetItem( 2996 __in CfxDevice* Device, 2997 __in FxWmiInstanceInternal* Instance, 2998 __in ULONG DataItemId, 2999 __in ULONG InBufferSize, 3000 __in PVOID InBuffer 3001 ); 3002 3003 BOOLEAN 3004 IsPresentPendingPnpIrp( 3005 VOID 3006 ) 3007 { 3008 return (m_PendingPnPIrp != NULL) ? TRUE : FALSE; 3009 } 3010 3011 VOID 3012 SetPendingPnpIrp( 3013 __inout FxIrp* Irp, 3014 __in BOOLEAN MarkIrpPending = TRUE 3015 ); 3016 3017 VOID 3018 SetPendingPnpIrpStatus( 3019 __in NTSTATUS Status 3020 ) 3021 { 3022 FxIrp irp(m_PendingPnPIrp); 3023 3024 ASSERT(m_PendingPnPIrp != NULL); 3025 irp.SetStatus(Status); 3026 } 3027 3028 MdIrp 3029 ClearPendingPnpIrp( 3030 VOID 3031 ) 3032 { 3033 MdIrp irp; 3034 3035 irp = m_PendingPnPIrp; 3036 m_PendingPnPIrp = NULL; 3037 3038 return irp; 3039 } 3040 3041 MdIrp 3042 GetPendingPnpIrp( 3043 VOID 3044 ) 3045 { 3046 return m_PendingPnPIrp; 3047 } 3048 3049 VOID 3050 SetPendingDevicePowerIrp( 3051 __inout FxIrp* Irp 3052 ) 3053 { 3054 ASSERT(m_PendingDevicePowerIrp == NULL); 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 } 3067 3068 MdIrp 3069 ClearPendingDevicePowerIrp( 3070 VOID 3071 ) 3072 { 3073 MdIrp irp; 3074 3075 irp = m_PendingDevicePowerIrp; 3076 m_PendingDevicePowerIrp = NULL; 3077 3078 return irp; 3079 } 3080 3081 VOID 3082 SetPendingSystemPowerIrp( 3083 __inout FxIrp* Irp 3084 ) 3085 { 3086 ASSERT(m_PendingSystemPowerIrp == NULL); 3087 Irp->MarkIrpPending(); 3088 m_PendingSystemPowerIrp = Irp->GetIrp(); 3089 } 3090 3091 MdIrp 3092 ClearPendingSystemPowerIrp( 3093 VOID 3094 ) 3095 { 3096 MdIrp irp; 3097 3098 irp = m_PendingSystemPowerIrp; 3099 m_PendingSystemPowerIrp = NULL; 3100 3101 return irp; 3102 } 3103 3104 MdIrp 3105 GetPendingSystemPowerIrp( 3106 VOID 3107 ) 3108 { 3109 return m_PendingSystemPowerIrp; 3110 } 3111 3112 BOOLEAN 3113 IsDevicePowerUpIrpPending( 3114 VOID 3115 ) 3116 { 3117 DEVICE_POWER_STATE state; 3118 FxIrp irp(m_PendingDevicePowerIrp); 3119 3120 if (irp.GetIrp() == NULL) { 3121 return FALSE; 3122 } 3123 3124 state = irp.GetParameterPowerStateDeviceState(); 3125 3126 return (state == PowerDeviceD0 ? TRUE : FALSE); 3127 } 3128 3129 BOOLEAN 3130 IsUsageSupported( 3131 __in DEVICE_USAGE_NOTIFICATION_TYPE Usage 3132 ) 3133 { 3134 return m_SpecialSupport[((ULONG)Usage)-1]; 3135 } 3136 3137 VOID 3138 SetUsageSupport( 3139 __in DEVICE_USAGE_NOTIFICATION_TYPE Usage, 3140 __in BOOLEAN Supported 3141 ) 3142 { 3143 m_SpecialSupport[((ULONG) Usage)-1] = Supported; 3144 } 3145 3146 LONG 3147 AdjustUsageCount( 3148 __in DEVICE_USAGE_NOTIFICATION_TYPE Usage, 3149 __in BOOLEAN Add 3150 ) 3151 { 3152 if (Add) { 3153 return InterlockedIncrement(&m_SpecialFileCount[((ULONG)Usage)-1]); 3154 } 3155 else { 3156 return InterlockedDecrement(&m_SpecialFileCount[((ULONG)Usage)-1]); 3157 } 3158 } 3159 3160 LONG 3161 GetUsageCount( 3162 // __range(WdfSpecialFilePaging, WdfSpecialFileBoot) 3163 __in __range(1, 4) ULONG Usage 3164 ) 3165 { 3166 return m_SpecialFileCount[Usage-1]; 3167 } 3168 3169 BOOLEAN 3170 IsInSpecialUse( 3171 VOID 3172 ) 3173 { 3174 if (GetUsageCount(WdfSpecialFilePaging) == 0 && 3175 GetUsageCount(WdfSpecialFileHibernation) == 0 && 3176 GetUsageCount(WdfSpecialFileDump) == 0 && 3177 GetUsageCount(WdfSpecialFileBoot) == 0) { 3178 return FALSE; 3179 } 3180 else { 3181 return TRUE; 3182 } 3183 } 3184 3185 static 3186 DEVICE_USAGE_NOTIFICATION_TYPE 3187 _SpecialTypeToUsage( 3188 __in WDF_SPECIAL_FILE_TYPE Type 3189 ) 3190 { 3191 switch (Type) { 3192 case WdfSpecialFilePaging: return DeviceUsageTypePaging; 3193 case WdfSpecialFileHibernation: return DeviceUsageTypeHibernation; 3194 case WdfSpecialFileDump: return DeviceUsageTypeDumpFile; 3195 case WdfSpecialFileBoot: return DeviceUsageTypeBoot; 3196 default: ASSERT(FALSE);return DeviceUsageTypePaging; 3197 } 3198 } 3199 3200 static 3201 WDF_SPECIAL_FILE_TYPE 3202 _UsageToSpecialType( 3203 __in DEVICE_USAGE_NOTIFICATION_TYPE Type 3204 ) 3205 { 3206 switch (Type) { 3207 case DeviceUsageTypePaging: return WdfSpecialFilePaging; 3208 case DeviceUsageTypeHibernation: return WdfSpecialFileHibernation; 3209 case DeviceUsageTypeDumpFile: return WdfSpecialFileDump; 3210 case DeviceUsageTypeBoot: return WdfSpecialFileBoot; 3211 default: ASSERT(FALSE); return WdfSpecialFilePaging; 3212 } 3213 } 3214 3215 ULONG 3216 SetUsageNotificationFlags( 3217 __in DEVICE_USAGE_NOTIFICATION_TYPE Type, 3218 __in BOOLEAN InPath 3219 ); 3220 3221 VOID 3222 RevertUsageNotificationFlags( 3223 __in DEVICE_USAGE_NOTIFICATION_TYPE Type, 3224 __in BOOLEAN InPath, 3225 __in ULONG OldFlags 3226 ); 3227 3228 VOID 3229 CommitUsageNotification( 3230 __in DEVICE_USAGE_NOTIFICATION_TYPE Type, 3231 __in ULONG OldFlags 3232 ); 3233 3234 _Must_inspect_result_ 3235 NTSTATUS 3236 CreatePowerThread( 3237 VOID 3238 ); 3239 3240 public: 3241 VOID 3242 PnpProcessEvent( 3243 __in FxPnpEvent Event, 3244 __in BOOLEAN ProcessEventOnDifferentThread = FALSE 3245 ); 3246 3247 VOID 3248 PowerProcessEvent( 3249 __in FxPowerEvent Event, 3250 __in BOOLEAN ProcessEventOnDifferentThread = FALSE 3251 ); 3252 3253 VOID 3254 PowerPolicyProcessEvent( 3255 __in FxPowerPolicyEvent Event, 3256 __in BOOLEAN ProcessEventOnDifferentThread = FALSE 3257 ); 3258 3259 BOOLEAN 3260 ShouldProcessPnpEventOnDifferentThread( 3261 __in KIRQL CurrentIrql, 3262 __in BOOLEAN CallerSpecifiedProcessingOnDifferentThread 3263 ); 3264 3265 BOOLEAN 3266 ShouldProcessPowerPolicyEventOnDifferentThread( 3267 __in KIRQL CurrentIrql, 3268 __in BOOLEAN CallerSpecifiedProcessingOnDifferentThread 3269 ); 3270 3271 VOID 3272 CleanupStateMachines( 3273 __in BOOLEAN ClenaupPnp 3274 ); 3275 3276 VOID 3277 CleanupDeviceFromFailedCreate( 3278 __in MxEvent * WaitEvent 3279 ); 3280 3281 _Must_inspect_result_ 3282 virtual 3283 NTSTATUS 3284 Initialize( 3285 __in PWDFDEVICE_INIT DeviceInit 3286 ); 3287 3288 _Must_inspect_result_ 3289 NTSTATUS 3290 PostCreateDeviceInitialize( 3291 VOID 3292 ); 3293 3294 virtual 3295 VOID 3296 FinishInitialize( 3297 __inout PWDFDEVICE_INIT DeviceInit 3298 ); 3299 3300 VOID 3301 SetSpecialFileSupport( 3302 __in WDF_SPECIAL_FILE_TYPE FileType, 3303 __in BOOLEAN Supported 3304 ); 3305 3306 _Must_inspect_result_ 3307 NTSTATUS 3308 RegisterCallbacks( 3309 __in PWDF_PNPPOWER_EVENT_CALLBACKS DispatchTable 3310 ); 3311 3312 VOID 3313 RegisterPowerPolicyCallbacks( 3314 __in PWDF_POWER_POLICY_EVENT_CALLBACKS Callbacks 3315 ); 3316 3317 NTSTATUS 3318 RegisterPowerPolicyWmiInstance( 3319 __in const GUID* Guid, 3320 __in FxWmiInstanceInternalCallbacks* Callbacks, 3321 __out FxWmiInstanceInternal** Instance 3322 ); 3323 3324 NTSTATUS 3325 PowerPolicySetS0IdleSettings( 3326 __in PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings 3327 ); 3328 3329 NTSTATUS 3330 AssignPowerFrameworkSettings( 3331 __in PWDF_POWER_FRAMEWORK_SETTINGS PowerFrameworkSettings 3332 ); 3333 3334 NTSTATUS 3335 PowerPolicySetSxWakeSettings( 3336 __in PWDF_DEVICE_POWER_POLICY_WAKE_SETTINGS Settings, 3337 __in BOOLEAN ArmForWakeIfChildrenAreArmedForWake, 3338 __in BOOLEAN IndicateChildWakeOnParentWake 3339 ); 3340 3341 private: 3342 3343 VOID 3344 DisconnectInterruptNP( 3345 VOID 3346 ); 3347 3348 NTSTATUS 3349 UpdateWmiInstanceForS0Idle( 3350 __in FxWmiInstanceAction Action 3351 ); 3352 3353 VOID 3354 ReadRegistryS0Idle( 3355 __in PCUNICODE_STRING ValueName, 3356 __out BOOLEAN *Enabled 3357 ); 3358 3359 NTSTATUS 3360 UpdateWmiInstanceForSxWake( 3361 __in FxWmiInstanceAction Action 3362 ); 3363 3364 VOID 3365 ReadRegistrySxWake( 3366 __in PCUNICODE_STRING ValueName, 3367 __out BOOLEAN *Enabled 3368 ); 3369 3370 VOID 3371 WriteStateToRegistry( 3372 __in HANDLE RegKey, 3373 __in PUNICODE_STRING ValueName, 3374 __in ULONG Value 3375 ); 3376 3377 NTSTATUS 3378 ReadStateFromRegistry( 3379 _In_ PCUNICODE_STRING ValueName, 3380 _Out_ PULONG Value 3381 ); 3382 3383 NTSTATUS 3384 UpdateWmiInstance( 3385 _In_ FxWmiInstanceAction Action, 3386 _In_ BOOLEAN ForS0Idle 3387 ); 3388 3389 public: 3390 BOOLEAN 3391 PowerIndicateWaitWakeStatus( 3392 __in NTSTATUS WaitWakeStatus 3393 ); 3394 3395 BOOLEAN 3396 PowerPolicyIsWakeEnabled( 3397 VOID 3398 ); 3399 3400 ULONG 3401 PowerPolicyGetCurrentWakeReason( 3402 VOID 3403 ); 3404 3405 BOOLEAN 3406 __inline 3407 PowerPolicyShouldPropagateWakeStatusToChildren( 3408 VOID 3409 ) 3410 { 3411 return m_PowerPolicyMachine.m_Owner->m_WakeSettings.IndicateChildWakeOnParentWake; 3412 } 3413 3414 VOID 3415 ChildRemoved( 3416 VOID 3417 ) 3418 { 3419 LONG c; 3420 3421 // 3422 // Called by a child that we are waiting on its removal 3423 // 3424 c = InterlockedDecrement(&m_PendingChildCount); 3425 ASSERT(c >= 0); 3426 3427 if (c == 0) { 3428 PnpProcessEvent(PnpEventChildrenRemovalComplete); 3429 } 3430 } 3431 3432 VOID 3433 PowerPolicySetS0IdleState( 3434 __in BOOLEAN State 3435 ); 3436 3437 VOID 3438 PowerPolicySetSxWakeState( 3439 __in BOOLEAN State 3440 ); 3441 3442 VOID 3443 SetPowerCaps( 3444 __in PWDF_DEVICE_POWER_CAPABILITIES PowerCapabilities 3445 ); 3446 3447 VOID 3448 SetPnpCaps( 3449 __in PWDF_DEVICE_PNP_CAPABILITIES PnpCapabilities 3450 ); 3451 3452 VOID 3453 GetPnpState( 3454 __out PWDF_DEVICE_STATE State 3455 ); 3456 3457 VOID 3458 SetPnpState( 3459 __in PWDF_DEVICE_STATE State 3460 ); 3461 3462 VOID 3463 SetDeviceFailed( 3464 __in WDF_DEVICE_FAILED_ACTION FailedAction 3465 ); 3466 3467 VOID 3468 SetChildBusInformation( 3469 __in PPNP_BUS_INFORMATION BusInformation 3470 ) 3471 { 3472 RtlCopyMemory(&m_BusInformation, 3473 BusInformation, 3474 sizeof(PNP_BUS_INFORMATION)); 3475 } 3476 3477 _Must_inspect_result_ 3478 NTSTATUS 3479 HandleQueryBusInformation( 3480 __inout FxIrp* Irp 3481 ); 3482 3483 _Must_inspect_result_ 3484 NTSTATUS 3485 __inline 3486 PowerReference( 3487 __in BOOLEAN WaitForD0, 3488 __in_opt PVOID Tag = NULL, 3489 __in_opt LONG Line = 0, 3490 __in_opt PSTR File = NULL 3491 ) 3492 { 3493 return m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.PowerReference(WaitForD0, Tag, Line, File); 3494 } 3495 3496 VOID 3497 __inline 3498 PowerDereference( 3499 __in_opt PVOID Tag = NULL, 3500 __in_opt LONG Line = 0, 3501 __in_opt PSTR File = NULL 3502 ) 3503 { 3504 m_PowerPolicyMachine.m_Owner->m_PowerIdleMachine.IoDecrement(Tag, Line, File); 3505 } 3506 3507 BOOLEAN 3508 HasPowerThread( 3509 VOID 3510 ) 3511 { 3512 return m_HasPowerThread; 3513 } 3514 3515 VOID 3516 QueueToPowerThread( 3517 __in PWORK_QUEUE_ITEM WorkItem 3518 ) 3519 { 3520 m_PowerThreadInterface.PowerThreadEnqueue( 3521 m_PowerThreadInterface.Interface.Context, 3522 WorkItem 3523 ); 3524 } 3525 3526 _Must_inspect_result_ 3527 NTSTATUS 3528 AddUsageDevice( 3529 __in MdDeviceObject DependentDevice 3530 ); 3531 3532 VOID 3533 RemoveUsageDevice( 3534 __in MdDeviceObject DependentDevice 3535 ); 3536 3537 _Must_inspect_result_ 3538 NTSTATUS 3539 AddRemovalDevice( 3540 __in MdDeviceObject DependentDevice 3541 ); 3542 3543 VOID 3544 RemoveRemovalDevice( 3545 __in MdDeviceObject DependentDevice 3546 ); 3547 3548 VOID 3549 ClearRemovalDevicesList( 3550 VOID 3551 ); 3552 3553 _Must_inspect_result_ 3554 NTSTATUS 3555 AllocateEnumInfo( 3556 VOID 3557 ); 3558 3559 VOID 3560 AddChildList( 3561 __in FxChildList* List 3562 ); 3563 3564 VOID 3565 RemoveChildList( 3566 __in FxChildList* List 3567 ); 3568 3569 VOID 3570 ChildListNotifyRemove( 3571 __inout PLONG PendingCount 3572 ); 3573 3574 _Must_inspect_result_ 3575 NTSTATUS 3576 AllocateDmaEnablerList( 3577 VOID 3578 ); 3579 3580 VOID 3581 AddDmaEnabler( 3582 __in FxDmaEnabler* Enabler 3583 ); 3584 3585 VOID 3586 RemoveDmaEnabler( 3587 __in FxDmaEnabler* Enabler 3588 ); 3589 3590 VOID 3591 RevokeDmaEnablerResources( 3592 __in FxDmaEnabler* Enabler 3593 ); 3594 3595 VOID 3596 AddQueryInterface( 3597 __in FxQueryInterface* QI, 3598 __in BOOLEAN Lock 3599 ); 3600 3601 VOID 3602 QueryForD3ColdInterface( 3603 VOID 3604 ); 3605 3606 VOID 3607 DropD3ColdInterface( 3608 VOID 3609 ); 3610 3611 BOOLEAN 3612 IsPowerPolicyOwner( 3613 VOID 3614 ) 3615 { 3616 return m_PowerPolicyMachine.m_Owner != NULL ? TRUE : FALSE; 3617 } 3618 3619 BOOLEAN 3620 SupportsWakeInterrupt( 3621 VOID 3622 ) 3623 { 3624 if (m_WakeInterruptCount > 0) { 3625 return TRUE; 3626 } else { 3627 return FALSE; 3628 } 3629 } 3630 3631 BOOLEAN 3632 IsS0IdleWakeFromS0Enabled( 3633 VOID 3634 ) 3635 { 3636 if (IsPowerPolicyOwner()) { 3637 return m_PowerPolicyMachine.m_Owner->m_IdleSettings.WakeFromS0Capable; 3638 } 3639 else { 3640 return FALSE; 3641 } 3642 } 3643 3644 BOOLEAN 3645 IsS0IdleSystemManaged( 3646 VOID 3647 ) 3648 { 3649 if (IsPowerPolicyOwner()) { 3650 return m_PowerPolicyMachine.m_Owner->m_IdleSettings.m_TimeoutMgmt.UsingSystemManagedIdleTimeout(); 3651 } 3652 else { 3653 return FALSE; 3654 } 3655 } 3656 3657 BOOLEAN 3658 IsS0IdleUsbSSEnabled( 3659 VOID 3660 ) 3661 { 3662 if (IsPowerPolicyOwner()) { 3663 return (m_PowerPolicyMachine.m_Owner->m_IdleSettings.WakeFromS0Capable && 3664 m_PowerPolicyMachine.m_Owner->m_IdleSettings.UsbSSCapable); 3665 } 3666 else { 3667 return FALSE; 3668 } 3669 } 3670 3671 BOOLEAN 3672 IsSxWakeEnabled( 3673 VOID 3674 ) 3675 { 3676 if (IsPowerPolicyOwner()) { 3677 return m_PowerPolicyMachine.m_Owner->m_WakeSettings.Enabled; 3678 } 3679 else { 3680 return FALSE; 3681 } 3682 } 3683 3684 _Must_inspect_result_ 3685 NTSTATUS 3686 PowerPolicyCanChildPowerUp( 3687 __out PBOOLEAN PowerUp 3688 ) 3689 { 3690 *PowerUp = FALSE; 3691 3692 if (IsPowerPolicyOwner()) { 3693 NTSTATUS status; 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 // 3700 status = PowerReference(FALSE); 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 // 3721 m_PowerPolicyMachine.m_Owner->m_ChildrenPoweredOnCount++; 3722 *PowerUp = m_PowerPolicyMachine.m_Owner->m_ChildrenCanPowerUp; 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 } 3744 3745 VOID 3746 PowerPolicyChildPoweredDown( 3747 VOID 3748 ) 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()); 3759 ASSERT(m_PowerPolicyMachine.m_Owner->m_ChildrenPoweredOnCount > 0); 3760 m_PowerPolicyMachine.m_Owner->m_ChildrenPoweredOnCount--; 3761 m_EnumInfo->ReleaseParentPowerStateLock(GetDriverGlobals()); 3762 3763 PowerDereference(); 3764 } 3765 } 3766 3767 POWER_ACTION 3768 GetSystemPowerAction( 3769 VOID 3770 ) 3771 { 3772 return (POWER_ACTION) m_SystemPowerAction; 3773 } 3774 3775 VOID 3776 ProcessDelayedDeletion( 3777 VOID 3778 ); 3779 3780 3781 VOID 3782 SignalDeviceRemovedEvent( 3783 VOID 3784 ) 3785 { 3786 m_DeviceRemoveProcessed->Set(); 3787 } 3788 3789 virtual 3790 NTSTATUS 3791 FireAndForgetIrp( 3792 FxIrp* Irp 3793 ) =0; 3794 3795 FxCmResList * 3796 GetTranslatedResourceList( 3797 VOID 3798 ) 3799 { 3800 return m_Resources; 3801 } 3802 3803 FxCmResList * 3804 GetRawResourceList( 3805 VOID 3806 ) 3807 { 3808 return m_ResourcesRaw; 3809 } 3810 3811 ULONG 3812 GetInterruptObjectCount( 3813 VOID 3814 ) 3815 { 3816 return m_InterruptObjectCount; 3817 } 3818 3819 VOID 3820 AckPendingWakeInterruptOperation( 3821 __in BOOLEAN ProcessPowerEventOnDifferentThread 3822 ); 3823 3824 VOID 3825 SendEventToAllWakeInterrupts( 3826 __in enum FxWakeInterruptEvents WakeInterruptEvent 3827 ); 3828 3829 private: 3830 VOID 3831 PowerPolicyCheckAssumptions( 3832 VOID 3833 ); 3834 3835 VOID 3836 PowerCheckAssumptions( 3837 VOID 3838 ); 3839 3840 VOID 3841 PnpCheckAssumptions( 3842 VOID 3843 ); 3844 3845 VOID 3846 NotifyResourceobjectsToReleaseResources( 3847 VOID 3848 ); 3849 3850 _Must_inspect_result_ 3851 NTSTATUS 3852 NotifyResourceObjectsD0( 3853 __in ULONG NotifyFlags 3854 ); 3855 3856 NTSTATUS 3857 NotifyResourceObjectsDx( 3858 __in ULONG NotifyFlags 3859 ); 3860 3861 BOOLEAN 3862 PnpCheckAndIncrementRestartCount( 3863 VOID 3864 ); 3865 3866 BOOLEAN 3867 PnpIncrementRestartCountLogic( 3868 _In_ HANDLE RestartKey, 3869 _In_ BOOLEAN CreatedNewKey 3870 ); 3871 3872 VOID 3873 PnpCleanupForRemove( 3874 __in BOOLEAN GracefulRemove 3875 ); 3876 3877 virtual 3878 NTSTATUS 3879 ProcessRemoveDeviceOverload( 3880 FxIrp* Irp 3881 ) =0; 3882 3883 virtual 3884 VOID 3885 DeleteSymbolicLinkOverload( 3886 BOOLEAN GracefulRemove 3887 ) =0; 3888 3889 virtual 3890 VOID 3891 QueryForReenumerationInterface( 3892 VOID 3893 ) =0; 3894 3895 virtual 3896 VOID 3897 ReleaseReenumerationInterface( 3898 VOID 3899 ) =0; 3900 3901 virtual 3902 NTSTATUS 3903 AskParentToRemoveAndReenumerate( 3904 VOID 3905 ) =0; 3906 3907 _Must_inspect_result_ 3908 NTSTATUS 3909 CreatePowerThreadIfNeeded( 3910 VOID 3911 ); 3912 3913 virtual 3914 NTSTATUS 3915 QueryForPowerThread( 3916 VOID 3917 ) =0; 3918 3919 VOID 3920 ReleasePowerThread( 3921 VOID 3922 ); 3923 3924 _Must_inspect_result_ 3925 NTSTATUS 3926 HandleQueryInterfaceForPowerThread( 3927 __inout FxIrp* Irp, 3928 __out PBOOLEAN CompleteRequest 3929 ); 3930 3931 _Must_inspect_result_ 3932 NTSTATUS 3933 PnpPowerReferenceSelf( 3934 VOID 3935 ); 3936 3937 VOID 3938 PnpPowerDereferenceSelf( 3939 VOID 3940 ); 3941 3942 static 3943 VOID 3944 _PowerThreadEnqueue( 3945 __in PVOID Context, 3946 __in PWORK_QUEUE_ITEM WorkItem 3947 ) 3948 { 3949 BOOLEAN result; 3950 3951 result = ((FxPkgPnp*) Context)->m_PowerThread->QueueWorkItem(WorkItem); 3952 #if DBG 3953 ASSERT(result); 3954 #else 3955 UNREFERENCED_PARAMETER(result); 3956 #endif 3957 } 3958 3959 static 3960 VOID 3961 STDCALL 3962 _PowerThreadInterfaceReference( 3963 __inout PVOID Context 3964 ); 3965 3966 static 3967 VOID 3968 STDCALL 3969 _PowerThreadInterfaceDereference( 3970 __inout PVOID Context 3971 ); 3972 3973 BOOLEAN 3974 PowerPolicyCanIdlePowerDown( 3975 __in DEVICE_POWER_STATE DxState 3976 ); 3977 3978 VOID 3979 PowerPolicyPostParentToD0ToChildren( 3980 VOID 3981 ); 3982 3983 VOID 3984 PowerPolicyChildrenCanPowerUp( 3985 VOID 3986 ); 3987 3988 VOID 3989 __inline 3990 PowerPolicyDisarmWakeFromSx( 3991 VOID 3992 ); 3993 3994 _Must_inspect_result_ 3995 NTSTATUS 3996 PowerPolicyPowerDownForSx( 3997 __in DEVICE_POWER_STATE DxState, 3998 __in SendDeviceRequestAction Action 3999 ) 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 // 4011 PowerPolicyBlockChildrenPowerUp(); 4012 4013 return PowerPolicySendDevicePowerRequest(DxState, Action); 4014 } 4015 4016 VOID 4017 PowerPolicyBlockChildrenPowerUp( 4018 VOID 4019 ) 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 // 4026 m_PowerPolicyMachine.m_Owner->m_ChildrenCanPowerUp = FALSE; 4027 m_EnumInfo->ReleaseParentPowerStateLock(GetDriverGlobals()); 4028 } 4029 } 4030 4031 _Must_inspect_result_ 4032 NTSTATUS 4033 PnpPowerReferenceDuringQueryPnp( 4034 VOID 4035 ); 4036 4037 public: 4038 _Must_inspect_result_ 4039 NTSTATUS 4040 ValidateCmResource( 4041 __inout PCM_PARTIAL_RESOURCE_DESCRIPTOR* CmResourceRaw, 4042 __inout PCM_PARTIAL_RESOURCE_DESCRIPTOR* CmResource 4043 ); 4044 4045 _Must_inspect_result_ 4046 NTSTATUS 4047 ValidateInterruptResourceCm( 4048 __in PCM_PARTIAL_RESOURCE_DESCRIPTOR CmIntResourceRaw, 4049 __in PCM_PARTIAL_RESOURCE_DESCRIPTOR CmIntResource, 4050 __in PWDF_INTERRUPT_CONFIG Configuration 4051 ); 4052 4053 BOOLEAN 4054 IsDefaultReleaseHardwareOrder( 4055 VOID 4056 ) 4057 { 4058 #if FX_IS_KERNEL_MODE 4059 return (m_ReleaseHardwareAfterDescendantsOnFailure == WdfReleaseHardwareOrderOnFailureEarly ? TRUE : FALSE); 4060 #else 4061 return FALSE; 4062 #endif 4063 } 4064 4065 BOOLEAN 4066 HasMultipleInterrupts( 4067 VOID 4068 ) 4069 { 4070 return (m_InterruptObjectCount > 1 ? TRUE : FALSE); 4071 } 4072 4073 VOID 4074 WakeInterruptCreated( 4075 VOID 4076 ) 4077 { 4078 ASSERT(IsPowerPolicyOwner() != FALSE); 4079 4080 ++m_WakeInterruptCount; 4081 } 4082 4083 // 4084 // Start of members 4085 // 4086 public: 4087 4088 FxPnpStateAndCaps m_PnpStateAndCaps; 4089 4090 ULONG m_PnpCapsAddress; 4091 ULONG m_PnpCapsUINumber; 4092 4093 FxPowerCaps m_PowerCaps; 4094 4095 BOOLEAN m_Failed; 4096 4097 // 4098 // Track the current device and system power states. 4099 // 4100 4101 // SYSTEM_POWER_STATE 4102 BYTE m_SystemPowerState; 4103 4104 // WDF_POWER_DEVICE_STATE 4105 BYTE m_DevicePowerState; 4106 4107 // WDF_POWER_DEVICE_STATE 4108 BYTE m_DevicePowerStateOld; 4109 4110 // 4111 // List of dependent devices for usage notifications 4112 // 4113 FxRelatedDeviceList* m_UsageDependentDeviceList; 4114 4115 FxRelatedDeviceList* m_RemovalDeviceList; 4116 4117 // 4118 // Collection of FxQueryInterface objects 4119 // 4120 FxWaitLockInternal m_QueryInterfaceLock; 4121 4122 SINGLE_LIST_ENTRY m_QueryInterfaceHead; 4123 4124 FxWaitLockInternal m_DeviceInterfaceLock; 4125 4126 SINGLE_LIST_ENTRY m_DeviceInterfaceHead; 4127 4128 BOOLEAN m_DeviceInterfacesCanBeEnabled; 4129 4130 // 4131 // Indicate the types of special files which are supported. 4132 // 4133 BOOLEAN m_SpecialSupport[WdfSpecialFileMax-1]; 4134 4135 // 4136 // Track the number of special file notifications 4137 // (ie. paging file, crash dump file, and hibernate file). 4138 // 4139 LONG m_SpecialFileCount[WdfSpecialFileMax-1]; 4140 4141 // 4142 // ULONG and not a BOOLEAN so the driver can match nest calls to 4143 // WdfDeviceSetStaticStopRemove without having to track the count on their 4144 // own. 4145 // 4146 ULONG m_DeviceStopCount; 4147 4148 // 4149 // All 3 state machine engines 4150 // 4151 FxPnpMachine m_PnpMachine; 4152 FxPowerMachine m_PowerMachine; 4153 FxPowerPolicyMachine m_PowerPolicyMachine; 4154 4155 FxSelfManagedIoMachine* m_SelfManagedIoMachine; 4156 4157 // 4158 // Data shared between the power and power policy machines determining how 4159 // we handle wait wake irps. 4160 // 4161 SharedPowerData m_SharedPower; 4162 4163 // 4164 // Interface for managing the difference between D3hot and D3cold. 4165 // 4166 D3COLD_SUPPORT_INTERFACE m_D3ColdInterface; 4167 4168 protected: 4169 // 4170 // Event that is set when processing a remove device is complete 4171 // 4172 MxEvent* m_DeviceRemoveProcessed; 4173 4174 // 4175 // Count of children we need to fully remove when the parent (this package) 4176 // is being removed. 4177 // 4178 LONG m_PendingChildCount; 4179 4180 // 4181 // DEVICE_WAKE_DEPTH - Indicates the lowest D-state that can successfully 4182 // generate a wake signal from a particular S-state. The array is tightly- 4183 // packed, with index 0 corresponding to PowerSystemWorking. 4184 // 4185 BYTE m_DeviceWake[DeviceWakeStates]; 4186 4187 // SYSTEM_POWER_STATE 4188 BYTE m_SystemWake; 4189 4190 // WDF_DEVICE_FAILED_ACTION 4191 BYTE m_FailedAction; 4192 4193 // 4194 // Set the event which indicates that the pnp state machine is done outside 4195 // of the state machine so that we can drain any remaining state machine 4196 // events in the removing thread before signaling the event. 4197 // 4198 BYTE m_SetDeviceRemoveProcessed; 4199 4200 // 4201 // Interface to queue a work item to the devnode's power thread. Any device 4202 // in the stack can export the power thread, but it must be the lowest 4203 // device in the stack capable of doing so. This would always be a WDF 4204 // enumerated PDO, but could theoretically be any PDO. If the PDO does 4205 // support this interface, WDF will try to export the interface in a filter 4206 // or FDO. 4207 // 4208 // This export is not publicly defined because this is an internal WDF 4209 // implementation detail where we want to use as few threads as possible, 4210 // but still guarantee that non power pagable devices can operate a passive 4211 // level and not be blocked by paging I/O (which eliminates using work items). 4212 // 4213 POWER_THREAD_INTERFACE m_PowerThreadInterface; 4214 4215 FxEnumerationInfo* m_EnumInfo; 4216 4217 // 4218 // Translated resources 4219 // 4220 FxCmResList* m_Resources; 4221 4222 // 4223 // Raw resources 4224 // 4225 FxCmResList* m_ResourcesRaw; 4226 4227 FxSpinLockTransactionedList* m_DmaEnablerList; 4228 4229 // 4230 // Bus information for any enumerated children 4231 // 4232 PNP_BUS_INFORMATION m_BusInformation; 4233 4234 // 4235 // Number of times we have tried to enumerate children but failed 4236 // 4237 UCHAR m_BusEnumRetries; 4238 4239 // 4240 // The power action corresponding to the system power transition 4241 // 4242 UCHAR m_SystemPowerAction; 4243 4244 // 4245 // TRUE once the entire stack has been queried for the caps 4246 // 4247 BOOLEAN m_CapsQueried; 4248 4249 BOOLEAN m_InternalFailure; 4250 4251 // 4252 // if FALSE, there is no power thread available on the devnode currently 4253 // and a work item should be enqueued. if TRUE, there is a power thread 4254 // and the callback should be enqueued to it. 4255 // 4256 BOOLEAN m_HasPowerThread; 4257 4258 // 4259 // If TRUE, we guarantee that in *all* cases that the ReleaseHardware 4260 // callback for the current device is invoked only after all descendent 4261 // devices have already been removed. We do this by ensuring that 4262 // ReleaseHardware is only ever invoked when there is a PNP IRP such as 4263 // remove, surprise-remove or stop is pending in the device. PNP already 4264 // ensures that it sends us that IRP only after all child devices have 4265 // processed the corresponding IRP in their stacks. 4266 // 4267 // Even if FALSE, in *most* cases, the ReleaseHardware callback of the 4268 // current device should still be invoked only after all descendent devices 4269 // have already been stopped/removed. However, in some failure paths we 4270 // might invoke the ReleaseHardware callback of the current device before 4271 // all descendent devices have been stopped. In these cases, we do not wait 4272 // for the surprise-remove IRP sent as a result of the failure in order to 4273 // invoke ReleaseHardware. Instead, we invoke it proactively. 4274 // 4275 // The default value is FALSE. 4276 // 4277 BOOLEAN m_ReleaseHardwareAfterDescendantsOnFailure; 4278 4279 // 4280 // GUID for querying for a power thread down the stack 4281 // 4282 static const GUID GUID_POWER_THREAD_INTERFACE; 4283 4284 #if (FX_CORE_MODE==FX_CORE_KERNEL_MODE) 4285 // 4286 // Interrupt APIs for Vista and forward 4287 // 4288 PFN_IO_CONNECT_INTERRUPT_EX m_IoConnectInterruptEx; 4289 PFN_IO_DISCONNECT_INTERRUPT_EX m_IoDisconnectInterruptEx; 4290 // 4291 // Interrupt APIs for Windows 8 and forward 4292 // 4293 PFN_IO_REPORT_INTERRUPT_ACTIVE m_IoReportInterruptActive; 4294 PFN_IO_REPORT_INTERRUPT_INACTIVE m_IoReportInterruptInactive; 4295 #endif 4296 4297 private: 4298 4299 // 4300 // For user mode we need to preallocate event since its initialization can 4301 // fail 4302 // 4303 #if (FX_CORE_MODE==FX_CORE_USER_MODE) 4304 FxCREvent m_CleanupEventUm; 4305 MxEvent m_RemoveEventUm; 4306 #endif 4307 4308 ULONG m_InterruptObjectCount; 4309 4310 LIST_ENTRY m_InterruptListHead; 4311 4312 // 4313 // Number of interrupts that are declared to be capable 4314 // of waking from low power 4315 // 4316 ULONG m_WakeInterruptCount; 4317 4318 // 4319 // Count that keeps track of the number of wake interrupt 4320 // machines that have acknowledged back an event queued 4321 // in to them by the device level PnP/Power code 4322 // 4323 ULONG m_WakeInterruptPendingAckCount; 4324 4325 // 4326 // Keeps track of whether the last system wake was due to 4327 // a wake interrupt, so that we can report this device as 4328 // the source of wake to the power manager 4329 // 4330 BOOLEAN m_SystemWokenByWakeInterrupt; 4331 4332 // 4333 // If TRUE, do not disconnect wake interrupts even if there is no 4334 // pended IRP_MN_WAIT_WAKE. This works around a race condition between 4335 // the wake interrupt firing (and the wake ISR running) and the device 4336 // powering down. This flag is set when we are in a wake-enabled device 4337 // powering down path and is cleared when the device is powered up again. 4338 // 4339 BOOLEAN m_WakeInterruptsKeepConnected; 4340 4341 // 4342 // If TRUE, the PNP State has reached PnpEventStarted at least once. 4343 // 4344 BOOLEAN m_AchievedStart; 4345 4346 // 4347 // Non NULL when this device is exporting the power thread interface. This 4348 // would be the lowest device in the stack that supports this interface. 4349 // 4350 FxSystemThread* m_PowerThread; 4351 4352 LONG m_PowerThreadInterfaceReferenceCount; 4353 4354 FxCREvent* m_PowerThreadEvent; 4355 4356 // 4357 // The current pnp state changing irp in the stack that we have pended to 4358 // process in the pnp state machine 4359 // 4360 MdIrp m_PendingPnPIrp; 4361 4362 // 4363 // The current system power irp in the stack that we have pended to process 4364 // in the power state machine 4365 // 4366 MdIrp m_PendingSystemPowerIrp; 4367 4368 // 4369 // The current device power irp in the stack that we have pended to process 4370 // in the power state machine 4371 // 4372 MdIrp m_PendingDevicePowerIrp; 4373 4374 FxPnpStateCallback* m_PnpStateCallbacks; 4375 4376 FxPowerStateCallback* m_PowerStateCallbacks; 4377 4378 FxPowerPolicyStateCallback* m_PowerPolicyStateCallbacks; 4379 4380 static const PNP_STATE_TABLE m_WdfPnpStates[]; 4381 static const POWER_STATE_TABLE m_WdfPowerStates[]; 4382 static const POWER_POLICY_STATE_TABLE m_WdfPowerPolicyStates[]; 4383 static const NOT_POWER_POLICY_OWNER_STATE_TABLE m_WdfNotPowerPolicyOwnerStates[]; 4384 4385 static const PNP_EVENT_TARGET_STATE m_PnpInitOtherStates[]; 4386 static const PNP_EVENT_TARGET_STATE m_PnpInitStartingOtherStates[]; 4387 static const PNP_EVENT_TARGET_STATE m_PnpHardwareAvailableOtherStates[]; 4388 static const PNP_EVENT_TARGET_STATE m_PnpQueryStopPendingOtherStates[]; 4389 static const PNP_EVENT_TARGET_STATE m_PnpRemovedPdoWaitOtherStates[]; 4390 static const PNP_EVENT_TARGET_STATE m_PnpRestartingOtherStates[]; 4391 static const PNP_EVENT_TARGET_STATE m_PnpStartedOtherStates[]; 4392 static const PNP_EVENT_TARGET_STATE m_PnpQueryRemovePendingOtherStates[]; 4393 static const PNP_EVENT_TARGET_STATE m_PnpQueriedRemovingOtherStates[]; 4394 static const PNP_EVENT_TARGET_STATE m_PnpInitQueryRemoveOtherStates[]; 4395 static const PNP_EVENT_TARGET_STATE m_PnpStoppedOtherStates[]; 4396 static const PNP_EVENT_TARGET_STATE m_PnpStoppedWaitForStartCompletionOtherStates[]; 4397 static const PNP_EVENT_TARGET_STATE m_PnpStartedStoppingOtherStates[]; 4398 static const PNP_EVENT_TARGET_STATE m_PnpStartedStoppingFailedOtherStates[]; 4399 static const PNP_EVENT_TARGET_STATE m_PnpEjectFailedOtherStates[]; 4400 static const PNP_EVENT_TARGET_STATE m_PnpStartedRemovingOtherStates[]; 4401 static const PNP_EVENT_TARGET_STATE m_PnpFailedPowerDownOtherStates[]; 4402 static const PNP_EVENT_TARGET_STATE m_PnpFailedIoStartingOtherStates[]; 4403 static const PNP_EVENT_TARGET_STATE m_PnpFailedWaitForRemoveOtherStates[]; 4404 static const PNP_EVENT_TARGET_STATE m_PnpRestartOtherStates[]; 4405 static const PNP_EVENT_TARGET_STATE m_PnpRestartReleaseHardware[]; 4406 static const PNP_EVENT_TARGET_STATE m_PnpRestartHardwareAvailableOtherStates[]; 4407 4408 static const POWER_EVENT_TARGET_STATE m_PowerD0OtherStates[]; 4409 static const POWER_EVENT_TARGET_STATE m_PowerD0NPOtherStates[]; 4410 static const POWER_EVENT_TARGET_STATE m_PowerD0BusWakeOwnerOtherStates[]; 4411 static const POWER_EVENT_TARGET_STATE m_PowerD0BusWakeOwnerNPOtherStates[]; 4412 static const POWER_EVENT_TARGET_STATE m_PowerD0ArmedForWakeOtherStates[]; 4413 static const POWER_EVENT_TARGET_STATE m_PowerD0ArmedForWakeNPOtherStates[]; 4414 static const POWER_EVENT_TARGET_STATE m_PowerDNotZeroOtherStates[]; 4415 static const POWER_EVENT_TARGET_STATE m_PowerDNotZeroNPOtherStates[]; 4416 static const POWER_EVENT_TARGET_STATE m_DxArmedForWakeOtherStates[]; 4417 static const POWER_EVENT_TARGET_STATE m_DxArmedForWakeNPOtherStates[]; 4418 static const POWER_EVENT_TARGET_STATE m_WakePendingOtherStates[]; 4419 static const POWER_EVENT_TARGET_STATE m_WakePendingNPOtherStates[]; 4420 static const POWER_EVENT_TARGET_STATE m_DxSurpriseRemovedOtherStates[]; 4421 static const POWER_EVENT_TARGET_STATE m_PowerStoppedOtherStates[]; 4422 static const POWER_EVENT_TARGET_STATE m_PowerDxStoppedOtherStates[]; 4423 4424 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolObjectCreatedOtherStates[]; 4425 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStartingOtherStates[]; 4426 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStartedIdleCapableOtherStates[]; 4427 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolIdleCapableDeviceIdleOtherStates[]; 4428 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredNoWakeOtherStates[]; 4429 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredNoWakeCompletePowerDownOtherStates[]; 4430 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolWaitingUnarmedOtherStates[]; 4431 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolS0NoWakePowerUpOtherStates[]; 4432 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolS0NoWakeCompletePowerUpOtherStates[]; 4433 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemSleepNeedWakeOtherStates[]; 4434 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemSleepNeedWakeCompletePowerUpOtherStates[]; 4435 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemAsleepWakeArmedOtherStates[]; 4436 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemAsleepWakeArmedNPOtherStates[]; 4437 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceToD0OtherStates[]; 4438 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceToD0CompletePowerUpOtherStates[]; 4439 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStartedWakeCapableOtherStates[]; 4440 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolWakeCapableDeviceIdleOtherStates[]; 4441 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapablePowerDownOtherStates[]; 4442 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableSendWakeOtherStates[]; 4443 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableUsbSSOtherStates[]; 4444 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolWaitingArmedOtherStates[]; 4445 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolDisarmingWakeForSystemSleepCompletePowerUpOtherStates[]; 4446 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolCancelingWakeForSystemSleepWakeCanceledOtherStates[]; 4447 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolWokeFromS0OtherStates[]; 4448 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingResetDeviceOtherStates[]; 4449 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingResetDeviceCompletePowerUpOtherStates[]; 4450 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingD0OtherStates[]; 4451 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingDisarmWakeOtherStates[]; 4452 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingDisarmWakeCancelWakeOtherStates[]; 4453 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolIoPresentArmedOtherStates[]; 4454 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolIoPresentArmedWakeCanceledOtherStates[]; 4455 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolS0WakeCompletePowerUpOtherStates[]; 4456 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableWakeSucceededOtherStates[]; 4457 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableWakeFailedOtherStates[]; 4458 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapablePowerDownFailedCancelWakeOtherStates[]; 4459 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolCancelingWakeForSystemSleepOtherStates[]; 4460 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableWakeArrivedOtherStates[]; 4461 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableCancelWakeOtherStates[]; 4462 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCompletedPowerDownOtherStates[]; 4463 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCompletedPowerUpOtherStates[]; 4464 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeEnabledOtherStates[]; 4465 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeEnabledNPOtherStates[]; 4466 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeEnabledWakeCanceledOtherStates[]; 4467 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeEnabledWakeCanceledNPOtherStates[]; 4468 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingWakeWakeArrivedOtherStates[]; 4469 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeTriggeredS0OtherStates[]; 4470 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeTriggeredS0NPOtherStates[]; 4471 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeCompletePowerUpOtherStates[]; 4472 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingNoWakePowerDownOtherStates[]; 4473 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingNoWakeCompletePowerDownOtherStates[]; 4474 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingWakePowerDownOtherStates[]; 4475 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingSendWakeOtherStates[]; 4476 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingWakeWakeArrivedNPOtherStates[]; 4477 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingWakePowerDownFailedOtherStates[]; 4478 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStartedOtherStates[]; 4479 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStartedWaitForIdleTimeoutOtherStates[]; 4480 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolDevicePowerRequestFailedOtherStates[]; 4481 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingOtherStates[]; 4482 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppedOtherStates[]; 4483 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolRestartingOtherStates[]; 4484 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolStoppingCancelWakeOtherStates[]; 4485 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolCancelUsbSSOtherStates[]; 4486 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingWakeRevertArmWakeOtherStates[]; 4487 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSleepingWakeRevertArmWakeNPOtherStates[]; 4488 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolRemovedOtherStates[]; 4489 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapableWakeInterruptArrivedOtherStates[]; 4490 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolTimerExpiredWakeCapablePowerDownFailedWakeInterruptArrivedOtherStates[]; 4491 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolWaitingArmedWakeInterruptFiredDuringPowerDownOtherStates[]; 4492 4493 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerObjectCreatedStates[]; 4494 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStartingStates[]; 4495 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStartingSucceededStates[]; 4496 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStartingFailedStates[]; 4497 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerGotoDxStates[]; 4498 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerGotoDxInDxStates[]; 4499 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerDxStates[]; 4500 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerGotoD0States[]; 4501 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerGotoD0InD0States[]; 4502 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStoppedStates[]; 4503 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStoppingWaitForImplicitPowerDownStates[]; 4504 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStoppingPoweringUpStates[]; 4505 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerStoppingPoweringDownStates[]; 4506 static const POWER_POLICY_EVENT_TARGET_STATE m_NotPowerPolOwnerRemovedStates[]; 4507 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolWaitingArmedWakeInterruptFiredOtherStates[]; 4508 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeInterruptFiredOtherStates[]; 4509 static const POWER_POLICY_EVENT_TARGET_STATE m_PowerPolSystemWakeDeviceWakeInterruptFiredNPOtherStates[]; 4510 4511 #if FX_STATE_MACHINE_VERIFY 4512 // 4513 // Array of possible states that can be returned by state entry functions 4514 // 4515 static const PNP_STATE_ENTRY_FN_RETURN_STATE_TABLE m_WdfPnpStateEntryFunctionReturnStates[]; 4516 static const POWER_STATE_ENTRY_FN_RETURN_STATE_TABLE m_WdfPowerStateEntryFunctionReturnStates[]; 4517 static const PWR_POL_STATE_ENTRY_FN_RETURN_STATE_TABLE m_WdfPwrPolStateEntryFunctionReturnStates[]; 4518 #endif // FX_STATE_MACHINE_VERIFY 4519 4520 // 4521 // Names for registry values in which we will store the beginning of the 4522 // restart time period, the number of restart attempts in that period, and 4523 // if the device successfully started. 4524 // 4525 static const PWCHAR m_RestartStartAchievedName; 4526 static const PWCHAR m_RestartStartTimeName; 4527 static const PWCHAR m_RestartCountName; 4528 4529 // 4530 // Time between successive restarts in which we will attempt to restart a 4531 // stack again. Expressed in seconds. 4532 // 4533 static const ULONG m_RestartTimePeriodMaximum; 4534 4535 // 4536 // Number of times in the restart time period in which we will attempt a 4537 // restart. 4538 // 4539 static const ULONG m_RestartCountMaximum; 4540 4541 // 4542 // Shove the function pointers to the end of the structure so that when 4543 // we dump the structure while debugging, the less pertinent info is at the 4544 // bottom. 4545 // 4546 public: 4547 FxPnpDeviceUsageNotification m_DeviceUsageNotification; 4548 FxPnpDeviceUsageNotificationEx m_DeviceUsageNotificationEx; 4549 FxPnpDeviceRelationsQuery m_DeviceRelationsQuery; 4550 4551 FxPnpDeviceD0Entry m_DeviceD0Entry; 4552 FxPnpDeviceD0EntryPostInterruptsEnabled m_DeviceD0EntryPostInterruptsEnabled; 4553 FxPnpDeviceD0ExitPreInterruptsDisabled m_DeviceD0ExitPreInterruptsDisabled; 4554 FxPnpDeviceD0Exit m_DeviceD0Exit; 4555 4556 FxPnpDevicePrepareHardware m_DevicePrepareHardware; 4557 FxPnpDeviceReleaseHardware m_DeviceReleaseHardware; 4558 4559 FxPnpDeviceQueryStop m_DeviceQueryStop; 4560 FxPnpDeviceQueryRemove m_DeviceQueryRemove; 4561 FxPnpDeviceSurpriseRemoval m_DeviceSurpriseRemoval; 4562 }; 4563 4564 __inline 4565 VOID 4566 FxPostProcessInfo::Evaluate( 4567 __inout FxPkgPnp* PkgPnp 4568 ) 4569 { 4570 if (m_SetRemovedEvent) { 4571 ASSERT(m_DeleteObject == FALSE && m_Event == NULL && m_FireAndForgetIrp == NULL); 4572 PkgPnp->SignalDeviceRemovedEvent(); 4573 return; 4574 } 4575 4576 // 4577 // Process any irp that should be sent down the stack/forgotten. 4578 // 4579 if (m_FireAndForgetIrp != NULL) { 4580 FxIrp irp(m_FireAndForgetIrp); 4581 4582 m_FireAndForgetIrp = NULL; 4583 (void) PkgPnp->FireAndForgetIrp(&irp); 4584 } 4585 4586 if (m_DeleteObject) { 4587 PkgPnp->ProcessDelayedDeletion(); 4588 } 4589 4590 if (m_Event != NULL) { 4591 m_Event->Set(); 4592 } 4593 } 4594 4595 #endif // _FXPKGPNP_H_ 4596