diff options
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/SupervisorCall')
-rw-r--r-- | Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs | 2 | ||||
-rw-r--r-- | Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs | 14 | ||||
-rw-r--r-- | Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallTable.cs | 40 |
3 files changed, 27 insertions, 29 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs index d9d492a5..571699d9 100644 --- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs +++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs @@ -1755,7 +1755,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall public ulong GetSystemTick() { - return KernelStatic.GetCurrentThread().Context.CntpctEl0; + return _context.TickSource.Counter; } public void Break(ulong reason) diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs index 5e795d35..cb693f59 100644 --- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs +++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs @@ -1,4 +1,4 @@ -using ARMeilleure.State; +using Ryujinx.Cpu; using Ryujinx.HLE.HOS.Kernel.Threading; using System; @@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall _syscall64 = new Syscall64(context.Syscall); } - public void SvcCall(object sender, InstExceptionEventArgs e) + public void SvcCall(IExecutionContext context, ulong address, int id) { KThread currentThread = KernelStatic.GetCurrentThread(); @@ -34,26 +34,24 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall _context.CriticalSection.Leave(); } - ExecutionContext context = (ExecutionContext)sender; - if (context.IsAarch32) { - var svcFunc = SyscallTable.SvcTable32[e.Id]; + var svcFunc = SyscallTable.SvcTable32[id]; if (svcFunc == null) { - throw new NotImplementedException($"SVC 0x{e.Id:X4} is not implemented."); + throw new NotImplementedException($"SVC 0x{id:X4} is not implemented."); } svcFunc(_syscall32, context); } else { - var svcFunc = SyscallTable.SvcTable64[e.Id]; + var svcFunc = SyscallTable.SvcTable64[id]; if (svcFunc == null) { - throw new NotImplementedException($"SVC 0x{e.Id:X4} is not implemented."); + throw new NotImplementedException($"SVC 0x{id:X4} is not implemented."); } svcFunc(_syscall64, context); diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallTable.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallTable.cs index 6e0b7010..8b7e7fb8 100644 --- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallTable.cs +++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallTable.cs @@ -1,5 +1,5 @@ -using ARMeilleure.State; using Ryujinx.Common.Logging; +using Ryujinx.Cpu; using Ryujinx.HLE.HOS.Kernel.Common; using System; using System.Collections.Generic; @@ -14,13 +14,13 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall private const int SvcFuncMaxArguments32 = 4; private const int SvcMax = 0x80; - public static Action<Syscall32, ExecutionContext>[] SvcTable32 { get; } - public static Action<Syscall64, ExecutionContext>[] SvcTable64 { get; } + public static Action<Syscall32, IExecutionContext>[] SvcTable32 { get; } + public static Action<Syscall64, IExecutionContext>[] SvcTable64 { get; } static SyscallTable() { - SvcTable32 = new Action<Syscall32, ExecutionContext>[SvcMax]; - SvcTable64 = new Action<Syscall64, ExecutionContext>[SvcMax]; + SvcTable32 = new Action<Syscall32, IExecutionContext>[SvcMax]; + SvcTable64 = new Action<Syscall64, IExecutionContext>[SvcMax]; Dictionary<int, string> svcFuncs64 = new Dictionary<int, string> { @@ -182,9 +182,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall } } - private static Action<T, ExecutionContext> GenerateMethod<T>(string svcName, int registerCleanCount) + private static Action<T, IExecutionContext> GenerateMethod<T>(string svcName, int registerCleanCount) { - Type[] argTypes = new Type[] { typeof(T), typeof(ExecutionContext) }; + Type[] argTypes = new Type[] { typeof(T), typeof(IExecutionContext) }; DynamicMethod method = new DynamicMethod(svcName, null, argTypes); @@ -292,9 +292,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall generator.Emit(OpCodes.Ldarg_1); generator.Emit(OpCodes.Ldc_I4, registerAttribute.Index); - MethodInfo info = typeof(ExecutionContext).GetMethod(nameof(ExecutionContext.GetX)); + MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.GetX)); - generator.Emit(OpCodes.Call, info); + generator.Emit(OpCodes.Callvirt, info); generator.Emit(OpCodes.Box, typeof(ulong)); @@ -339,9 +339,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall generator.Emit(OpCodes.Ldarg_1); generator.Emit(OpCodes.Ldc_I4, registerAttribute.Index); - MethodInfo info = typeof(ExecutionContext).GetMethod(nameof(ExecutionContext.GetX)); + MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.GetX)); - generator.Emit(OpCodes.Call, info); + generator.Emit(OpCodes.Callvirt, info); ConvertToArgType(argType); @@ -355,9 +355,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall generator.Emit(OpCodes.Ldarg_1); generator.Emit(OpCodes.Ldc_I4, registerAttribute.Index); - MethodInfo info = typeof(ExecutionContext).GetMethod(nameof(ExecutionContext.GetX)); + MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.GetX)); - generator.Emit(OpCodes.Call, info); + generator.Emit(OpCodes.Callvirt, info); ConvertToArgType(argType); } @@ -393,9 +393,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall ConvertToFieldType(retType); - MethodInfo info = typeof(ExecutionContext).GetMethod(nameof(ExecutionContext.SetX)); + MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.SetX)); - generator.Emit(OpCodes.Call, info); + generator.Emit(OpCodes.Callvirt, info); registerInUse |= 1u << 0; } @@ -415,9 +415,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall ConvertToFieldType(local.LocalType); - MethodInfo info = typeof(ExecutionContext).GetMethod(nameof(ExecutionContext.SetX)); + MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.SetX)); - generator.Emit(OpCodes.Call, info); + generator.Emit(OpCodes.Callvirt, info); registerInUse |= 1u << attribute.Index; } @@ -434,14 +434,14 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall generator.Emit(OpCodes.Ldc_I4, i); generator.Emit(OpCodes.Ldc_I8, 0L); - MethodInfo info = typeof(ExecutionContext).GetMethod(nameof(ExecutionContext.SetX)); + MethodInfo info = typeof(IExecutionContext).GetMethod(nameof(IExecutionContext.SetX)); - generator.Emit(OpCodes.Call, info); + generator.Emit(OpCodes.Callvirt, info); } generator.Emit(OpCodes.Ret); - return method.CreateDelegate<Action<T, ExecutionContext>>(); + return method.CreateDelegate<Action<T, IExecutionContext>>(); } private static void CheckIfTypeIsSupported(Type type, string svcName) |