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.5 2002/09/07 15:13:04 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
32 #include <internal/debug.h>
35 PDEVICE_NODE PopSystemPowerDeviceNode
= NULL
;
41 IN PDEVICE_OBJECT DeviceObject
,
46 Status
= IoCallDriver(DeviceObject
, Irp
);
53 PoRegisterDeviceForIdleDetection(
54 IN PDEVICE_OBJECT DeviceObject
,
55 IN ULONG ConservationIdleTime
,
56 IN ULONG PerformanceIdleTime
,
57 IN DEVICE_POWER_STATE State
)
64 PoRegisterSystemState(
66 IN EXECUTION_STATE Flags
)
74 IN PDEVICE_OBJECT DeviceObject
,
75 IN UCHAR MinorFunction
,
76 IN POWER_STATE PowerState
,
77 IN PREQUEST_POWER_COMPLETE CompletionFunction
,
79 OUT PIRP
*Irp OPTIONAL
)
81 return STATUS_NOT_IMPLEMENTED
;
94 IN PDEVICE_OBJECT DeviceObject
,
95 IN POWER_STATE_TYPE Type
,
100 ps
.SystemState
= PowerSystemWorking
; // Fully on
101 ps
.DeviceState
= PowerDeviceD0
; // Fully on
109 IN EXECUTION_STATE Flags
)
122 PoUnregisterSystemState(
123 IN PVOID StateHandle
)
128 PopSetSystemPowerState(
129 SYSTEM_POWER_STATE PowerState
)
134 IO_STATUS_BLOCK IoStatusBlock
;
135 PDEVICE_OBJECT DeviceObject
;
136 PIO_STACK_LOCATION IrpSp
;
142 Status
= IopGetSystemPowerDeviceObject(&DeviceObject
);
143 if (!NT_SUCCESS(Status
)) {
144 CPRINT("No system power driver available\n");
145 return STATUS_UNSUCCESSFUL
;
148 Fdo
= IoGetAttachedDeviceReference(DeviceObject
);
150 if (Fdo
== DeviceObject
)
152 DPRINT("An FDO was not attached\n");
153 return STATUS_UNSUCCESSFUL
;
156 KeInitializeEvent(&Event
,
160 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_POWER
,
168 IrpSp
= IoGetNextIrpStackLocation(Irp
);
169 IrpSp
->MinorFunction
= IRP_MN_SET_POWER
;
170 IrpSp
->Parameters
.Power
.Type
= SystemPowerState
;
171 IrpSp
->Parameters
.Power
.State
.SystemState
= PowerState
;
173 Status
= PoCallDriver(Fdo
, Irp
);
174 if (Status
== STATUS_PENDING
)
176 KeWaitForSingleObject(&Event
,
181 Status
= IoStatusBlock
.Status
;
184 ObDereferenceObject(Fdo
);
190 return STATUS_NOT_IMPLEMENTED
;