KThread: Fix GetPsr mask (#3180)
* ExecutionContext: GetPstate / SetPstate * Put it in NativeContext * KThread: Fix GetPsr mask * ExecutionContext: Turn methods into Pstate property * Address nit
This commit is contained in:
parent
54bfaa125d
commit
bb2f9df0a1
4 changed files with 28 additions and 9 deletions
|
@ -43,6 +43,12 @@ namespace ARMeilleure.State
|
||||||
public long TpidrEl0 { get; set; }
|
public long TpidrEl0 { get; set; }
|
||||||
public long Tpidr { get; set; }
|
public long Tpidr { get; set; }
|
||||||
|
|
||||||
|
public uint Pstate
|
||||||
|
{
|
||||||
|
get => _nativeContext.GetPstate();
|
||||||
|
set => _nativeContext.SetPstate(value);
|
||||||
|
}
|
||||||
|
|
||||||
public FPCR Fpcr { get; set; }
|
public FPCR Fpcr { get; set; }
|
||||||
public FPSR Fpsr { get; set; }
|
public FPSR Fpsr { get; set; }
|
||||||
public FPCR StandardFpcrValue => (Fpcr & (FPCR.Ahp)) | FPCR.Dn | FPCR.Fz;
|
public FPCR StandardFpcrValue => (Fpcr & (FPCR.Ahp)) | FPCR.Dn | FPCR.Fz;
|
||||||
|
|
|
@ -95,6 +95,25 @@ namespace ARMeilleure.State
|
||||||
GetStorage().Flags[(int)flag] = value ? 1u : 0u;
|
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)
|
public unsafe bool GetFPStateFlag(FPState flag)
|
||||||
{
|
{
|
||||||
if ((uint)flag >= RegisterConsts.FpFlagsCount)
|
if ((uint)flag >= RegisterConsts.FpFlagsCount)
|
||||||
|
|
|
@ -658,10 +658,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
|
|
||||||
private static uint GetPsr(ARMeilleure.State.ExecutionContext context)
|
private static uint GetPsr(ARMeilleure.State.ExecutionContext context)
|
||||||
{
|
{
|
||||||
return (context.GetPstateFlag(ARMeilleure.State.PState.NFlag) ? (1U << (int)ARMeilleure.State.PState.NFlag) : 0U) |
|
return context.Pstate & 0xFF0FFE20;
|
||||||
(context.GetPstateFlag(ARMeilleure.State.PState.ZFlag) ? (1U << (int)ARMeilleure.State.PState.ZFlag) : 0U) |
|
|
||||||
(context.GetPstateFlag(ARMeilleure.State.PState.CFlag) ? (1U << (int)ARMeilleure.State.PState.CFlag) : 0U) |
|
|
||||||
(context.GetPstateFlag(ARMeilleure.State.PState.VFlag) ? (1U << (int)ARMeilleure.State.PState.VFlag) : 0U);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ThreadContext GetCurrentContext()
|
private ThreadContext GetCurrentContext()
|
||||||
|
@ -1371,7 +1368,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||||
|
|
||||||
PreferredCore = _originalPreferredCore;
|
PreferredCore = _originalPreferredCore;
|
||||||
AffinityMask = _originalAffinityMask;
|
AffinityMask = _originalAffinityMask;
|
||||||
|
|
||||||
if (AffinityMask != affinityMask)
|
if (AffinityMask != affinityMask)
|
||||||
{
|
{
|
||||||
if ((AffinityMask & 1UL << ActiveCore) != 0)
|
if ((AffinityMask & 1UL << ActiveCore) != 0)
|
||||||
|
|
|
@ -283,10 +283,7 @@ namespace Ryujinx.Tests.Cpu
|
||||||
}
|
}
|
||||||
|
|
||||||
uint finalCpsr = test.FinalRegs[15];
|
uint finalCpsr = test.FinalRegs[15];
|
||||||
for (int i = 0; i < 32; i++)
|
Assert.That(GetContext().Pstate, Is.EqualTo(finalCpsr));
|
||||||
{
|
|
||||||
Assert.That(GetContext().GetPstateFlag((PState)i), Is.EqualTo((finalCpsr & (1u << i)) != 0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void SetWorkingMemory(uint offset, byte[] data)
|
protected void SetWorkingMemory(uint offset, byte[] data)
|
||||||
|
|
Reference in a new issue