summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-02-25 13:22:11 -0400
committerGravatar Fernando Sahmkow2020-06-27 11:35:12 -0400
commit589f9cf108d306e8265ff4856b522cd32fbc121f (patch)
treed9e78acb03901cdbbc3f7649b03048f7cd946f06 /src/core/hle/kernel/svc.cpp
parentSVC: Correct CreateThread, StartThread, ExitThread, SleepThread. (diff)
downloadyuzu-589f9cf108d306e8265ff4856b522cd32fbc121f.tar.gz
yuzu-589f9cf108d306e8265ff4856b522cd32fbc121f.tar.xz
yuzu-589f9cf108d306e8265ff4856b522cd32fbc121f.zip
SVC: Correct GetThreadPriority, SetThreadPriority, GetThreadCoreMask, SetThreadCoreMask, GetCurrentProcessorNumber
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index dfb032b4b..2a218e294 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -27,6 +27,7 @@
27#include "core/hle/kernel/memory/memory_block.h" 27#include "core/hle/kernel/memory/memory_block.h"
28#include "core/hle/kernel/memory/page_table.h" 28#include "core/hle/kernel/memory/page_table.h"
29#include "core/hle/kernel/mutex.h" 29#include "core/hle/kernel/mutex.h"
30#include "core/hle/kernel/physical_core.h"
30#include "core/hle/kernel/process.h" 31#include "core/hle/kernel/process.h"
31#include "core/hle/kernel/readable_event.h" 32#include "core/hle/kernel/readable_event.h"
32#include "core/hle/kernel/resource_limit.h" 33#include "core/hle/kernel/resource_limit.h"
@@ -1071,6 +1072,7 @@ static ResultCode GetThreadPriority(Core::System& system, u32* priority, Handle
1071 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 1072 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
1072 const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(handle); 1073 const std::shared_ptr<Thread> thread = handle_table.Get<Thread>(handle);
1073 if (!thread) { 1074 if (!thread) {
1075 *priority = 0;
1074 LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle); 1076 LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}", handle);
1075 return ERR_INVALID_HANDLE; 1077 return ERR_INVALID_HANDLE;
1076 } 1078 }
@@ -1105,14 +1107,13 @@ static ResultCode SetThreadPriority(Core::System& system, Handle handle, u32 pri
1105 1107
1106 thread->SetPriority(priority); 1108 thread->SetPriority(priority);
1107 1109
1108 system.PrepareReschedule(thread->GetProcessorID());
1109 return RESULT_SUCCESS; 1110 return RESULT_SUCCESS;
1110} 1111}
1111 1112
1112/// Get which CPU core is executing the current thread 1113/// Get which CPU core is executing the current thread
1113static u32 GetCurrentProcessorNumber(Core::System& system) { 1114static u32 GetCurrentProcessorNumber(Core::System& system) {
1114 LOG_TRACE(Kernel_SVC, "called"); 1115 LOG_TRACE(Kernel_SVC, "called");
1115 return system.CurrentScheduler().GetCurrentThread()->GetProcessorID(); 1116 return static_cast<u32>(system.CurrentPhysicalCore().CoreIndex());
1116} 1117}
1117 1118
1118static ResultCode MapSharedMemory(Core::System& system, Handle shared_memory_handle, VAddr addr, 1119static ResultCode MapSharedMemory(Core::System& system, Handle shared_memory_handle, VAddr addr,
@@ -1430,8 +1431,8 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e
1430 1431
1431 ThreadType type = THREADTYPE_USER; 1432 ThreadType type = THREADTYPE_USER;
1432 CASCADE_RESULT(std::shared_ptr<Thread> thread, 1433 CASCADE_RESULT(std::shared_ptr<Thread> thread,
1433 Thread::Create(system, type, "", entry_point, priority, arg, processor_id, stack_top, 1434 Thread::Create(system, type, "", entry_point, priority, arg, processor_id,
1434 current_process)); 1435 stack_top, current_process));
1435 1436
1436 const auto new_thread_handle = current_process->GetHandleTable().Create(thread); 1437 const auto new_thread_handle = current_process->GetHandleTable().Create(thread);
1437 if (new_thread_handle.Failed()) { 1438 if (new_thread_handle.Failed()) {
@@ -1804,6 +1805,8 @@ static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle,
1804 if (!thread) { 1805 if (!thread) {
1805 LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", 1806 LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}",
1806 thread_handle); 1807 thread_handle);
1808 *core = 0;
1809 *mask = 0;
1807 return ERR_INVALID_HANDLE; 1810 return ERR_INVALID_HANDLE;
1808 } 1811 }
1809 1812
@@ -1866,11 +1869,7 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle,
1866 return ERR_INVALID_HANDLE; 1869 return ERR_INVALID_HANDLE;
1867 } 1870 }
1868 1871
1869 system.PrepareReschedule(thread->GetProcessorID()); 1872 return thread->SetCoreAndAffinityMask(core, affinity_mask);
1870 thread->ChangeCore(core, affinity_mask);
1871 system.PrepareReschedule(thread->GetProcessorID());
1872
1873 return RESULT_SUCCESS;
1874} 1873}
1875 1874
1876static ResultCode CreateEvent(Core::System& system, Handle* write_handle, Handle* read_handle) { 1875static ResultCode CreateEvent(Core::System& system, Handle* write_handle, Handle* read_handle) {