mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
Kernel: Move PC BIOS-related code to the x86_64 architecture directory
All code that is related to PC BIOS should not be in the Kernel/Firmware directory as this directory is for abstracted and platform-agnostic code like ACPI (and device tree parsing in the future). This fixes a problem with the aarch64 architecure, as these machines don't have any PC-BIOS in them so actually trying to access these memory locations (EBDA, BIOS ROM) does not make any sense, as they're specific to x86 machines only.
This commit is contained in:
parent
5fd975da8f
commit
d550b09871
Notes:
sideshowbarker
2024-07-17 06:40:21 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/d550b09871 Pull-request: https://github.com/SerenityOS/serenity/pull/19336 Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/kleinesfilmroellchen
@ -4,8 +4,8 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Arch/x86_64/Firmware/PCBIOS/Mapper.h>
|
||||
#include <Kernel/Firmware/ACPI/StaticParsing.h>
|
||||
#include <Kernel/Firmware/BIOS.h>
|
||||
#include <Kernel/Memory/MemoryManager.h>
|
||||
|
||||
namespace Kernel::ACPI::StaticParsing {
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/Arch/x86_64/Firmware/MultiProcessor/Parser.h>
|
||||
#include <Kernel/Arch/x86_64/Firmware/PCBIOS/Mapper.h>
|
||||
#include <Kernel/Arch/x86_64/Interrupts/IOAPIC.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/Firmware/BIOS.h>
|
||||
#include <Kernel/Library/StdLib.h>
|
||||
#include <Kernel/Memory/TypedMapping.h>
|
||||
#include <Kernel/Sections.h>
|
||||
|
@ -5,7 +5,7 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Firmware/BIOS.h>
|
||||
#include <Kernel/Arch/x86_64/Firmware/PCBIOS/Mapper.h>
|
||||
#include <Kernel/Memory/MemoryManager.h>
|
||||
#include <Kernel/Memory/TypedMapping.h>
|
||||
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/Arch/x86_64/Firmware/PCBIOS/Mapper.h>
|
||||
#include <Kernel/Arch/x86_64/Firmware/PCBIOS/SysFSComponent.h>
|
||||
#include <Kernel/FileSystem/OpenFileDescription.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS/Component.h>
|
||||
#include <Kernel/Firmware/BIOS.h>
|
||||
#include <Kernel/Library/KBufferBuilder.h>
|
||||
#include <Kernel/Memory/MemoryManager.h>
|
||||
#include <Kernel/Memory/TypedMapping.h>
|
||||
@ -15,12 +15,12 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
NonnullRefPtr<BIOSSysFSComponent> BIOSSysFSComponent::must_create(Type type, PhysicalAddress blob_paddr, size_t blob_size)
|
||||
NonnullRefPtr<SysFSPCBIOSComponent> SysFSPCBIOSComponent::must_create(Type type, PhysicalAddress blob_paddr, size_t blob_size)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new (nothrow) BIOSSysFSComponent(type, blob_paddr, blob_size)).release_nonnull();
|
||||
return adopt_ref_if_nonnull(new (nothrow) SysFSPCBIOSComponent(type, blob_paddr, blob_size)).release_nonnull();
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT BIOSSysFSComponent::BIOSSysFSComponent(Type type, PhysicalAddress blob_paddr, size_t blob_size)
|
||||
UNMAP_AFTER_INIT SysFSPCBIOSComponent::SysFSPCBIOSComponent(Type type, PhysicalAddress blob_paddr, size_t blob_size)
|
||||
: SysFSComponent()
|
||||
, m_blob_paddr(blob_paddr)
|
||||
, m_blob_length(blob_size)
|
||||
@ -28,7 +28,7 @@ UNMAP_AFTER_INIT BIOSSysFSComponent::BIOSSysFSComponent(Type type, PhysicalAddre
|
||||
{
|
||||
}
|
||||
|
||||
ErrorOr<size_t> BIOSSysFSComponent::read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription*) const
|
||||
ErrorOr<size_t> SysFSPCBIOSComponent::read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription*) const
|
||||
{
|
||||
auto blob = TRY(try_to_generate_buffer());
|
||||
|
||||
@ -40,7 +40,7 @@ ErrorOr<size_t> BIOSSysFSComponent::read_bytes(off_t offset, size_t count, UserO
|
||||
return nread;
|
||||
}
|
||||
|
||||
StringView BIOSSysFSComponent::name() const
|
||||
StringView SysFSPCBIOSComponent::name() const
|
||||
{
|
||||
switch (m_type) {
|
||||
case Type::DMIEntryPoint:
|
||||
@ -53,9 +53,9 @@ StringView BIOSSysFSComponent::name() const
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<KBuffer>> BIOSSysFSComponent::try_to_generate_buffer() const
|
||||
ErrorOr<NonnullOwnPtr<KBuffer>> SysFSPCBIOSComponent::try_to_generate_buffer() const
|
||||
{
|
||||
auto blob = TRY(Memory::map_typed<u8>((m_blob_paddr), m_blob_length));
|
||||
return KBuffer::try_create_with_bytes("BIOSSysFSComponent: Blob"sv, Span<u8> { blob.ptr(), m_blob_length });
|
||||
return KBuffer::try_create_with_bytes("SysFSPCBIOSComponent: Blob"sv, Span<u8> { blob.ptr(), m_blob_length });
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class BIOSSysFSComponent final : public SysFSComponent {
|
||||
class SysFSPCBIOSComponent final : public SysFSComponent {
|
||||
public:
|
||||
enum class Type {
|
||||
DMIEntryPoint,
|
||||
@ -24,13 +24,13 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<BIOSSysFSComponent> must_create(Type, PhysicalAddress, size_t blob_size);
|
||||
static NonnullRefPtr<SysFSPCBIOSComponent> must_create(Type, PhysicalAddress, size_t blob_size);
|
||||
virtual StringView name() const override;
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override;
|
||||
|
||||
private:
|
||||
ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const;
|
||||
BIOSSysFSComponent(Type, PhysicalAddress, size_t blob_size);
|
||||
SysFSPCBIOSComponent(Type, PhysicalAddress, size_t blob_size);
|
||||
|
||||
virtual size_t size() const override { return m_blob_length; }
|
||||
|
@ -5,11 +5,11 @@
|
||||
*/
|
||||
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/Arch/x86_64/Firmware/PCBIOS/DMI/Definitions.h>
|
||||
#include <Kernel/Arch/x86_64/Firmware/PCBIOS/Mapper.h>
|
||||
#include <Kernel/Arch/x86_64/Firmware/PCBIOS/SysFSComponent.h>
|
||||
#include <Kernel/Arch/x86_64/Firmware/PCBIOS/SysFSDirectory.h>
|
||||
#include <Kernel/FileSystem/OpenFileDescription.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS/Component.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS/DMI/Definitions.h>
|
||||
#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS/Directory.h>
|
||||
#include <Kernel/Firmware/BIOS.h>
|
||||
#include <Kernel/Library/KBufferBuilder.h>
|
||||
#include <Kernel/Memory/MemoryManager.h>
|
||||
#include <Kernel/Memory/TypedMapping.h>
|
||||
@ -21,51 +21,51 @@ namespace Kernel {
|
||||
#define SMBIOS_END_SEARCH_ADDR 0xfffff
|
||||
#define SMBIOS_SEARCH_AREA_SIZE (SMBIOS_END_SEARCH_ADDR - SMBIOS_BASE_SEARCH_ADDR)
|
||||
|
||||
UNMAP_AFTER_INIT void BIOSSysFSDirectory::set_dmi_64_bit_entry_initialization_values()
|
||||
UNMAP_AFTER_INIT void SysFSBIOSDirectory::set_dmi_64_bit_entry_initialization_values()
|
||||
{
|
||||
dbgln("BIOSSysFSDirectory: SMBIOS 64bit Entry point @ {}", m_dmi_entry_point);
|
||||
dbgln("SysFSBIOSDirectory: SMBIOS 64bit Entry point @ {}", m_dmi_entry_point);
|
||||
auto smbios_entry = Memory::map_typed<SMBIOS::EntryPoint64bit>(m_dmi_entry_point, SMBIOS_SEARCH_AREA_SIZE).release_value_but_fixme_should_propagate_errors();
|
||||
m_smbios_structure_table = PhysicalAddress(smbios_entry.ptr()->table_ptr);
|
||||
m_dmi_entry_point_length = smbios_entry.ptr()->length;
|
||||
m_smbios_structure_table_length = smbios_entry.ptr()->table_maximum_size;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void BIOSSysFSDirectory::set_dmi_32_bit_entry_initialization_values()
|
||||
UNMAP_AFTER_INIT void SysFSBIOSDirectory::set_dmi_32_bit_entry_initialization_values()
|
||||
{
|
||||
dbgln("BIOSSysFSDirectory: SMBIOS 32bit Entry point @ {}", m_dmi_entry_point);
|
||||
dbgln("SysFSBIOSDirectory: SMBIOS 32bit Entry point @ {}", m_dmi_entry_point);
|
||||
auto smbios_entry = Memory::map_typed<SMBIOS::EntryPoint32bit>(m_dmi_entry_point, SMBIOS_SEARCH_AREA_SIZE).release_value_but_fixme_should_propagate_errors();
|
||||
m_smbios_structure_table = PhysicalAddress(smbios_entry.ptr()->legacy_structure.smbios_table_ptr);
|
||||
m_dmi_entry_point_length = smbios_entry.ptr()->length;
|
||||
m_smbios_structure_table_length = smbios_entry.ptr()->legacy_structure.smbios_table_length;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<BIOSSysFSDirectory> BIOSSysFSDirectory::must_create(SysFSFirmwareDirectory& firmware_directory)
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<SysFSBIOSDirectory> SysFSBIOSDirectory::must_create(SysFSFirmwareDirectory& firmware_directory)
|
||||
{
|
||||
auto bios_directory = MUST(adopt_nonnull_ref_or_enomem(new (nothrow) BIOSSysFSDirectory(firmware_directory)));
|
||||
auto bios_directory = MUST(adopt_nonnull_ref_or_enomem(new (nothrow) SysFSBIOSDirectory(firmware_directory)));
|
||||
bios_directory->create_components();
|
||||
return bios_directory;
|
||||
}
|
||||
|
||||
void BIOSSysFSDirectory::create_components()
|
||||
void SysFSBIOSDirectory::create_components()
|
||||
{
|
||||
if (m_dmi_entry_point.is_null() || m_smbios_structure_table.is_null())
|
||||
return;
|
||||
if (m_dmi_entry_point_length == 0) {
|
||||
dbgln("BIOSSysFSDirectory: invalid dmi entry length");
|
||||
dbgln("SysFSBIOSDirectory: invalid dmi entry length");
|
||||
return;
|
||||
}
|
||||
if (m_smbios_structure_table_length == 0) {
|
||||
dbgln("BIOSSysFSDirectory: invalid smbios structure table length");
|
||||
dbgln("SysFSBIOSDirectory: invalid smbios structure table length");
|
||||
return;
|
||||
}
|
||||
MUST(m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.append(BIOSSysFSComponent::must_create(BIOSSysFSComponent::Type::DMIEntryPoint, m_dmi_entry_point, m_dmi_entry_point_length));
|
||||
list.append(BIOSSysFSComponent::must_create(BIOSSysFSComponent::Type::SMBIOSTable, m_smbios_structure_table, m_smbios_structure_table_length));
|
||||
list.append(SysFSPCBIOSComponent::must_create(SysFSPCBIOSComponent::Type::DMIEntryPoint, m_dmi_entry_point, m_dmi_entry_point_length));
|
||||
list.append(SysFSPCBIOSComponent::must_create(SysFSPCBIOSComponent::Type::SMBIOSTable, m_smbios_structure_table, m_smbios_structure_table_length));
|
||||
return {};
|
||||
}));
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void BIOSSysFSDirectory::initialize_dmi_exposer()
|
||||
UNMAP_AFTER_INIT void SysFSBIOSDirectory::initialize_dmi_exposer()
|
||||
{
|
||||
VERIFY(!(m_dmi_entry_point.is_null()));
|
||||
if (m_using_64bit_dmi_entry_point) {
|
||||
@ -73,10 +73,10 @@ UNMAP_AFTER_INIT void BIOSSysFSDirectory::initialize_dmi_exposer()
|
||||
} else {
|
||||
set_dmi_32_bit_entry_initialization_values();
|
||||
}
|
||||
dbgln("BIOSSysFSDirectory: Data table @ {}", m_smbios_structure_table);
|
||||
dbgln("SysFSBIOSDirectory: Data table @ {}", m_smbios_structure_table);
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT BIOSSysFSDirectory::BIOSSysFSDirectory(SysFSFirmwareDirectory& firmware_directory)
|
||||
UNMAP_AFTER_INIT SysFSBIOSDirectory::SysFSBIOSDirectory(SysFSFirmwareDirectory& firmware_directory)
|
||||
: SysFSDirectory(firmware_directory)
|
||||
{
|
||||
auto entry_32bit = find_dmi_entry32bit_point();
|
||||
@ -94,7 +94,7 @@ UNMAP_AFTER_INIT BIOSSysFSDirectory::BIOSSysFSDirectory(SysFSFirmwareDirectory&
|
||||
initialize_dmi_exposer();
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT Optional<PhysicalAddress> BIOSSysFSDirectory::find_dmi_entry64bit_point()
|
||||
UNMAP_AFTER_INIT Optional<PhysicalAddress> SysFSBIOSDirectory::find_dmi_entry64bit_point()
|
||||
{
|
||||
auto bios_or_error = map_bios();
|
||||
if (bios_or_error.is_error())
|
||||
@ -102,7 +102,7 @@ UNMAP_AFTER_INIT Optional<PhysicalAddress> BIOSSysFSDirectory::find_dmi_entry64b
|
||||
return bios_or_error.value().find_chunk_starting_with("_SM3_"sv, 16);
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT Optional<PhysicalAddress> BIOSSysFSDirectory::find_dmi_entry32bit_point()
|
||||
UNMAP_AFTER_INIT Optional<PhysicalAddress> SysFSBIOSDirectory::find_dmi_entry32bit_point()
|
||||
{
|
||||
auto bios_or_error = map_bios();
|
||||
if (bios_or_error.is_error())
|
@ -15,15 +15,15 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class BIOSSysFSDirectory : public SysFSDirectory {
|
||||
class SysFSBIOSDirectory : public SysFSDirectory {
|
||||
public:
|
||||
virtual StringView name() const override { return "bios"sv; }
|
||||
static NonnullRefPtr<BIOSSysFSDirectory> must_create(SysFSFirmwareDirectory&);
|
||||
static NonnullRefPtr<SysFSBIOSDirectory> must_create(SysFSFirmwareDirectory&);
|
||||
|
||||
void create_components();
|
||||
|
||||
private:
|
||||
explicit BIOSSysFSDirectory(SysFSFirmwareDirectory&);
|
||||
explicit SysFSBIOSDirectory(SysFSFirmwareDirectory&);
|
||||
|
||||
void set_dmi_64_bit_entry_initialization_values();
|
||||
void set_dmi_32_bit_entry_initialization_values();
|
@ -172,8 +172,6 @@ set(KERNEL_SOURCES
|
||||
FileSystem/SysFS/Subsystems/Devices/Graphics/DisplayConnector/DeviceDirectory.cpp
|
||||
FileSystem/SysFS/Subsystems/Devices/Graphics/DisplayConnector/DeviceAttribute.cpp
|
||||
FileSystem/SysFS/Subsystems/Devices/Directory.cpp
|
||||
FileSystem/SysFS/Subsystems/Firmware/BIOS/Component.cpp
|
||||
FileSystem/SysFS/Subsystems/Firmware/BIOS/Directory.cpp
|
||||
FileSystem/SysFS/Subsystems/Firmware/Directory.cpp
|
||||
FileSystem/SysFS/Subsystems/Kernel/Interrupts.cpp
|
||||
FileSystem/SysFS/Subsystems/Kernel/Processes.cpp
|
||||
@ -206,7 +204,6 @@ set(KERNEL_SOURCES
|
||||
FileSystem/SysFS/Subsystems/Kernel/Variables/StringVariable.cpp
|
||||
FileSystem/SysFS/Subsystems/Kernel/Variables/UBSANDeadly.cpp
|
||||
FileSystem/VirtualFileSystem.cpp
|
||||
Firmware/BIOS.cpp
|
||||
Firmware/ACPI/Initialize.cpp
|
||||
Firmware/ACPI/Parser.cpp
|
||||
Firmware/ACPI/StaticParsing.cpp
|
||||
@ -372,6 +369,9 @@ if ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
||||
|
||||
Arch/x86_64/Firmware/ACPI/StaticParsing.cpp
|
||||
Arch/x86_64/Firmware/MultiProcessor/Parser.cpp
|
||||
Arch/x86_64/Firmware/PCBIOS/Mapper.cpp
|
||||
Arch/x86_64/Firmware/PCBIOS/SysFSComponent.cpp
|
||||
Arch/x86_64/Firmware/PCBIOS/SysFSDirectory.cpp
|
||||
|
||||
Arch/x86_64/Hypervisor/BochsDisplayConnector.cpp
|
||||
Arch/x86_64/Hypervisor/VMWareBackdoor.cpp
|
||||
|
@ -4,8 +4,11 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Platform.h>
|
||||
#if ARCH(X86_64)
|
||||
# include <Kernel/Arch/x86_64/Firmware/PCBIOS/SysFSDirectory.h>
|
||||
#endif
|
||||
#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/Firmware/ACPI/Parser.h>
|
||||
#include <Kernel/Sections.h>
|
||||
@ -22,7 +25,9 @@ UNMAP_AFTER_INIT void SysFSFirmwareDirectory::initialize()
|
||||
void SysFSFirmwareDirectory::create_components()
|
||||
{
|
||||
MUST(m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.append(BIOSSysFSDirectory::must_create(*this));
|
||||
#if ARCH(X86_64)
|
||||
list.append(SysFSBIOSDirectory::must_create(*this));
|
||||
#endif
|
||||
if (ACPI::is_enabled())
|
||||
list.append(ACPI::ACPISysFSDirectory::must_create(*this));
|
||||
return {};
|
||||
|
@ -12,12 +12,12 @@
|
||||
#include <AK/Try.h>
|
||||
#include <Kernel/Interrupts/InterruptDisabler.h>
|
||||
#if ARCH(X86_64)
|
||||
# include <Kernel/Arch/x86_64/Firmware/PCBIOS/Mapper.h>
|
||||
# include <Kernel/Arch/x86_64/IO.h>
|
||||
#endif
|
||||
#include <Kernel/Bus/PCI/API.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/Firmware/ACPI/Parser.h>
|
||||
#include <Kernel/Firmware/BIOS.h>
|
||||
#include <Kernel/Library/StdLib.h>
|
||||
#include <Kernel/Memory/TypedMapping.h>
|
||||
#include <Kernel/Sections.h>
|
||||
|
Loading…
Reference in New Issue
Block a user