From fd075d8d68736223f973390342f775d5e7e986b1 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Fri, 26 Jan 2018 18:50:41 +0000 Subject: [PATCH] system: Raise exception for YIELD, WFE, WFI, SEV, SEVL --- include/dynarmic/A64/config.h | 10 ++++++++++ src/frontend/A64/translate/impl/impl.cpp | 14 +++++++------- src/frontend/A64/translate/impl/impl.h | 1 + src/frontend/A64/translate/impl/system.cpp | 10 +++++----- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/include/dynarmic/A64/config.h b/include/dynarmic/A64/config.h index aab79f01..7e87c86c 100644 --- a/include/dynarmic/A64/config.h +++ b/include/dynarmic/A64/config.h @@ -28,6 +28,16 @@ enum class Exception { /// This behaviour is up to the user of this library to define. /// Note: Constraints on unpredictable behaviour are specified in the ARMv8 ARM. UnpredictableInstruction, + /// A WFI instruction was executed. You may now enter a low-power state. + WaitForInterrupt, + /// A WFE instruction was executed. You may now enter a low-power state if the event register is clear. + WaitForEvent, + /// A SEV instruction was executed. The event register of all PEs should be set. + SendEvent, + /// A SEV instruction was executed. The event register of the current PE should be set. + SendEventLocal, + /// A YIELD instruction was executed. + Yield, }; enum class DataCacheOperation { diff --git a/src/frontend/A64/translate/impl/impl.cpp b/src/frontend/A64/translate/impl/impl.cpp index 98261947..b4cf47d7 100644 --- a/src/frontend/A64/translate/impl/impl.cpp +++ b/src/frontend/A64/translate/impl/impl.cpp @@ -16,9 +16,7 @@ bool TranslatorVisitor::InterpretThisInstruction() { } bool TranslatorVisitor::UnpredictableInstruction() { - ir.ExceptionRaised(Exception::UnpredictableInstruction); - ir.SetTerm(IR::Term::CheckHalt{IR::Term::ReturnToDispatch{}}); - return false; + return RaiseException(Exception::UnpredictableInstruction); } bool TranslatorVisitor::DecodeError() { @@ -27,13 +25,15 @@ bool TranslatorVisitor::DecodeError() { } bool TranslatorVisitor::ReservedValue() { - ir.ExceptionRaised(Exception::ReservedValue); - ir.SetTerm(IR::Term::CheckHalt{IR::Term::ReturnToDispatch{}}); - return false; + return RaiseException(Exception::ReservedValue); } bool TranslatorVisitor::UnallocatedEncoding() { - ir.ExceptionRaised(Exception::UnallocatedEncoding); + return RaiseException(Exception::UnallocatedEncoding); +} + +bool TranslatorVisitor::RaiseException(Exception exception) { + ir.ExceptionRaised(exception); ir.SetTerm(IR::Term::CheckHalt{IR::Term::ReturnToDispatch{}}); return false; } diff --git a/src/frontend/A64/translate/impl/impl.h b/src/frontend/A64/translate/impl/impl.h index 0ea9baeb..03e3277a 100644 --- a/src/frontend/A64/translate/impl/impl.h +++ b/src/frontend/A64/translate/impl/impl.h @@ -35,6 +35,7 @@ struct TranslatorVisitor final { bool DecodeError(); bool ReservedValue(); bool UnallocatedEncoding(); + bool RaiseException(Exception exception); struct BitMasks { u64 wmask, tmask; diff --git a/src/frontend/A64/translate/impl/system.cpp b/src/frontend/A64/translate/impl/system.cpp index bab196a2..33b9ed84 100644 --- a/src/frontend/A64/translate/impl/system.cpp +++ b/src/frontend/A64/translate/impl/system.cpp @@ -17,23 +17,23 @@ bool TranslatorVisitor::NOP() { } bool TranslatorVisitor::YIELD() { - return true; + return RaiseException(Exception::Yield); } bool TranslatorVisitor::WFE() { - return true; + return RaiseException(Exception::WaitForEvent); } bool TranslatorVisitor::WFI() { - return true; + return RaiseException(Exception::WaitForInterrupt); } bool TranslatorVisitor::SEV() { - return true; + return RaiseException(Exception::SendEvent); } bool TranslatorVisitor::SEVL() { - return true; + return RaiseException(Exception::SendEventLocal); } bool TranslatorVisitor::CLREX(Imm<4> /*CRm*/) {