summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/resource_limit.h6
-rw-r--r--src/core/hle/kernel/svc.cpp29
2 files changed, 33 insertions, 2 deletions
diff --git a/src/core/hle/kernel/resource_limit.h b/src/core/hle/kernel/resource_limit.h
index bec065543..59dc11c22 100644
--- a/src/core/hle/kernel/resource_limit.h
+++ b/src/core/hle/kernel/resource_limit.h
@@ -14,7 +14,7 @@ namespace Kernel {
14 14
15class KernelCore; 15class KernelCore;
16 16
17enum class ResourceType { 17enum class ResourceType : u32 {
18 PhysicalMemory, 18 PhysicalMemory,
19 Threads, 19 Threads,
20 Events, 20 Events,
@@ -25,6 +25,10 @@ enum class ResourceType {
25 ResourceTypeCount 25 ResourceTypeCount
26}; 26};
27 27
28constexpr bool IsValidResourceType(ResourceType type) {
29 return type < ResourceType::ResourceTypeCount;
30}
31
28class ResourceLimit final : public Object { 32class ResourceLimit final : public Object {
29public: 33public:
30 /** 34 /**
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 4b7991c32..5e604411b 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -1364,6 +1364,33 @@ static ResultCode CreateResourceLimit(Handle* out_handle) {
1364 return RESULT_SUCCESS; 1364 return RESULT_SUCCESS;
1365} 1365}
1366 1366
1367static ResultCode GetResourceLimitLimitValue(u64* out_value, Handle resource_limit,
1368 u32 resource_type) {
1369 LOG_DEBUG(Kernel_SVC, "called. Handle={:08X}, Resource type={}", resource_limit, resource_type);
1370
1371 const auto type = static_cast<ResourceType>(resource_type);
1372 if (!IsValidResourceType(type)) {
1373 LOG_ERROR(Kernel_SVC, "Invalid resource limit type: '{}'.", resource_type);
1374 return ERR_INVALID_ENUM_VALUE;
1375 }
1376
1377 const auto& kernel = Core::System::GetInstance().Kernel();
1378 const auto* const current_process = kernel.CurrentProcess();
1379 ASSERT(current_process != nullptr);
1380
1381 const auto resource_limit_object =
1382 current_process->GetHandleTable().Get<ResourceLimit>(resource_limit);
1383 if (!resource_limit_object) {
1384 LOG_ERROR(Kernel_SVC, "Handle to non-existent resource limit instance used. Handle={:08X}",
1385 resource_limit);
1386 return ERR_INVALID_HANDLE;
1387 }
1388
1389 const s64 limit_value = resource_limit_object->GetMaxResourceValue(type);
1390 *out_value = static_cast<u64>(limit_value);
1391 return RESULT_SUCCESS;
1392}
1393
1367namespace { 1394namespace {
1368struct FunctionDef { 1395struct FunctionDef {
1369 using Func = void(); 1396 using Func = void();
@@ -1423,7 +1450,7 @@ static const FunctionDef SVC_Table[] = {
1423 {0x2D, nullptr, "UnmapPhysicalMemory"}, 1450 {0x2D, nullptr, "UnmapPhysicalMemory"},
1424 {0x2E, nullptr, "GetFutureThreadInfo"}, 1451 {0x2E, nullptr, "GetFutureThreadInfo"},
1425 {0x2F, nullptr, "GetLastThreadInfo"}, 1452 {0x2F, nullptr, "GetLastThreadInfo"},
1426 {0x30, nullptr, "GetResourceLimitLimitValue"}, 1453 {0x30, SvcWrap<GetResourceLimitLimitValue>, "GetResourceLimitLimitValue"},
1427 {0x31, nullptr, "GetResourceLimitCurrentValue"}, 1454 {0x31, nullptr, "GetResourceLimitCurrentValue"},
1428 {0x32, SvcWrap<SetThreadActivity>, "SetThreadActivity"}, 1455 {0x32, SvcWrap<SetThreadActivity>, "SetThreadActivity"},
1429 {0x33, SvcWrap<GetThreadContext>, "GetThreadContext"}, 1456 {0x33, SvcWrap<GetThreadContext>, "GetThreadContext"},