0
0
Fork 0
This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ryujinx-final/Ryujinx.Cpu/IExecutionContext.cs
gdkchan 0c87bf9ea4
Refactor CPU interface to allow the implementation of other CPU emulators (#3362)
* 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
2022-05-31 16:29:35 -03:00

112 lines
No EOL
4 KiB
C#

using ARMeilleure.State;
using System;
namespace Ryujinx.Cpu
{
/// <summary>
/// CPU register state interface.
/// </summary>
public interface IExecutionContext : IDisposable
{
/// <summary>
/// Current Program Counter.
/// </summary>
/// <remarks>
/// In some implementations, this value might not be accurate and might not point to the last instruction executed.
/// </remarks>
ulong Pc { get; }
/// <summary>
/// Thread ID Register (EL0).
/// </summary>
long TpidrEl0 { get; set; }
/// <summary>
/// Thread ID Register (read-only) (EL0).
/// </summary>
long TpidrroEl0 { get; set; }
/// <summary>
/// Processor State register.
/// </summary>
uint Pstate { get; set; }
/// <summary>
/// Floating-point Control Register.
/// </summary>
uint Fpcr { get; set; }
/// <summary>
/// Floating-point Status Register.
/// </summary>
uint Fpsr { get; set; }
/// <summary>
/// Indicates whenever the CPU is running 64-bit (AArch64 mode) or 32-bit (AArch32 mode) code.
/// </summary>
bool IsAarch32 { get; set; }
/// <summary>
/// Indicates whenever the CPU is still running code.
/// </summary>
/// <remarks>
/// Even if this is false, the guest code might be still exiting.
/// One must not assume that the code is no longer running from this property alone.
/// </remarks>
bool Running { get; }
/// <summary>
/// Gets the value of a general purpose register.
/// </summary>
/// <remarks>
/// The special <paramref name="index"/> of 31 can be used to access the SP (Stack Pointer) register.
/// </remarks>
/// <param name="index">Index of the register, in the range 0-31 (inclusive)</param>
/// <returns>The register value</returns>
ulong GetX(int index);
/// <summary>
/// Sets the value of a general purpose register.
/// </summary>
/// <remarks>
/// The special <paramref name="index"/> of 31 can be used to access the SP (Stack Pointer) register.
/// </remarks>
/// <param name="index">Index of the register, in the range 0-31 (inclusive)</param>
/// <param name="value">Value to be set</param>
void SetX(int index, ulong value);
/// <summary>
/// Gets the value of a FP/SIMD register.
/// </summary>
/// <param name="index">Index of the register, in the range 0-31 (inclusive)</param>
/// <returns>The register value</returns>
V128 GetV(int index);
/// <summary>
/// Sets the value of a FP/SIMD register.
/// </summary>
/// <param name="index">Index of the register, in the range 0-31 (inclusive)</param>
/// <param name="value">Value to be set</param>
void SetV(int index, V128 value);
/// <summary>
/// Requests the thread to stop running temporarily and call <see cref="ExceptionCallbacks.InterruptCallback"/>.
/// </summary>
/// <remarks>
/// The thread might not pause immediately.
/// One must not assume that guest code is no longer being executed by the thread after calling this function.
/// </remarks>
void RequestInterrupt();
/// <summary>
/// Requests the thread to stop running guest code and return as soon as possible.
/// </summary>
/// <remarks>
/// The thread might not stop immediately.
/// One must not assume that guest code is no longer being executed by the thread after calling this function.
/// After a thread has been stopped, it can't be restarted with the same <see cref="IExecutionContext"/>.
/// If you only need to pause the thread temporarily, use <see cref="RequestInterrupt"/> instead.
/// </remarks>
void StopRunning();
}
}