summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/kernel/process.h21
-rw-r--r--src/core/hle/kernel/svc.cpp25
-rw-r--r--src/core/hle/kernel/svc_wrap.h8
3 files changed, 50 insertions, 4 deletions
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index 73ec01e11..f2816943a 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -24,6 +24,7 @@ class ProgramMetadata;
24namespace Kernel { 24namespace Kernel {
25 25
26class KernelCore; 26class KernelCore;
27class ResourceLimit;
27 28
28struct AddressMapping { 29struct AddressMapping {
29 // Address and size must be page-aligned 30 // Address and size must be page-aligned
@@ -57,9 +58,23 @@ union ProcessFlags {
57 BitField<12, 1, u16> loaded_high; ///< Application loaded high (not at 0x00100000). 58 BitField<12, 1, u16> loaded_high; ///< Application loaded high (not at 0x00100000).
58}; 59};
59 60
60enum class ProcessStatus { Created, Running, Exited }; 61/**
61 62 * Indicates the status of a Process instance.
62class ResourceLimit; 63 *
64 * @note These match the values as used by kernel,
65 * so new entries should only be added if RE
66 * shows that a new value has been introduced.
67 */
68enum class ProcessStatus {
69 Created,
70 CreatedWithDebuggerAttached,
71 Running,
72 WaitingForDebuggerToAttach,
73 DebuggerAttached,
74 Exiting,
75 Exited,
76 DebugBreak,
77};
63 78
64struct CodeSet final { 79struct CodeSet final {
65 struct Segment { 80 struct Segment {
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index e406df829..d9d919e18 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -1092,6 +1092,29 @@ static ResultCode ClearEvent(Handle handle) {
1092 return RESULT_SUCCESS; 1092 return RESULT_SUCCESS;
1093} 1093}
1094 1094
1095static ResultCode GetProcessInfo(u64* out, Handle process_handle, u32 type) {
1096 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type);
1097
1098 // This function currently only allows retrieving a process' status.
1099 enum class InfoType {
1100 Status,
1101 };
1102
1103 const auto& kernel = Core::System::GetInstance().Kernel();
1104 const auto process = kernel.HandleTable().Get<Process>(process_handle);
1105 if (!process) {
1106 return ERR_INVALID_HANDLE;
1107 }
1108
1109 const auto info_type = static_cast<InfoType>(type);
1110 if (info_type != InfoType::Status) {
1111 return ERR_INVALID_ENUM_VALUE;
1112 }
1113
1114 *out = static_cast<u64>(process->GetStatus());
1115 return RESULT_SUCCESS;
1116}
1117
1095namespace { 1118namespace {
1096struct FunctionDef { 1119struct FunctionDef {
1097 using Func = void(); 1120 using Func = void();
@@ -1227,7 +1250,7 @@ static const FunctionDef SVC_Table[] = {
1227 {0x79, nullptr, "CreateProcess"}, 1250 {0x79, nullptr, "CreateProcess"},
1228 {0x7A, nullptr, "StartProcess"}, 1251 {0x7A, nullptr, "StartProcess"},
1229 {0x7B, nullptr, "TerminateProcess"}, 1252 {0x7B, nullptr, "TerminateProcess"},
1230 {0x7C, nullptr, "GetProcessInfo"}, 1253 {0x7C, SvcWrap<GetProcessInfo>, "GetProcessInfo"},
1231 {0x7D, nullptr, "CreateResourceLimit"}, 1254 {0x7D, nullptr, "CreateResourceLimit"},
1232 {0x7E, nullptr, "SetResourceLimitLimitValue"}, 1255 {0x7E, nullptr, "SetResourceLimitLimitValue"},
1233 {0x7F, nullptr, "CallSecureMonitor"}, 1256 {0x7F, nullptr, "CallSecureMonitor"},
diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h
index cbb80c3c4..b09753c80 100644
--- a/src/core/hle/kernel/svc_wrap.h
+++ b/src/core/hle/kernel/svc_wrap.h
@@ -77,6 +77,14 @@ void SvcWrap() {
77 FuncReturn(retval); 77 FuncReturn(retval);
78} 78}
79 79
80template <ResultCode func(u64*, u32, u32)>
81void SvcWrap() {
82 u64 param_1 = 0;
83 u32 retval = func(&param_1, static_cast<u32>(Param(1)), static_cast<u32>(Param(2))).raw;
84 Core::CurrentArmInterface().SetReg(1, param_1);
85 FuncReturn(retval);
86}
87
80template <ResultCode func(u32, u64)> 88template <ResultCode func(u32, u64)>
81void SvcWrap() { 89void SvcWrap() {
82 FuncReturn(func(static_cast<u32>(Param(0)), Param(1)).raw); 90 FuncReturn(func(static_cast<u32>(Param(0)), Param(1)).raw);