From 6416bc193843702fc9d77be24e7b5b86c2b5e68c Mon Sep 17 00:00:00 2001 From: mageven <62494521+mageven@users.noreply.github.com> Date: Sat, 23 May 2020 15:45:59 +0530 Subject: [PATCH] Implement CNTVCT_EL0 (#1268) * Implement CNTVCT_EL0 * Fix comment --- ARMeilleure/Instructions/InstEmitSystem.cs | 1 + ARMeilleure/Instructions/NativeInterface.cs | 5 +++++ ARMeilleure/State/ExecutionContext.cs | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/ARMeilleure/Instructions/InstEmitSystem.cs b/ARMeilleure/Instructions/InstEmitSystem.cs index 49973404f..c13f0c3e4 100644 --- a/ARMeilleure/Instructions/InstEmitSystem.cs +++ b/ARMeilleure/Instructions/InstEmitSystem.cs @@ -40,6 +40,7 @@ namespace ARMeilleure.Instructions case 0b11_011_1101_0000_011: dlg = new _U64(NativeInterface.GetTpidr); break; case 0b11_011_1110_0000_000: dlg = new _U64(NativeInterface.GetCntfrqEl0); break; case 0b11_011_1110_0000_001: dlg = new _U64(NativeInterface.GetCntpctEl0); break; + case 0b11_011_1110_0000_010: dlg = new _U64(NativeInterface.GetCntvctEl0); break; default: throw new NotImplementedException($"Unknown MRS 0x{op.RawOpCode:X8} at 0x{op.Address:X16}."); } diff --git a/ARMeilleure/Instructions/NativeInterface.cs b/ARMeilleure/Instructions/NativeInterface.cs index f42dc2835..49faab357 100644 --- a/ARMeilleure/Instructions/NativeInterface.cs +++ b/ARMeilleure/Instructions/NativeInterface.cs @@ -136,6 +136,11 @@ namespace ARMeilleure.Instructions return GetContext().CntpctEl0; } + public static ulong GetCntvctEl0() + { + return GetContext().CntvctEl0; + } + public static void SetFpcr(ulong value) { GetContext().Fpcr = (FPCR)value; diff --git a/ARMeilleure/State/ExecutionContext.cs b/ARMeilleure/State/ExecutionContext.cs index 8593f41e4..2755122f3 100644 --- a/ARMeilleure/State/ExecutionContext.cs +++ b/ARMeilleure/State/ExecutionContext.cs @@ -32,6 +32,10 @@ namespace ARMeilleure.State } } + // CNTVCT_EL0 = CNTPCT_EL0 - CNTVOFF_EL2 + // Since EL2 isn't implemented, CNTVOFF_EL2 = 0 + public ulong CntvctEl0 => CntpctEl0; + public static TimeSpan ElapsedTime => _tickCounter.Elapsed; public long TpidrEl0 { get; set; }