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
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <Kernel/Arch/aarch64/ASM_wrapper.h>
|
||||||
#include <Kernel/Memory/PageDirectory.h>
|
#include <Kernel/Memory/PageDirectory.h>
|
||||||
|
|
||||||
namespace Kernel::Memory {
|
namespace Kernel::Memory {
|
||||||
@ -27,7 +28,7 @@ LockRefPtr<PageDirectory> PageDirectory::find_current()
|
|||||||
|
|
||||||
void activate_kernel_page_directory(PageDirectory const&)
|
void activate_kernel_page_directory(PageDirectory const&)
|
||||||
{
|
{
|
||||||
VERIFY_NOT_REACHED();
|
// FIXME: Implement this
|
||||||
}
|
}
|
||||||
|
|
||||||
void activate_page_directory(PageDirectory const&, Thread*)
|
void activate_page_directory(PageDirectory const&, Thread*)
|
||||||
|
@ -39,4 +39,9 @@ void Processor::initialize(u32 cpu)
|
|||||||
asm volatile("wfi");
|
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/ProcessorSpecificDataID.h>
|
||||||
#include <Kernel/Arch/aarch64/Registers.h>
|
#include <Kernel/Arch/aarch64/Registers.h>
|
||||||
|
#include <Kernel/VirtualAddress.h>
|
||||||
class VirtualAddress;
|
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
@ -36,18 +35,19 @@ struct [[gnu::aligned(16)]] FPUState
|
|||||||
extern Processor* g_current_processor;
|
extern Processor* g_current_processor;
|
||||||
|
|
||||||
class Processor {
|
class Processor {
|
||||||
|
void* m_processor_specific_data[static_cast<size_t>(ProcessorSpecificDataID::__Count)];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void initialize(u32 cpu);
|
void initialize(u32 cpu);
|
||||||
|
|
||||||
void set_specific(ProcessorSpecificDataID /*specific_id*/, void* /*ptr*/)
|
|
||||||
{
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T* get_specific()
|
T* get_specific()
|
||||||
{
|
{
|
||||||
VERIFY_NOT_REACHED();
|
return static_cast<T*>(m_processor_specific_data[static_cast<size_t>(T::processor_specific_data_id())]);
|
||||||
return 0;
|
}
|
||||||
|
void set_specific(ProcessorSpecificDataID specific_id, void* ptr)
|
||||||
|
{
|
||||||
|
m_processor_specific_data[static_cast<size_t>(specific_id)] = ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE static void pause()
|
ALWAYS_INLINE static void pause()
|
||||||
@ -76,11 +76,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE static void flush_tlb_local(VirtualAddress&, size_t&)
|
static void flush_tlb_local(VirtualAddress vaddr, size_t page_count);
|
||||||
{
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
ALWAYS_INLINE static void flush_tlb(Memory::PageDirectory const*, VirtualAddress const&, size_t)
|
ALWAYS_INLINE static void flush_tlb(Memory::PageDirectory const*, VirtualAddress const&, size_t)
|
||||||
{
|
{
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <Kernel/Devices/DeviceManagement.h>
|
#include <Kernel/Devices/DeviceManagement.h>
|
||||||
#include <Kernel/Graphics/Console/BootFramebufferConsole.h>
|
#include <Kernel/Graphics/Console/BootFramebufferConsole.h>
|
||||||
#include <Kernel/KSyms.h>
|
#include <Kernel/KSyms.h>
|
||||||
|
#include <Kernel/Memory/MemoryManager.h>
|
||||||
#include <Kernel/Panic.h>
|
#include <Kernel/Panic.h>
|
||||||
|
|
||||||
extern "C" void exception_common(Kernel::TrapFrame const* const trap_frame);
|
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;
|
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("Welcome to Serenity OS!");
|
||||||
dbgln("Imagine this being your ideal operating system.");
|
dbgln("Imagine this being your ideal operating system.");
|
||||||
dbgln("Observed deviations from that ideal are shortcomings of your imagination.");
|
dbgln("Observed deviations from that ideal are shortcomings of your imagination.");
|
||||||
@ -119,6 +131,9 @@ extern "C" [[noreturn]] void init()
|
|||||||
}
|
}
|
||||||
dmesgln("Starting SerenityOS...");
|
dmesgln("Starting SerenityOS...");
|
||||||
|
|
||||||
|
dmesgln("Initialize MMU");
|
||||||
|
init_page_tables();
|
||||||
|
Memory::MemoryManager::initialize(0);
|
||||||
DeviceManagement::initialize();
|
DeviceManagement::initialize();
|
||||||
|
|
||||||
// Invoke all static global constructors in the kernel.
|
// Invoke all static global constructors in the kernel.
|
||||||
@ -133,9 +148,6 @@ extern "C" [[noreturn]] void init()
|
|||||||
auto firmware_version = query_firmware_version();
|
auto firmware_version = query_firmware_version();
|
||||||
dmesgln("Firmware version: {}", firmware_version);
|
dmesgln("Firmware version: {}", firmware_version);
|
||||||
|
|
||||||
dmesgln("Initialize MMU");
|
|
||||||
init_page_tables();
|
|
||||||
|
|
||||||
auto& timer = RPi::Timer::the();
|
auto& timer = RPi::Timer::the();
|
||||||
timer.set_interrupt_interval_usec(1'000'000);
|
timer.set_interrupt_interval_usec(1'000'000);
|
||||||
timer.enable_interrupt_mode();
|
timer.enable_interrupt_mode();
|
||||||
@ -146,6 +158,8 @@ extern "C" [[noreturn]] void init()
|
|||||||
// interrupts are working!
|
// interrupts are working!
|
||||||
for (;;)
|
for (;;)
|
||||||
asm volatile("wfi");
|
asm volatile("wfi");
|
||||||
|
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
class QueryFirmwareVersionMboxMessage : RPi::Mailbox::Message {
|
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));
|
auto* pd = reinterpret_cast<PageDirectoryEntry*>(quickmap_page(boot_pd_kernel));
|
||||||
PageDirectoryEntry& pde = pd[page_directory_index];
|
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
|
VERIFY(!pde.is_present()); // Nothing should be using this PD yet
|
||||||
|
#endif
|
||||||
// We can't use ensure_pte quite yet!
|
// We can't use ensure_pte quite yet!
|
||||||
pde.set_page_table_base(pt_paddr.get());
|
pde.set_page_table_base(pt_paddr.get());
|
||||||
pde.set_user_allowed(false);
|
pde.set_user_allowed(false);
|
||||||
|
@ -43,7 +43,12 @@ struct multiboot_mmap_entry {
|
|||||||
u64 addr;
|
u64 addr;
|
||||||
u64 len;
|
u64 len;
|
||||||
u32 type;
|
u32 type;
|
||||||
|
#if ARCH(AARCH64)
|
||||||
|
// __attribute__((packed)) causes alignment issues on aarch64
|
||||||
|
};
|
||||||
|
#else
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
#endif
|
||||||
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
|
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
|
||||||
|
|
||||||
#define MULTIBOOT_INFO_FRAMEBUFFER_INFO (1 << 12)
|
#define MULTIBOOT_INFO_FRAMEBUFFER_INFO (1 << 12)
|
||||||
|
Loading…
Reference in New Issue
Block a user