From b6087e35b5fe624a072d923efdf700b4671da132 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 30 Dec 2017 12:10:58 -0500 Subject: thread: Main thread should set thread handle to reg 1. --- src/core/hle/kernel/thread.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index fc0364d5f..b20092761 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -490,7 +490,8 @@ void Thread::BoostPriority(u32 priority) { current_priority = priority; } -SharedPtr SetupMainThread(VAddr entry_point, u32 priority, SharedPtr owner_process) { +SharedPtr SetupMainThread(VAddr entry_point, u32 priority, + SharedPtr owner_process) { // Setup page table so we can write to memory SetCurrentPageTable(&Kernel::g_current_process->vm_manager.page_table); @@ -500,6 +501,8 @@ SharedPtr SetupMainThread(VAddr entry_point, u32 priority, SharedPtr thread = std::move(thread_res).Unwrap(); + // Register 1 must be a handle to the main thread + thread->context.cpu_registers[1] = Kernel::g_handle_table.Create(thread).Unwrap(); thread->context.fpscr = FPSCR_DEFAULT_NAN | FPSCR_FLUSH_TO_ZERO | FPSCR_ROUND_TOZERO | FPSCR_IXC; // 0x03C00010 -- cgit v1.2.3