diff options
| author | 2018-12-30 20:32:41 -0500 | |
|---|---|---|
| committer | 2018-12-30 20:32:41 -0500 | |
| commit | e5dfbe22ee458dc818e5e56daa7f1a43e6ed7205 (patch) | |
| tree | d12208284c7f3bff0d24ba5750019307eddccefe /src/core/hle/kernel/process.cpp | |
| parent | Merge pull request #1847 from ogniK5377/backtrace-break (diff) | |
| parent | kernel/process: Start the main thread using the specified ideal core (diff) | |
| download | yuzu-e5dfbe22ee458dc818e5e56daa7f1a43e6ed7205.tar.gz yuzu-e5dfbe22ee458dc818e5e56daa7f1a43e6ed7205.tar.xz yuzu-e5dfbe22ee458dc818e5e56daa7f1a43e6ed7205.zip | |
Merge pull request #1956 from lioncash/process-thread
kernel/process: Start the main thread using the specified ideal core
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 06a673b9b..c5aa19afa 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -20,6 +20,35 @@ | |||
| 20 | #include "core/settings.h" | 20 | #include "core/settings.h" |
| 21 | 21 | ||
| 22 | namespace Kernel { | 22 | namespace Kernel { |
| 23 | namespace { | ||
| 24 | /** | ||
| 25 | * Sets up the primary application thread | ||
| 26 | * | ||
| 27 | * @param owner_process The parent process for the main thread | ||
| 28 | * @param kernel The kernel instance to create the main thread under. | ||
| 29 | * @param entry_point The address at which the thread should start execution | ||
| 30 | * @param priority The priority to give the main thread | ||
| 31 | */ | ||
| 32 | void SetupMainThread(Process& owner_process, KernelCore& kernel, VAddr entry_point, u32 priority) { | ||
| 33 | // Setup page table so we can write to memory | ||
| 34 | SetCurrentPageTable(&owner_process.VMManager().page_table); | ||
| 35 | |||
| 36 | // Initialize new "main" thread | ||
| 37 | const VAddr stack_top = owner_process.VMManager().GetTLSIORegionEndAddress(); | ||
| 38 | auto thread_res = Thread::Create(kernel, "main", entry_point, priority, 0, | ||
| 39 | owner_process.GetIdealCore(), stack_top, owner_process); | ||
| 40 | |||
| 41 | SharedPtr<Thread> thread = std::move(thread_res).Unwrap(); | ||
| 42 | |||
| 43 | // Register 1 must be a handle to the main thread | ||
| 44 | const Handle guest_handle = owner_process.GetHandleTable().Create(thread).Unwrap(); | ||
| 45 | thread->SetGuestHandle(guest_handle); | ||
| 46 | thread->GetContext().cpu_registers[1] = guest_handle; | ||
| 47 | |||
| 48 | // Threads by default are dormant, wake up the main thread so it runs when the scheduler fires | ||
| 49 | thread->ResumeFromWait(); | ||
| 50 | } | ||
| 51 | } // Anonymous namespace | ||
| 23 | 52 | ||
| 24 | CodeSet::CodeSet() = default; | 53 | CodeSet::CodeSet() = default; |
| 25 | CodeSet::~CodeSet() = default; | 54 | CodeSet::~CodeSet() = default; |
| @@ -64,7 +93,7 @@ ResultCode Process::ClearSignalState() { | |||
| 64 | 93 | ||
| 65 | ResultCode Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata) { | 94 | ResultCode Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata) { |
| 66 | program_id = metadata.GetTitleID(); | 95 | program_id = metadata.GetTitleID(); |
| 67 | ideal_processor = metadata.GetMainThreadCore(); | 96 | ideal_core = metadata.GetMainThreadCore(); |
| 68 | is_64bit_process = metadata.Is64BitProgram(); | 97 | is_64bit_process = metadata.Is64BitProgram(); |
| 69 | 98 | ||
| 70 | vm_manager.Reset(metadata.GetAddressSpaceType()); | 99 | vm_manager.Reset(metadata.GetAddressSpaceType()); |
| @@ -86,7 +115,7 @@ void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) { | |||
| 86 | vm_manager.LogLayout(); | 115 | vm_manager.LogLayout(); |
| 87 | ChangeStatus(ProcessStatus::Running); | 116 | ChangeStatus(ProcessStatus::Running); |
| 88 | 117 | ||
| 89 | Kernel::SetupMainThread(kernel, entry_point, main_thread_priority, *this); | 118 | SetupMainThread(*this, kernel, entry_point, main_thread_priority); |
| 90 | } | 119 | } |
| 91 | 120 | ||
| 92 | void Process::PrepareForTermination() { | 121 | void Process::PrepareForTermination() { |