diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/process.h | 21 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 25 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc_wrap.h | 8 |
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; | |||
| 24 | namespace Kernel { | 24 | namespace Kernel { |
| 25 | 25 | ||
| 26 | class KernelCore; | 26 | class KernelCore; |
| 27 | class ResourceLimit; | ||
| 27 | 28 | ||
| 28 | struct AddressMapping { | 29 | struct 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 | ||
| 60 | enum class ProcessStatus { Created, Running, Exited }; | 61 | /** |
| 61 | 62 | * Indicates the status of a Process instance. | |
| 62 | class 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 | */ | ||
| 68 | enum class ProcessStatus { | ||
| 69 | Created, | ||
| 70 | CreatedWithDebuggerAttached, | ||
| 71 | Running, | ||
| 72 | WaitingForDebuggerToAttach, | ||
| 73 | DebuggerAttached, | ||
| 74 | Exiting, | ||
| 75 | Exited, | ||
| 76 | DebugBreak, | ||
| 77 | }; | ||
| 63 | 78 | ||
| 64 | struct CodeSet final { | 79 | struct 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 | ||
| 1101 | static 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 | |||
| 1101 | namespace { | 1124 | namespace { |
| 1102 | struct FunctionDef { | 1125 | struct 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 | ||
| 80 | template <ResultCode func(u64*, u32, u32)> | ||
| 81 | void SvcWrap() { | ||
| 82 | u64 param_1 = 0; | ||
| 83 | u32 retval = func(¶m_1, static_cast<u32>(Param(1)), static_cast<u32>(Param(2))).raw; | ||
| 84 | Core::CurrentArmInterface().SetReg(1, param_1); | ||
| 85 | FuncReturn(retval); | ||
| 86 | } | ||
| 87 | |||
| 80 | template <ResultCode func(u32, u64)> | 88 | template <ResultCode func(u32, u64)> |
| 81 | void SvcWrap() { | 89 | void SvcWrap() { |
| 82 | FuncReturn(func(static_cast<u32>(Param(0)), Param(1)).raw); | 90 | FuncReturn(func(static_cast<u32>(Param(0)), Param(1)).raw); |