From bbb22ae7cd39747e760f92661691a8b45216284e Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Tue, 21 Jun 2022 01:01:12 +0200 Subject: [PATCH] early-access version 2795 --- README.md | 4 ++-- src/core/hle/kernel/k_thread.cpp | 13 +++++++++++++ src/core/hle/kernel/k_thread.h | 2 ++ src/core/hle/kernel/kernel.cpp | 7 +++++++ src/core/hle/service/am/am.cpp | 12 +++++++++++- src/core/hle/service/am/am.h | 13 +++++++++++++ 6 files changed, 48 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 046cd4dea..63af8727a 100755 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ yuzu emulator early access ============= -This is the source code for early-access 2794. +This is the source code for early-access 2795. ## Legal Notice -yuzu is a GPLv2 program, which allows fully free redistribution of its source code. \ No newline at end of file +yuzu is a GPLv3 program, which allows fully free redistribution of its source code. \ No newline at end of file diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 268789150..c0a091bb6 100755 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp @@ -748,6 +748,19 @@ void KThread::Continue() { KScheduler::OnThreadStateChanged(kernel, this, old_state); } +void KThread::WaitUntilSuspended() { + // Make sure we have a suspend requested. + ASSERT(IsSuspendRequested()); + + // Loop until the thread is not executing on any core. + for (std::size_t i = 0; i < static_cast(Core::Hardware::NUM_CPU_CORES); ++i) { + KThread* core_thread{}; + do { + core_thread = kernel.Scheduler(i).GetCurrentThread(); + } while (core_thread == this); + } +} + ResultCode KThread::SetActivity(Svc::ThreadActivity activity) { // Lock ourselves. KScopedLightLock lk(activity_pause_lock); diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index f4d83f99a..8c1f8a344 100755 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h @@ -207,6 +207,8 @@ public: void Continue(); + void WaitUntilSuspended(); + constexpr void SetSyncedIndex(s32 index) { synced_index = index; } diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 66c8f4455..94953e257 100755 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -1078,6 +1078,13 @@ void KernelCore::Suspend(bool suspended) { for (auto* process : GetProcessList()) { process->SetActivity(activity); + + if (should_suspend) { + // Wait for execution to stop + for (auto* thread : process->GetThreadList()) { + thread->WaitUntilSuspended(); + } + } } } diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 4657bdabc..c4a93e524 100755 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -686,7 +686,7 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, {66, &ICommonStateGetter::SetCpuBoostMode, "SetCpuBoostMode"}, {67, nullptr, "CancelCpuBoostMode"}, {68, nullptr, "GetBuiltInDisplayType"}, - {80, nullptr, "PerformSystemButtonPressingIfInFocus"}, + {80, &ICommonStateGetter::PerformSystemButtonPressingIfInFocus, "PerformSystemButtonPressingIfInFocus"}, {90, nullptr, "SetPerformanceConfigurationChangedNotification"}, {91, nullptr, "GetCurrentPerformanceConfiguration"}, {100, nullptr, "SetHandlingHomeButtonShortPressedEnabled"}, @@ -826,6 +826,16 @@ void ICommonStateGetter::SetCpuBoostMode(Kernel::HLERequestContext& ctx) { apm_sys->SetCpuBoostMode(ctx); } +void ICommonStateGetter::PerformSystemButtonPressingIfInFocus(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto system_button{rp.PopEnum()}; + + LOG_WARNING(Service_AM, "(STUBBED) called, system_button={}", system_button); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + void ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled( Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_AM, "(STUBBED) called"); diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 06f13aa09..988ead215 100755 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -220,6 +220,18 @@ private: Docked = 1, }; + // This is nn::am::service::SystemButtonType + enum class SystemButtonType { + None, + HomeButtonShortPressing, + HomeButtonLongPressing, + PowerButtonShortPressing, + PowerButtonLongPressing, + ShutdownSystem, + CaptureButtonShortPressing, + CaptureButtonLongPressing, + }; + void GetEventHandle(Kernel::HLERequestContext& ctx); void ReceiveMessage(Kernel::HLERequestContext& ctx); void GetCurrentFocusState(Kernel::HLERequestContext& ctx); @@ -234,6 +246,7 @@ private: void EndVrModeEx(Kernel::HLERequestContext& ctx); void GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx); void SetCpuBoostMode(Kernel::HLERequestContext& ctx); + void PerformSystemButtonPressingIfInFocus(Kernel::HLERequestContext& ctx); void SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(Kernel::HLERequestContext& ctx); std::shared_ptr msg_queue;