aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Cpu/IExecutionContext.cs
blob: c3821080005c552e3581f108755f520d15a7a02e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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();
    }
}