mirror of
https://github.com/reactos/reactos.git
synced 2024-06-01 10:11:43 +00:00
[NTOSKRNL] Use global power capabilities and report button presence
- Add and initialize a global power capabilities variable. - Return the global power capabilities via NtPowerInformation.SystemPowerCapabilities. - Report the presence of power button, sleep button and lid.
This commit is contained in:
parent
b71429059a
commit
626aaf227c
|
@ -365,4 +365,5 @@ extern KGUARDED_MUTEX PopVolumeLock;
|
|||
extern LIST_ENTRY PopVolumeDevices;
|
||||
extern KSPIN_LOCK PopDopeGlobalLock;
|
||||
extern POP_POWER_ACTION PopAction;
|
||||
extern SYSTEM_POWER_CAPABILITIES PopCapabilities;
|
||||
|
||||
|
|
|
@ -242,13 +242,23 @@ PopAddRemoveSysCapsCallback(IN PVOID NotificationStructure,
|
|||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
/* FIXME: What do do with the capabilities? */
|
||||
DPRINT("Device capabilities: 0x%x\n", Caps);
|
||||
if (Caps & SYS_BUTTON_POWER)
|
||||
{
|
||||
DPRINT("Device capabilities: 0x%x (", Caps);
|
||||
if (Caps & SYS_BUTTON_POWER) DPRINT(" POWER");
|
||||
if (Caps & SYS_BUTTON_SLEEP) DPRINT(" SLEEP");
|
||||
if (Caps & SYS_BUTTON_LID) DPRINT(" LID");
|
||||
DPRINT(" )\n");
|
||||
DPRINT("POWER button present\n");
|
||||
PopCapabilities.PowerButtonPresent = TRUE;
|
||||
}
|
||||
|
||||
if (Caps & SYS_BUTTON_SLEEP)
|
||||
{
|
||||
DPRINT("SLEEP button present\n");
|
||||
PopCapabilities.SleepButtonPresent = TRUE;
|
||||
}
|
||||
|
||||
if (Caps & SYS_BUTTON_LID)
|
||||
{
|
||||
DPRINT("LID present\n");
|
||||
PopCapabilities.LidPresent = TRUE;
|
||||
}
|
||||
|
||||
SysButtonContext = ExAllocatePoolWithTag(NonPagedPool,
|
||||
|
|
|
@ -26,6 +26,7 @@ PDEVICE_NODE PopSystemPowerDeviceNode = NULL;
|
|||
BOOLEAN PopAcpiPresent = FALSE;
|
||||
POP_POWER_ACTION PopAction;
|
||||
WORK_QUEUE_ITEM PopShutdownWorkItem;
|
||||
SYSTEM_POWER_CAPABILITIES PopCapabilities;
|
||||
|
||||
/* PRIVATE FUNCTIONS *********************************************************/
|
||||
|
||||
|
@ -323,6 +324,9 @@ PoInitSystem(IN ULONG BootPhase)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* Initialize the power capabilities */
|
||||
RtlZeroMemory(&PopCapabilities, sizeof(SYSTEM_POWER_CAPABILITIES));
|
||||
|
||||
/* Get the Command Line */
|
||||
CommandLine = KeLoaderBlock->LoadOptions;
|
||||
|
||||
|
@ -343,6 +347,9 @@ PoInitSystem(IN ULONG BootPhase)
|
|||
PopAcpiPresent = KeLoaderBlock->Extension->AcpiTable != NULL ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/* Enable shutdown by power button */
|
||||
if (PopAcpiPresent)
|
||||
PopCapabilities.SystemS5 = TRUE;
|
||||
|
||||
/* Initialize volume support */
|
||||
InitializeListHead(&PopVolumeDevices);
|
||||
|
@ -720,9 +727,9 @@ NtPowerInformation(IN POWER_INFORMATION_LEVEL PowerInformationLevel,
|
|||
|
||||
_SEH2_TRY
|
||||
{
|
||||
/* Just zero the struct (and thus set PowerCapabilities->SystemBatteriesPresent = FALSE) */
|
||||
RtlZeroMemory(PowerCapabilities, sizeof(SYSTEM_POWER_CAPABILITIES));
|
||||
//PowerCapabilities->SystemBatteriesPresent = 0;
|
||||
RtlCopyMemory(PowerCapabilities,
|
||||
&PopCapabilities,
|
||||
sizeof(SYSTEM_POWER_CAPABILITIES));
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue