Branch setupapi (again)
[reactos.git] / reactos / ntoskrnl / po / power.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4 *
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.
9 *
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.
14 *
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.
18 */
19 /* $Id$
20 * PROJECT: ReactOS kernel
21 * FILE: ntoskrnl/po/power.c
22 * PURPOSE: Power Manager
23 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
24 * UPDATE HISTORY:
25 * 20/08/1999 EA Created
26 * 16/04/2001 CSH Stubs added
27 */
28
29 #include <ntoskrnl.h>
30 #define NDEBUG
31 #include <internal/debug.h>
32
33
34 PDEVICE_NODE PopSystemPowerDeviceNode = NULL;
35
36 /*
37 * @implemented
38 */
39 NTSTATUS
40 STDCALL
41 PoCallDriver(
42 IN PDEVICE_OBJECT DeviceObject,
43 IN OUT PIRP Irp)
44 {
45 NTSTATUS Status;
46
47 Status = IoCallDriver(DeviceObject, Irp);
48
49 return Status;
50 }
51
52 /*
53 * @unimplemented
54 */
55 PULONG
56 STDCALL
57 PoRegisterDeviceForIdleDetection(
58 IN PDEVICE_OBJECT DeviceObject,
59 IN ULONG ConservationIdleTime,
60 IN ULONG PerformanceIdleTime,
61 IN DEVICE_POWER_STATE State)
62 {
63 return NULL;
64 }
65
66 /*
67 * @unimplemented
68 */
69 PVOID
70 STDCALL
71 PoRegisterSystemState(
72 IN PVOID StateHandle,
73 IN EXECUTION_STATE Flags)
74 {
75 return NULL;
76 }
77
78 /*
79 * @unimplemented
80 */
81 NTSTATUS
82 STDCALL
83 PoRequestPowerIrp(
84 IN PDEVICE_OBJECT DeviceObject,
85 IN UCHAR MinorFunction,
86 IN POWER_STATE PowerState,
87 IN PREQUEST_POWER_COMPLETE CompletionFunction,
88 IN PVOID Context,
89 OUT PIRP *Irp OPTIONAL)
90 {
91 return STATUS_NOT_IMPLEMENTED;
92 }
93
94 VOID
95 STDCALL
96 PoSetDeviceBusy(
97 PULONG IdlePointer)
98 {
99 }
100
101 /*
102 * @unimplemented
103 */
104 POWER_STATE
105 STDCALL
106 PoSetPowerState(
107 IN PDEVICE_OBJECT DeviceObject,
108 IN POWER_STATE_TYPE Type,
109 IN POWER_STATE State)
110 {
111 POWER_STATE ps;
112
113 ps.SystemState = PowerSystemWorking; // Fully on
114 ps.DeviceState = PowerDeviceD0; // Fully on
115
116 return ps;
117 }
118
119 /*
120 * @unimplemented
121 */
122 VOID
123 STDCALL
124 PoSetSystemState(
125 IN EXECUTION_STATE Flags)
126 {
127 }
128
129 /*
130 * @unimplemented
131 */
132 VOID
133 STDCALL
134 PoStartNextPowerIrp(
135 IN PIRP Irp)
136 {
137 }
138
139 /*
140 * @unimplemented
141 */
142 VOID
143 STDCALL
144 PoUnregisterSystemState(
145 IN PVOID StateHandle)
146 {
147 }
148
149 NTSTATUS
150 PopSetSystemPowerState(
151 SYSTEM_POWER_STATE PowerState)
152 {
153
154 #ifdef ACPI
155
156 IO_STATUS_BLOCK IoStatusBlock;
157 PDEVICE_OBJECT DeviceObject;
158 PIO_STACK_LOCATION IrpSp;
159 PDEVICE_OBJECT Fdo;
160 NTSTATUS Status;
161 KEVENT Event;
162 PIRP Irp;
163
164 Status = IopGetSystemPowerDeviceObject(&DeviceObject);
165 if (!NT_SUCCESS(Status)) {
166 CPRINT("No system power driver available\n");
167 return STATUS_UNSUCCESSFUL;
168 }
169
170 Fdo = IoGetAttachedDeviceReference(DeviceObject);
171
172 if (Fdo == DeviceObject)
173 {
174 DPRINT("An FDO was not attached\n");
175 return STATUS_UNSUCCESSFUL;
176 }
177
178 KeInitializeEvent(&Event,
179 NotificationEvent,
180 FALSE);
181
182 Irp = IoBuildSynchronousFsdRequest(IRP_MJ_POWER,
183 Fdo,
184 NULL,
185 0,
186 NULL,
187 &Event,
188 &IoStatusBlock);
189
190 IrpSp = IoGetNextIrpStackLocation(Irp);
191 IrpSp->MinorFunction = IRP_MN_SET_POWER;
192 IrpSp->Parameters.Power.Type = SystemPowerState;
193 IrpSp->Parameters.Power.State.SystemState = PowerState;
194
195 Status = PoCallDriver(Fdo, Irp);
196 if (Status == STATUS_PENDING)
197 {
198 KeWaitForSingleObject(&Event,
199 Executive,
200 KernelMode,
201 FALSE,
202 NULL);
203 Status = IoStatusBlock.Status;
204 }
205
206 ObDereferenceObject(Fdo);
207
208 return Status;
209
210 #endif /* ACPI */
211
212 return STATUS_NOT_IMPLEMENTED;
213 }
214
215 VOID INIT_FUNCTION
216 PoInit(VOID)
217 {
218 }
219
220 /*
221 * @unimplemented
222 */
223 NTSTATUS
224 STDCALL
225 NtInitiatePowerAction (
226 IN POWER_ACTION SystemAction,
227 IN SYSTEM_POWER_STATE MinSystemState,
228 IN ULONG Flags,
229 IN BOOLEAN Asynchronous)
230 {
231 UNIMPLEMENTED;
232 return STATUS_NOT_IMPLEMENTED;
233 }
234
235 /*
236 * @unimplemented
237 */
238 NTSTATUS
239 STDCALL
240 NtPowerInformation(
241 IN POWER_INFORMATION_LEVEL PowerInformationLevel,
242 IN PVOID InputBuffer OPTIONAL,
243 IN ULONG InputBufferLength,
244 OUT PVOID OutputBuffer OPTIONAL,
245 IN ULONG OutputBufferLength
246 )
247 {
248 UNIMPLEMENTED;
249 return STATUS_NOT_IMPLEMENTED;
250 }
251
252 /* EOF */