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);
/// Exception callback.
/// <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);
/// Stores handlers for the various CPU exceptions.
public readonly struct ExceptionCallbacks
/// Handler for CPU interrupts triggered using <see cref="IExecutionContext.RequestInterrupt"/>.
public readonly ExceptionCallbackNoArgs InterruptCallback;
/// Handler for CPU software interrupts caused by the Arm BRK instruction.
public readonly ExceptionCallback BreakCallback;
/// Handler for CPU software interrupts caused by the Arm SVC instruction.
public readonly ExceptionCallback SupervisorCallback;
/// Handler for CPU software interrupts caused by any undefined Arm instruction.
public readonly ExceptionCallback UndefinedCallback;
/// Creates a new exception callbacks structure.
/// <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;
}