IExecutionContext.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using ARMeilleure.State;
  2. using System;
  3. namespace Ryujinx.Cpu
  4. {
  5. /// <summary>
  6. /// CPU register state interface.
  7. /// </summary>
  8. public interface IExecutionContext : IDisposable
  9. {
  10. /// <summary>
  11. /// Current Program Counter.
  12. /// </summary>
  13. /// <remarks>
  14. /// In some implementations, this value might not be accurate and might not point to the last instruction executed.
  15. /// </remarks>
  16. ulong Pc { get; }
  17. /// <summary>
  18. /// Thread ID Register (EL0).
  19. /// </summary>
  20. long TpidrEl0 { get; set; }
  21. /// <summary>
  22. /// Thread ID Register (read-only) (EL0).
  23. /// </summary>
  24. long TpidrroEl0 { get; set; }
  25. /// <summary>
  26. /// Processor State Register.
  27. /// </summary>
  28. uint Pstate { get; set; }
  29. /// <summary>
  30. /// Floating-point Control Register.
  31. /// </summary>
  32. uint Fpcr { get; set; }
  33. /// <summary>
  34. /// Floating-point Status Register.
  35. /// </summary>
  36. uint Fpsr { get; set; }
  37. /// <summary>
  38. /// Indicates whenever the CPU is running 64-bit (AArch64 mode) or 32-bit (AArch32 mode) code.
  39. /// </summary>
  40. bool IsAarch32 { get; set; }
  41. /// <summary>
  42. /// Indicates whenever the CPU is still running code.
  43. /// </summary>
  44. /// <remarks>
  45. /// Even if this is false, the guest code might be still exiting.
  46. /// One must not assume that the code is no longer running from this property alone.
  47. /// </remarks>
  48. bool Running { get; }
  49. /// <summary>
  50. /// Gets the value of a general purpose register.
  51. /// </summary>
  52. /// <remarks>
  53. /// The special <paramref name="index"/> of 31 can be used to access the SP (Stack Pointer) register.
  54. /// </remarks>
  55. /// <param name="index">Index of the register, in the range 0-31 (inclusive)</param>
  56. /// <returns>The register value</returns>
  57. ulong GetX(int index);
  58. /// <summary>
  59. /// Sets the value of a general purpose register.
  60. /// </summary>
  61. /// <remarks>
  62. /// The special <paramref name="index"/> of 31 can be used to access the SP (Stack Pointer) register.
  63. /// </remarks>
  64. /// <param name="index">Index of the register, in the range 0-31 (inclusive)</param>
  65. /// <param name="value">Value to be set</param>
  66. void SetX(int index, ulong value);
  67. /// <summary>
  68. /// Gets the value of a FP/SIMD register.
  69. /// </summary>
  70. /// <param name="index">Index of the register, in the range 0-31 (inclusive)</param>
  71. /// <returns>The register value</returns>
  72. V128 GetV(int index);
  73. /// <summary>
  74. /// Sets the value of a FP/SIMD register.
  75. /// </summary>
  76. /// <param name="index">Index of the register, in the range 0-31 (inclusive)</param>
  77. /// <param name="value">Value to be set</param>
  78. void SetV(int index, V128 value);
  79. /// <summary>
  80. /// Requests the thread to stop running temporarily and call <see cref="ExceptionCallbacks.InterruptCallback"/>.
  81. /// </summary>
  82. /// <remarks>
  83. /// The thread might not pause immediately.
  84. /// One must not assume that guest code is no longer being executed by the thread after calling this function.
  85. /// </remarks>
  86. void RequestInterrupt();
  87. /// <summary>
  88. /// Requests the thread to stop running guest code and return as soon as possible.
  89. /// </summary>
  90. /// <remarks>
  91. /// The thread might not stop immediately.
  92. /// One must not assume that guest code is no longer being executed by the thread after calling this function.
  93. /// After a thread has been stopped, it can't be restarted with the same <see cref="IExecutionContext"/>.
  94. /// If you only need to pause the thread temporarily, use <see cref="RequestInterrupt"/> instead.
  95. /// </remarks>
  96. void StopRunning();
  97. }
  98. }