Kernel: Add all memory files to aarch64 and fix resulting linker errors

This commit is contained in:
James Mintram 2022-04-02 23:49:19 +01:00 committed by Brian Gianforcaro
parent 2e63215346
commit 9186ed3101
Notes: sideshowbarker 2024-07-17 14:35:20 +09:00
3 changed files with 137 additions and 0 deletions

View File

@ -4,16 +4,122 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Singleton.h>
#include <AK/Types.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/KString.h>
#include <Kernel/KSyms.h>
#include <Kernel/Locking/SpinlockProtected.h>
#include <Kernel/Memory/SharedInodeVMObject.h>
#include <Kernel/Panic.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/Random.h>
#include <Kernel/Sections.h>
#include <Kernel/UserOrKernelBuffer.h>
// 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<SpinlockProtected<Inode::AllInstancesList>> s_all_instances;
SpinlockProtected<Inode::AllInstancesList>& Inode::all_instances()
{
return s_all_instances;
}
RefPtr<Memory::SharedInodeVMObject> Inode::shared_vmobject() const
{
return RefPtr<Memory::SharedInodeVMObject>(nullptr);
}
void Inode::will_be_destroyed()
{
}
ErrorOr<void> Inode::set_shared_vmobject(Memory::SharedInodeVMObject&)
{
return {};
}
}
// UserOrKernelBuffer.cpp
namespace Kernel {
ErrorOr<void> UserOrKernelBuffer::write(void const*, size_t, size_t)
{
return {};
}
ErrorOr<void> 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; }

View File

@ -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 = .;

View File

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