summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2022-02-21 12:29:19 -0800
committerGravatar bunnei2022-02-21 12:40:09 -0800
commitc7019db6f49edae8431480d7a58d47df760d2871 (patch)
tree468437f46f55ca012e483291f85a017983745515 /src
parentMerge pull request #7919 from bunnei/phys-mem-updates (diff)
downloadyuzu-c7019db6f49edae8431480d7a58d47df760d2871.tar.gz
yuzu-c7019db6f49edae8431480d7a58d47df760d2871.tar.xz
yuzu-c7019db6f49edae8431480d7a58d47df760d2871.zip
core: hle: kernel: KResourceLimit: Add a helper function for creating a KResourceLimit for a process.
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/k_resource_limit.cpp19
-rw-r--r--src/core/hle/kernel/k_resource_limit.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_resource_limit.cpp b/src/core/hle/kernel/k_resource_limit.cpp
index 0c4bba66b..a84977c68 100644
--- a/src/core/hle/kernel/k_resource_limit.cpp
+++ b/src/core/hle/kernel/k_resource_limit.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/assert.h" 5#include "common/assert.h"
6#include "core/core.h"
6#include "core/core_timing.h" 7#include "core/core_timing.h"
7#include "core/hle/kernel/k_resource_limit.h" 8#include "core/hle/kernel/k_resource_limit.h"
8#include "core/hle/kernel/svc_results.h" 9#include "core/hle/kernel/svc_results.h"
@@ -151,4 +152,22 @@ void KResourceLimit::Release(LimitableResource which, s64 value, s64 hint) {
151 } 152 }
152} 153}
153 154
155KResourceLimit* CreateResourceLimitForProcess(Core::System& system, s64 physical_memory_size) {
156 auto* resource_limit = KResourceLimit::Create(system.Kernel());
157 resource_limit->Initialize(&system.CoreTiming());
158
159 // Initialize default resource limit values.
160 // TODO(bunnei): These values are the system defaults, the limits for service processes are
161 // lower. These should use the correct limit values.
162
163 ASSERT(resource_limit->SetLimitValue(LimitableResource::PhysicalMemory, physical_memory_size)
164 .IsSuccess());
165 ASSERT(resource_limit->SetLimitValue(LimitableResource::Threads, 800).IsSuccess());
166 ASSERT(resource_limit->SetLimitValue(LimitableResource::Events, 900).IsSuccess());
167 ASSERT(resource_limit->SetLimitValue(LimitableResource::TransferMemory, 200).IsSuccess());
168 ASSERT(resource_limit->SetLimitValue(LimitableResource::Sessions, 1133).IsSuccess());
169
170 return resource_limit;
171}
172
154} // namespace Kernel 173} // namespace Kernel
diff --git a/src/core/hle/kernel/k_resource_limit.h b/src/core/hle/kernel/k_resource_limit.h
index fab6005ff..d23d16aa4 100644
--- a/src/core/hle/kernel/k_resource_limit.h
+++ b/src/core/hle/kernel/k_resource_limit.h
@@ -67,4 +67,7 @@ private:
67 KLightConditionVariable cond_var; 67 KLightConditionVariable cond_var;
68 const Core::Timing::CoreTiming* core_timing{}; 68 const Core::Timing::CoreTiming* core_timing{};
69}; 69};
70
71KResourceLimit* CreateResourceLimitForProcess(Core::System& system, s64 physical_memory_size);
72
70} // namespace Kernel 73} // namespace Kernel