Move kernel state out of the Horizon class (#1107)
* Move kernel state from Horizon to KernelContext * Merge syscalls partial classes, split 32 and 64-bit variants * Sort usings
This commit is contained in:
parent
cd48576f58
commit
15d1cc806b
68 changed files with 3678 additions and 3570 deletions
|
@ -4,20 +4,20 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
class KAutoObject
|
||||
{
|
||||
protected Horizon System;
|
||||
protected KernelContext KernelContext;
|
||||
|
||||
private int _referenceCount;
|
||||
|
||||
public KAutoObject(Horizon system)
|
||||
public KAutoObject(KernelContext context)
|
||||
{
|
||||
System = system;
|
||||
KernelContext = context;
|
||||
|
||||
_referenceCount = 1;
|
||||
}
|
||||
|
||||
public virtual KernelResult SetName(string name)
|
||||
{
|
||||
if (!System.AutoObjectNames.TryAdd(name, this))
|
||||
if (!KernelContext.AutoObjectNames.TryAdd(name, this))
|
||||
{
|
||||
return KernelResult.InvalidState;
|
||||
}
|
||||
|
@ -25,9 +25,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
return KernelResult.Success;
|
||||
}
|
||||
|
||||
public static KernelResult RemoveName(Horizon system, string name)
|
||||
public static KernelResult RemoveName(KernelContext context, string name)
|
||||
{
|
||||
if (!system.AutoObjectNames.TryRemove(name, out _))
|
||||
if (!context.AutoObjectNames.TryRemove(name, out _))
|
||||
{
|
||||
return KernelResult.NotFound;
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
return KernelResult.Success;
|
||||
}
|
||||
|
||||
public static KAutoObject FindNamedObject(Horizon system, string name)
|
||||
public static KAutoObject FindNamedObject(KernelContext context, string name)
|
||||
{
|
||||
if (system.AutoObjectNames.TryGetValue(name, out KAutoObject obj))
|
||||
if (context.AutoObjectNames.TryGetValue(name, out KAutoObject obj))
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
|
|
@ -8,17 +8,17 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
private const int Time10SecondsMs = 10000;
|
||||
|
||||
private long[] _current;
|
||||
private long[] _limit;
|
||||
private long[] _available;
|
||||
private readonly long[] _current;
|
||||
private readonly long[] _limit;
|
||||
private readonly long[] _available;
|
||||
|
||||
private object _lockObj;
|
||||
private readonly object _lockObj;
|
||||
|
||||
private LinkedList<KThread> _waitingThreads;
|
||||
private readonly LinkedList<KThread> _waitingThreads;
|
||||
|
||||
private int _waitingThreadsCount;
|
||||
|
||||
public KResourceLimit(Horizon system) : base(system)
|
||||
public KResourceLimit(KernelContext context) : base(context)
|
||||
{
|
||||
_current = new long[(int)LimitableResource.Count];
|
||||
_limit = new long[(int)LimitableResource.Count];
|
||||
|
@ -57,7 +57,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
_waitingThreadsCount++;
|
||||
|
||||
KConditionVariable.Wait(System, _waitingThreads, _lockObj, timeout);
|
||||
KConditionVariable.Wait(KernelContext, _waitingThreads, _lockObj, timeout);
|
||||
|
||||
_waitingThreadsCount--;
|
||||
|
||||
|
@ -101,7 +101,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
|
||||
if (_waitingThreadsCount > 0)
|
||||
{
|
||||
KConditionVariable.NotifyAll(System, _waitingThreads);
|
||||
KConditionVariable.NotifyAll(KernelContext, _waitingThreads);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
public LinkedList<KThread> WaitingThreads { get; }
|
||||
|
||||
public KSynchronizationObject(Horizon system) : base(system)
|
||||
public KSynchronizationObject(KernelContext context) : base(context)
|
||||
{
|
||||
WaitingThreads = new LinkedList<KThread>();
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
|
||||
public virtual void Signal()
|
||||
{
|
||||
System.Synchronization.SignalObject(this);
|
||||
KernelContext.Synchronization.SignalObject(this);
|
||||
}
|
||||
|
||||
public virtual bool IsSignaled()
|
||||
|
|
|
@ -5,9 +5,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
static class KernelTransfer
|
||||
{
|
||||
public static bool UserToKernelInt32(Horizon system, ulong address, out int value)
|
||||
public static bool UserToKernelInt32(KernelContext context, ulong address, out int value)
|
||||
{
|
||||
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
|
||||
KProcess currentProcess = context.Scheduler.GetCurrentProcess();
|
||||
|
||||
if (currentProcess.CpuMemory.IsMapped(address) &&
|
||||
currentProcess.CpuMemory.IsMapped(address + 3))
|
||||
|
@ -22,9 +22,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
return false;
|
||||
}
|
||||
|
||||
public static bool UserToKernelInt32Array(Horizon system, ulong address, int[] values)
|
||||
public static bool UserToKernelInt32Array(KernelContext context, ulong address, int[] values)
|
||||
{
|
||||
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
|
||||
KProcess currentProcess = context.Scheduler.GetCurrentProcess();
|
||||
|
||||
for (int index = 0; index < values.Length; index++, address += 4)
|
||||
{
|
||||
|
@ -42,9 +42,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
return true;
|
||||
}
|
||||
|
||||
public static bool UserToKernelString(Horizon system, ulong address, int size, out string value)
|
||||
public static bool UserToKernelString(KernelContext context, ulong address, int size, out string value)
|
||||
{
|
||||
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
|
||||
KProcess currentProcess = context.Scheduler.GetCurrentProcess();
|
||||
|
||||
if (currentProcess.CpuMemory.IsMapped(address) &&
|
||||
currentProcess.CpuMemory.IsMapped(address + (ulong)size - 1))
|
||||
|
@ -59,9 +59,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
return false;
|
||||
}
|
||||
|
||||
public static bool KernelToUserInt32(Horizon system, ulong address, int value)
|
||||
public static bool KernelToUserInt32(KernelContext context, ulong address, int value)
|
||||
{
|
||||
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
|
||||
KProcess currentProcess = context.Scheduler.GetCurrentProcess();
|
||||
|
||||
if (currentProcess.CpuMemory.IsMapped(address) &&
|
||||
currentProcess.CpuMemory.IsMapped(address + 3))
|
||||
|
@ -74,9 +74,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
return false;
|
||||
}
|
||||
|
||||
public static bool KernelToUserInt64(Horizon system, ulong address, long value)
|
||||
public static bool KernelToUserInt64(KernelContext context, ulong address, long value)
|
||||
{
|
||||
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
|
||||
KProcess currentProcess = context.Scheduler.GetCurrentProcess();
|
||||
|
||||
if (currentProcess.CpuMemory.IsMapped(address) &&
|
||||
currentProcess.CpuMemory.IsMapped(address + 7))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue