2001-04-16 00:51:19 +00:00
|
|
|
/*
|
|
|
|
* ReactOS kernel
|
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
1999-08-20 16:31:17 +00:00
|
|
|
*
|
2001-04-16 00:51:19 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
1999-08-20 16:31:17 +00:00
|
|
|
*
|
2001-04-16 00:51:19 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
2002-09-08 10:23:54 +00:00
|
|
|
/* $Id: power.c,v 1.6 2002/09/08 10:23:39 chorns Exp $
|
2001-04-16 00:51:19 +00:00
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: ntoskrnl/po/power.c
|
|
|
|
* PURPOSE: Power Manager
|
|
|
|
* PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* 20/08/1999 EA Created
|
|
|
|
* 16/04/2001 CSH Stubs added
|
1999-08-20 16:31:17 +00:00
|
|
|
*/
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <ddk/ntddk.h>
|
|
|
|
#include <roscfg.h>
|
|
|
|
#include <internal/io.h>
|
|
|
|
#include <internal/po.h>
|
2001-05-01 23:08:21 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <internal/debug.h>
|
|
|
|
|
|
|
|
|
|
|
|
PDEVICE_NODE PopSystemPowerDeviceNode = NULL;
|
|
|
|
|
1999-08-20 16:31:17 +00:00
|
|
|
|
2001-04-16 00:51:19 +00:00
|
|
|
NTSTATUS
|
|
|
|
STDCALL
|
|
|
|
PoCallDriver(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN OUT PIRP Irp)
|
|
|
|
{
|
2001-05-01 23:08:21 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Status = IoCallDriver(DeviceObject, Irp);
|
|
|
|
|
|
|
|
return Status;
|
2001-04-16 00:51:19 +00:00
|
|
|
}
|
1999-08-20 16:31:17 +00:00
|
|
|
|
2001-04-16 00:51:19 +00:00
|
|
|
PULONG
|
1999-08-20 16:31:17 +00:00
|
|
|
STDCALL
|
2001-04-16 00:51:19 +00:00
|
|
|
PoRegisterDeviceForIdleDetection(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN ULONG ConservationIdleTime,
|
|
|
|
IN ULONG PerformanceIdleTime,
|
|
|
|
IN DEVICE_POWER_STATE State)
|
1999-08-20 16:31:17 +00:00
|
|
|
{
|
2001-04-16 00:51:19 +00:00
|
|
|
return NULL;
|
1999-08-20 16:31:17 +00:00
|
|
|
}
|
|
|
|
|
2001-04-16 00:51:19 +00:00
|
|
|
PVOID
|
|
|
|
STDCALL
|
|
|
|
PoRegisterSystemState(
|
|
|
|
IN PVOID StateHandle,
|
|
|
|
IN EXECUTION_STATE Flags)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
1999-08-20 16:31:17 +00:00
|
|
|
|
2001-04-16 00:51:19 +00:00
|
|
|
NTSTATUS
|
|
|
|
STDCALL
|
|
|
|
PoRequestPowerIrp(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN UCHAR MinorFunction,
|
|
|
|
IN POWER_STATE PowerState,
|
|
|
|
IN PREQUEST_POWER_COMPLETE CompletionFunction,
|
|
|
|
IN PVOID Context,
|
|
|
|
OUT PIRP *Irp OPTIONAL)
|
|
|
|
{
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
1999-08-20 16:31:17 +00:00
|
|
|
STDCALL
|
2001-04-16 00:51:19 +00:00
|
|
|
PoSetDeviceBusy(
|
|
|
|
PULONG IdlePointer)
|
1999-08-20 16:31:17 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-04-16 00:51:19 +00:00
|
|
|
POWER_STATE
|
|
|
|
STDCALL
|
|
|
|
PoSetPowerState(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN POWER_STATE_TYPE Type,
|
|
|
|
IN POWER_STATE State)
|
|
|
|
{
|
|
|
|
POWER_STATE ps;
|
|
|
|
|
|
|
|
ps.SystemState = PowerSystemWorking; // Fully on
|
|
|
|
ps.DeviceState = PowerDeviceD0; // Fully on
|
|
|
|
|
|
|
|
return ps;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
STDCALL
|
|
|
|
PoSetSystemState(
|
|
|
|
IN EXECUTION_STATE Flags)
|
|
|
|
{
|
|
|
|
}
|
1999-08-20 16:31:17 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
STDCALL
|
2001-04-16 00:51:19 +00:00
|
|
|
PoStartNextPowerIrp(
|
|
|
|
IN PIRP Irp)
|
1999-08-20 16:31:17 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-04-16 00:51:19 +00:00
|
|
|
VOID
|
|
|
|
STDCALL
|
|
|
|
PoUnregisterSystemState(
|
|
|
|
IN PVOID StateHandle)
|
|
|
|
{
|
|
|
|
}
|
1999-08-20 16:31:17 +00:00
|
|
|
|
2001-05-01 23:08:21 +00:00
|
|
|
NTSTATUS
|
|
|
|
PopSetSystemPowerState(
|
|
|
|
SYSTEM_POWER_STATE PowerState)
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef ACPI
|
|
|
|
|
|
|
|
IO_STATUS_BLOCK IoStatusBlock;
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
PIO_STACK_LOCATION IrpSp;
|
|
|
|
PDEVICE_OBJECT Fdo;
|
|
|
|
NTSTATUS Status;
|
|
|
|
KEVENT Event;
|
|
|
|
PIRP Irp;
|
|
|
|
|
|
|
|
Status = IopGetSystemPowerDeviceObject(&DeviceObject);
|
|
|
|
if (!NT_SUCCESS(Status)) {
|
|
|
|
CPRINT("No system power driver available\n");
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Fdo = IoGetAttachedDeviceReference(DeviceObject);
|
|
|
|
|
|
|
|
if (Fdo == DeviceObject)
|
|
|
|
{
|
|
|
|
DPRINT("An FDO was not attached\n");
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
KeInitializeEvent(&Event,
|
|
|
|
NotificationEvent,
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_POWER,
|
|
|
|
Fdo,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&Event,
|
|
|
|
&IoStatusBlock);
|
|
|
|
|
|
|
|
IrpSp = IoGetNextIrpStackLocation(Irp);
|
|
|
|
IrpSp->MinorFunction = IRP_MN_SET_POWER;
|
|
|
|
IrpSp->Parameters.Power.Type = SystemPowerState;
|
|
|
|
IrpSp->Parameters.Power.State.SystemState = PowerState;
|
|
|
|
|
|
|
|
Status = PoCallDriver(Fdo, Irp);
|
|
|
|
if (Status == STATUS_PENDING)
|
|
|
|
{
|
|
|
|
KeWaitForSingleObject(&Event,
|
|
|
|
Executive,
|
|
|
|
KernelMode,
|
|
|
|
FALSE,
|
|
|
|
NULL);
|
|
|
|
Status = IoStatusBlock.Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
ObDereferenceObject(Fdo);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
|
|
|
|
#endif /* ACPI */
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PoInit(VOID)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1999-08-20 16:31:17 +00:00
|
|
|
/* EOF */
|