1 /*++
2 Copyright (c) Microsoft. All rights reserved.
3 
4 Module Name:
5 
6     PowerStateMachineKm.cpp
7 
8 Abstract:
9 
10     This module implements the Power state machine for the driver framework.
11     This code was split out from FxPkgPnp.cpp.
12 
13 Author:
14 
15 
16 
17 
18 Environment:
19 
20     Kernel mode only
21 
22 Revision History:
23 
24 --*/
25 
26 #include "../pnppriv.hpp"
27 
28 extern "C" {
29 #if defined(EVENT_TRACING)
30 #include "PowerStateMachineKm.tmh"
31 #endif
32 }
33 
34 _Must_inspect_result_
35 BOOLEAN
36 FxPkgPnp::PowerDmaPowerUp(
37     VOID
38     )
39 /*++
40 
41 Routine Description:
42     Calls FxDmaEnabler::PowerUp on all registered FxDmaEnabler objects.  As soon
43     as a PowerUp call fails, we stop iterating over the list.
44 
45 Arguments:
46     None
47 
48 Return Value:
49     TRUE if PowerUp succeeded on all enablers, FALSE otherwise
50 
51   --*/
52 
53 {
54     // FxTransactionedEntry* ple;
55     // NTSTATUS status;
56     BOOLEAN result;
57 
58     result = TRUE;
59 
60     //
61     // Power up each dma enabler
62     //
63     // if (m_DmaEnablerList != NULL) {
64     //     m_DmaEnablerList->LockForEnum(GetDriverGlobals());
65 
66     //     ple = NULL;
67     //     while ((ple = m_DmaEnablerList->GetNextEntry(ple)) != NULL) {
68     //         status = ((FxDmaEnabler*) ple->GetTransactionedObject())->PowerUp();
69 
70     //         if (!NT_SUCCESS(status)) {
71     //             result = FALSE;
72     //             break;
73     //         }
74     //     }
75 
76     //     m_DmaEnablerList->UnlockFromEnum(GetDriverGlobals());
77     // }
78 
79     return result;
80 }
81 
82 BOOLEAN
83 FxPkgPnp::PowerDmaPowerDown(
84     VOID
85     )
86 /*++
87 
88 Routine Description:
89     Calls FxDmaEnabler::PowerDown on all registered FxDmaEnabler objects.  All
90     errors are accumulated, all enablers will be PowerDown'ed.
91 
92 Arguments:
93     None
94 
95 Return Value:
96     TRUE if PowerDown succeeded on all enablers, FALSE otherwise
97 
98   --*/
99 {
100     // FxTransactionedEntry* ple;
101     // NTSTATUS status;
102     BOOLEAN result;
103 
104     result = TRUE;
105 
106     //
107     // Power up each dma enabler
108     //
109     // if (m_DmaEnablerList != NULL) {
110     //     m_DmaEnablerList->LockForEnum(GetDriverGlobals());
111 
112     //     ple = NULL;
113     //     while ((ple = m_DmaEnablerList->GetNextEntry(ple)) != NULL) {
114     //         status = ((FxDmaEnabler*) ple->GetTransactionedObject())->PowerDown();
115 
116     //         if (!NT_SUCCESS(status)) {
117     //             //
118     //             // We do not break out of the loop on power down failure.  We will
119     //             // continue to power down each channel regardless of the previous
120     //             // channel's power down status.
121     //             //
122     //             result = FALSE;
123     //         }
124     //     }
125 
126     //     m_DmaEnablerList->UnlockFromEnum(GetDriverGlobals());
127     // }
128 
129     return result;
130 }
131 
132 VOID
133 FxPkgPnp::_PowerSetSystemWakeSource(
134     __in FxIrp* Irp
135     )
136 /*++
137 
138 Routine Description:
139     Set source of wake if OS supports this.
140 
141 Arguments:
142     Irp
143 
144 Return Value:
145     None
146 
147   --*/
148 {
149     PoSetSystemWake(Irp->GetIrp());
150 }
151 
152