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.10 2004/08/07 19:13:26 ion 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
28 #include <ddk/ntddk.h>
30 #include <internal/io.h>
31 #include <internal/po.h>
34 #include <internal/debug.h>
37 PDEVICE_NODE PopSystemPowerDeviceNode
= NULL
;
45 IN PDEVICE_OBJECT DeviceObject
,
50 Status
= IoCallDriver(DeviceObject
, Irp
);
60 PoRegisterDeviceForIdleDetection(
61 IN PDEVICE_OBJECT DeviceObject
,
62 IN ULONG ConservationIdleTime
,
63 IN ULONG PerformanceIdleTime
,
64 IN DEVICE_POWER_STATE State
)
74 PoRegisterSystemState(
76 IN EXECUTION_STATE Flags
)
87 IN PDEVICE_OBJECT DeviceObject
,
88 IN UCHAR MinorFunction
,
89 IN POWER_STATE PowerState
,
90 IN PREQUEST_POWER_COMPLETE CompletionFunction
,
92 OUT PIRP
*Irp OPTIONAL
)
94 return STATUS_NOT_IMPLEMENTED
;
110 IN PDEVICE_OBJECT DeviceObject
,
111 IN POWER_STATE_TYPE Type
,
112 IN POWER_STATE State
)
116 ps
.SystemState
= PowerSystemWorking
; // Fully on
117 ps
.DeviceState
= PowerDeviceD0
; // Fully on
128 IN EXECUTION_STATE Flags
)
147 PoUnregisterSystemState(
148 IN PVOID StateHandle
)
153 PopSetSystemPowerState(
154 SYSTEM_POWER_STATE PowerState
)
159 IO_STATUS_BLOCK IoStatusBlock
;
160 PDEVICE_OBJECT DeviceObject
;
161 PIO_STACK_LOCATION IrpSp
;
167 Status
= IopGetSystemPowerDeviceObject(&DeviceObject
);
168 if (!NT_SUCCESS(Status
)) {
169 CPRINT("No system power driver available\n");
170 return STATUS_UNSUCCESSFUL
;
173 Fdo
= IoGetAttachedDeviceReference(DeviceObject
);
175 if (Fdo
== DeviceObject
)
177 DPRINT("An FDO was not attached\n");
178 return STATUS_UNSUCCESSFUL
;
181 KeInitializeEvent(&Event
,
185 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_POWER
,
193 IrpSp
= IoGetNextIrpStackLocation(Irp
);
194 IrpSp
->MinorFunction
= IRP_MN_SET_POWER
;
195 IrpSp
->Parameters
.Power
.Type
= SystemPowerState
;
196 IrpSp
->Parameters
.Power
.State
.SystemState
= PowerState
;
198 Status
= PoCallDriver(Fdo
, Irp
);
199 if (Status
== STATUS_PENDING
)
201 KeWaitForSingleObject(&Event
,
206 Status
= IoStatusBlock
.Status
;
209 ObDereferenceObject(Fdo
);
215 return STATUS_NOT_IMPLEMENTED
;
228 NtInitiatePowerAction (
229 POWER_ACTION SystemAction
,
230 SYSTEM_POWER_STATE MinSystemState
,
232 BOOLEAN Asynchronous
)
235 return STATUS_NOT_IMPLEMENTED
;
244 POWER_INFORMATION_LEVEL PowerInformationLevel
,
246 ULONG InputBufferLength
,
248 ULONG OutputBufferLength
252 return STATUS_NOT_IMPLEMENTED
;