diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcHandler.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcHandler.cs index 0bf5e5fa3d..d5698e2bc5 100644 --- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcHandler.cs +++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcHandler.cs @@ -20,15 +20,15 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall public void SvcCall(object sender, InstExceptionEventArgs e) { - Action svcFunc = SvcTable.GetSvcFunc(e.Id); + ExecutionContext context = (ExecutionContext)sender; + + Action svcFunc = context.IsAarch32 ? SvcTable.SvcTable32[e.Id] : SvcTable.SvcTable64[e.Id]; if (svcFunc == null) { throw new NotImplementedException($"SVC 0x{e.Id:X4} is not implemented."); } - ExecutionContext context = (ExecutionContext)sender; - svcFunc(this, context); PostSvcHandler(); diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcTable.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcTable.cs index 03e5b94eef..2326b630a9 100644 --- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcTable.cs +++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcTable.cs @@ -13,14 +13,17 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall { private const int SvcFuncMaxArguments64 = 8; private const int SvcFuncMaxArguments32 = 4; + private const int SvcMax = 0x80; - private static Dictionary _svcFuncs64; - - private static Action[] _svcTable64; + public static Action[] SvcTable32 { get; } + public static Action[] SvcTable64 { get; } static SvcTable() { - _svcFuncs64 = new Dictionary + SvcTable32 = new Action[SvcMax]; + SvcTable64 = new Action[SvcMax]; + + Dictionary svcFuncs64 = new Dictionary { { 0x01, nameof(SvcHandler.SetHeapSize64) }, { 0x03, nameof(SvcHandler.SetMemoryAttribute64) }, @@ -80,22 +83,20 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall { 0x7B, nameof(SvcHandler.TerminateProcess64) } }; - _svcTable64 = new Action[0x80]; - } - - public static Action GetSvcFunc(int svcId) - { - if (_svcTable64[svcId] != null) + foreach (KeyValuePair value in svcFuncs64) { - return _svcTable64[svcId]; + SvcTable64[value.Key] = GenerateMethod(value.Value, SvcFuncMaxArguments64); } - if (_svcFuncs64.TryGetValue(svcId, out string svcName)) + Dictionary svcFuncs32 = new Dictionary { - return _svcTable64[svcId] = GenerateMethod(svcName, SvcFuncMaxArguments64); - } + // TODO + }; - return null; + foreach (KeyValuePair value in svcFuncs32) + { + SvcTable32[value.Key] = GenerateMethod(value.Value, SvcFuncMaxArguments32); + } } private static Action GenerateMethod(string svcName, int registerCleanCount)