mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 18:24:45 -05:00
8d0dbdeaac
This change removes the halt and reboot syscalls, and create a new mechanism to change the power state of the machine. Instead of how power state was changed until now, put a SysFS node as writable only for the superuser, that with a defined value, can result in either reboot or poweroff. In the future, a power group can be assigned to this node (which will be the GroupID responsible for power management). This opens an opportunity to permit to shutdown/reboot without superuser permissions, so in the future, a userspace daemon can take control of this node to perform power management operations without superuser permissions, if we enforce different UserID/GroupID on that node.
39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/Firmware/ACPI/Parser.h>
|
|
#include <Kernel/Firmware/BIOS.h>
|
|
#include <Kernel/Firmware/PowerStateSwitch.h>
|
|
#include <Kernel/Firmware/SysFSFirmware.h>
|
|
#include <Kernel/Sections.h>
|
|
|
|
namespace Kernel {
|
|
|
|
UNMAP_AFTER_INIT void FirmwareSysFSDirectory::initialize()
|
|
{
|
|
auto firmware_directory = adopt_ref_if_nonnull(new (nothrow) FirmwareSysFSDirectory()).release_nonnull();
|
|
SysFSComponentRegistry::the().register_new_component(firmware_directory);
|
|
firmware_directory->create_components();
|
|
}
|
|
|
|
void FirmwareSysFSDirectory::create_components()
|
|
{
|
|
auto bios_directory_or_error = BIOSSysFSDirectory::try_create(*this);
|
|
VERIFY(!bios_directory_or_error.is_error());
|
|
auto acpi_directory_or_error = ACPI::ACPISysFSDirectory::try_create(*this);
|
|
VERIFY(!acpi_directory_or_error.is_error());
|
|
auto power_state_switch_node = PowerStateSwitchNode::must_create(*this);
|
|
m_components.append(bios_directory_or_error.release_value());
|
|
m_components.append(acpi_directory_or_error.release_value());
|
|
m_components.append(power_state_switch_node);
|
|
}
|
|
|
|
UNMAP_AFTER_INIT FirmwareSysFSDirectory::FirmwareSysFSDirectory()
|
|
: SysFSDirectory("firmware", SysFSComponentRegistry::the().root_directory())
|
|
{
|
|
}
|
|
|
|
}
|