mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 14:14:45 +03:00
Kernel: Unify BIOS and ACPI components in the SysFS firmware directory
Both should reside in the SysFS firmware directory which is normally located in /sys/firmware. Also, apply some OOM-safety patterns when creating the BIOS and ACPI directories.
This commit is contained in:
parent
9132596b8e
commit
33f033066c
Notes:
sideshowbarker
2024-07-18 04:11:38 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/33f033066c5 Pull-request: https://github.com/SerenityOS/serenity/pull/9958
@ -127,6 +127,7 @@ set(KERNEL_SOURCES
|
||||
Firmware/ACPI/MultiProcessorParser.cpp
|
||||
Firmware/ACPI/Parser.cpp
|
||||
Firmware/BIOS.cpp
|
||||
Firmware/SysFSFirmware.cpp
|
||||
FutexQueue.cpp
|
||||
Interrupts/APIC.cpp
|
||||
Interrupts/GenericInterruptHandler.cpp
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <AK/Format.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Try.h>
|
||||
#include <Kernel/Arch/x86/InterruptDisabler.h>
|
||||
#include <Kernel/Bus/PCI/API.h>
|
||||
#include <Kernel/Debug.h>
|
||||
@ -63,14 +64,14 @@ UNMAP_AFTER_INIT ACPISysFSComponent::ACPISysFSComponent(String name, PhysicalAdd
|
||||
{
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void ACPISysFSDirectory::initialize()
|
||||
UNMAP_AFTER_INIT KResultOr<NonnullRefPtr<ACPISysFSDirectory>> ACPISysFSDirectory::try_create(FirmwareSysFSDirectory& firmware_directory)
|
||||
{
|
||||
auto acpi_directory = adopt_ref(*new (nothrow) ACPISysFSDirectory());
|
||||
SysFSComponentRegistry::the().register_new_component(acpi_directory);
|
||||
auto acpi_directory = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ACPISysFSDirectory(firmware_directory)));
|
||||
return acpi_directory;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT ACPISysFSDirectory::ACPISysFSDirectory()
|
||||
: SysFSDirectory("acpi", SysFSComponentRegistry::the().root_directory())
|
||||
UNMAP_AFTER_INIT ACPISysFSDirectory::ACPISysFSDirectory(FirmwareSysFSDirectory& firmware_directory)
|
||||
: SysFSDirectory("acpi", firmware_directory)
|
||||
{
|
||||
NonnullRefPtrVector<SysFSComponent> components;
|
||||
size_t ssdt_count = 0;
|
||||
|
@ -6,11 +6,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/CommandLine.h>
|
||||
#include <Kernel/FileSystem/SysFSComponent.h>
|
||||
#include <Kernel/Firmware/ACPI/Definitions.h>
|
||||
#include <Kernel/Firmware/ACPI/Initialize.h>
|
||||
#include <Kernel/Firmware/SysFSFirmware.h>
|
||||
#include <Kernel/Interrupts/IRQHandler.h>
|
||||
#include <Kernel/Memory/Region.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
@ -20,10 +22,10 @@ namespace Kernel::ACPI {
|
||||
|
||||
class ACPISysFSDirectory : public SysFSDirectory {
|
||||
public:
|
||||
static void initialize();
|
||||
static KResultOr<NonnullRefPtr<ACPISysFSDirectory>> try_create(FirmwareSysFSDirectory& firmware_directory);
|
||||
|
||||
private:
|
||||
ACPISysFSDirectory();
|
||||
explicit ACPISysFSDirectory(FirmwareSysFSDirectory& firmware_directory);
|
||||
};
|
||||
|
||||
class ACPISysFSComponent : public SysFSComponent {
|
||||
|
@ -90,11 +90,11 @@ UNMAP_AFTER_INIT void BIOSSysFSDirectory::set_dmi_32_bit_entry_initialization_va
|
||||
m_smbios_structure_table_length = smbios_entry.ptr()->legacy_structure.smboios_table_length;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void BIOSSysFSDirectory::initialize()
|
||||
UNMAP_AFTER_INIT KResultOr<NonnullRefPtr<BIOSSysFSDirectory>> BIOSSysFSDirectory::try_create(FirmwareSysFSDirectory& firmware_directory)
|
||||
{
|
||||
auto bios_directory = adopt_ref(*new (nothrow) BIOSSysFSDirectory());
|
||||
SysFSComponentRegistry::the().register_new_component(bios_directory);
|
||||
auto bios_directory = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) BIOSSysFSDirectory(firmware_directory)));
|
||||
bios_directory->create_components();
|
||||
return bios_directory;
|
||||
}
|
||||
|
||||
void BIOSSysFSDirectory::create_components()
|
||||
@ -126,8 +126,8 @@ UNMAP_AFTER_INIT void BIOSSysFSDirectory::initialize_dmi_exposer()
|
||||
dbgln("BIOSSysFSDirectory: Data table @ {}", m_smbios_structure_table);
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT BIOSSysFSDirectory::BIOSSysFSDirectory()
|
||||
: SysFSDirectory("bios", SysFSComponentRegistry::the().root_directory())
|
||||
UNMAP_AFTER_INIT BIOSSysFSDirectory::BIOSSysFSDirectory(FirmwareSysFSDirectory& firmware_directory)
|
||||
: SysFSDirectory("bios", firmware_directory)
|
||||
{
|
||||
auto entry_32bit = find_dmi_entry32bit_point();
|
||||
if (entry_32bit.has_value()) {
|
||||
|
@ -7,9 +7,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <Kernel/FileSystem/SysFS.h>
|
||||
#include <Kernel/Firmware/SysFSFirmware.h>
|
||||
#include <Kernel/KBuffer.h>
|
||||
#include <Kernel/Memory/MappedROM.h>
|
||||
#include <Kernel/Memory/Region.h>
|
||||
@ -92,12 +94,12 @@ private:
|
||||
|
||||
class BIOSSysFSDirectory : public SysFSDirectory {
|
||||
public:
|
||||
static void initialize();
|
||||
static KResultOr<NonnullRefPtr<BIOSSysFSDirectory>> try_create(FirmwareSysFSDirectory&);
|
||||
|
||||
void create_components();
|
||||
|
||||
private:
|
||||
BIOSSysFSDirectory();
|
||||
explicit BIOSSysFSDirectory(FirmwareSysFSDirectory&);
|
||||
|
||||
void set_dmi_64_bit_entry_initialization_values();
|
||||
void set_dmi_32_bit_entry_initialization_values();
|
||||
|
36
Kernel/Firmware/SysFSFirmware.cpp
Normal file
36
Kernel/Firmware/SysFSFirmware.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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/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());
|
||||
m_components.append(bios_directory_or_error.release_value());
|
||||
m_components.append(acpi_directory_or_error.release_value());
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT FirmwareSysFSDirectory::FirmwareSysFSDirectory()
|
||||
: SysFSDirectory("firmware", SysFSComponentRegistry::the().root_directory())
|
||||
{
|
||||
}
|
||||
|
||||
}
|
24
Kernel/Firmware/SysFSFirmware.h
Normal file
24
Kernel/Firmware/SysFSFirmware.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/FileSystem/SysFS.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class FirmwareSysFSDirectory : public SysFSDirectory {
|
||||
public:
|
||||
static void initialize();
|
||||
|
||||
void create_components();
|
||||
|
||||
private:
|
||||
FirmwareSysFSDirectory();
|
||||
};
|
||||
|
||||
}
|
@ -30,7 +30,7 @@
|
||||
#include <Kernel/Firmware/ACPI/Initialize.h>
|
||||
#include <Kernel/Firmware/ACPI/MultiProcessorParser.h>
|
||||
#include <Kernel/Firmware/ACPI/Parser.h>
|
||||
#include <Kernel/Firmware/BIOS.h>
|
||||
#include <Kernel/Firmware/SysFSFirmware.h>
|
||||
#include <Kernel/Graphics/GraphicsManagement.h>
|
||||
#include <Kernel/Heap/SlabAllocator.h>
|
||||
#include <Kernel/Heap/kmalloc.h>
|
||||
@ -300,9 +300,7 @@ void init_stage2(void*)
|
||||
auto boot_profiling = kernel_command_line().is_boot_profiling_enabled();
|
||||
|
||||
USB::USBManagement::initialize();
|
||||
|
||||
BIOSSysFSDirectory::initialize();
|
||||
ACPI::ACPISysFSDirectory::initialize();
|
||||
FirmwareSysFSDirectory::initialize();
|
||||
|
||||
VirtIO::detect();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user