From 9186ed310109f29eabfa77c5d6fbeb847ea62d4c Mon Sep 17 00:00:00 2001 From: James Mintram Date: Sat, 2 Apr 2022 23:49:19 +0100 Subject: [PATCH] Kernel: Add all memory files to aarch64 and fix resulting linker errors --- Kernel/Arch/aarch64/dummy.cpp | 106 ++++++++++++++++++++++++++++++++++ Kernel/Arch/aarch64/linker.ld | 14 +++++ Kernel/CMakeLists.txt | 17 ++++++ 3 files changed, 137 insertions(+) diff --git a/Kernel/Arch/aarch64/dummy.cpp b/Kernel/Arch/aarch64/dummy.cpp index 9c6bc88165..39f5bafc29 100644 --- a/Kernel/Arch/aarch64/dummy.cpp +++ b/Kernel/Arch/aarch64/dummy.cpp @@ -4,16 +4,122 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include + +#include #include #include +#include +#include +#include +#include +#include #include +#include // This is a temporary file to get a non-empty Kernel binary on aarch64. // The prekernel currently never jumps to the kernel. This is dead code. void dummy(); void dummy() { } +// Scheduler +namespace Kernel { + +READONLY_AFTER_INIT Thread* g_finalizer; + +} + +// Panic +namespace Kernel { + +void __panic(char const*, unsigned int, char const*) +{ + for (;;) { } +} + +} + +// Random +namespace Kernel { + +void get_fast_random_bytes(Bytes) { } + +} + +// Inode +namespace Kernel { + +static Singleton> s_all_instances; + +SpinlockProtected& Inode::all_instances() +{ + return s_all_instances; +} + +RefPtr Inode::shared_vmobject() const +{ + return RefPtr(nullptr); +} + +void Inode::will_be_destroyed() +{ +} + +ErrorOr Inode::set_shared_vmobject(Memory::SharedInodeVMObject&) +{ + return {}; +} + +} + +// UserOrKernelBuffer.cpp +namespace Kernel { + +ErrorOr UserOrKernelBuffer::write(void const*, size_t, size_t) +{ + return {}; +} + +ErrorOr UserOrKernelBuffer::read(void*, size_t, size_t) const +{ + return {}; +} + +} + +// x86 init + +multiboot_module_entry_t multiboot_copy_boot_modules_array[16]; +size_t multiboot_copy_boot_modules_count; + +extern "C" { +READONLY_AFTER_INIT PhysicalAddress start_of_prekernel_image; +READONLY_AFTER_INIT PhysicalAddress end_of_prekernel_image; +READONLY_AFTER_INIT size_t physical_to_virtual_offset; +// READONLY_AFTER_INIT FlatPtr kernel_mapping_base; +READONLY_AFTER_INIT FlatPtr kernel_load_base; +#if ARCH(X86_64) +READONLY_AFTER_INIT PhysicalAddress boot_pml4t; +#endif +READONLY_AFTER_INIT PhysicalAddress boot_pdpt; +READONLY_AFTER_INIT PhysicalAddress boot_pd0; +READONLY_AFTER_INIT PhysicalAddress boot_pd_kernel; +READONLY_AFTER_INIT Kernel::PageTableEntry* boot_pd_kernel_pt1023; +READONLY_AFTER_INIT char const* kernel_cmdline; +READONLY_AFTER_INIT u32 multiboot_flags; +READONLY_AFTER_INIT multiboot_memory_map_t* multiboot_memory_map; +READONLY_AFTER_INIT size_t multiboot_memory_map_count; +READONLY_AFTER_INIT multiboot_module_entry_t* multiboot_modules; +READONLY_AFTER_INIT size_t multiboot_modules_count; +READONLY_AFTER_INIT PhysicalAddress multiboot_framebuffer_addr; +READONLY_AFTER_INIT u32 multiboot_framebuffer_pitch; +READONLY_AFTER_INIT u32 multiboot_framebuffer_width; +READONLY_AFTER_INIT u32 multiboot_framebuffer_height; +READONLY_AFTER_INIT u8 multiboot_framebuffer_bpp; +READONLY_AFTER_INIT u8 multiboot_framebuffer_type; +} + // kmalloc.h size_t kmalloc_good_size(size_t); size_t kmalloc_good_size(size_t) { return 0; } diff --git a/Kernel/Arch/aarch64/linker.ld b/Kernel/Arch/aarch64/linker.ld index e04e9290ab..6407869d9d 100644 --- a/Kernel/Arch/aarch64/linker.ld +++ b/Kernel/Arch/aarch64/linker.ld @@ -39,6 +39,20 @@ SECTIONS physical memory. 8M is wasteful, so this should be properly calculated. */ + /* FIXME: Placeholder to satisfy linker */ + start_of_kernel_ksyms = .; + end_of_kernel_ksyms = .; + start_of_kernel_text = .; + end_of_kernel_text = .; + start_of_kernel_image = .; + end_of_kernel_image = .; + start_of_unmap_after_init = .; + end_of_unmap_after_init = .; + start_of_ro_after_init = .; + end_of_ro_after_init = .; + start_of_kernel_data = .; + end_of_kernel_data = .; + . = ALIGN(4K); page_tables_phys_start = .; diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 81f873cb81..6f5a351160 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -421,6 +421,23 @@ else() Arch/aarch64/ScopedCritical.cpp MiniStdLib.cpp Prekernel/UBSanitizer.cpp + + Memory/AddressSpace.cpp + Memory/AnonymousVMObject.cpp + Memory/InodeVMObject.cpp + Memory/PhysicalRegion.cpp + Memory/PhysicalPage.cpp + Memory/PhysicalZone.cpp + Memory/PageDirectory.cpp + Memory/MemoryManager.cpp + Memory/PrivateInodeVMObject.cpp + Memory/Region.cpp + Memory/RingBuffer.cpp + Memory/SharedInodeVMObject.cpp + Memory/ScatterGatherList.cpp + Memory/VirtualRange.cpp + Memory/VirtualRangeAllocator.cpp + Memory/VMObject.cpp ) # Otherwise linker errors e.g undefined reference to `__aarch64_cas8_acq_rel'