Update 32 bits syscalls to match 64 bits implementation (#892)

* Implement 32 bits syscalls

Co-authored-by: riperiperi <rhy3756547@hotmail.com>

Implement all 32 bits counterparts of the 64 bits syscalls we currently
have.

* Add FlushProcessDataCache32

* Address jd's comments
This commit is contained in:
Thog 2020-01-19 23:21:53 +01:00 committed by gdkchan
parent 81cca88bcd
commit d0f15cb0b1
6 changed files with 481 additions and 1 deletions

View file

@ -19,6 +19,17 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return CreateThread(entrypoint, argsPtr, stackTop, priority, cpuCore, out handle);
}
public KernelResult CreateThread32(
[R(1)] uint entrypoint,
[R(2)] uint argsPtr,
[R(3)] uint stackTop,
[R(0)] int priority,
[R(4)] int cpuCore,
[R(1)] out int handle)
{
return CreateThread(entrypoint, argsPtr, stackTop, priority, cpuCore, out handle);
}
private KernelResult CreateThread(
ulong entrypoint,
ulong argsPtr,
@ -83,6 +94,11 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return StartThread(handle);
}
public KernelResult StartThread32([R(0)] int handle)
{
return StartThread(handle);
}
private KernelResult StartThread(int handle)
{
KThread thread = _process.HandleTable.GetKThread(handle);
@ -113,6 +129,11 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
ExitThread();
}
public void ExitThread32()
{
ExitThread();
}
private void ExitThread()
{
KThread currentThread = _system.Scheduler.GetCurrentThread();
@ -127,6 +148,13 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
SleepThread(timeout);
}
public void SleepThread32([R(0)] uint timeoutLow, [R(1)] uint timeoutHigh)
{
long timeout = (long)(timeoutLow | ((ulong)timeoutHigh << 32));
SleepThread(timeout);
}
private void SleepThread(long timeout)
{
KThread currentThread = _system.Scheduler.GetCurrentThread();
@ -151,6 +179,11 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return GetThreadPriority(handle, out priority);
}
public KernelResult GetThreadPriority32([R(1)] int handle, [R(1)] out int priority)
{
return GetThreadPriority(handle, out priority);
}
private KernelResult GetThreadPriority(int handle, out int priority)
{
KThread thread = _process.HandleTable.GetKThread(handle);
@ -174,6 +207,11 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return SetThreadPriority(handle, priority);
}
public KernelResult SetThreadPriority32([R(0)] int handle, [R(1)] int priority)
{
return SetThreadPriority(handle, priority);
}
public KernelResult SetThreadPriority(int handle, int priority)
{
// TODO: NPDM check.
@ -195,6 +233,16 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return GetThreadCoreMask(handle, out preferredCore, out affinityMask);
}
public KernelResult GetThreadCoreMask32([R(2)] int handle, [R(1)] out int preferredCore, [R(2)] out int affinityMaskLow, [R(3)] out int affinityMaskHigh)
{
KernelResult result = GetThreadCoreMask(handle, out preferredCore, out long affinityMask);
affinityMaskLow = (int)(affinityMask >> 32);
affinityMaskHigh = (int)(affinityMask & uint.MaxValue);
return result;
}
private KernelResult GetThreadCoreMask(int handle, out int preferredCore, out long affinityMask)
{
KThread thread = _process.HandleTable.GetKThread(handle);
@ -220,6 +268,13 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return SetThreadCoreMask(handle, preferredCore, affinityMask);
}
public KernelResult SetThreadCoreMask32([R(0)] int handle, [R(1)] int preferredCore, [R(2)] uint affinityMaskLow, [R(3)] uint affinityMaskHigh)
{
long affinityMask = (long)(affinityMaskLow | ((ulong)affinityMaskHigh << 32));
return SetThreadCoreMask(handle, preferredCore, affinityMask);
}
private KernelResult SetThreadCoreMask(int handle, int preferredCore, long affinityMask)
{
KProcess currentProcess = _system.Scheduler.GetCurrentProcess();
@ -271,11 +326,28 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return _system.Scheduler.GetCurrentThread().CurrentCore;
}
public int GetCurrentProcessorNumber32()
{
return _system.Scheduler.GetCurrentThread().CurrentCore;
}
public KernelResult GetThreadId64([R(1)] int handle, [R(1)] out long threadUid)
{
return GetThreadId(handle, out threadUid);
}
public KernelResult GetThreadId32([R(1)] int handle, [R(1)] out uint threadUidLow, [R(2)] out uint threadUidHigh)
{
long threadUid;
KernelResult result = GetThreadId(handle, out threadUid);
threadUidLow = (uint)(threadUid >> 32);
threadUidHigh = (uint)(threadUid & uint.MaxValue);
return result;
}
private KernelResult GetThreadId(int handle, out long threadUid)
{
KThread thread = _process.HandleTable.GetKThread(handle);
@ -299,6 +371,11 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return SetThreadActivity(handle, pause);
}
public KernelResult SetThreadActivity32([R(0)] int handle, [R(1)] bool pause)
{
return SetThreadActivity(handle, pause);
}
private KernelResult SetThreadActivity(int handle, bool pause)
{
KThread thread = _process.HandleTable.GetObject<KThread>(handle);
@ -326,6 +403,11 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return GetThreadContext3(address, handle);
}
public KernelResult GetThreadContext332([R(0)] uint address, [R(1)] int handle)
{
return GetThreadContext3(address, handle);
}
private KernelResult GetThreadContext3(ulong address, int handle)
{
KProcess currentProcess = _system.Scheduler.GetCurrentProcess();