diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 223b3ce37..344635c6a 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -102,7 +102,7 @@ public: */ ResultVal> CreateThread(std::string name, VAddr entry_point, u32 priority, u32 arg, s32 processor_id, VAddr stack_top, - Process* owner_process); + Process& owner_process); /** * Creates a semaphore. diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 0e7a21c0a..6a33736ba 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -787,7 +787,7 @@ static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point CASCADE_RESULT(SharedPtr thread, Core::System::GetInstance().Kernel().CreateThread( name, entry_point, priority, arg, processor_id, - stack_top, current_process.get())); + stack_top, *current_process)); thread->context->SetFpscr(FPSCR_DEFAULT_NAN | FPSCR_FLUSH_TO_ZERO | FPSCR_ROUND_TOZERO); // 0x03C00000 diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 11ea54fbd..a7b6eba1e 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -320,7 +320,7 @@ static void ResetThreadContext(const std::unique_ptr> KernelSystem::CreateThread(std::string name, VAddr entry_point, u32 priority, u32 arg, s32 processor_id, - VAddr stack_top, Process* owner_process) { + VAddr stack_top, Process& owner_process) { // Check if priority is in ranged. Lowest priority -> highest priority id. if (priority > ThreadPrioLowest) { LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority); @@ -334,7 +334,7 @@ ResultVal> KernelSystem::CreateThread(std::string name, VAddr // TODO(yuriks): Other checks, returning 0xD9001BEA - if (!Memory::IsValidVirtualAddress(*owner_process, entry_point)) { + if (!Memory::IsValidVirtualAddress(owner_process, entry_point)) { LOG_ERROR(Kernel_SVC, "(name={}): invalid entry {:08x}", name, entry_point); // TODO: Verify error return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, @@ -357,10 +357,10 @@ ResultVal> KernelSystem::CreateThread(std::string name, VAddr thread->wait_address = 0; thread->name = std::move(name); wakeup_callback_table[thread->thread_id] = thread.get(); - thread->owner_process = owner_process; + thread->owner_process = &owner_process; // Find the next available TLS index, and mark it as used - auto& tls_slots = owner_process->tls_slots; + auto& tls_slots = owner_process.tls_slots; auto [available_page, available_slot, needs_allocation] = GetFreeThreadLocalSlot(tls_slots); @@ -381,13 +381,13 @@ ResultVal> KernelSystem::CreateThread(std::string name, VAddr // Allocate some memory from the end of the linear heap for this region. linheap_memory->insert(linheap_memory->end(), Memory::PAGE_SIZE, 0); memory_region->used += Memory::PAGE_SIZE; - owner_process->linear_heap_used += Memory::PAGE_SIZE; + owner_process.linear_heap_used += Memory::PAGE_SIZE; tls_slots.emplace_back(0); // The page is completely available at the start available_page = tls_slots.size() - 1; available_slot = 0; // Use the first slot in the new page - auto& vm_manager = owner_process->vm_manager; + auto& vm_manager = owner_process.vm_manager; vm_manager.RefreshMemoryBlockMappings(linheap_memory.get()); // Map the page to the current process' address space. @@ -446,7 +446,7 @@ SharedPtr SetupMainThread(KernelSystem& kernel, u32 entry_point, u32 pri // Initialize new "main" thread auto thread_res = kernel.CreateThread("main", entry_point, priority, 0, owner_process->ideal_processor, - Memory::HEAP_VADDR_END, owner_process.get()); + Memory::HEAP_VADDR_END, *owner_process); SharedPtr thread = std::move(thread_res).Unwrap();