From 20a3b9c2b13647a4765e1a3ebe71a67a9d8f7508 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Fri, 29 Jan 2021 07:48:33 +0100 Subject: [PATCH] early-access version 1393 --- README.md | 2 +- src/common/common_funcs.h | 2 +- src/core/arm/dynarmic/arm_dynarmic_32.cpp | 6 ++++++ src/core/arm/dynarmic/arm_dynarmic_64.cpp | 6 ++++++ src/core/hle/kernel/k_light_lock.cpp | 6 +++--- src/core/hle/kernel/k_thread.cpp | 1 + src/core/hle/service/acc/profile_manager.cpp | 10 ++++++++-- 7 files changed, 26 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7a7809fb8..1b5f1fe00 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 1392. +This is the source code for early-access 1393. ## Legal Notice diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 71d136d4a..71b64e32a 100755 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -98,7 +98,7 @@ __declspec(dllimport) void __stdcall DebugBreak(void); { \ if (!(expr)) { \ if (res.IsError()) { \ - LOG_CRITICAL(Kernel, "Failed with error {}", res.raw); \ + LOG_ERROR(Kernel, "Failed with result: {}", res.raw); \ } \ return res; \ } \ diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 6c4c8e9e4..c650a4dfb 100755 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -255,6 +255,9 @@ void ARM_Dynarmic_32::ChangeProcessorID(std::size_t new_core_id) { } void ARM_Dynarmic_32::SaveContext(ThreadContext32& ctx) { + if (!jit) { + return; + } Dynarmic::A32::Context context; jit->SaveContext(context); ctx.cpu_registers = context.Regs(); @@ -264,6 +267,9 @@ void ARM_Dynarmic_32::SaveContext(ThreadContext32& ctx) { } void ARM_Dynarmic_32::LoadContext(const ThreadContext32& ctx) { + if (!jit) { + return; + } Dynarmic::A32::Context context; context.Regs() = ctx.cpu_registers; context.ExtRegs() = ctx.extension_registers; diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 4c5ebca22..ae5566ab8 100755 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -294,6 +294,9 @@ void ARM_Dynarmic_64::ChangeProcessorID(std::size_t new_core_id) { } void ARM_Dynarmic_64::SaveContext(ThreadContext64& ctx) { + if (!jit) { + return; + } ctx.cpu_registers = jit->GetRegisters(); ctx.sp = jit->GetSP(); ctx.pc = jit->GetPC(); @@ -305,6 +308,9 @@ void ARM_Dynarmic_64::SaveContext(ThreadContext64& ctx) { } void ARM_Dynarmic_64::LoadContext(const ThreadContext64& ctx) { + if (!jit) { + return; + } jit->SetRegisters(ctx.cpu_registers); jit->SetSP(ctx.sp); jit->SetPC(ctx.pc); diff --git a/src/core/hle/kernel/k_light_lock.cpp b/src/core/hle/kernel/k_light_lock.cpp index 08fa65fd5..f974022e8 100755 --- a/src/core/hle/kernel/k_light_lock.cpp +++ b/src/core/hle/kernel/k_light_lock.cpp @@ -54,7 +54,7 @@ void KLightLock::LockSlowPath(uintptr_t _owner, uintptr_t _cur_thread) { } // Add the current thread as a waiter on the owner. - KThread* owner_thread = reinterpret_cast(_owner & ~1ul); + KThread* owner_thread = reinterpret_cast(_owner & ~1ULL); cur_thread->SetAddressKey(reinterpret_cast(std::addressof(tag))); owner_thread->AddWaiter(cur_thread); @@ -67,7 +67,6 @@ void KLightLock::LockSlowPath(uintptr_t _owner, uintptr_t _cur_thread) { if (owner_thread->IsSuspended()) { owner_thread->ContinueIfHasKernelWaiters(); - KScheduler::SetSchedulerUpdateNeeded(kernel); } } @@ -77,6 +76,7 @@ void KLightLock::LockSlowPath(uintptr_t _owner, uintptr_t _cur_thread) { KThread* owner_thread = cur_thread->GetLockOwner(); if (owner_thread) { owner_thread->RemoveWaiter(cur_thread); + KScheduler::SetSchedulerUpdateNeeded(kernel); } } } @@ -124,7 +124,7 @@ void KLightLock::UnlockSlowPath(uintptr_t _cur_thread) { } bool KLightLock::IsLockedByCurrentThread() const { - return (tag | 0x1ul) == (reinterpret_cast(GetCurrentThreadPointer(kernel)) | 0x1ul); + return (tag | 1ULL) == (reinterpret_cast(GetCurrentThreadPointer(kernel)) | 1ULL); } } // namespace Kernel diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 45ad589d9..aa100e139 100755 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp @@ -247,6 +247,7 @@ void KThread::Finalize() { // Decrement the parent process's thread count. if (parent != nullptr) { parent->DecrementThreadCount(); + parent->GetResourceLimit()->Release(ResourceType::Threads, 1); } } diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index d9865d56f..50b2c58e2 100755 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp @@ -41,12 +41,18 @@ constexpr char ACC_SAVE_AVATORS_BASE_PATH[] = "/system/save/8000000000000010/su/ ProfileManager::ProfileManager() { ParseUserSaveFile(); - if (user_count == 0) + // Create an user if none are present + if (user_count == 0) { CreateNewUser(UUID::Generate(), "yuzu"); + } auto current = std::clamp(Settings::values.current_user, 0, MAX_USERS - 1); - if (UserExistsIndex(current)) + + // If user index don't exist. Load the first user and change the active user + if (!UserExistsIndex(current)) { current = 0; + Settings::values.current_user = 0; + } OpenUser(*GetUser(current)); }