summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2018-10-14 14:37:58 -0400
committerGravatar GitHub2018-10-14 14:37:58 -0400
commit2f8ca32020d2b32abfcb96d433ca79c4974e15be (patch)
tree8a63f146f9b1a4f647900866f84142c08784611b
parentMerge pull request #1495 from ogniK5377/break-stop (diff)
parentsvc: Implement svcGetProcessInfo (diff)
downloadyuzu-2f8ca32020d2b32abfcb96d433ca79c4974e15be.tar.gz
yuzu-2f8ca32020d2b32abfcb96d433ca79c4974e15be.tar.xz
yuzu-2f8ca32020d2b32abfcb96d433ca79c4974e15be.zip
Merge pull request #1492 from lioncash/proc
svc: Implement svcGetProcessInfo
-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 198865fd0..7a053da1e 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -1098,6 +1098,29 @@ static ResultCode ClearEvent(Handle handle) {
1098 return RESULT_SUCCESS; 1098 return RESULT_SUCCESS;
1099} 1099}
1100 1100
1101static ResultCode GetProcessInfo(u64* out, Handle process_handle, u32 type) {
1102 LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type);
1103
1104 // This function currently only allows retrieving a process' status.
1105 enum class InfoType {
1106 Status,
1107 };
1108
1109 const auto& kernel = Core::System::GetInstance().Kernel();
1110 const auto process = kernel.HandleTable().Get<Process>(process_handle);
1111 if (!process) {
1112 return ERR_INVALID_HANDLE;
1113 }
1114
1115 const auto info_type = static_cast<InfoType>(type);
1116 if (info_type != InfoType::Status) {
1117 return ERR_INVALID_ENUM_VALUE;
1118 }
1119
1120 *out = static_cast<u64>(process->GetStatus());
1121 return RESULT_SUCCESS;
1122}
1123
1101namespace { 1124namespace {
1102struct FunctionDef { 1125struct FunctionDef {
1103 using Func = void(); 1126 using Func = void();
@@ -1233,7 +1256,7 @@ static const FunctionDef SVC_Table[] = {
1233 {0x79, nullptr, "CreateProcess"}, 1256 {0x79, nullptr, "CreateProcess"},
1234 {0x7A, nullptr, "StartProcess"}, 1257 {0x7A, nullptr, "StartProcess"},
1235 {0x7B, nullptr, "TerminateProcess"}, 1258 {0x7B, nullptr, "TerminateProcess"},
1236 {0x7C, nullptr, "GetProcessInfo"}, 1259 {0x7C, SvcWrap<GetProcessInfo>, "GetProcessInfo"},
1237 {0x7D, nullptr, "CreateResourceLimit"}, 1260 {0x7D, nullptr, "CreateResourceLimit"},
1238 {0x7E, nullptr, "SetResourceLimitLimitValue"}, 1261 {0x7E, nullptr, "SetResourceLimitLimitValue"},
1239 {0x7F, nullptr, "CallSecureMonitor"}, 1262 {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);