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