aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure
diff options
context:
space:
mode:
authormerry <git@mary.rs>2022-03-11 02:16:32 +0000
committerGitHub <noreply@github.com>2022-03-11 03:16:32 +0100
commitbb2f9df0a1d5e7cbd333c39cd485a42a19a772dc (patch)
tree4f33eed9a64cd7b001dec68d344eae852a370c06 /ARMeilleure
parent54bfaa125d9b6ae1be53ec431d40326fba51d0de (diff)
KThread: Fix GetPsr mask (#3180)
* ExecutionContext: GetPstate / SetPstate * Put it in NativeContext * KThread: Fix GetPsr mask * ExecutionContext: Turn methods into Pstate property * Address nit
Diffstat (limited to 'ARMeilleure')
-rw-r--r--ARMeilleure/State/ExecutionContext.cs6
-rw-r--r--ARMeilleure/State/NativeContext.cs19
2 files changed, 25 insertions, 0 deletions
diff --git a/ARMeilleure/State/ExecutionContext.cs b/ARMeilleure/State/ExecutionContext.cs
index a6f74cd0..8309864f 100644
--- a/ARMeilleure/State/ExecutionContext.cs
+++ b/ARMeilleure/State/ExecutionContext.cs
@@ -43,6 +43,12 @@ namespace ARMeilleure.State
public long TpidrEl0 { get; set; }
public long Tpidr { get; set; }
+ public uint Pstate
+ {
+ get => _nativeContext.GetPstate();
+ set => _nativeContext.SetPstate(value);
+ }
+
public FPCR Fpcr { get; set; }
public FPSR Fpsr { get; set; }
public FPCR StandardFpcrValue => (Fpcr & (FPCR.Ahp)) | FPCR.Dn | FPCR.Fz;
diff --git a/ARMeilleure/State/NativeContext.cs b/ARMeilleure/State/NativeContext.cs
index 962783f5..f911f762 100644
--- a/ARMeilleure/State/NativeContext.cs
+++ b/ARMeilleure/State/NativeContext.cs
@@ -95,6 +95,25 @@ namespace ARMeilleure.State
GetStorage().Flags[(int)flag] = value ? 1u : 0u;
}
+ public unsafe uint GetPstate()
+ {
+ uint value = 0;
+ for (int flag = 0; flag < RegisterConsts.FlagsCount; flag++)
+ {
+ value |= GetStorage().Flags[flag] != 0 ? 1u << flag : 0u;
+ }
+ return value;
+ }
+
+ public unsafe void SetPstate(uint value)
+ {
+ for (int flag = 0; flag < RegisterConsts.FlagsCount; flag++)
+ {
+ uint bit = 1u << flag;
+ GetStorage().Flags[flag] = (value & bit) == bit ? 1u : 0u;
+ }
+ }
+
public unsafe bool GetFPStateFlag(FPState flag)
{
if ((uint)flag >= RegisterConsts.FpFlagsCount)