mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-18 12:36:40 +00:00
0c87bf9ea4
* Refactor CPU interface * Use IExecutionContext interface on SVC handler, change how CPU interrupts invokes the handlers * Make CpuEngine take a ITickSource rather than returning one The previous implementation had the scenario where the CPU engine had to implement the tick source in mind, like for example, when we have a hypervisor and the game can read CNTPCT on the host directly. However given that we need to do conversion due to different frequencies anyway, it's not worth it. It's better to just let the user pass the tick source and redirect any reads to CNTPCT to the user tick source * XML docs for the public interfaces * PPTC invalidation due to NativeInterface function name changes * Fix build of the CPU tests * PR feedback
64 lines
2.9 KiB
C#
64 lines
2.9 KiB
C#
namespace Ryujinx.Cpu
|
|
{
|
|
/// <summary>
|
|
/// Exception callback without any additional arguments.
|
|
/// </summary>
|
|
/// <param name="context">Context for the thread where the exception was triggered</param>
|
|
public delegate void ExceptionCallbackNoArgs(IExecutionContext context);
|
|
|
|
/// <summary>
|
|
/// Exception callback.
|
|
/// </summary>
|
|
/// <param name="context">Context for the thread where the exception was triggered</param>
|
|
/// <param name="address">Address of the instruction that caused the exception</param>
|
|
/// <param name="imm">Immediate value of the instruction that caused the exception, or for undefined instruction, the instruction itself</param>
|
|
public delegate void ExceptionCallback(IExecutionContext context, ulong address, int imm);
|
|
|
|
/// <summary>
|
|
/// Stores handlers for the various CPU exceptions.
|
|
/// </summary>
|
|
public struct ExceptionCallbacks
|
|
{
|
|
/// <summary>
|
|
/// Handler for CPU interrupts triggered using <see cref="IExecutionContext.RequestInterrupt"/>.
|
|
/// </summary>
|
|
public readonly ExceptionCallbackNoArgs InterruptCallback;
|
|
|
|
/// <summary>
|
|
/// Handler for CPU software interrupts caused by the Arm BRK instruction.
|
|
/// </summary>
|
|
public readonly ExceptionCallback BreakCallback;
|
|
|
|
/// <summary>
|
|
/// Handler for CPU software interrupts caused by the Arm SVC instruction.
|
|
/// </summary>
|
|
public readonly ExceptionCallback SupervisorCallback;
|
|
|
|
/// <summary>
|
|
/// Handler for CPU software interrupts caused by any undefined Arm instruction.
|
|
/// </summary>
|
|
public readonly ExceptionCallback UndefinedCallback;
|
|
|
|
/// <summary>
|
|
/// Creates a new exception callbacks structure.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// All handlers are optional, and if null, the CPU will just continue executing as if nothing happened.
|
|
/// </remarks>
|
|
/// <param name="interruptCallback">Handler for CPU interrupts triggered using <see cref="IExecutionContext.RequestInterrupt"/></param>
|
|
/// <param name="breakCallback">Handler for CPU software interrupts caused by the Arm BRK instruction</param>
|
|
/// <param name="supervisorCallback">Handler for CPU software interrupts caused by the Arm SVC instruction</param>
|
|
/// <param name="undefinedCallback">Handler for CPU software interrupts caused by any undefined Arm instruction</param>
|
|
public ExceptionCallbacks(
|
|
ExceptionCallbackNoArgs interruptCallback = null,
|
|
ExceptionCallback breakCallback = null,
|
|
ExceptionCallback supervisorCallback = null,
|
|
ExceptionCallback undefinedCallback = null)
|
|
{
|
|
InterruptCallback = interruptCallback;
|
|
BreakCallback = breakCallback;
|
|
SupervisorCallback = supervisorCallback;
|
|
UndefinedCallback = undefinedCallback;
|
|
}
|
|
}
|
|
}
|