ExceptionCallbacks.cs 2.9 KB

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