summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar bunnei2022-09-05 17:47:00 -0700
committerGravatar bunnei2022-10-18 19:13:34 -0700
commit25dcaf1ecaeb3998a2cb8b03a7aa8a02402e0bad (patch)
tree1007ca27eaa8cb9f76c0359903d11432e17c44d8 /src/core
parentcore: hle: kernel: svc_types: Add SystemThreadPriorityHighest and ProcessState. (diff)
downloadyuzu-25dcaf1ecaeb3998a2cb8b03a7aa8a02402e0bad.tar.gz
yuzu-25dcaf1ecaeb3998a2cb8b03a7aa8a02402e0bad.tar.xz
yuzu-25dcaf1ecaeb3998a2cb8b03a7aa8a02402e0bad.zip
core: hle: kernel: k_process: Change Status -> State.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/kernel/k_process.cpp20
-rw-r--r--src/core/hle/kernel/k_process.h40
-rw-r--r--src/core/hle/kernel/svc.cpp4
3 files changed, 27 insertions, 37 deletions
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp
index d3e99665f..1d3157a9f 100644
--- a/src/core/hle/kernel/k_process.cpp
+++ b/src/core/hle/kernel/k_process.cpp
@@ -72,7 +72,7 @@ Result KProcess::Initialize(KProcess* process, Core::System& system, std::string
72 72
73 process->name = std::move(process_name); 73 process->name = std::move(process_name);
74 process->resource_limit = res_limit; 74 process->resource_limit = res_limit;
75 process->status = ProcessStatus::Created; 75 process->state = State::Created;
76 process->program_id = 0; 76 process->program_id = 0;
77 process->process_id = type == ProcessType::KernelInternal ? kernel.CreateNewKernelProcessID() 77 process->process_id = type == ProcessType::KernelInternal ? kernel.CreateNewKernelProcessID()
78 : kernel.CreateNewUserProcessID(); 78 : kernel.CreateNewUserProcessID();
@@ -289,7 +289,7 @@ Result KProcess::Reset() {
289 KScopedSchedulerLock sl{kernel}; 289 KScopedSchedulerLock sl{kernel};
290 290
291 // Validate that we're in a state that we can reset. 291 // Validate that we're in a state that we can reset.
292 R_UNLESS(status != ProcessStatus::Exited, ResultInvalidState); 292 R_UNLESS(state != State::Terminated, ResultInvalidState);
293 R_UNLESS(is_signaled, ResultInvalidState); 293 R_UNLESS(is_signaled, ResultInvalidState);
294 294
295 // Clear signaled. 295 // Clear signaled.
@@ -304,8 +304,8 @@ Result KProcess::SetActivity(ProcessActivity activity) {
304 KScopedSchedulerLock sl{kernel}; 304 KScopedSchedulerLock sl{kernel};
305 305
306 // Validate our state. 306 // Validate our state.
307 R_UNLESS(status != ProcessStatus::Exiting, ResultInvalidState); 307 R_UNLESS(state != State::Terminating, ResultInvalidState);
308 R_UNLESS(status != ProcessStatus::Exited, ResultInvalidState); 308 R_UNLESS(state != State::Terminated, ResultInvalidState);
309 309
310 // Either pause or resume. 310 // Either pause or resume.
311 if (activity == ProcessActivity::Paused) { 311 if (activity == ProcessActivity::Paused) {
@@ -411,13 +411,13 @@ void KProcess::Run(s32 main_thread_priority, u64 stack_size) {
411 const std::size_t heap_capacity{memory_usage_capacity - (main_thread_stack_size + image_size)}; 411 const std::size_t heap_capacity{memory_usage_capacity - (main_thread_stack_size + image_size)};
412 ASSERT(!page_table->SetMaxHeapSize(heap_capacity).IsError()); 412 ASSERT(!page_table->SetMaxHeapSize(heap_capacity).IsError());
413 413
414 ChangeStatus(ProcessStatus::Running); 414 ChangeState(State::Running);
415 415
416 SetupMainThread(kernel.System(), *this, main_thread_priority, main_thread_stack_top); 416 SetupMainThread(kernel.System(), *this, main_thread_priority, main_thread_stack_top);
417} 417}
418 418
419void KProcess::PrepareForTermination() { 419void KProcess::PrepareForTermination() {
420 ChangeStatus(ProcessStatus::Exiting); 420 ChangeState(State::Terminating);
421 421
422 const auto stop_threads = [this](const std::vector<KThread*>& in_thread_list) { 422 const auto stop_threads = [this](const std::vector<KThread*>& in_thread_list) {
423 for (auto* thread : in_thread_list) { 423 for (auto* thread : in_thread_list) {
@@ -445,7 +445,7 @@ void KProcess::PrepareForTermination() {
445 main_thread_stack_size + image_size); 445 main_thread_stack_size + image_size);
446 } 446 }
447 447
448 ChangeStatus(ProcessStatus::Exited); 448 ChangeState(State::Terminated);
449} 449}
450 450
451void KProcess::Finalize() { 451void KProcess::Finalize() {
@@ -652,12 +652,12 @@ KProcess::KProcess(KernelCore& kernel_)
652 652
653KProcess::~KProcess() = default; 653KProcess::~KProcess() = default;
654 654
655void KProcess::ChangeStatus(ProcessStatus new_status) { 655void KProcess::ChangeState(State new_state) {
656 if (status == new_status) { 656 if (state == new_state) {
657 return; 657 return;
658 } 658 }
659 659
660 status = new_status; 660 state = new_state;
661 is_signaled = true; 661 is_signaled = true;
662 NotifyAvailable(); 662 NotifyAvailable();
663} 663}
diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h
index d56d73bab..b1c7da454 100644
--- a/src/core/hle/kernel/k_process.h
+++ b/src/core/hle/kernel/k_process.h
@@ -45,24 +45,6 @@ enum class MemoryRegion : u16 {
45 BASE = 3, 45 BASE = 3,
46}; 46};
47 47
48/**
49 * Indicates the status of a Process instance.
50 *
51 * @note These match the values as used by kernel,
52 * so new entries should only be added if RE
53 * shows that a new value has been introduced.
54 */
55enum class ProcessStatus {
56 Created,
57 CreatedWithDebuggerAttached,
58 Running,
59 WaitingForDebuggerToAttach,
60 DebuggerAttached,
61 Exiting,
62 Exited,
63 DebugBreak,
64};
65
66enum class ProcessActivity : u32 { 48enum class ProcessActivity : u32 {
67 Runnable, 49 Runnable,
68 Paused, 50 Paused,
@@ -89,6 +71,17 @@ public:
89 explicit KProcess(KernelCore& kernel_); 71 explicit KProcess(KernelCore& kernel_);
90 ~KProcess() override; 72 ~KProcess() override;
91 73
74 enum class State {
75 Created = Svc::ProcessState_Created,
76 CreatedAttached = Svc::ProcessState_CreatedAttached,
77 Running = Svc::ProcessState_Running,
78 Crashed = Svc::ProcessState_Crashed,
79 RunningAttached = Svc::ProcessState_RunningAttached,
80 Terminating = Svc::ProcessState_Terminating,
81 Terminated = Svc::ProcessState_Terminated,
82 DebugBreak = Svc::ProcessState_DebugBreak,
83 };
84
92 enum : u64 { 85 enum : u64 {
93 /// Lowest allowed process ID for a kernel initial process. 86 /// Lowest allowed process ID for a kernel initial process.
94 InitialKIPIDMin = 1, 87 InitialKIPIDMin = 1,
@@ -163,8 +156,8 @@ public:
163 } 156 }
164 157
165 /// Gets the current status of the process 158 /// Gets the current status of the process
166 ProcessStatus GetStatus() const { 159 State GetState() const {
167 return status; 160 return state;
168 } 161 }
169 162
170 /// Gets the unique ID that identifies this particular process. 163 /// Gets the unique ID that identifies this particular process.
@@ -415,10 +408,7 @@ private:
415 pinned_threads[core_id] = nullptr; 408 pinned_threads[core_id] = nullptr;
416 } 409 }
417 410
418 /// Changes the process status. If the status is different 411 void ChangeState(State new_state);
419 /// from the current process status, then this will trigger
420 /// a process signal.
421 void ChangeStatus(ProcessStatus new_status);
422 412
423 /// Allocates the main thread stack for the process, given the stack size in bytes. 413 /// Allocates the main thread stack for the process, given the stack size in bytes.
424 Result AllocateMainThreadStack(std::size_t stack_size); 414 Result AllocateMainThreadStack(std::size_t stack_size);
@@ -427,7 +417,7 @@ private:
427 std::unique_ptr<KPageTable> page_table; 417 std::unique_ptr<KPageTable> page_table;
428 418
429 /// Current status of the process 419 /// Current status of the process
430 ProcessStatus status{}; 420 State state{};
431 421
432 /// The ID of this process 422 /// The ID of this process
433 u64 process_id = 0; 423 u64 process_id = 0;
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 1d145ea91..bac61fd09 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -1888,7 +1888,7 @@ static void ExitProcess(Core::System& system) {
1888 auto* current_process = system.Kernel().CurrentProcess(); 1888 auto* current_process = system.Kernel().CurrentProcess();
1889 1889
1890 LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessID()); 1890 LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessID());
1891 ASSERT_MSG(current_process->GetStatus() == ProcessStatus::Running, 1891 ASSERT_MSG(current_process->GetState() == KProcess::State::Running,
1892 "Process has already exited"); 1892 "Process has already exited");
1893 1893
1894 system.Exit(); 1894 system.Exit();
@@ -2557,7 +2557,7 @@ static Result GetProcessInfo(Core::System& system, u64* out, Handle process_hand
2557 return ResultInvalidEnumValue; 2557 return ResultInvalidEnumValue;
2558 } 2558 }
2559 2559
2560 *out = static_cast<u64>(process->GetStatus()); 2560 *out = static_cast<u64>(process->GetState());
2561 return ResultSuccess; 2561 return ResultSuccess;
2562} 2562}
2563 2563