summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-11-26 18:48:07 -0500
committerGravatar Lioncash2018-11-26 21:12:13 -0500
commit1d6399c222e6c0478193160648cddf43b8d8eff9 (patch)
tree576472b5ccb74dacf7e55f7e651e8c0ff55a7ae4 /src/core/hle/kernel/svc.cpp
parentsvc: Implement svcCreateResourceLimit() (diff)
downloadyuzu-1d6399c222e6c0478193160648cddf43b8d8eff9.tar.gz
yuzu-1d6399c222e6c0478193160648cddf43b8d8eff9.tar.xz
yuzu-1d6399c222e6c0478193160648cddf43b8d8eff9.zip
svc: Implement svcGetResourceLimitLimitValue()
This kernel service function retrieves the maximum allowable value for a provided resource category for a given resource limit instance. Given we already have the functionality added to the resource limit instance itself, it's sufficient to just hook it up. The error scenarios for this are: 1. If an invalid resource category type is provided, then ERR_INVALID_ENUM is returned. 2. If an invalid handle is provided, then ERR_INVALID_HANDLE is returned (bad thing goes in, bad thing goes out, as one would expect). If neither of the above error cases occur, then the out parameter is provided with the maximum limit value for the given category and success is returned.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp29
1 files changed, 28 insertions, 1 deletions
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"},