From 8364135939a0c181e3c40cfec0720128e86623e6 Mon Sep 17 00:00:00 2001 From: Timon Kruiper Date: Tue, 25 Oct 2022 18:55:42 +0200 Subject: Kernel/aarch64: Unify building kernel source files in CMakeLists.txt This now builds most of the kernel source files for both x86(_64) and the aarch64 build. Also remove a bunch of stubbed functions. :^) --- Kernel/Arch/aarch64/Dummy.cpp | 426 ++---------------------------------------- Kernel/CMakeLists.txt | 178 ++++++------------ 2 files changed, 73 insertions(+), 531 deletions(-) diff --git a/Kernel/Arch/aarch64/Dummy.cpp b/Kernel/Arch/aarch64/Dummy.cpp index 0c78fcefc5..2d13ddd1d8 100644 --- a/Kernel/Arch/aarch64/Dummy.cpp +++ b/Kernel/Arch/aarch64/Dummy.cpp @@ -7,22 +7,10 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include -#include #include -#include -#include -#include -#include +#include // Process char const* asm_signal_trampoline = nullptr; @@ -44,430 +32,40 @@ ErrorOr Process::exec(NonnullOwnPtr, NonnullOwnPtrVector } -// OpenFileDescription +// Delay.cpp namespace Kernel { -OpenFileDescription::~OpenFileDescription() -{ - TODO_AARCH64(); -} - -ErrorOr OpenFileDescription::write(UserOrKernelBuffer const&, size_t) -{ - TODO_AARCH64(); -} - -} - -// Custody -namespace Kernel { - -SpinlockProtected& Custody::all_instances() -{ - TODO_AARCH64(); -} - -Custody::~Custody() -{ - TODO_AARCH64(); -} - -} - -// VirtualFileSystem -namespace Kernel { - -VirtualFileSystem& VirtualFileSystem::the() -{ - TODO_AARCH64(); -} - -NonnullRefPtr VirtualFileSystem::root_custody() -{ - TODO_AARCH64(); -} - -ErrorOr> VirtualFileSystem::open(Credentials const&, StringView, int, mode_t, Custody&, Optional) -{ - TODO_AARCH64(); -} - -} - -// ProcFS -namespace Kernel { - -ProcFSInode::~ProcFSInode() -{ - TODO_AARCH64(); -} - -ErrorOr> ProcFSProcessDirectoryInode::try_create(ProcFS const&, ProcessID) -{ - TODO_AARCH64(); -} - -ProcFSComponentRegistry& ProcFSComponentRegistry::the() -{ - TODO_AARCH64(); -} - -ErrorOr> ProcFSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID) -{ - TODO_AARCH64(); -} - -ErrorOr ProcFSInode::add_child(Inode&, StringView, mode_t) -{ - TODO_AARCH64(); -} - -ErrorOr ProcFSInode::remove_child(StringView) -{ - TODO_AARCH64(); -} - -ErrorOr ProcFSInode::chmod(mode_t) -{ - TODO_AARCH64(); -} - -ErrorOr ProcFSInode::chown(UserID, GroupID) -{ - TODO_AARCH64(); -} - -ErrorOr ProcFSInode::flush_metadata() -{ - TODO_AARCH64(); -} - -ErrorOr ProcFSGlobalInode::attach(OpenFileDescription&) -{ - TODO_AARCH64(); -} - -ErrorOr ProcFSGlobalInode::read_bytes_locked(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const -{ - TODO_AARCH64(); -} - -StringView ProcFSGlobalInode::name() const -{ - TODO_AARCH64(); -} - -ErrorOr ProcFSGlobalInode::traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const -{ - TODO_AARCH64(); -} - -ErrorOr> ProcFSGlobalInode::lookup(StringView) -{ - TODO_AARCH64(); -} - -ErrorOr ProcFSGlobalInode::truncate(u64) -{ - TODO_AARCH64(); -} - -ErrorOr ProcFSGlobalInode::update_timestamps(Optional, Optional, Optional) -{ - TODO_AARCH64(); -} - -InodeMetadata ProcFSGlobalInode::metadata() const -{ - TODO_AARCH64(); -} - -void ProcFSGlobalInode::did_seek(OpenFileDescription&, off_t) -{ - TODO_AARCH64(); -} - -ErrorOr ProcFSGlobalInode::write_bytes_locked(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) -{ - TODO_AARCH64(); -} - -} - -// ProcessGroup -namespace Kernel { - -ProcessGroup::~ProcessGroup() -{ - TODO_AARCH64(); -} - -} - -// ProcessExposed -namespace Kernel { - -ErrorOr> ProcFSExposedComponent::to_inode(ProcFS const&) const -{ - TODO_AARCH64(); -} - -InodeIndex SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(ProcessID, SegmentedProcFSIndex::MainProcessProperty) -{ - TODO_AARCH64(); -} - -InodeIndex SegmentedProcFSIndex::build_segmented_index_for_pid_directory(ProcessID) -{ - TODO_AARCH64(); -} - -InodeIndex SegmentedProcFSIndex::build_segmented_index_for_sub_directory(ProcessID, ProcessSubDirectory) -{ - TODO_AARCH64(); -} - -ProcFSExposedComponent::ProcFSExposedComponent() -{ - TODO_AARCH64(); -} - -} - -// FileSystem -namespace Kernel { - -FileSystem::DirectoryEntryView::DirectoryEntryView(StringView, InodeIdentifier, u8) -{ - TODO_AARCH64(); -} - -} - -// Coredump -namespace Kernel { - -ErrorOr> Coredump::try_create(NonnullLockRefPtr, StringView) -{ - TODO_AARCH64(); -} - -ErrorOr Coredump::write() +void microseconds_delay(u32) { TODO_AARCH64(); } } -// ThreadBlockers -namespace Kernel { - -bool Thread::Blocker::setup_blocker() -{ - TODO_AARCH64(); -} +// Initializer.cpp +namespace Kernel::PCI { -void Thread::Blocker::finalize() -{ -} +bool g_pci_access_io_probe_failed { false }; +bool g_pci_access_is_disabled_from_commandline { false }; -Thread::Blocker::~Blocker() -{ - TODO_AARCH64(); } -void Thread::Blocker::begin_blocking(Badge) +// kprintf.cpp +void dbgputstr(StringView) { TODO_AARCH64(); } -Thread::BlockTimeout::BlockTimeout(bool, Time const*, Time const*, clockid_t) +void dbgputstr(char const*, size_t) { TODO_AARCH64(); } -bool Thread::JoinBlocker::unblock(void*, bool) +void dbgputchar(char) { TODO_AARCH64(); } -bool Thread::SignalBlocker::check_pending_signals(bool) -{ - TODO_AARCH64(); -} - -Thread::SleepBlocker::SleepBlocker(BlockTimeout const&, Time*) -{ - TODO_AARCH64(); -} - -Thread::BlockResult Thread::SleepBlocker::block_result() -{ - TODO_AARCH64(); -} - -Thread::BlockTimeout const& Thread::SleepBlocker::override_timeout(BlockTimeout const&) -{ - TODO_AARCH64(); -} - -void Thread::SleepBlocker::will_unblock_immediately_without_blocking(UnblockImmediatelyReason) -{ - TODO_AARCH64(); -} - -void Thread::SleepBlocker::was_unblocked(bool) -{ - TODO_AARCH64(); -} - -bool Thread::WaitQueueBlocker::unblock() -{ - TODO_AARCH64(); -} - -Thread::WaitQueueBlocker::WaitQueueBlocker(WaitQueue& wait_queue, StringView) - : m_wait_queue(wait_queue) -{ - TODO_AARCH64(); -} - -bool Thread::WaitQueueBlocker::setup_blocker() -{ - TODO_AARCH64(); -} - -Thread::WaitQueueBlocker::~WaitQueueBlocker() -{ - TODO_AARCH64(); -} - -void Thread::WaitBlockerSet::finalize() -{ - TODO_AARCH64(); -} - -bool Thread::WaitBlockerSet::unblock(Process&, WaitBlocker::UnblockFlags, u8) -{ - TODO_AARCH64(); -} - -void Thread::WaitBlockerSet::disowned_by_waiter(Process&) -{ - TODO_AARCH64(); -} - -bool Thread::WaitBlockerSet::should_add_blocker(Blocker&, void*) -{ - TODO_AARCH64(); -} - -Thread::WaitBlockerSet::ProcessBlockInfo::~ProcessBlockInfo() -{ - TODO_AARCH64(); -} - -} - -// PerformanceEventBuffer -namespace Kernel { - -bool g_profiling_all_threads = false; -PerformanceEventBuffer* g_global_perf_events = nullptr; - -ErrorOr PerformanceEventBuffer::append(int, unsigned long, unsigned long, AK::StringView, Kernel::Thread*, unsigned long, u64, ErrorOr) -{ - TODO_AARCH64(); -} - -OwnPtr PerformanceEventBuffer::try_create_with_size(size_t) -{ - TODO_AARCH64(); -} - -ErrorOr PerformanceEventBuffer::add_process(Process const&, ProcessEventType) -{ - TODO_AARCH64(); -} - -ErrorOr PerformanceEventBuffer::to_json(KBufferBuilder&) const -{ - TODO_AARCH64(); -} - -ErrorOr PerformanceEventBuffer::append_with_ip_and_bp(ProcessID, ThreadID, - FlatPtr, FlatPtr, int, u32, FlatPtr, FlatPtr, StringView, FlatPtr, u64, ErrorOr) -{ - TODO_AARCH64(); -} - -} - -// LockRank -namespace Kernel { - -void track_lock_acquire(LockRank) { } -void track_lock_release(LockRank) { } - -} - -// Inode -namespace Kernel { - -static Singleton> s_all_instances; - -SpinlockProtected& Inode::all_instances() -{ - TODO_AARCH64(); - return s_all_instances; -} - -LockRefPtr Inode::shared_vmobject() const -{ - TODO_AARCH64(); - return LockRefPtr(nullptr); -} - -void Inode::will_be_destroyed() -{ - TODO_AARCH64(); -} - -ErrorOr Inode::set_shared_vmobject(Memory::SharedInodeVMObject&) -{ - TODO_AARCH64(); - return {}; -} - -ErrorOr Inode::read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const -{ - TODO_AARCH64(); - return 0; -} - -ErrorOr Inode::write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) -{ - TODO_AARCH64(); - return 0; -} - -ErrorOr Inode::update_timestamps([[maybe_unused]] Optional atime, [[maybe_unused]] Optional ctime, [[maybe_unused]] Optional mtime) -{ - TODO_AARCH64(); -} - -ErrorOr Inode::increment_link_count() -{ - TODO_AARCH64(); -} - -ErrorOr Inode::decrement_link_count() -{ - TODO_AARCH64(); -} - -} - // x86 init multiboot_module_entry_t multiboot_copy_boot_modules_array[16]; diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 84f775b433..5b24d5ef26 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -187,7 +187,6 @@ set(KERNEL_SOURCES Interrupts/GenericInterruptHandler.cpp Interrupts/IRQHandler.cpp Interrupts/SharedIRQHandler.cpp - Interrupts/SpuriousInterruptHandler.cpp Interrupts/UnhandledInterruptHandler.cpp KBufferBuilder.cpp KLexicalPath.cpp @@ -230,7 +229,6 @@ set(KERNEL_SOURCES Net/Socket.cpp Net/TCPSocket.cpp Net/UDPSocket.cpp - Panic.cpp PerformanceEventBuffer.cpp Process.cpp ProcessExposed.cpp @@ -240,7 +238,6 @@ set(KERNEL_SOURCES Random.cpp Scheduler.cpp StdLib.cpp - Syscall.cpp Syscalls/anon_create.cpp Syscalls/access.cpp Syscalls/alarm.cpp @@ -253,11 +250,9 @@ set(KERNEL_SOURCES Syscalls/disown.cpp Syscalls/dup2.cpp Syscalls/emuctl.cpp - Syscalls/execve.cpp Syscalls/exit.cpp Syscalls/fallocate.cpp Syscalls/fcntl.cpp - Syscalls/fork.cpp Syscalls/fsync.cpp Syscalls/ftruncate.cpp Syscalls/futex.cpp @@ -273,7 +268,6 @@ set(KERNEL_SOURCES Syscalls/lseek.cpp Syscalls/mkdir.cpp Syscalls/mknod.cpp - Syscalls/mmap.cpp Syscalls/mount.cpp Syscalls/open.cpp Syscalls/perf_event.cpp @@ -283,7 +277,6 @@ set(KERNEL_SOURCES Syscalls/prctl.cpp Syscalls/process.cpp Syscalls/profiling.cpp - Syscalls/ptrace.cpp Syscalls/purge.cpp Syscalls/read.cpp Syscalls/readlink.cpp @@ -295,7 +288,6 @@ set(KERNEL_SOURCES Syscalls/sendfd.cpp Syscalls/setpgid.cpp Syscalls/setuid.cpp - Syscalls/sigaction.cpp Syscalls/socket.cpp Syscalls/stat.cpp Syscalls/statvfs.cpp @@ -329,7 +321,6 @@ set(KERNEL_SOURCES UserOrKernelBuffer.cpp WaitQueue.cpp WorkQueue.cpp - kprintf.cpp ) if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64") @@ -375,6 +366,17 @@ if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64") Arch/x86/Time/RTC.cpp Arch/x86/VGA/IOArbiter.cpp + + # TODO: Share these with the aarch64 build + Interrupts/SpuriousInterruptHandler.cpp + kprintf.cpp + Panic.cpp + Syscall.cpp + Syscalls/execve.cpp + Syscalls/fork.cpp + Syscalls/mmap.cpp + Syscalls/ptrace.cpp + Syscalls/sigaction.cpp ) set(KERNEL_SOURCES @@ -414,6 +416,48 @@ if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64") ${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/Atomics.cpp ) endif() +elseif("${SERENITY_ARCH}" STREQUAL "aarch64") + set(RPI_SOURCES + Arch/aarch64/RPi/DebugOutput.cpp + Arch/aarch64/RPi/Framebuffer.cpp + Arch/aarch64/RPi/GPIO.cpp + Arch/aarch64/RPi/InterruptController.cpp + Arch/aarch64/RPi/Mailbox.cpp + Arch/aarch64/RPi/MMIO.cpp + Arch/aarch64/RPi/Timer.cpp + Arch/aarch64/RPi/UART.cpp + ) + set(KERNEL_SOURCES + ${KERNEL_SOURCES} + ${RPI_SOURCES} + Arch/Processor.cpp + + Arch/aarch64/boot.S + Arch/aarch64/BootPPMParser.cpp + Arch/aarch64/CrashHandler.cpp + Arch/aarch64/CurrentTime.cpp + Arch/aarch64/Dummy.cpp + Arch/aarch64/Exceptions.cpp + Arch/aarch64/init.cpp + Arch/aarch64/InterruptManagement.cpp + Arch/aarch64/Interrupts.cpp + Arch/aarch64/kprintf.cpp + Arch/aarch64/MainIdRegister.cpp + Arch/aarch64/MMU.cpp + Arch/aarch64/PageDirectory.cpp + Arch/aarch64/Panic.cpp + Arch/aarch64/Processor.cpp + Arch/aarch64/SafeMem.cpp + Arch/aarch64/ScopedCritical.cpp + Arch/aarch64/SmapDisabler.cpp + Arch/aarch64/vector_table.S + ) + + # Otherwise linker errors e.g undefined reference to `__aarch64_cas8_acq_rel' + add_compile_options(-mno-outline-atomics -latomic) + + # FIXME: Remove this once compiling MemoryManager.cpp doesn't give the nonnull error anymore. + add_compile_options(-Wno-nonnull) endif() set(AK_SOURCES @@ -472,115 +516,15 @@ set(PARTITION_SOURCES ) set(SOURCES + ${KERNEL_SOURCES} + ${GENERATED_SOURCES} ${AK_SOURCES} - ) -if (NOT "${SERENITY_ARCH}" STREQUAL "aarch64") - set(SOURCES - ${KERNEL_SOURCES} - ${GENERATED_SOURCES} - ${SOURCES} - ${EDID_SOURCES} - ${ELF_SOURCES} - ${VT_SOURCES} - ${CRYPTO_SOURCES} - ${PARTITION_SOURCES} - ) -else() - set(RPI_SOURCES - Arch/aarch64/RPi/DebugOutput.cpp - Arch/aarch64/RPi/Framebuffer.cpp - Arch/aarch64/RPi/GPIO.cpp - Arch/aarch64/RPi/InterruptController.cpp - Arch/aarch64/RPi/Mailbox.cpp - Arch/aarch64/RPi/MMIO.cpp - Arch/aarch64/RPi/Timer.cpp - Arch/aarch64/RPi/UART.cpp - ) - set(SOURCES - ${AK_SOURCES} - ${RPI_SOURCES} - ${CRYPTO_SOURCES} - - Arch/Processor.cpp - - Arch/aarch64/boot.S - Arch/aarch64/BootPPMParser.cpp - Arch/aarch64/CrashHandler.cpp - Arch/aarch64/CurrentTime.cpp - Arch/aarch64/Dummy.cpp - Arch/aarch64/Exceptions.cpp - Arch/aarch64/init.cpp - Arch/aarch64/InterruptManagement.cpp - Arch/aarch64/Interrupts.cpp - Arch/aarch64/kprintf.cpp - Arch/aarch64/MainIdRegister.cpp - Arch/aarch64/MMU.cpp - Arch/aarch64/PageDirectory.cpp - Arch/aarch64/Panic.cpp - Arch/aarch64/Processor.cpp - Arch/aarch64/SafeMem.cpp - Arch/aarch64/ScopedCritical.cpp - Arch/aarch64/SmapDisabler.cpp - Arch/aarch64/vector_table.S - - # Files from base Kernel - CommandLine.cpp - Credentials.cpp - KBufferBuilder.cpp - KString.cpp - KSyms.cpp - MiniStdLib.cpp - Process.cpp - ProcessProcFSTraits.cpp - Random.cpp - Scheduler.cpp - StdLib.cpp - Time/TimeManagement.cpp - TimerQueue.cpp - Thread.cpp - ThreadTracer.cpp - UBSanitizer.cpp - UserOrKernelBuffer.cpp - WaitQueue.cpp - - Devices/DeviceManagement.cpp - - Graphics/Console/BootFramebufferConsole.cpp - Graphics/Console/GenericFramebufferConsole.cpp - - Locking/Mutex.cpp - Locking/Spinlock.cpp - - Memory/AddressSpace.cpp - Memory/AnonymousVMObject.cpp - Memory/InodeVMObject.cpp - Memory/MemoryManager.cpp - Memory/PageDirectory.cpp - Memory/PhysicalPage.cpp - Memory/PhysicalRegion.cpp - Memory/PhysicalZone.cpp - Memory/PrivateInodeVMObject.cpp - Memory/Region.cpp - Memory/RegionTree.cpp - Memory/RingBuffer.cpp - Memory/ScatterGatherList.cpp - Memory/ScopedAddressSpaceSwitcher.cpp - Memory/SharedInodeVMObject.cpp - Memory/VirtualRange.cpp - Memory/VMObject.cpp - - Interrupts/GenericInterruptHandler.cpp - Interrupts/IRQHandler.cpp - Interrupts/SharedIRQHandler.cpp - Interrupts/UnhandledInterruptHandler.cpp - ) - - # Otherwise linker errors e.g undefined reference to `__aarch64_cas8_acq_rel' - add_compile_options(-mno-outline-atomics -latomic) - - # FIXME: Remove this once compiling MemoryManager.cpp doesn't give the nonnull error anymore. - add_compile_options(-Wno-nonnull) -endif() + ${EDID_SOURCES} + ${ELF_SOURCES} + ${VT_SOURCES} + ${CRYPTO_SOURCES} + ${PARTITION_SOURCES} +) add_compile_options(-fsigned-char) add_compile_options(-Wno-unknown-warning-option -Wvla -Wnull-dereference) -- cgit v1.2.3