ExceptionCallbacks.cs
1 namespace Ryujinx.Cpu 2 { 3 /// <summary> 4 /// Exception callback without any additional arguments. 5 /// </summary> 6 /// <param name="context">Context for the thread where the exception was triggered</param> 7 public delegate void ExceptionCallbackNoArgs(IExecutionContext context); 8 9 /// <summary> 10 /// Exception callback. 11 /// </summary> 12 /// <param name="context">Context for the thread where the exception was triggered</param> 13 /// <param name="address">Address of the instruction that caused the exception</param> 14 /// <param name="imm">Immediate value of the instruction that caused the exception, or for undefined instruction, the instruction itself</param> 15 public delegate void ExceptionCallback(IExecutionContext context, ulong address, int imm); 16 17 /// <summary> 18 /// Stores handlers for the various CPU exceptions. 19 /// </summary> 20 public readonly struct ExceptionCallbacks 21 { 22 /// <summary> 23 /// Handler for CPU interrupts triggered using <see cref="IExecutionContext.RequestInterrupt"/>. 24 /// </summary> 25 public readonly ExceptionCallbackNoArgs InterruptCallback; 26 27 /// <summary> 28 /// Handler for CPU software interrupts caused by the Arm BRK instruction. 29 /// </summary> 30 public readonly ExceptionCallback BreakCallback; 31 32 /// <summary> 33 /// Handler for CPU software interrupts caused by the Arm SVC instruction. 34 /// </summary> 35 public readonly ExceptionCallback SupervisorCallback; 36 37 /// <summary> 38 /// Handler for CPU software interrupts caused by any undefined Arm instruction. 39 /// </summary> 40 public readonly ExceptionCallback UndefinedCallback; 41 42 /// <summary> 43 /// Creates a new exception callbacks structure. 44 /// </summary> 45 /// <remarks> 46 /// All handlers are optional, and if null, the CPU will just continue executing as if nothing happened. 47 /// </remarks> 48 /// <param name="interruptCallback">Handler for CPU interrupts triggered using <see cref="IExecutionContext.RequestInterrupt"/></param> 49 /// <param name="breakCallback">Handler for CPU software interrupts caused by the Arm BRK instruction</param> 50 /// <param name="supervisorCallback">Handler for CPU software interrupts caused by the Arm SVC instruction</param> 51 /// <param name="undefinedCallback">Handler for CPU software interrupts caused by any undefined Arm instruction</param> 52 public ExceptionCallbacks( 53 ExceptionCallbackNoArgs interruptCallback = null, 54 ExceptionCallback breakCallback = null, 55 ExceptionCallback supervisorCallback = null, 56 ExceptionCallback undefinedCallback = null) 57 { 58 InterruptCallback = interruptCallback; 59 BreakCallback = breakCallback; 60 SupervisorCallback = supervisorCallback; 61 UndefinedCallback = undefinedCallback; 62 } 63 } 64 }