mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 21:37:58 +03:00
Kernel: Add basic aarch64 support to MemoryManager
FIXME: There's still a lot to do like for example, port `quickmap_page`. This does however get us further into the boot process than before.
This commit is contained in:
parent
14fe03569a
commit
7e1e208d08
Notes:
sideshowbarker
2024-07-17 09:41:18 +09:00
Author: https://github.com/filiphsps Commit: https://github.com/SerenityOS/serenity/commit/7e1e208d08 Pull-request: https://github.com/SerenityOS/serenity/pull/14815 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/FireFox317 ✅ Reviewed-by: https://github.com/kleinesfilmroellchen ✅ Reviewed-by: https://github.com/linusg
@ -5,6 +5,7 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Arch/aarch64/ASM_wrapper.h>
|
||||
#include <Kernel/Memory/PageDirectory.h>
|
||||
|
||||
namespace Kernel::Memory {
|
||||
@ -27,7 +28,7 @@ LockRefPtr<PageDirectory> PageDirectory::find_current()
|
||||
|
||||
void activate_kernel_page_directory(PageDirectory const&)
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
// FIXME: Implement this
|
||||
}
|
||||
|
||||
void activate_page_directory(PageDirectory const&, Thread*)
|
||||
|
@ -39,4 +39,9 @@ void Processor::initialize(u32 cpu)
|
||||
asm volatile("wfi");
|
||||
}
|
||||
|
||||
void Processor::flush_tlb_local(VirtualAddress, size_t)
|
||||
{
|
||||
// FIXME: Implement this
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,7 @@
|
||||
|
||||
#include <Kernel/Arch/ProcessorSpecificDataID.h>
|
||||
#include <Kernel/Arch/aarch64/Registers.h>
|
||||
|
||||
class VirtualAddress;
|
||||
#include <Kernel/VirtualAddress.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
@ -36,18 +35,19 @@ struct [[gnu::aligned(16)]] FPUState
|
||||
extern Processor* g_current_processor;
|
||||
|
||||
class Processor {
|
||||
void* m_processor_specific_data[static_cast<size_t>(ProcessorSpecificDataID::__Count)];
|
||||
|
||||
public:
|
||||
void initialize(u32 cpu);
|
||||
|
||||
void set_specific(ProcessorSpecificDataID /*specific_id*/, void* /*ptr*/)
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
template<typename T>
|
||||
T* get_specific()
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
return 0;
|
||||
return static_cast<T*>(m_processor_specific_data[static_cast<size_t>(T::processor_specific_data_id())]);
|
||||
}
|
||||
void set_specific(ProcessorSpecificDataID specific_id, void* ptr)
|
||||
{
|
||||
m_processor_specific_data[static_cast<size_t>(specific_id)] = ptr;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static void pause()
|
||||
@ -76,11 +76,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static void flush_tlb_local(VirtualAddress&, size_t&)
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
static void flush_tlb_local(VirtualAddress vaddr, size_t page_count);
|
||||
ALWAYS_INLINE static void flush_tlb(Memory::PageDirectory const*, VirtualAddress const&, size_t)
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <Kernel/Devices/DeviceManagement.h>
|
||||
#include <Kernel/Graphics/Console/BootFramebufferConsole.h>
|
||||
#include <Kernel/KSyms.h>
|
||||
#include <Kernel/Memory/MemoryManager.h>
|
||||
#include <Kernel/Panic.h>
|
||||
|
||||
extern "C" void exception_common(Kernel::TrapFrame const* const trap_frame);
|
||||
@ -91,6 +92,17 @@ extern "C" [[noreturn]] void init()
|
||||
{
|
||||
g_in_early_boot = true;
|
||||
|
||||
// FIXME: Don't hardcode this
|
||||
multiboot_memory_map_t mmap[] = {
|
||||
{ sizeof(struct multiboot_mmap_entry) - sizeof(u32),
|
||||
(u64)0x0,
|
||||
(u64)0xA2F000,
|
||||
MULTIBOOT_MEMORY_AVAILABLE }
|
||||
};
|
||||
|
||||
multiboot_memory_map = mmap;
|
||||
multiboot_memory_map_count = 1;
|
||||
|
||||
dbgln("Welcome to Serenity OS!");
|
||||
dbgln("Imagine this being your ideal operating system.");
|
||||
dbgln("Observed deviations from that ideal are shortcomings of your imagination.");
|
||||
@ -119,6 +131,9 @@ extern "C" [[noreturn]] void init()
|
||||
}
|
||||
dmesgln("Starting SerenityOS...");
|
||||
|
||||
dmesgln("Initialize MMU");
|
||||
init_page_tables();
|
||||
Memory::MemoryManager::initialize(0);
|
||||
DeviceManagement::initialize();
|
||||
|
||||
// Invoke all static global constructors in the kernel.
|
||||
@ -133,9 +148,6 @@ extern "C" [[noreturn]] void init()
|
||||
auto firmware_version = query_firmware_version();
|
||||
dmesgln("Firmware version: {}", firmware_version);
|
||||
|
||||
dmesgln("Initialize MMU");
|
||||
init_page_tables();
|
||||
|
||||
auto& timer = RPi::Timer::the();
|
||||
timer.set_interrupt_interval_usec(1'000'000);
|
||||
timer.enable_interrupt_mode();
|
||||
@ -146,6 +158,8 @@ extern "C" [[noreturn]] void init()
|
||||
// interrupts are working!
|
||||
for (;;)
|
||||
asm volatile("wfi");
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
class QueryFirmwareVersionMboxMessage : RPi::Mailbox::Message {
|
||||
|
@ -487,8 +487,10 @@ UNMAP_AFTER_INIT void MemoryManager::initialize_physical_pages()
|
||||
auto* pd = reinterpret_cast<PageDirectoryEntry*>(quickmap_page(boot_pd_kernel));
|
||||
PageDirectoryEntry& pde = pd[page_directory_index];
|
||||
|
||||
// FIXME: port quickmap_page to aarch64
|
||||
#if !ARCH(AARCH64)
|
||||
VERIFY(!pde.is_present()); // Nothing should be using this PD yet
|
||||
|
||||
#endif
|
||||
// We can't use ensure_pte quite yet!
|
||||
pde.set_page_table_base(pt_paddr.get());
|
||||
pde.set_user_allowed(false);
|
||||
|
@ -43,7 +43,12 @@ struct multiboot_mmap_entry {
|
||||
u64 addr;
|
||||
u64 len;
|
||||
u32 type;
|
||||
#if ARCH(AARCH64)
|
||||
// __attribute__((packed)) causes alignment issues on aarch64
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
|
||||
|
||||
#define MULTIBOOT_INFO_FRAMEBUFFER_INFO (1 << 12)
|
||||
|
Loading…
Reference in New Issue
Block a user