From cede752cd1ebad45a1559048cdb1d59e5a3c2fdf Mon Sep 17 00:00:00 2001 From: Timon Kruiper Date: Thu, 20 Oct 2022 13:17:25 +0200 Subject: [PATCH] Kernel/aarch64: Stub enough functions to build Random.cpp Also update Random.cpp such that it builds for aarch64. --- Kernel/Arch/aarch64/Dummy.cpp | 27 ++++++++++++++++----------- Kernel/CMakeLists.txt | 2 ++ Kernel/Random.cpp | 9 +++++---- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Kernel/Arch/aarch64/Dummy.cpp b/Kernel/Arch/aarch64/Dummy.cpp index 302d5efe355..0c78fcefc5e 100644 --- a/Kernel/Arch/aarch64/Dummy.cpp +++ b/Kernel/Arch/aarch64/Dummy.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -25,16 +24,6 @@ #include #include -// Random -namespace Kernel { - -void get_fast_random_bytes(Bytes) -{ - TODO_AARCH64(); -} - -} - // Process char const* asm_signal_trampoline = nullptr; char const* asm_signal_trampoline_end = nullptr; @@ -337,6 +326,22 @@ 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(); diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 4433bffa26e..eb7b98d8b35 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -474,6 +474,7 @@ else() set(SOURCES ${AK_SOURCES} ${RPI_SOURCES} + ${CRYPTO_SOURCES} Arch/Processor.cpp @@ -506,6 +507,7 @@ else() MiniStdLib.cpp Process.cpp ProcessProcFSTraits.cpp + Random.cpp Scheduler.cpp StdLib.cpp Time/TimeManagement.cpp diff --git a/Kernel/Random.cpp b/Kernel/Random.cpp index dd6dc742eaf..722a712a27e 100644 --- a/Kernel/Random.cpp +++ b/Kernel/Random.cpp @@ -28,6 +28,7 @@ KernelRng& KernelRng::the() UNMAP_AFTER_INIT KernelRng::KernelRng() { +#if ARCH(I386) || ARCH(X86_64) bool supports_rdseed = Processor::current().has_feature(CPUFeature::RDSEED); bool supports_rdrand = Processor::current().has_feature(CPUFeature::RDRAND); if (supports_rdseed || supports_rdrand) { @@ -50,9 +51,7 @@ UNMAP_AFTER_INIT KernelRng::KernelRng() add_random_event(value, i % 32); } - } -#if ARCH(I386) || ARCH(X86_64) - else if (TimeManagement::the().can_query_precise_time()) { + } else if (TimeManagement::the().can_query_precise_time()) { // Add HPET as entropy source if we don't have anything better. dmesgln("KernelRng: Using HPET as entropy source"); @@ -70,6 +69,8 @@ UNMAP_AFTER_INIT KernelRng::KernelRng() current_time += 0x40b2u; } } +#else + dmesgln("KernelRng: No entropy source available!"); #endif } @@ -121,7 +122,7 @@ bool get_good_random_bytes(Bytes buffer, bool allow_wait, bool fallback_to_fast) bool result = false; auto& kernel_rng = KernelRng::the(); // FIXME: What if interrupts are disabled because we're in an interrupt? - bool can_wait = are_interrupts_enabled(); + bool can_wait = Processor::are_interrupts_enabled(); if (!can_wait && allow_wait) { // If we can't wait but the caller would be ok with it, then we // need to definitely fallback to *something*, even if it's less