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.
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;
43 IN PDEVICE_OBJECT DeviceObject,
48 Status = IoCallDriver(DeviceObject, Irp);
58 PoRegisterDeviceForIdleDetection(
59 IN PDEVICE_OBJECT DeviceObject,
60 IN ULONG ConservationIdleTime,
61 IN ULONG PerformanceIdleTime,
62 IN DEVICE_POWER_STATE State)
72 PoRegisterSystemState(
74 IN EXECUTION_STATE Flags)
85 IN PDEVICE_OBJECT DeviceObject,
86 IN UCHAR MinorFunction,
87 IN POWER_STATE PowerState,
88 IN PREQUEST_POWER_COMPLETE CompletionFunction,
90 OUT PIRP *Irp OPTIONAL)
92 return STATUS_NOT_IMPLEMENTED;
108 IN PDEVICE_OBJECT DeviceObject,
109 IN POWER_STATE_TYPE Type,
110 IN POWER_STATE State)
114 ps.SystemState = PowerSystemWorking; // Fully on
115 ps.DeviceState = PowerDeviceD0; // Fully on
126 IN EXECUTION_STATE Flags)
145 PoUnregisterSystemState(
146 IN PVOID StateHandle)
151 PopSetSystemPowerState(
152 SYSTEM_POWER_STATE PowerState)
157 IO_STATUS_BLOCK IoStatusBlock;
158 PDEVICE_OBJECT DeviceObject;
159 PIO_STACK_LOCATION IrpSp;
165 Status = IopGetSystemPowerDeviceObject(&DeviceObject);
166 if (!NT_SUCCESS(Status)) {
167 CPRINT("No system power driver available\n");
168 return STATUS_UNSUCCESSFUL;
171 Fdo = IoGetAttachedDeviceReference(DeviceObject);
173 if (Fdo == DeviceObject)
175 DPRINT("An FDO was not attached\n");
176 return STATUS_UNSUCCESSFUL;
179 KeInitializeEvent(&Event,
183 Irp = IoBuildSynchronousFsdRequest(IRP_MJ_POWER,
191 IrpSp = IoGetNextIrpStackLocation(Irp);
192 IrpSp->MinorFunction = IRP_MN_SET_POWER;
193 IrpSp->Parameters.Power.Type = SystemPowerState;
194 IrpSp->Parameters.Power.State.SystemState = PowerState;
196 Status = PoCallDriver(Fdo, Irp);
197 if (Status == STATUS_PENDING)
199 KeWaitForSingleObject(&Event,
204 Status = IoStatusBlock.Status;
207 ObDereferenceObject(Fdo);
213 return STATUS_NOT_IMPLEMENTED;