ReactOS 0.4.16-dev-329-g9223134
power.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for power.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI Bus_Power (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS Bus_FDO_Power (PFDO_DEVICE_DATA Data, PIRP Irp)
 
NTSTATUS Bus_PDO_Power (PPDO_DEVICE_DATA PdoData, PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 3 of file power.c.

Function Documentation

◆ Bus_FDO_Power()

NTSTATUS Bus_FDO_Power ( PFDO_DEVICE_DATA  Data,
PIRP  Irp 
)

Definition at line 49 of file power.c.

53{
55 POWER_STATE powerState;
56 POWER_STATE_TYPE powerType;
58 ULONG AcpiState;
59 ACPI_STATUS AcpiStatus;
60 SYSTEM_POWER_STATE oldPowerState;
61
63 powerType = stack->Parameters.Power.Type;
64 powerState = stack->Parameters.Power.State;
65
66
67 if (stack->MinorFunction == IRP_MN_SET_POWER) {
68 DPRINT("\tRequest to set %s state to %s\n",
69 ((powerType == SystemPowerState) ? "System" : "Device"),
70 ((powerType == SystemPowerState) ? \
73
74 if (powerType == SystemPowerState)
75 {
76 switch (powerState.SystemState) {
78 AcpiState = ACPI_STATE_S1;
79 break;
81 AcpiState = ACPI_STATE_S2;
82 break;
84 AcpiState = ACPI_STATE_S3;
85 break;
87 AcpiState = ACPI_STATE_S4;
88 break;
90 AcpiState = ACPI_STATE_S5;
91 break;
92 default:
93 AcpiState = ACPI_STATE_UNKNOWN;
95 break;
96 }
97 oldPowerState = Data->Common.SystemPowerState;
98 Data->Common.SystemPowerState = powerState.SystemState;
99 AcpiStatus = acpi_suspend(AcpiState);
100 if (!ACPI_SUCCESS(AcpiStatus)) {
101 DPRINT1("Failed to enter sleep state %d (Status 0x%X)\n",
102 AcpiState, AcpiStatus);
103 Data->Common.SystemPowerState = oldPowerState;
105 }
106 }
107 }
110 status = PoCallDriver (Data->NextLowerDriver, Irp);
111 return status;
112}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
PCHAR DbgSystemPowerString(SYSTEM_POWER_STATE Type)
PCHAR DbgDevicePowerString(DEVICE_POWER_STATE Type)
#define ACPI_STATE_S5
Definition: actypes.h:629
#define ACPI_STATE_S2
Definition: actypes.h:626
#define ACPI_STATE_S1
Definition: actypes.h:625
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_STATE_S4
Definition: actypes.h:628
#define ACPI_STATE_UNKNOWN
Definition: actypes.h:622
#define ACPI_STATE_S3
Definition: actypes.h:627
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
_In_ PIRP Irp
Definition: csq.h:116
#define FALSE
Definition: types.h:117
ACPI_STATUS acpi_suspend(UINT32 state)
Definition: system.c:347
#define ASSERT(a)
Definition: mode.c:44
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:758
@ PowerSystemSleeping1
Definition: ntpoapi.h:37
@ PowerSystemSleeping2
Definition: ntpoapi.h:38
@ PowerSystemSleeping3
Definition: ntpoapi.h:39
@ PowerSystemShutdown
Definition: ntpoapi.h:41
@ PowerSystemHibernate
Definition: ntpoapi.h:40
enum _POWER_STATE_TYPE POWER_STATE_TYPE
enum _SYSTEM_POWER_STATE SYSTEM_POWER_STATE
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
Definition: format.c:80
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
DEVICE_POWER_STATE DeviceState
Definition: ntpoapi.h:58
SYSTEM_POWER_STATE SystemState
Definition: ntpoapi.h:57
#define IRP_MN_SET_POWER
_In_ SYSTEM_POWER_STATE SystemPowerState
Definition: iotypes.h:7519

Referenced by Bus_Power().

◆ Bus_PDO_Power()

NTSTATUS Bus_PDO_Power ( PPDO_DEVICE_DATA  PdoData,
PIRP  Irp 
)

Definition at line 116 of file power.c.

120{
123 POWER_STATE powerState;
124 POWER_STATE_TYPE powerType;
125 ULONG error;
126
128 powerType = stack->Parameters.Power.Type;
129 powerState = stack->Parameters.Power.State;
130
131 switch (stack->MinorFunction) {
132 case IRP_MN_SET_POWER:
133
134 DPRINT("\tSetting %s power state to %s\n",
135 ((powerType == SystemPowerState) ? "System" : "Device"),
136 ((powerType == SystemPowerState) ? \
137 DbgSystemPowerString(powerState.SystemState) : \
138 DbgDevicePowerString(powerState.DeviceState)));
139
140 switch (powerType) {
141 case DevicePowerState:
142 if (!PdoData->AcpiHandle || !acpi_bus_power_manageable(PdoData->AcpiHandle))
143 {
144 PoSetPowerState(PdoData->Common.Self, DevicePowerState, powerState);
145 PdoData->Common.DevicePowerState = powerState.DeviceState;
147 break;
148 }
149
150 switch (powerState.DeviceState)
151 {
152 case PowerDeviceD0:
154 break;
155
156 case PowerDeviceD1:
158 break;
159
160 case PowerDeviceD2:
162 break;
163
164 case PowerDeviceD3:
166 break;
167
168 default:
169 error = 0;
170 break;
171 }
172
173 if (ACPI_SUCCESS(error))
174 {
175 PoSetPowerState(PdoData->Common.Self, DevicePowerState, powerState);
176 PdoData->Common.DevicePowerState = powerState.DeviceState;
178 }
179 else
181 break;
182
183 case SystemPowerState:
184 PdoData->Common.SystemPowerState = powerState.SystemState;
186 break;
187
188 default:
190 break;
191 }
192 break;
193
196 break;
197
198 case IRP_MN_WAIT_WAKE:
199 //
200 // We cannot support wait-wake because we are root-enumerated
201 // driver, and our parent, the PnP manager, doesn't support wait-wake.
202 //
204 default:
206 break;
207 }
208
210
211 Irp->IoStatus.Status = status;
212 }
213
215 status = Irp->IoStatus.Status;
217
218 return status;
219}
#define ACPI_STATE_D2
Definition: actypes.h:635
#define ACPI_STATE_D0
Definition: actypes.h:633
#define ACPI_STATE_D3
Definition: actypes.h:636
#define ACPI_STATE_D1
Definition: actypes.h:634
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
BOOLEAN acpi_bus_power_manageable(ACPI_HANDLE handle)
Definition: bus.c:351
int acpi_bus_set_power(ACPI_HANDLE handle, int state)
Definition: bus.c:249
#define error(str)
Definition: mkdosfs.c:1605
#define IoCompleteRequest
Definition: irp.c:1240
POWER_STATE NTAPI PoSetPowerState(IN PDEVICE_OBJECT DeviceObject, IN POWER_STATE_TYPE Type, IN POWER_STATE State)
Definition: power.c:729
@ DevicePowerState
Definition: ntpoapi.h:63
@ PowerDeviceD1
Definition: ntpoapi.h:50
@ PowerDeviceD0
Definition: ntpoapi.h:49
@ PowerDeviceD2
Definition: ntpoapi.h:51
@ PowerDeviceD3
Definition: ntpoapi.h:52
SYSTEM_POWER_STATE SystemPowerState
Definition: acpisys.h:32
DEVICE_POWER_STATE DevicePowerState
Definition: acpisys.h:33
PDEVICE_OBJECT Self
Definition: acpisys.h:28
ACPI_HANDLE AcpiHandle
Definition: acpisys.h:39
COMMON_DEVICE_DATA Common
Definition: acpisys.h:38
#define IRP_MN_WAIT_WAKE
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_POWER_SEQUENCE
#define IRP_MN_QUERY_POWER

Referenced by Bus_Power().

◆ Bus_Power()

NTSTATUS NTAPI Bus_Power ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 8 of file power.c.

12{
13 PIO_STACK_LOCATION irpStack;
15 PCOMMON_DEVICE_DATA commonData;
16
19 ASSERT (IRP_MJ_POWER == irpStack->MajorFunction);
20
21 commonData = (PCOMMON_DEVICE_DATA) DeviceObject->DeviceExtension;
22
23 if (commonData->IsFDO) {
24
25 DPRINT("FDO %s IRP:0x%p %s %s\n",
29
30
32 Irp);
33 } else {
34
35 DPRINT("PDO %s IRP:0x%p %s %s\n",
39
41 Irp);
42 }
43
44 return status;
45}
struct _COMMON_DEVICE_DATA * PCOMMON_DEVICE_DATA
NTSTATUS Bus_PDO_Power(PPDO_DEVICE_DATA PdoData, PIRP Irp)
Definition: power.c:116
NTSTATUS Bus_FDO_Power(PFDO_DEVICE_DATA Data, PIRP Irp)
Definition: power.c:49
PCHAR NTAPI PowerMinorFunctionString(IN UCHAR MinorFunction)
Definition: fbtpwr.c:1042
if(dx< 0)
Definition: linetemp.h:194
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define IRP_MJ_POWER

Referenced by DriverEntry().