3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* $Id: power.c,v 1.11 2004/08/15 16:39:10 chorns Exp $
20 * PROJECT: ReactOS kernel
21 * FILE: ntoskrnl/po/power.c
22 * PURPOSE: Power Manager
23 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
25 * 20/08/1999 EA Created
26 * 16/04/2001 CSH Stubs added
31 #include <internal/debug.h>
34 PDEVICE_NODE PopSystemPowerDeviceNode
= NULL
;
42 IN PDEVICE_OBJECT DeviceObject
,
47 Status
= IoCallDriver(DeviceObject
, Irp
);
57 PoRegisterDeviceForIdleDetection(
58 IN PDEVICE_OBJECT DeviceObject
,
59 IN ULONG ConservationIdleTime
,
60 IN ULONG PerformanceIdleTime
,
61 IN DEVICE_POWER_STATE State
)
71 PoRegisterSystemState(
73 IN EXECUTION_STATE Flags
)
84 IN PDEVICE_OBJECT DeviceObject
,
85 IN UCHAR MinorFunction
,
86 IN POWER_STATE PowerState
,
87 IN PREQUEST_POWER_COMPLETE CompletionFunction
,
89 OUT PIRP
*Irp OPTIONAL
)
91 return STATUS_NOT_IMPLEMENTED
;
107 IN PDEVICE_OBJECT DeviceObject
,
108 IN POWER_STATE_TYPE Type
,
109 IN POWER_STATE State
)
113 ps
.SystemState
= PowerSystemWorking
; // Fully on
114 ps
.DeviceState
= PowerDeviceD0
; // Fully on
125 IN EXECUTION_STATE Flags
)
144 PoUnregisterSystemState(
145 IN PVOID StateHandle
)
150 PopSetSystemPowerState(
151 SYSTEM_POWER_STATE PowerState
)
156 IO_STATUS_BLOCK IoStatusBlock
;
157 PDEVICE_OBJECT DeviceObject
;
158 PIO_STACK_LOCATION IrpSp
;
164 Status
= IopGetSystemPowerDeviceObject(&DeviceObject
);
165 if (!NT_SUCCESS(Status
)) {
166 CPRINT("No system power driver available\n");
167 return STATUS_UNSUCCESSFUL
;
170 Fdo
= IoGetAttachedDeviceReference(DeviceObject
);
172 if (Fdo
== DeviceObject
)
174 DPRINT("An FDO was not attached\n");
175 return STATUS_UNSUCCESSFUL
;
178 KeInitializeEvent(&Event
,
182 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_POWER
,
190 IrpSp
= IoGetNextIrpStackLocation(Irp
);
191 IrpSp
->MinorFunction
= IRP_MN_SET_POWER
;
192 IrpSp
->Parameters
.Power
.Type
= SystemPowerState
;
193 IrpSp
->Parameters
.Power
.State
.SystemState
= PowerState
;
195 Status
= PoCallDriver(Fdo
, Irp
);
196 if (Status
== STATUS_PENDING
)
198 KeWaitForSingleObject(&Event
,
203 Status
= IoStatusBlock
.Status
;
206 ObDereferenceObject(Fdo
);
212 return STATUS_NOT_IMPLEMENTED
;
225 NtInitiatePowerAction (
226 POWER_ACTION SystemAction
,
227 SYSTEM_POWER_STATE MinSystemState
,
229 BOOLEAN Asynchronous
)
232 return STATUS_NOT_IMPLEMENTED
;
241 POWER_INFORMATION_LEVEL PowerInformationLevel
,
243 ULONG InputBufferLength
,
245 ULONG OutputBufferLength
249 return STATUS_NOT_IMPLEMENTED
;