Rewrite SVC handler using source generators rather than IL emit (#3371)

* Implement syscall handlers using a source generator

* Copy FlushProcessDataCache implementation to Syscall since it was only implemented on Syscall32

* Fix wrong argument order in some syscalls

* Delete old Reflection.Emit based syscall handling code

* Improvements to the code generation

* ControlCodeMemory address and size is always 64-bit
This commit is contained in:
gdkchan 2022-05-31 17:12:46 -03:00 committed by GitHub
parent 0c87bf9ea4
commit e546e5933f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 845 additions and 1553 deletions

View file

@ -12,6 +12,7 @@ using System.Threading;
namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
{
[SvcImpl]
class Syscall
{
private readonly KernelContext _context;
@ -23,6 +24,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
// Process
[Svc(0x24)]
public KernelResult GetProcessId(out ulong pid, int handle)
{
KProcess currentProcess = KernelStatic.GetCurrentProcess();
@ -167,9 +169,18 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
[Svc(0x5f)]
public KernelResult FlushProcessDataCache(int processHandle, ulong address, ulong size)
{
// FIXME: This needs to be implemented as ARMv7 doesn't have any way to do cache maintenance operations on EL0.
// As we don't support (and don't actually need) to flush the cache, this is stubbed.
return KernelResult.Success;
}
// IPC
public KernelResult ConnectToNamedPort(out int handle, ulong namePtr)
[Svc(0x1f)]
public KernelResult ConnectToNamedPort(out int handle, [PointerSized] ulong namePtr)
{
handle = 0;
@ -222,6 +233,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(0x21)]
public KernelResult SendSyncRequest(int handle)
{
KProcess currentProcess = KernelStatic.GetCurrentProcess();
@ -236,7 +248,11 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return session.SendSyncRequest();
}
public KernelResult SendSyncRequestWithUserBuffer(ulong messagePtr, ulong messageSize, int handle)
[Svc(0x22)]
public KernelResult SendSyncRequestWithUserBuffer(
[PointerSized] ulong messagePtr,
[PointerSized] ulong messageSize,
int handle)
{
if (!PageAligned(messagePtr))
{
@ -283,7 +299,12 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
public KernelResult SendAsyncRequestWithUserBuffer(out int doneEventHandle, ulong messagePtr, ulong messageSize, int handle)
[Svc(0x23)]
public KernelResult SendAsyncRequestWithUserBuffer(
out int doneEventHandle,
[PointerSized] ulong messagePtr,
[PointerSized] ulong messageSize,
int handle)
{
doneEventHandle = 0;
@ -353,11 +374,12 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(0x40)]
public KernelResult CreateSession(
out int serverSessionHandle,
out int clientSessionHandle,
bool isLight,
ulong namePtr)
[PointerSized] ulong namePtr)
{
serverSessionHandle = 0;
clientSessionHandle = 0;
@ -419,6 +441,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(0x41)]
public KernelResult AcceptSession(out int sessionHandle, int portHandle)
{
sessionHandle = 0;
@ -470,9 +493,10 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(0x43)]
public KernelResult ReplyAndReceive(
out int handleIndex,
ulong handlesPtr,
[PointerSized] ulong handlesPtr,
int handlesCount,
int replyTargetHandle,
long timeout)
@ -575,11 +599,12 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(0x44)]
public KernelResult ReplyAndReceiveWithUserBuffer(
out int handleIndex,
ulong handlesPtr,
ulong messagePtr,
ulong messageSize,
[PointerSized] ulong messagePtr,
[PointerSized] ulong messageSize,
[PointerSized] ulong handlesPtr,
int handlesCount,
int replyTargetHandle,
long timeout)
@ -679,12 +704,13 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(0x70)]
public KernelResult CreatePort(
out int serverPortHandle,
out int clientPortHandle,
int maxSessions,
bool isLight,
ulong namePtr)
[PointerSized] ulong namePtr)
{
serverPortHandle = clientPortHandle = 0;
@ -714,7 +740,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
public KernelResult ManageNamedPort(out int handle, ulong namePtr, int maxSessions)
[Svc(0x71)]
public KernelResult ManageNamedPort(out int handle, [PointerSized] ulong namePtr, int maxSessions)
{
handle = 0;
@ -766,6 +793,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(0x72)]
public KernelResult ConnectToPort(out int clientSessionHandle, int clientPortHandle)
{
clientSessionHandle = 0;
@ -819,7 +847,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
// Memory
public KernelResult SetHeapSize(out ulong address, ulong size)
[Svc(1)]
public KernelResult SetHeapSize([PointerSized] out ulong address, [PointerSized] ulong size)
{
if ((size & 0xfffffffe001fffff) != 0)
{
@ -833,7 +862,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return process.MemoryManager.SetHeapSize(size, out address);
}
public KernelResult SetMemoryPermission(ulong address, ulong size, KMemoryPermission permission)
[Svc(2)]
public KernelResult SetMemoryPermission([PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission)
{
if (!PageAligned(address))
{
@ -865,9 +895,10 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return currentProcess.MemoryManager.SetMemoryPermission(address, size, permission);
}
[Svc(3)]
public KernelResult SetMemoryAttribute(
ulong address,
ulong size,
[PointerSized] ulong address,
[PointerSized] ulong size,
MemoryAttribute attributeMask,
MemoryAttribute attributeValue)
{
@ -905,7 +936,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
public KernelResult MapMemory(ulong dst, ulong src, ulong size)
[Svc(4)]
public KernelResult MapMemory([PointerSized] ulong dst, [PointerSized] ulong src, [PointerSized] ulong size)
{
if (!PageAligned(src | dst))
{
@ -941,7 +973,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return process.MemoryManager.Map(dst, src, size);
}
public KernelResult UnmapMemory(ulong dst, ulong src, ulong size)
[Svc(5)]
public KernelResult UnmapMemory([PointerSized] ulong dst, [PointerSized] ulong src, [PointerSized] ulong size)
{
if (!PageAligned(src | dst))
{
@ -977,7 +1010,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return process.MemoryManager.Unmap(dst, src, size);
}
public KernelResult QueryMemory(ulong infoPtr, out ulong pageInfo, ulong address)
[Svc(6)]
public KernelResult QueryMemory([PointerSized] ulong infoPtr, [PointerSized] out ulong pageInfo, [PointerSized] ulong address)
{
KernelResult result = QueryMemory(out MemoryInfo info, out pageInfo, address);
@ -1011,7 +1045,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
public KernelResult MapSharedMemory(int handle, ulong address, ulong size, KMemoryPermission permission)
[Svc(0x13)]
public KernelResult MapSharedMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission)
{
if (!PageAligned(address))
{
@ -1057,7 +1092,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
permission);
}
public KernelResult UnmapSharedMemory(int handle, ulong address, ulong size)
[Svc(0x14)]
public KernelResult UnmapSharedMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size)
{
if (!PageAligned(address))
{
@ -1097,7 +1133,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
currentProcess);
}
public KernelResult CreateTransferMemory(out int handle, ulong address, ulong size, KMemoryPermission permission)
[Svc(0x15)]
public KernelResult CreateTransferMemory(out int handle, [PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission)
{
handle = 0;
@ -1160,7 +1197,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
public KernelResult MapTransferMemory(int handle, ulong address, ulong size, KMemoryPermission permission)
[Svc(0x51)]
public KernelResult MapTransferMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission)
{
if (!PageAligned(address))
{
@ -1206,7 +1244,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
permission);
}
public KernelResult UnmapTransferMemory(int handle, ulong address, ulong size)
[Svc(0x52)]
public KernelResult UnmapTransferMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size)
{
if (!PageAligned(address))
{
@ -1246,7 +1285,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
currentProcess);
}
public KernelResult MapPhysicalMemory(ulong address, ulong size)
[Svc(0x2c)]
public KernelResult MapPhysicalMemory([PointerSized] ulong address, [PointerSized] ulong size)
{
if (!PageAligned(address))
{
@ -1281,7 +1321,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return process.MemoryManager.MapPhysicalMemory(address, size);
}
public KernelResult UnmapPhysicalMemory(ulong address, ulong size)
[Svc(0x2d)]
public KernelResult UnmapPhysicalMemory([PointerSized] ulong address, [PointerSized] ulong size)
{
if (!PageAligned(address))
{
@ -1316,7 +1357,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return process.MemoryManager.UnmapPhysicalMemory(address, size);
}
public KernelResult CreateCodeMemory(ulong address, ulong size, out int handle)
[Svc(0x4b)]
public KernelResult CreateCodeMemory(out int handle, [PointerSized] ulong address, [PointerSized] ulong size)
{
handle = 0;
@ -1356,7 +1398,13 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return currentProcess.HandleTable.GenerateHandle(codeMemory, out handle);
}
public KernelResult ControlCodeMemory(int handle, CodeMemoryOperation op, ulong address, ulong size, KMemoryPermission permission)
[Svc(0x4c)]
public KernelResult ControlCodeMemory(
int handle,
CodeMemoryOperation op,
ulong address,
ulong size,
KMemoryPermission permission)
{
KProcess currentProcess = KernelStatic.GetCurrentProcess();
@ -1428,7 +1476,12 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
}
}
public KernelResult SetProcessMemoryPermission(int handle, ulong src, ulong size, KMemoryPermission permission)
[Svc(0x73)]
public KernelResult SetProcessMemoryPermission(
int handle,
[PointerSized] ulong src,
[PointerSized] ulong size,
KMemoryPermission permission)
{
if (!PageAligned(src))
{
@ -1465,7 +1518,12 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return targetProcess.MemoryManager.SetProcessMemoryPermission(src, size, permission);
}
public KernelResult MapProcessMemory(ulong dst, int handle, ulong src, ulong size)
[Svc(0x74)]
public KernelResult MapProcessMemory(
[PointerSized] ulong dst,
int handle,
ulong src,
[PointerSized] ulong size)
{
if (!PageAligned(src) || !PageAligned(dst))
{
@ -1517,7 +1575,12 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return dstProcess.MemoryManager.MapPages(dst, pageList, MemoryState.ProcessMemory, KMemoryPermission.ReadAndWrite);
}
public KernelResult UnmapProcessMemory(ulong dst, int handle, ulong src, ulong size)
[Svc(0x75)]
public KernelResult UnmapProcessMemory(
[PointerSized] ulong dst,
int handle,
ulong src,
[PointerSized] ulong size)
{
if (!PageAligned(src) || !PageAligned(dst))
{
@ -1558,6 +1621,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
[Svc(0x77)]
public KernelResult MapProcessCodeMemory(int handle, ulong dst, ulong src, ulong size)
{
if (!PageAligned(dst) || !PageAligned(src))
@ -1595,6 +1659,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return targetProcess.MemoryManager.MapProcessCodeMemory(dst, src, size);
}
[Svc(0x78)]
public KernelResult UnmapProcessCodeMemory(int handle, ulong dst, ulong src, ulong size)
{
if (!PageAligned(dst) || !PageAligned(src))
@ -1639,6 +1704,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
// System
[Svc(0x7b)]
public KernelResult TerminateProcess(int handle)
{
KProcess process = KernelStatic.GetCurrentProcess();
@ -1668,11 +1734,13 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(7)]
public void ExitProcess()
{
KernelStatic.GetCurrentProcess().TerminateCurrentProcess();
}
[Svc(0x11)]
public KernelResult SignalEvent(int handle)
{
KProcess process = KernelStatic.GetCurrentProcess();
@ -1695,6 +1763,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(0x12)]
public KernelResult ClearEvent(int handle)
{
KernelResult result;
@ -1717,6 +1786,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(0x16)]
public KernelResult CloseHandle(int handle)
{
KProcess currentProcess = KernelStatic.GetCurrentProcess();
@ -1724,6 +1794,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return currentProcess.HandleTable.CloseHandle(handle) ? KernelResult.Success : KernelResult.InvalidHandle;
}
[Svc(0x17)]
public KernelResult ResetSignal(int handle)
{
KProcess currentProcess = KernelStatic.GetCurrentProcess();
@ -1753,11 +1824,13 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(0x1e)]
public ulong GetSystemTick()
{
return _context.TickSource.Counter;
}
[Svc(0x26)]
public void Break(ulong reason)
{
KThread currentThread = KernelStatic.GetCurrentThread();
@ -1784,7 +1857,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
}
}
public void OutputDebugString(ulong strPtr, ulong size)
[Svc(0x27)]
public void OutputDebugString([PointerSized] ulong strPtr, [PointerSized] ulong size)
{
KProcess process = KernelStatic.GetCurrentProcess();
@ -1793,6 +1867,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
Logger.Warning?.Print(LogClass.KernelSvc, str);
}
[Svc(0x29)]
public KernelResult GetInfo(out ulong value, InfoType id, int handle, long subId)
{
value = 0;
@ -2038,6 +2113,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
[Svc(0x45)]
public KernelResult CreateEvent(out int wEventHandle, out int rEventHandle)
{
KEvent Event = new KEvent(_context);
@ -2063,7 +2139,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
public KernelResult GetProcessList(out int count, ulong address, int maxCount)
[Svc(0x65)]
public KernelResult GetProcessList(out int count, [PointerSized] ulong address, int maxCount)
{
count = 0;
@ -2112,6 +2189,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
[Svc(0x6f)]
public KernelResult GetSystemInfo(out long value, uint id, int handle, long subId)
{
value = 0;
@ -2168,6 +2246,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
[Svc(0x30)]
public KernelResult GetResourceLimitLimitValue(out long limitValue, int handle, LimitableResource resource)
{
limitValue = 0;
@ -2189,6 +2268,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
[Svc(0x31)]
public KernelResult GetResourceLimitCurrentValue(out long limitValue, int handle, LimitableResource resource)
{
limitValue = 0;
@ -2210,6 +2290,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
[Svc(0x37)]
public KernelResult GetResourceLimitPeakValue(out long peak, int handle, LimitableResource resource)
{
peak = 0;
@ -2231,6 +2312,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
[Svc(0x7d)]
public KernelResult CreateResourceLimit(out int handle)
{
KResourceLimit limit = new KResourceLimit(_context);
@ -2240,6 +2322,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return process.HandleTable.GenerateHandle(limit, out handle);
}
[Svc(0x7e)]
public KernelResult SetResourceLimitLimitValue(int handle, LimitableResource resource, long limitValue)
{
if (resource >= LimitableResource.Count)
@ -2259,11 +2342,12 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
// Thread
[Svc(8)]
public KernelResult CreateThread(
out int handle,
ulong entrypoint,
ulong argsPtr,
ulong stackTop,
[PointerSized] ulong entrypoint,
[PointerSized] ulong argsPtr,
[PointerSized] ulong stackTop,
int priority,
int cpuCore)
{
@ -2320,6 +2404,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(9)]
public KernelResult StartThread(int handle)
{
KProcess process = KernelStatic.GetCurrentProcess();
@ -2347,6 +2432,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
}
}
[Svc(0xa)]
public void ExitThread()
{
KThread currentThread = KernelStatic.GetCurrentThread();
@ -2354,6 +2440,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
currentThread.Exit();
}
[Svc(0xb)]
public void SleepThread(long timeout)
{
if (timeout < 1)
@ -2371,6 +2458,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
}
}
[Svc(0xc)]
public KernelResult GetThreadPriority(out int priority, int handle)
{
KProcess process = KernelStatic.GetCurrentProcess();
@ -2391,6 +2479,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
}
}
[Svc(0xd)]
public KernelResult SetThreadPriority(int handle, int priority)
{
// TODO: NPDM check.
@ -2409,6 +2498,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
[Svc(0xe)]
public KernelResult GetThreadCoreMask(out int preferredCore, out ulong affinityMask, int handle)
{
KProcess process = KernelStatic.GetCurrentProcess();
@ -2431,6 +2521,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
}
}
[Svc(0xf)]
public KernelResult SetThreadCoreMask(int handle, int preferredCore, ulong affinityMask)
{
KProcess currentProcess = KernelStatic.GetCurrentProcess();
@ -2479,11 +2570,13 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return thread.SetCoreAndAffinityMask(preferredCore, affinityMask);
}
[Svc(0x10)]
public int GetCurrentProcessorNumber()
{
return KernelStatic.GetCurrentThread().CurrentCore;
}
[Svc(0x25)]
public KernelResult GetThreadId(out ulong threadUid, int handle)
{
KProcess process = KernelStatic.GetCurrentProcess();
@ -2504,6 +2597,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
}
}
[Svc(0x32)]
public KernelResult SetThreadActivity(int handle, bool pause)
{
KProcess process = KernelStatic.GetCurrentProcess();
@ -2528,7 +2622,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return thread.SetActivity(pause);
}
public KernelResult GetThreadContext3(ulong address, int handle)
[Svc(0x33)]
public KernelResult GetThreadContext3([PointerSized] ulong address, int handle)
{
KProcess currentProcess = KernelStatic.GetCurrentProcess();
KThread currentThread = KernelStatic.GetCurrentThread();
@ -2564,7 +2659,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
// Thread synchronization
public KernelResult WaitSynchronization(out int handleIndex, ulong handlesPtr, int handlesCount, long timeout)
[Svc(0x18)]
public KernelResult WaitSynchronization(out int handleIndex, [PointerSized] ulong handlesPtr, int handlesCount, long timeout)
{
handleIndex = 0;
@ -2653,6 +2749,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
[Svc(0x19)]
public KernelResult CancelSynchronization(int handle)
{
KProcess process = KernelStatic.GetCurrentProcess();
@ -2669,7 +2766,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
public KernelResult ArbitrateLock(int ownerHandle, ulong mutexAddress, int requesterHandle)
[Svc(0x1a)]
public KernelResult ArbitrateLock(int ownerHandle, [PointerSized] ulong mutexAddress, int requesterHandle)
{
if (IsPointingInsideKernel(mutexAddress))
{
@ -2686,7 +2784,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return currentProcess.AddressArbiter.ArbitrateLock(ownerHandle, mutexAddress, requesterHandle);
}
public KernelResult ArbitrateUnlock(ulong mutexAddress)
[Svc(0x1b)]
public KernelResult ArbitrateUnlock([PointerSized] ulong mutexAddress)
{
if (IsPointingInsideKernel(mutexAddress))
{
@ -2703,9 +2802,10 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return currentProcess.AddressArbiter.ArbitrateUnlock(mutexAddress);
}
[Svc(0x1c)]
public KernelResult WaitProcessWideKeyAtomic(
ulong mutexAddress,
ulong condVarAddress,
[PointerSized] ulong mutexAddress,
[PointerSized] ulong condVarAddress,
int handle,
long timeout)
{
@ -2733,7 +2833,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
timeout);
}
public KernelResult SignalProcessWideKey(ulong address, int count)
[Svc(0x1d)]
public KernelResult SignalProcessWideKey([PointerSized] ulong address, int count)
{
KProcess currentProcess = KernelStatic.GetCurrentProcess();
@ -2742,7 +2843,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
public KernelResult WaitForAddress(ulong address, ArbitrationType type, int value, long timeout)
[Svc(0x34)]
public KernelResult WaitForAddress([PointerSized] ulong address, ArbitrationType type, int value, long timeout)
{
if (IsPointingInsideKernel(address))
{
@ -2773,7 +2875,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
};
}
public KernelResult SignalToAddress(ulong address, SignalType type, int value, int count)
[Svc(0x35)]
public KernelResult SignalToAddress([PointerSized] ulong address, SignalType type, int value, int count)
{
if (IsPointingInsideKernel(address))
{
@ -2799,6 +2902,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
};
}
[Svc(0x36)]
public KernelResult SynchronizePreemptionState()
{
KernelStatic.GetCurrentThread().SynchronizePreemptionState();
@ -2806,12 +2910,12 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.Success;
}
private bool IsPointingInsideKernel(ulong address)
private static bool IsPointingInsideKernel(ulong address)
{
return (address + 0x1000000000) < 0xffffff000;
}
private bool IsAddressNotWordAligned(ulong address)
private static bool IsAddressNotWordAligned(ulong address)
{
return (address & 3) != 0;
}