diff options
| author | Mary <me@thog.eu> | 2021-10-24 01:40:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-24 01:40:13 +0200 |
| commit | dc837c00428b6f67079e362631fe7fc503ceeacb (patch) | |
| tree | caf888404363bb8b2d7d547c7273a78b1f206a99 /Ryujinx.HLE/HOS/Kernel/Common | |
| parent | c94d47cc408910af8342d47886937dd9feb32f4d (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/Common')
| -rw-r--r-- | Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs b/Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs index 64b964da..7caff21a 100644 --- a/Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs +++ b/Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs @@ -11,6 +11,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common private readonly long[] _current; private readonly long[] _limit; private readonly long[] _current2; + private readonly long[] _peak; private readonly object _lock; @@ -23,6 +24,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common _current = new long[(int)LimitableResource.Count]; _limit = new long[(int)LimitableResource.Count]; _current2 = new long[(int)LimitableResource.Count]; + _peak = new long[(int)LimitableResource.Count]; _lock = new object(); @@ -79,6 +81,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Common _current[index] = newCurrent; _current2[index] += amount; + if (_current[index] > _peak[index]) + { + _peak[index] = _current[index]; + } + success = true; } } @@ -122,6 +129,36 @@ namespace Ryujinx.HLE.HOS.Kernel.Common } } + public long GetCurrentValue(LimitableResource resource) + { + int index = GetIndex(resource); + + lock (_lock) + { + return _current[index]; + } + } + + public long GetLimitValue(LimitableResource resource) + { + int index = GetIndex(resource); + + lock (_lock) + { + return _limit[index]; + } + } + + public long GetPeakValue(LimitableResource resource) + { + int index = GetIndex(resource); + + lock (_lock) + { + return _peak[index]; + } + } + public KernelResult SetLimitValue(LimitableResource resource, long limit) { int index = GetIndex(resource); @@ -131,6 +168,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common if (_current[index] <= limit) { _limit[index] = limit; + _peak[index] = _current[index]; return KernelResult.Success; } |
