1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 02:28:12 +00: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:
Liav A 2023-06-09 21:22:30 +03:00 committed by Jelle Raaijmakers
parent 5fd975da8f
commit d550b09871
12 changed files with 49 additions and 44 deletions

View file

@ -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>

View file

@ -1,41 +0,0 @@
/*
* 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;
}
}

View file

@ -1,20 +0,0 @@
/*
* 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/PhysicalAddress.h>
#include <Kernel/Memory/Region.h>
#include <Kernel/Memory/VirtualAddress.h>
namespace Kernel {
ErrorOr<Memory::MappedROM> map_bios();
ErrorOr<Memory::MappedROM> map_ebda();
}