mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-02-14 21:33:35 +00:00
Remove interrupt counting and interrupt CPU immediately
This commit is contained in:
parent
1cca3e99ab
commit
5bd349e2c9
4 changed files with 15 additions and 33 deletions
|
@ -5,14 +5,10 @@ namespace ARMeilleure.State
|
||||||
{
|
{
|
||||||
public class ExecutionContext
|
public class ExecutionContext
|
||||||
{
|
{
|
||||||
private const int MinCountForCheck = 4000;
|
|
||||||
|
|
||||||
private NativeContext _nativeContext;
|
private NativeContext _nativeContext;
|
||||||
|
|
||||||
internal IntPtr NativeContextPtr => _nativeContext.BasePtr;
|
internal IntPtr NativeContextPtr => _nativeContext.BasePtr;
|
||||||
|
|
||||||
private bool _interrupted;
|
|
||||||
|
|
||||||
private readonly ICounter _counter;
|
private readonly ICounter _counter;
|
||||||
|
|
||||||
public ulong Pc => _nativeContext.GetPc();
|
public ulong Pc => _nativeContext.GetPc();
|
||||||
|
@ -101,8 +97,7 @@ namespace ARMeilleure.State
|
||||||
_undefinedCallback = undefinedCallback;
|
_undefinedCallback = undefinedCallback;
|
||||||
|
|
||||||
Running = true;
|
Running = true;
|
||||||
|
_nativeContext.SetInterruptState(0);
|
||||||
_nativeContext.SetCounter(MinCountForCheck);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ulong GetX(int index) => _nativeContext.GetX(index);
|
public ulong GetX(int index) => _nativeContext.GetX(index);
|
||||||
|
@ -119,19 +114,13 @@ namespace ARMeilleure.State
|
||||||
|
|
||||||
internal void CheckInterrupt()
|
internal void CheckInterrupt()
|
||||||
{
|
{
|
||||||
if (_interrupted)
|
_nativeContext.SetInterruptState(0);
|
||||||
{
|
_interruptCallback?.Invoke(this);
|
||||||
_interrupted = false;
|
|
||||||
|
|
||||||
_interruptCallback?.Invoke(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
_nativeContext.SetCounter(MinCountForCheck);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequestInterrupt()
|
public void RequestInterrupt()
|
||||||
{
|
{
|
||||||
_interrupted = true;
|
_nativeContext.SetInterruptState(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void OnBreak(ulong address, int imm)
|
internal void OnBreak(ulong address, int imm)
|
||||||
|
@ -152,8 +141,7 @@ namespace ARMeilleure.State
|
||||||
public void StopRunning()
|
public void StopRunning()
|
||||||
{
|
{
|
||||||
Running = false;
|
Running = false;
|
||||||
|
_nativeContext.SetInterruptState(1);
|
||||||
_nativeContext.SetCounter(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ARMeilleure.State
|
||||||
public fixed ulong V[RegisterConsts.VecRegsCount * 2];
|
public fixed ulong V[RegisterConsts.VecRegsCount * 2];
|
||||||
public fixed uint Flags[RegisterConsts.FlagsCount];
|
public fixed uint Flags[RegisterConsts.FlagsCount];
|
||||||
public fixed uint FpFlags[RegisterConsts.FpFlagsCount];
|
public fixed uint FpFlags[RegisterConsts.FpFlagsCount];
|
||||||
public int Counter;
|
public int InterruptState;
|
||||||
public ulong DispatchAddress;
|
public ulong DispatchAddress;
|
||||||
public ulong ExclusiveAddress;
|
public ulong ExclusiveAddress;
|
||||||
public ulong ExclusiveValueLow;
|
public ulong ExclusiveValueLow;
|
||||||
|
@ -168,8 +168,8 @@ namespace ARMeilleure.State
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetCounter() => GetStorage().Counter;
|
public int GetInterruptState() => GetStorage().InterruptState;
|
||||||
public void SetCounter(int value) => GetStorage().Counter = value;
|
public void SetInterruptState(int value) => GetStorage().InterruptState = value;
|
||||||
|
|
||||||
public bool GetRunning() => GetStorage().Running != 0;
|
public bool GetRunning() => GetStorage().Running != 0;
|
||||||
public void SetRunning(bool value) => GetStorage().Running = value ? 1 : 0;
|
public void SetRunning(bool value) => GetStorage().Running = value ? 1 : 0;
|
||||||
|
@ -214,9 +214,9 @@ namespace ARMeilleure.State
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetCounterOffset()
|
public static int GetInterruptStateOffset()
|
||||||
{
|
{
|
||||||
return StorageOffset(ref _dummyStorage, ref _dummyStorage.Counter);
|
return StorageOffset(ref _dummyStorage, ref _dummyStorage.InterruptState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetDispatchAddressOffset()
|
public static int GetDispatchAddressOffset()
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
private const string OuterHeaderMagicString = "PTCohd\0\0";
|
private const string OuterHeaderMagicString = "PTCohd\0\0";
|
||||||
private const string InnerHeaderMagicString = "PTCihd\0\0";
|
private const string InnerHeaderMagicString = "PTCihd\0\0";
|
||||||
|
|
||||||
private const uint InternalVersion = 4140; //! To be incremented manually for each change to the ARMeilleure project.
|
private const int InternalVersion = 123; //! To be incremented manually for each change to the ARMeilleure project.
|
||||||
|
|
||||||
private const string ActualDir = "0";
|
private const string ActualDir = "0";
|
||||||
private const string BackupDir = "1";
|
private const string BackupDir = "1";
|
||||||
|
|
|
@ -432,24 +432,18 @@ namespace ARMeilleure.Translation
|
||||||
|
|
||||||
internal static void EmitSynchronization(EmitterContext context)
|
internal static void EmitSynchronization(EmitterContext context)
|
||||||
{
|
{
|
||||||
long countOffs = NativeContext.GetCounterOffset();
|
long interruptedOffs = NativeContext.GetInterruptStateOffset();
|
||||||
|
|
||||||
Operand lblNonZero = Label();
|
Operand interruptedAddr = context.Add(context.LoadArgument(OperandType.I64, 0), Const(interruptedOffs));
|
||||||
|
Operand interrupted = context.Load(OperandType.I32, interruptedAddr);
|
||||||
Operand lblExit = Label();
|
Operand lblExit = Label();
|
||||||
|
|
||||||
Operand countAddr = context.Add(context.LoadArgument(OperandType.I64, 0), Const(countOffs));
|
context.BranchIfFalse(lblExit, interrupted, BasicBlockFrequency.Cold);
|
||||||
Operand count = context.Load(OperandType.I32, countAddr);
|
|
||||||
context.BranchIfTrue(lblNonZero, count, BasicBlockFrequency.Cold);
|
|
||||||
|
|
||||||
Operand running = context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.CheckSynchronization)));
|
Operand running = context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.CheckSynchronization)));
|
||||||
context.BranchIfTrue(lblExit, running, BasicBlockFrequency.Cold);
|
context.BranchIfTrue(lblExit, running, BasicBlockFrequency.Cold);
|
||||||
|
|
||||||
context.Return(Const(0L));
|
context.Return(Const(0L));
|
||||||
|
|
||||||
context.MarkLabel(lblNonZero);
|
|
||||||
count = context.Subtract(count, Const(1));
|
|
||||||
context.Store(countAddr, count);
|
|
||||||
|
|
||||||
context.MarkLabel(lblExit);
|
context.MarkLabel(lblExit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue