mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 19:45:08 +00:00

This enforces us to remove duplicated code across the SysFS code. This results in great simplification of how the SysFS works now, because we enforce one way to treat SysFSDirectory objects.
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/FileSystem/SysFS/Registry.h>
|
|
#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS/Directory.h>
|
|
#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/Directory.h>
|
|
#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/PowerStateSwitch.h>
|
|
#include <Kernel/Firmware/ACPI/Parser.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()
|
|
{
|
|
MUST(m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
|
list.append(BIOSSysFSDirectory::must_create(*this));
|
|
if (ACPI::is_enabled())
|
|
list.append(ACPI::ACPISysFSDirectory::must_create(*this));
|
|
list.append(PowerStateSwitchNode::must_create(*this));
|
|
return {};
|
|
}));
|
|
}
|
|
|
|
UNMAP_AFTER_INIT FirmwareSysFSDirectory::FirmwareSysFSDirectory()
|
|
: SysFSDirectory(SysFSComponentRegistry::the().root_directory())
|
|
{
|
|
}
|
|
|
|
}
|