mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2025-06-30 01:00:48 -07:00
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
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user