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:
gdkchan 2020-05-04 00:41:29 -03:00 committed by GitHub
parent cd48576f58
commit 15d1cc806b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
68 changed files with 3678 additions and 3570 deletions

View file

@ -5,11 +5,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{
class KSynchronization
{
private Horizon _system;
private KernelContext _context;
public KSynchronization(Horizon system)
public KSynchronization(KernelContext context)
{
_system = system;
_context = context;
}
public KernelResult WaitFor(KSynchronizationObject[] syncObjs, long timeout, out int handleIndex)
@ -18,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
KernelResult result = KernelResult.TimedOut;
_system.CriticalSection.Enter();
_context.CriticalSection.Enter();
// Check if objects are already signaled before waiting.
for (int index = 0; index < syncObjs.Length; index++)
@ -30,19 +30,19 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
handleIndex = index;
_system.CriticalSection.Leave();
_context.CriticalSection.Leave();
return KernelResult.Success;
}
if (timeout == 0)
{
_system.CriticalSection.Leave();
_context.CriticalSection.Leave();
return result;
}
KThread currentThread = _system.Scheduler.GetCurrentThread();
KThread currentThread = _context.Scheduler.GetCurrentThread();
if (currentThread.ShallBeTerminated ||
currentThread.SchedFlags == ThreadSchedState.TerminationPending)
@ -72,19 +72,19 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
if (timeout > 0)
{
_system.TimeManager.ScheduleFutureInvocation(currentThread, timeout);
_context.TimeManager.ScheduleFutureInvocation(currentThread, timeout);
}
_system.CriticalSection.Leave();
_context.CriticalSection.Leave();
currentThread.WaitingSync = false;
if (timeout > 0)
{
_system.TimeManager.UnscheduleFutureInvocation(currentThread);
_context.TimeManager.UnscheduleFutureInvocation(currentThread);
}
_system.CriticalSection.Enter();
_context.CriticalSection.Enter();
result = currentThread.ObjSyncResult;
@ -101,14 +101,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
}
}
_system.CriticalSection.Leave();
_context.CriticalSection.Leave();
return result;
}
public void SignalObject(KSynchronizationObject syncObj)
{
_system.CriticalSection.Enter();
_context.CriticalSection.Enter();
if (syncObj.IsSignaled())
{
@ -130,7 +130,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
}
}
_system.CriticalSection.Leave();
_context.CriticalSection.Leave();
}
}
}