aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs
diff options
context:
space:
mode:
authorMary <me@thog.eu>2021-10-24 01:40:13 +0200
committerGitHub <noreply@github.com>2021-10-24 01:40:13 +0200
commitdc837c00428b6f67079e362631fe7fc503ceeacb (patch)
treecaf888404363bb8b2d7d547c7273a78b1f206a99 /Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs
parentc94d47cc408910af8342d47886937dd9feb32f4d (diff)
kernel: Add resource limit related syscalls (#2773)
* kernel: Add resource limit related syscalls This commit implements all resource limit related syscalls. * Fix register mapping being wrong for SetResourceLimitLimitValue * Address gdkchan's comment
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs')
-rw-r--r--Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs89
1 files changed, 89 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs
index 237c1a54..a1e84935 100644
--- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs
+++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs
@@ -1918,6 +1918,95 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
+ public KernelResult GetResourceLimitLimitValue(int handle, LimitableResource resource, out long limitValue)
+ {
+ limitValue = 0;
+
+ if (resource >= LimitableResource.Count)
+ {
+ return KernelResult.InvalidEnumValue;
+ }
+
+ KResourceLimit resourceLimit = KernelStatic.GetCurrentProcess().HandleTable.GetObject<KResourceLimit>(handle);
+
+ if (resourceLimit == null)
+ {
+ return KernelResult.InvalidHandle;
+ }
+
+ limitValue = resourceLimit.GetLimitValue(resource);
+
+ return KernelResult.Success;
+ }
+
+ public KernelResult GetResourceLimitCurrentValue(int handle, LimitableResource resource, out long limitValue)
+ {
+ limitValue = 0;
+
+ if (resource >= LimitableResource.Count)
+ {
+ return KernelResult.InvalidEnumValue;
+ }
+
+ KResourceLimit resourceLimit = KernelStatic.GetCurrentProcess().HandleTable.GetObject<KResourceLimit>(handle);
+
+ if (resourceLimit == null)
+ {
+ return KernelResult.InvalidHandle;
+ }
+
+ limitValue = resourceLimit.GetCurrentValue(resource);
+
+ return KernelResult.Success;
+ }
+
+ public KernelResult GetResourceLimitPeakValue(int handle, LimitableResource resource, out long peak)
+ {
+ peak = 0;
+
+ if (resource >= LimitableResource.Count)
+ {
+ return KernelResult.InvalidEnumValue;
+ }
+
+ KResourceLimit resourceLimit = KernelStatic.GetCurrentProcess().HandleTable.GetObject<KResourceLimit>(handle);
+
+ if (resourceLimit == null)
+ {
+ return KernelResult.InvalidHandle;
+ }
+
+ peak = resourceLimit.GetPeakValue(resource);
+
+ return KernelResult.Success;
+ }
+
+ public KernelResult CreateResourceLimit(out int handle)
+ {
+ KResourceLimit limit = new KResourceLimit(_context);
+
+ KProcess process = KernelStatic.GetCurrentProcess();
+
+ return process.HandleTable.GenerateHandle(limit, out handle);
+ }
+
+ public KernelResult SetResourceLimitLimitValue(int handle, LimitableResource resource, long limitValue)
+ {
+ if (resource >= LimitableResource.Count)
+ {
+ return KernelResult.InvalidEnumValue;
+ }
+
+ KResourceLimit resourceLimit = KernelStatic.GetCurrentProcess().HandleTable.GetObject<KResourceLimit>(handle);
+
+ if (resourceLimit == null)
+ {
+ return KernelResult.InvalidHandle;
+ }
+
+ return resourceLimit.SetLimitValue(resource, limitValue);
+ }
+
// Thread
public KernelResult CreateThread(