From a288c2e737e3d849647393b9d63e0b89ed6028d3 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 6 Nov 2017 13:47:48 -0500 Subject: [PATCH] Kernel/Thread: Use the process' ideal CPU when specifying the Default CPU on CreateThread. This behavior was reverse engineered from the real kernel. --- src/core/hle/svc.cpp | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 079a39a7df..d8cb7f6546 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -736,11 +736,22 @@ static ResultCode CreateThread(Kernel::Handle* out_handle, u32 priority, u32 ent return Kernel::ERR_NOT_AUTHORIZED; } + if (processor_id == THREADPROCESSORID_DEFAULT) { + // Set the target CPU to the one specified in the process' exheader. + processor_id = Kernel::g_current_process->ideal_processor; + ASSERT(processor_id != THREADPROCESSORID_DEFAULT); + } + switch (processor_id) { - case THREADPROCESSORID_ALL: - case THREADPROCESSORID_DEFAULT: case THREADPROCESSORID_0: + break; + case THREADPROCESSORID_ALL: + LOG_INFO(Kernel_SVC, + "Newly created thread is allowed to be run in any Core, unimplemented."); + break; case THREADPROCESSORID_1: + LOG_ERROR(Kernel_SVC, + "Newly created thread must run in the SysCore (Core1), unimplemented."); break; default: // TODO(bunnei): Implement support for other processor IDs @@ -748,23 +759,6 @@ static ResultCode CreateThread(Kernel::Handle* out_handle, u32 priority, u32 ent break; } - if (processor_id == THREADPROCESSORID_ALL) { - LOG_INFO(Kernel_SVC, - "Newly created thread is allowed to be run in any Core, unimplemented."); - } - - if (processor_id == THREADPROCESSORID_DEFAULT && - Kernel::g_current_process->ideal_processor == THREADPROCESSORID_1) { - LOG_WARNING( - Kernel_SVC, - "Newly created thread is allowed to be run in the SysCore (Core1), unimplemented."); - } - - if (processor_id == THREADPROCESSORID_1) { - LOG_ERROR(Kernel_SVC, - "Newly created thread must run in the SysCore (Core1), unimplemented."); - } - CASCADE_RESULT(SharedPtr thread, Kernel::Thread::Create(name, entry_point, priority, arg, processor_id, stack_top, Kernel::g_current_process));