mirror of
https://github.com/reactos/reactos.git
synced 2025-04-29 10:39:07 +00:00
- Add power.c file for power management functions
- Move GetSystemPowerStatus, SetSystemPowerState, GetDevicePowerState, RequestDeviceWakeup, RequestWakeupLatency, CancelDeviceWakeupRequest, IsSystemResumeAutomatic, and SetMessageWaitingIndicator to power.c - Implement GetSystemPowerStatus svn path=/trunk/; revision=38769
This commit is contained in:
parent
3c445f492d
commit
154c781d64
3 changed files with 159 additions and 114 deletions
|
@ -80,6 +80,7 @@
|
|||
<file>muldiv.c</file>
|
||||
<file>nls.c</file>
|
||||
<file>perfcnt.c</file>
|
||||
<file>power.c</file>
|
||||
<file>recovery.c</file>
|
||||
<file>res.c</file>
|
||||
<file>sortkey.c</file>
|
||||
|
|
158
reactos/dll/win32/kernel32/misc/power.c
Normal file
158
reactos/dll/win32/kernel32/misc/power.c
Normal file
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: dll/win32/kernel32/misc/power.c
|
||||
* PURPOSE: Power Management Functions
|
||||
* PROGRAMMER: Dmitry Chapyshev <dmitry@reactos.org>
|
||||
*
|
||||
* UPDATE HISTORY:
|
||||
* 01/15/2009 Created
|
||||
*/
|
||||
|
||||
#include <k32.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#define STUB \
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); \
|
||||
DPRINT1("%s() is UNIMPLEMENTED!\n", __FUNCTION__)
|
||||
|
||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
GetSystemPowerStatus(LPSYSTEM_POWER_STATUS PowerStatus)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
SYSTEM_BATTERY_STATE SysBatState;
|
||||
|
||||
Status = NtPowerInformation(SystemBatteryState,
|
||||
NULL,
|
||||
0,
|
||||
&SysBatState,
|
||||
sizeof(SYSTEM_BATTERY_STATE));
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastErrorByStatus(Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RtlZeroMemory(PowerStatus, sizeof(LPSYSTEM_POWER_STATUS));
|
||||
|
||||
PowerStatus->BatteryLifeTime = BATTERY_LIFE_UNKNOWN;
|
||||
PowerStatus->BatteryFullLifeTime = BATTERY_LIFE_UNKNOWN;
|
||||
|
||||
PowerStatus->BatteryLifePercent = BATTERY_PERCENTAGE_UNKNOWN;
|
||||
if (SysBatState.MaxCapacity)
|
||||
{
|
||||
if (SysBatState.MaxCapacity >= SysBatState.RemainingCapacity)
|
||||
PowerStatus->BatteryLifePercent = (SysBatState.RemainingCapacity / SysBatState.MaxCapacity) * 100;
|
||||
else
|
||||
PowerStatus->BatteryLifePercent = 100; /* 100% */
|
||||
|
||||
if (PowerStatus->BatteryLifePercent <= 32)
|
||||
PowerStatus->BatteryFlag |= BATTERY_FLAG_LOW;
|
||||
|
||||
if (PowerStatus->BatteryLifePercent >= 67)
|
||||
PowerStatus->BatteryFlag |= BATTERY_FLAG_HIGH;
|
||||
}
|
||||
|
||||
if (!SysBatState.BatteryPresent)
|
||||
PowerStatus->BatteryFlag |= BATTERY_FLAG_NO_BATTERY;
|
||||
|
||||
if (SysBatState.Charging)
|
||||
PowerStatus->BatteryFlag |= BATTERY_FLAG_CHARGING;
|
||||
|
||||
if (!SysBatState.AcOnLine && SysBatState.BatteryPresent)
|
||||
PowerStatus->ACLineStatus = AC_LINE_OFFLINE;
|
||||
else
|
||||
PowerStatus->ACLineStatus = AC_LINE_ONLINE;
|
||||
|
||||
if (SysBatState.EstimatedTime)
|
||||
PowerStatus->BatteryLifeTime = SysBatState.EstimatedTime;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL WINAPI
|
||||
SetSystemPowerState(BOOL fSuspend, BOOL fForce)
|
||||
{
|
||||
STUB;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
GetDevicePowerState(HANDLE hDevice, BOOL *pfOn)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
RequestDeviceWakeup(HANDLE hDevice)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
RequestWakeupLatency(LATENCY_TIME latency)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
CancelDeviceWakeupRequest(HANDLE hDevice)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
IsSystemResumeAutomatic(VOID)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
SetMessageWaitingIndicator(HANDLE hMsgIndicator,
|
||||
ULONG ulMsgCount)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
|
@ -153,26 +153,6 @@ GetNextVDMCommand (
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
GetSystemPowerStatus (
|
||||
LPSYSTEM_POWER_STATUS PowerStatus
|
||||
)
|
||||
{
|
||||
STUB;
|
||||
PowerStatus->ACLineStatus = 1;
|
||||
PowerStatus->BatteryFlag = 128;
|
||||
PowerStatus->BatteryLifePercent = 255;
|
||||
PowerStatus->Reserved1 = 0;
|
||||
PowerStatus->BatteryLifeTime = -1;
|
||||
PowerStatus->BatteryFullLifeTime = -1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
@ -240,20 +220,6 @@ RegisterWowExec (
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL WINAPI
|
||||
SetSystemPowerState (
|
||||
BOOL fSuspend,
|
||||
BOOL fForce
|
||||
)
|
||||
{
|
||||
STUB;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
@ -367,19 +333,6 @@ BindIoCompletionCallback(HANDLE FileHandle,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
CancelDeviceWakeupRequest(
|
||||
HANDLE hDevice
|
||||
)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
@ -422,20 +375,6 @@ FreeUserPhysicalPages(
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
GetDevicePowerState(
|
||||
HANDLE hDevice,
|
||||
BOOL *pfOn
|
||||
)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
|
@ -511,19 +450,6 @@ HeapSetInformation (
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
IsSystemResumeAutomatic(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
@ -609,32 +535,6 @@ RemoveVectoredExceptionHandler(
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
RequestDeviceWakeup(
|
||||
HANDLE hDevice
|
||||
)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
RequestWakeupLatency(
|
||||
LATENCY_TIME latency
|
||||
)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
@ -661,20 +561,6 @@ RestoreLastError(
|
|||
STUB;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
SetMessageWaitingIndicator(
|
||||
HANDLE hMsgIndicator,
|
||||
ULONG ulMsgCount
|
||||
)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue