Pregenerate all SVC handler
Also clean up + 32 bits code path
This commit is contained in:
parent
c3a00fe08e
commit
4e81df0e5c
2 changed files with 19 additions and 18 deletions
|
@ -20,15 +20,15 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||||
|
|
||||||
public void SvcCall(object sender, InstExceptionEventArgs e)
|
public void SvcCall(object sender, InstExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
Action<SvcHandler, ExecutionContext> svcFunc = SvcTable.GetSvcFunc(e.Id);
|
ExecutionContext context = (ExecutionContext)sender;
|
||||||
|
|
||||||
|
Action<SvcHandler, ExecutionContext> svcFunc = context.IsAarch32 ? SvcTable.SvcTable32[e.Id] : SvcTable.SvcTable64[e.Id];
|
||||||
|
|
||||||
if (svcFunc == null)
|
if (svcFunc == null)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException($"SVC 0x{e.Id:X4} is not implemented.");
|
throw new NotImplementedException($"SVC 0x{e.Id:X4} is not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutionContext context = (ExecutionContext)sender;
|
|
||||||
|
|
||||||
svcFunc(this, context);
|
svcFunc(this, context);
|
||||||
|
|
||||||
PostSvcHandler();
|
PostSvcHandler();
|
||||||
|
|
|
@ -13,14 +13,17 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||||
{
|
{
|
||||||
private const int SvcFuncMaxArguments64 = 8;
|
private const int SvcFuncMaxArguments64 = 8;
|
||||||
private const int SvcFuncMaxArguments32 = 4;
|
private const int SvcFuncMaxArguments32 = 4;
|
||||||
|
private const int SvcMax = 0x80;
|
||||||
|
|
||||||
private static Dictionary<int, string> _svcFuncs64;
|
public static Action<SvcHandler, ExecutionContext>[] SvcTable32 { get; }
|
||||||
|
public static Action<SvcHandler, ExecutionContext>[] SvcTable64 { get; }
|
||||||
private static Action<SvcHandler, ExecutionContext>[] _svcTable64;
|
|
||||||
|
|
||||||
static SvcTable()
|
static SvcTable()
|
||||||
{
|
{
|
||||||
_svcFuncs64 = new Dictionary<int, string>
|
SvcTable32 = new Action<SvcHandler, ExecutionContext>[SvcMax];
|
||||||
|
SvcTable64 = new Action<SvcHandler, ExecutionContext>[SvcMax];
|
||||||
|
|
||||||
|
Dictionary<int, string> svcFuncs64 = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
{ 0x01, nameof(SvcHandler.SetHeapSize64) },
|
{ 0x01, nameof(SvcHandler.SetHeapSize64) },
|
||||||
{ 0x03, nameof(SvcHandler.SetMemoryAttribute64) },
|
{ 0x03, nameof(SvcHandler.SetMemoryAttribute64) },
|
||||||
|
@ -80,22 +83,20 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||||
{ 0x7B, nameof(SvcHandler.TerminateProcess64) }
|
{ 0x7B, nameof(SvcHandler.TerminateProcess64) }
|
||||||
};
|
};
|
||||||
|
|
||||||
_svcTable64 = new Action<SvcHandler, ExecutionContext>[0x80];
|
foreach (KeyValuePair<int, string> value in svcFuncs64)
|
||||||
|
{
|
||||||
|
SvcTable64[value.Key] = GenerateMethod(value.Value, SvcFuncMaxArguments64);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Action<SvcHandler, ExecutionContext> GetSvcFunc(int svcId)
|
Dictionary<int, string> svcFuncs32 = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
if (_svcTable64[svcId] != null)
|
// TODO
|
||||||
{
|
};
|
||||||
return _svcTable64[svcId];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_svcFuncs64.TryGetValue(svcId, out string svcName))
|
foreach (KeyValuePair<int, string> value in svcFuncs32)
|
||||||
{
|
{
|
||||||
return _svcTable64[svcId] = GenerateMethod(svcName, SvcFuncMaxArguments64);
|
SvcTable32[value.Key] = GenerateMethod(value.Value, SvcFuncMaxArguments32);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Action<SvcHandler, ExecutionContext> GenerateMethod(string svcName, int registerCleanCount)
|
private static Action<SvcHandler, ExecutionContext> GenerateMethod(string svcName, int registerCleanCount)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue