summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorFiliph Sandström <filiph.sandstrom@filfatstudios.com>2022-08-17 12:38:58 +0200
committerLinus Groh <mail@linusgroh.de>2022-09-12 00:56:44 +0100
commit7e1e208d089cb873931b4180be9227cb46b47235 (patch)
tree489162c70ba025035ec277e5551ce403b75c2677 /Kernel
parent14fe03569a02caeb2b9bcc21c65caa5abb67139e (diff)
downloadserenity-7e1e208d089cb873931b4180be9227cb46b47235.zip
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.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Arch/aarch64/PageDirectory.cpp3
-rw-r--r--Kernel/Arch/aarch64/Processor.cpp5
-rw-r--r--Kernel/Arch/aarch64/Processor.h22
-rw-r--r--Kernel/Arch/aarch64/init.cpp20
-rw-r--r--Kernel/Memory/MemoryManager.cpp4
-rw-r--r--Kernel/Multiboot.h5
6 files changed, 41 insertions, 18 deletions
diff --git a/Kernel/Arch/aarch64/PageDirectory.cpp b/Kernel/Arch/aarch64/PageDirectory.cpp
index 7709fb9ec8..c64e4edf04 100644
--- a/Kernel/Arch/aarch64/PageDirectory.cpp
+++ b/Kernel/Arch/aarch64/PageDirectory.cpp
@@ -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*)
diff --git a/Kernel/Arch/aarch64/Processor.cpp b/Kernel/Arch/aarch64/Processor.cpp
index 54f582d754..f61d4f0b30 100644
--- a/Kernel/Arch/aarch64/Processor.cpp
+++ b/Kernel/Arch/aarch64/Processor.cpp
@@ -39,4 +39,9 @@ void Processor::initialize(u32 cpu)
asm volatile("wfi");
}
+void Processor::flush_tlb_local(VirtualAddress, size_t)
+{
+ // FIXME: Implement this
+}
+
}
diff --git a/Kernel/Arch/aarch64/Processor.h b/Kernel/Arch/aarch64/Processor.h
index 4dd878e15a..a6e93d8dbd 100644
--- a/Kernel/Arch/aarch64/Processor.h
+++ b/Kernel/Arch/aarch64/Processor.h
@@ -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();
diff --git a/Kernel/Arch/aarch64/init.cpp b/Kernel/Arch/aarch64/init.cpp
index 90fdd1928e..63dc655416 100644
--- a/Kernel/Arch/aarch64/init.cpp
+++ b/Kernel/Arch/aarch64/init.cpp
@@ -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 {
diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp
index 4db696a92e..72e7e4c665 100644
--- a/Kernel/Memory/MemoryManager.cpp
+++ b/Kernel/Memory/MemoryManager.cpp
@@ -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);
diff --git a/Kernel/Multiboot.h b/Kernel/Multiboot.h
index 901115bd19..9192555152 100644
--- a/Kernel/Multiboot.h
+++ b/Kernel/Multiboot.h
@@ -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)