diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/CMakeLists.txt | 14 | ||||
-rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_32.cpp | 5 | ||||
-rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_cp15.cpp | 22 | ||||
-rw-r--r-- | src/core/arm/exclusive_monitor.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/kernel/k_event.cpp | 15 | ||||
-rw-r--r-- | src/core/hle/kernel/physical_core.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/kernel/service_thread.cpp | 27 |
7 files changed, 44 insertions, 47 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f6e082c36..f67f1ce92 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -497,10 +497,6 @@ add_library(core STATIC hle/service/hid/irsensor/processor_base.h hle/service/hid/irsensor/tera_plugin_processor.cpp hle/service/hid/irsensor/tera_plugin_processor.h - hle/service/jit/jit_context.cpp - hle/service/jit/jit_context.h - hle/service/jit/jit.cpp - hle/service/jit/jit.h hle/service/lbl/lbl.cpp hle/service/lbl/lbl.h hle/service/ldn/lan_discovery.cpp @@ -805,14 +801,18 @@ if (ENABLE_WEB_SERVICE) target_link_libraries(core PRIVATE web_service) endif() -if (ARCHITECTURE_x86_64) +if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64) target_sources(core PRIVATE - arm/dynarmic/arm_dynarmic_32.cpp - arm/dynarmic/arm_dynarmic_32.h arm/dynarmic/arm_dynarmic_64.cpp arm/dynarmic/arm_dynarmic_64.h + arm/dynarmic/arm_dynarmic_32.cpp + arm/dynarmic/arm_dynarmic_32.h arm/dynarmic/arm_dynarmic_cp15.cpp arm/dynarmic/arm_dynarmic_cp15.h + hle/service/jit/jit_context.cpp + hle/service/jit/jit_context.h + hle/service/jit/jit.cpp + hle/service/jit/jit.h ) target_link_libraries(core PRIVATE dynarmic) endif() diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 287ba102e..227e06ea1 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -301,6 +301,11 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable* } } +#ifdef ARCHITECTURE_arm64 + // TODO: remove when fixed in dynarmic + config.optimizations &= ~Dynarmic::OptimizationFlag::BlockLinking; +#endif + return std::make_unique<Dynarmic::A32::Jit>(config); } diff --git a/src/core/arm/dynarmic/arm_dynarmic_cp15.cpp b/src/core/arm/dynarmic/arm_dynarmic_cp15.cpp index 200efe4db..5a4eba3eb 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_cp15.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_cp15.cpp @@ -52,12 +52,16 @@ CallbackOrAccessOneWord DynarmicCP15::CompileSendOneWord(bool two, unsigned opc1 case 4: // CP15_DATA_SYNC_BARRIER return Callback{ - [](Dynarmic::A32::Jit*, void*, std::uint32_t, std::uint32_t) -> std::uint64_t { -#ifdef _MSC_VER + [](void*, std::uint32_t, std::uint32_t) -> std::uint64_t { +#if defined(_MSC_VER) && defined(ARCHITECTURE_x86_64) _mm_mfence(); _mm_lfence(); -#else +#elif defined(ARCHITECTURE_x86_64) asm volatile("mfence\n\tlfence\n\t" : : : "memory"); +#elif defined(ARCHITECTURE_arm64) + asm volatile("dsb sy\n\t" : : : "memory"); +#else +#error Unsupported architecture #endif return 0; }, @@ -66,11 +70,15 @@ CallbackOrAccessOneWord DynarmicCP15::CompileSendOneWord(bool two, unsigned opc1 case 5: // CP15_DATA_MEMORY_BARRIER return Callback{ - [](Dynarmic::A32::Jit*, void*, std::uint32_t, std::uint32_t) -> std::uint64_t { -#ifdef _MSC_VER + [](void*, std::uint32_t, std::uint32_t) -> std::uint64_t { +#if defined(_MSC_VER) && defined(ARCHITECTURE_x86_64) _mm_mfence(); -#else +#elif defined(ARCHITECTURE_x86_64) asm volatile("mfence\n\t" : : : "memory"); +#elif defined(ARCHITECTURE_arm64) + asm volatile("dmb sy\n\t" : : : "memory"); +#else +#error Unsupported architecture #endif return 0; }, @@ -115,7 +123,7 @@ CallbackOrAccessOneWord DynarmicCP15::CompileGetOneWord(bool two, unsigned opc1, CallbackOrAccessTwoWords DynarmicCP15::CompileGetTwoWords(bool two, unsigned opc, CoprocReg CRm) { if (!two && opc == 0 && CRm == CoprocReg::C14) { // CNTPCT - const auto callback = [](Dynarmic::A32::Jit*, void* arg, u32, u32) -> u64 { + const auto callback = [](void* arg, u32, u32) -> u64 { const auto& parent_arg = *static_cast<ARM_Dynarmic_32*>(arg); return parent_arg.system.CoreTiming().GetClockTicks(); }; diff --git a/src/core/arm/exclusive_monitor.cpp b/src/core/arm/exclusive_monitor.cpp index 2db0b035d..20550faeb 100644 --- a/src/core/arm/exclusive_monitor.cpp +++ b/src/core/arm/exclusive_monitor.cpp @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#ifdef ARCHITECTURE_x86_64 +#if defined(ARCHITECTURE_x86_64) || defined(ARCHITECTURE_arm64) #include "core/arm/dynarmic/arm_exclusive_monitor.h" #endif #include "core/arm/exclusive_monitor.h" @@ -13,7 +13,7 @@ ExclusiveMonitor::~ExclusiveMonitor() = default; std::unique_ptr<Core::ExclusiveMonitor> MakeExclusiveMonitor(Memory::Memory& memory, std::size_t num_cores) { -#ifdef ARCHITECTURE_x86_64 +#if defined(ARCHITECTURE_x86_64) || defined(ARCHITECTURE_arm64) return std::make_unique<Core::DynarmicExclusiveMonitor>(memory, num_cores); #else // TODO(merry): Passthrough exclusive monitor diff --git a/src/core/hle/kernel/k_event.cpp b/src/core/hle/kernel/k_event.cpp index 27f70e5c5..d973853ab 100644 --- a/src/core/hle/kernel/k_event.cpp +++ b/src/core/hle/kernel/k_event.cpp @@ -20,8 +20,12 @@ void KEvent::Initialize(KProcess* owner) { m_readable_event.Initialize(this); // Set our owner process. - m_owner = owner; - m_owner->Open(); + // HACK: this should never be nullptr, but service threads don't have a + // proper parent process yet. + if (owner != nullptr) { + m_owner = owner; + m_owner->Open(); + } // Mark initialized. m_initialized = true; @@ -50,8 +54,11 @@ Result KEvent::Clear() { void KEvent::PostDestroy(uintptr_t arg) { // Release the event count resource the owner process holds. KProcess* owner = reinterpret_cast<KProcess*>(arg); - owner->GetResourceLimit()->Release(LimitableResource::EventCountMax, 1); - owner->Close(); + + if (owner != nullptr) { + owner->GetResourceLimit()->Release(LimitableResource::EventCountMax, 1); + owner->Close(); + } } } // namespace Kernel diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index d4375962f..3044922ac 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp @@ -12,7 +12,7 @@ namespace Kernel { PhysicalCore::PhysicalCore(std::size_t core_index_, Core::System& system_, KScheduler& scheduler_) : core_index{core_index_}, system{system_}, scheduler{scheduler_} { -#ifdef ARCHITECTURE_x86_64 +#if defined(ARCHITECTURE_x86_64) || defined(ARCHITECTURE_arm64) // TODO(bunnei): Initialization relies on a core being available. We may later replace this with // a 32-bit instance of Dynarmic. This should be abstracted out to a CPU manager. auto& kernel = system.Kernel(); @@ -26,7 +26,7 @@ PhysicalCore::PhysicalCore(std::size_t core_index_, Core::System& system_, KSche PhysicalCore::~PhysicalCore() = default; void PhysicalCore::Initialize([[maybe_unused]] bool is_64_bit) { -#ifdef ARCHITECTURE_x86_64 +#if defined(ARCHITECTURE_x86_64) || defined(ARCHITECTURE_arm64) auto& kernel = system.Kernel(); if (!is_64_bit) { // We already initialized a 64-bit core, replace with a 32-bit one. diff --git a/src/core/hle/kernel/service_thread.cpp b/src/core/hle/kernel/service_thread.cpp index f5c2ab23f..e6e41ac34 100644 --- a/src/core/hle/kernel/service_thread.cpp +++ b/src/core/hle/kernel/service_thread.cpp @@ -40,7 +40,6 @@ private: std::mutex m_session_mutex; std::map<KServerSession*, std::shared_ptr<SessionRequestManager>> m_sessions; KEvent* m_wakeup_event; - KProcess* m_process; KThread* m_thread; std::atomic<bool> m_shutdown_requested; const std::string m_service_name; @@ -180,39 +179,17 @@ ServiceThread::Impl::~Impl() { // Close thread. m_thread->Close(); - - // Close process. - m_process->Close(); } ServiceThread::Impl::Impl(KernelCore& kernel_, const std::string& service_name) : kernel{kernel_}, m_service_name{service_name} { - // Initialize process. - m_process = KProcess::Create(kernel); - KProcess::Initialize(m_process, kernel.System(), service_name, - KProcess::ProcessType::KernelInternal, kernel.GetSystemResourceLimit()); - - // Reserve a new event from the process resource limit - KScopedResourceReservation event_reservation(m_process, LimitableResource::EventCountMax); - ASSERT(event_reservation.Succeeded()); - // Initialize event. m_wakeup_event = KEvent::Create(kernel); - m_wakeup_event->Initialize(m_process); - - // Commit the event reservation. - event_reservation.Commit(); - - // Reserve a new thread from the process resource limit - KScopedResourceReservation thread_reservation(m_process, LimitableResource::ThreadCountMax); - ASSERT(thread_reservation.Succeeded()); + m_wakeup_event->Initialize(nullptr); // Initialize thread. m_thread = KThread::Create(kernel); - ASSERT(KThread::InitializeDummyThread(m_thread, m_process).IsSuccess()); - - // Commit the thread reservation. - thread_reservation.Commit(); + ASSERT(KThread::InitializeDummyThread(m_thread, nullptr).IsSuccess()); // Start thread. m_host_thread = std::jthread([this] { LoopProcess(); }); |