diff options
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Kernel/Devices/MemoryDevice.cpp | 1 | ||||
-rw-r--r-- | Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.cpp | 28 | ||||
-rw-r--r-- | Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.h | 3 | ||||
-rw-r--r-- | Kernel/Firmware/ACPI/Parser.cpp | 2 | ||||
-rw-r--r-- | Kernel/Firmware/BIOS.cpp | 41 | ||||
-rw-r--r-- | Kernel/Firmware/BIOS.h | 20 | ||||
-rw-r--r-- | Kernel/Firmware/MultiProcessor/Parser.cpp | 2 |
8 files changed, 65 insertions, 33 deletions
diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index be72abbe59..54527f2c0c 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -153,6 +153,7 @@ set(KERNEL_SOURCES FileSystem/SysFS/Subsystems/Firmware/PowerStateSwitch.cpp FileSystem/TmpFS.cpp FileSystem/VirtualFileSystem.cpp + Firmware/BIOS.cpp Firmware/ACPI/Initialize.cpp Firmware/ACPI/Parser.cpp Firmware/Hypervisor/VMWareBackdoor.cpp diff --git a/Kernel/Devices/MemoryDevice.cpp b/Kernel/Devices/MemoryDevice.cpp index 357bd2e02c..732d4ca5d3 100644 --- a/Kernel/Devices/MemoryDevice.cpp +++ b/Kernel/Devices/MemoryDevice.cpp @@ -8,7 +8,6 @@ #include <AK/StdLibExtras.h> #include <Kernel/Devices/DeviceManagement.h> #include <Kernel/Devices/MemoryDevice.h> -#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.h> #include <Kernel/Memory/AnonymousVMObject.h> #include <Kernel/Memory/TypedMapping.h> #include <Kernel/Sections.h> diff --git a/Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.cpp b/Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.cpp index ad42d1336a..0eea9ac40c 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.cpp +++ b/Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.cpp @@ -8,6 +8,7 @@ #include <AK/StringView.h> #include <Kernel/FileSystem/OpenFileDescription.h> #include <Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.h> +#include <Kernel/Firmware/BIOS.h> #include <Kernel/KBufferBuilder.h> #include <Kernel/Memory/MemoryManager.h> #include <Kernel/Memory/TypedMapping.h> @@ -157,31 +158,4 @@ UNMAP_AFTER_INIT Optional<PhysicalAddress> BIOSSysFSDirectory::find_dmi_entry32b return bios_or_error.value().find_chunk_starting_with("_SM_", 16); } -ErrorOr<Memory::MappedROM> map_bios() -{ - Memory::MappedROM mapping; - mapping.size = 128 * KiB; - mapping.paddr = PhysicalAddress(0xe0000); - auto region_size = TRY(Memory::page_round_up(mapping.size)); - mapping.region = TRY(MM.allocate_kernel_region(mapping.paddr, region_size, {}, Memory::Region::Access::Read)); - return mapping; -} - -ErrorOr<Memory::MappedROM> map_ebda() -{ - auto ebda_segment_ptr = TRY(Memory::map_typed<u16>(PhysicalAddress(0x40e))); - PhysicalAddress ebda_paddr(PhysicalAddress(*ebda_segment_ptr).get() << 4); - // The EBDA size is stored in the first byte of the EBDA in 1K units - size_t ebda_size = *TRY(Memory::map_typed<u8>(ebda_paddr)); - ebda_size *= 1024; - - Memory::MappedROM mapping; - auto region_size = TRY(Memory::page_round_up(ebda_size)); - mapping.region = TRY(MM.allocate_kernel_region(ebda_paddr.page_base(), region_size, {}, Memory::Region::Access::Read)); - mapping.offset = ebda_paddr.offset_in_page(); - mapping.size = ebda_size; - mapping.paddr = ebda_paddr; - return mapping; -} - } diff --git a/Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.h b/Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.h index 19a1dd5224..1f41695dd1 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.h +++ b/Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.h @@ -57,9 +57,6 @@ struct [[gnu::packed]] EntryPoint64bit { namespace Kernel { -ErrorOr<Memory::MappedROM> map_bios(); -ErrorOr<Memory::MappedROM> map_ebda(); - class BIOSSysFSComponent : public SysFSComponent { public: virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override; diff --git a/Kernel/Firmware/ACPI/Parser.cpp b/Kernel/Firmware/ACPI/Parser.cpp index ae064f843a..406275bffb 100644 --- a/Kernel/Firmware/ACPI/Parser.cpp +++ b/Kernel/Firmware/ACPI/Parser.cpp @@ -13,8 +13,8 @@ #include <Kernel/Arch/x86/IO.h> #include <Kernel/Bus/PCI/API.h> #include <Kernel/Debug.h> -#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.h> #include <Kernel/Firmware/ACPI/Parser.h> +#include <Kernel/Firmware/BIOS.h> #include <Kernel/Memory/TypedMapping.h> #include <Kernel/Sections.h> #include <Kernel/StdLib.h> diff --git a/Kernel/Firmware/BIOS.cpp b/Kernel/Firmware/BIOS.cpp new file mode 100644 index 0000000000..0a1ee1be64 --- /dev/null +++ b/Kernel/Firmware/BIOS.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <Kernel/Firmware/BIOS.h> +#include <Kernel/Memory/MemoryManager.h> +#include <Kernel/Memory/TypedMapping.h> + +namespace Kernel { + +ErrorOr<Memory::MappedROM> map_bios() +{ + Memory::MappedROM mapping; + mapping.size = 128 * KiB; + mapping.paddr = PhysicalAddress(0xe0000); + auto region_size = TRY(Memory::page_round_up(mapping.size)); + mapping.region = TRY(MM.allocate_kernel_region(mapping.paddr, region_size, {}, Memory::Region::Access::Read)); + return mapping; +} + +ErrorOr<Memory::MappedROM> map_ebda() +{ + auto ebda_segment_ptr = TRY(Memory::map_typed<u16>(PhysicalAddress(0x40e))); + PhysicalAddress ebda_paddr(PhysicalAddress(*ebda_segment_ptr).get() << 4); + // The EBDA size is stored in the first byte of the EBDA in 1K units + size_t ebda_size = *TRY(Memory::map_typed<u8>(ebda_paddr)); + ebda_size *= 1024; + + Memory::MappedROM mapping; + auto region_size = TRY(Memory::page_round_up(ebda_size)); + mapping.region = TRY(MM.allocate_kernel_region(ebda_paddr.page_base(), region_size, {}, Memory::Region::Access::Read)); + mapping.offset = ebda_paddr.offset_in_page(); + mapping.size = ebda_size; + mapping.paddr = ebda_paddr; + return mapping; +} + +} diff --git a/Kernel/Firmware/BIOS.h b/Kernel/Firmware/BIOS.h new file mode 100644 index 0000000000..c58af9675d --- /dev/null +++ b/Kernel/Firmware/BIOS.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <Kernel/Memory/MappedROM.h> +#include <Kernel/Memory/Region.h> +#include <Kernel/PhysicalAddress.h> +#include <Kernel/VirtualAddress.h> + +namespace Kernel { + +ErrorOr<Memory::MappedROM> map_bios(); +ErrorOr<Memory::MappedROM> map_ebda(); + +} diff --git a/Kernel/Firmware/MultiProcessor/Parser.cpp b/Kernel/Firmware/MultiProcessor/Parser.cpp index 75b7a75b95..1883afc775 100644 --- a/Kernel/Firmware/MultiProcessor/Parser.cpp +++ b/Kernel/Firmware/MultiProcessor/Parser.cpp @@ -8,7 +8,7 @@ #include <AK/StringView.h> #include <Kernel/Debug.h> -#include <Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS.h> +#include <Kernel/Firmware/BIOS.h> #include <Kernel/Firmware/MultiProcessor/Parser.h> #include <Kernel/Interrupts/IOAPIC.h> #include <Kernel/Memory/TypedMapping.h> |