From 368a8630e05b40c865efafe3895983642fa72bdb Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 18 Feb 2021 23:58:12 -0500 Subject: [PATCH 1/4] thumb32: Implement DSB --- src/frontend/A32/decoder/thumb32.inc | 2 +- src/frontend/A32/translate/impl/thumb32_control.cpp | 5 +++++ src/frontend/A32/translate/impl/translate_thumb.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index 4e48875a..68b61148 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -107,7 +107,7 @@ INST(thumb32_EOR_imm, "EOR (imm)", "11110v00100Snnnn0vvvdd //INST(thumb32_ENTERX, "ENTERX", "111100111011----10-0----0001----") //INST(thumb32_LEAVEX, "LEAVEX", "111100111011----10-0----0000----") //INST(thumb32_CLREX, "CLREX", "111100111011----10-0----0010----") -//INST(thumb32_DSB, "DSB", "111100111011----10-0----0100----") +INST(thumb32_DSB, "DSB", "1111001110111111100011110100oooo") //INST(thumb32_DMB, "DMB", "111100111011----10-0----0101----") //INST(thumb32_ISB, "ISB", "111100111011----10-0----0110----") diff --git a/src/frontend/A32/translate/impl/thumb32_control.cpp b/src/frontend/A32/translate/impl/thumb32_control.cpp index a42ca76a..6eca2686 100644 --- a/src/frontend/A32/translate/impl/thumb32_control.cpp +++ b/src/frontend/A32/translate/impl/thumb32_control.cpp @@ -7,6 +7,11 @@ namespace Dynarmic::A32 { +bool ThumbTranslatorVisitor::thumb32_DSB([[maybe_unused]] Imm<4> option) { + ir.DataSynchronizationBarrier(); + return true; +} + bool ThumbTranslatorVisitor::thumb32_UDF() { return thumb16_UDF(); } diff --git a/src/frontend/A32/translate/impl/translate_thumb.h b/src/frontend/A32/translate/impl/translate_thumb.h index b0741615..c20b5bb3 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -160,6 +160,7 @@ struct ThumbTranslatorVisitor final { bool thumb32_EOR_imm(Imm<1> i, bool S, Reg n, Imm<3> imm3, Reg d, Imm<8> imm8); // thumb32 miscellaneous control instructions + bool thumb32_DSB(Imm<4> option); bool thumb32_UDF(); // thumb32 branch instructions From 085147b5a48102f1a809172d039cf95ae556c33f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 18 Feb 2021 23:59:34 -0500 Subject: [PATCH 2/4] thumb32: Implement DMB --- src/frontend/A32/decoder/thumb32.inc | 2 +- src/frontend/A32/translate/impl/thumb32_control.cpp | 5 +++++ src/frontend/A32/translate/impl/translate_thumb.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index 68b61148..79b29174 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -108,7 +108,7 @@ INST(thumb32_EOR_imm, "EOR (imm)", "11110v00100Snnnn0vvvdd //INST(thumb32_LEAVEX, "LEAVEX", "111100111011----10-0----0000----") //INST(thumb32_CLREX, "CLREX", "111100111011----10-0----0010----") INST(thumb32_DSB, "DSB", "1111001110111111100011110100oooo") -//INST(thumb32_DMB, "DMB", "111100111011----10-0----0101----") +INST(thumb32_DMB, "DMB", "1111001110111111100011110101oooo") //INST(thumb32_ISB, "ISB", "111100111011----10-0----0110----") //INST(thumb32_BXJ, "BXJ", "111100111100----1000111100000000") diff --git a/src/frontend/A32/translate/impl/thumb32_control.cpp b/src/frontend/A32/translate/impl/thumb32_control.cpp index 6eca2686..24e099c9 100644 --- a/src/frontend/A32/translate/impl/thumb32_control.cpp +++ b/src/frontend/A32/translate/impl/thumb32_control.cpp @@ -7,6 +7,11 @@ namespace Dynarmic::A32 { +bool ThumbTranslatorVisitor::thumb32_DMB([[maybe_unused]] Imm<4> option) { + ir.DataMemoryBarrier(); + return true; +} + bool ThumbTranslatorVisitor::thumb32_DSB([[maybe_unused]] Imm<4> option) { ir.DataSynchronizationBarrier(); return true; diff --git a/src/frontend/A32/translate/impl/translate_thumb.h b/src/frontend/A32/translate/impl/translate_thumb.h index c20b5bb3..658c129e 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -160,6 +160,7 @@ struct ThumbTranslatorVisitor final { bool thumb32_EOR_imm(Imm<1> i, bool S, Reg n, Imm<3> imm3, Reg d, Imm<8> imm8); // thumb32 miscellaneous control instructions + bool thumb32_DMB(Imm<4> option); bool thumb32_DSB(Imm<4> option); bool thumb32_UDF(); From 5543e4f9ebbcc38cc9048e498ec3b716c32e9680 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 19 Feb 2021 00:01:24 -0500 Subject: [PATCH 3/4] thumb32: Implement ISB --- src/frontend/A32/decoder/thumb32.inc | 2 +- src/frontend/A32/translate/impl/thumb32_control.cpp | 7 +++++++ src/frontend/A32/translate/impl/translate_thumb.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index 79b29174..e7b0aebf 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -109,7 +109,7 @@ INST(thumb32_EOR_imm, "EOR (imm)", "11110v00100Snnnn0vvvdd //INST(thumb32_CLREX, "CLREX", "111100111011----10-0----0010----") INST(thumb32_DSB, "DSB", "1111001110111111100011110100oooo") INST(thumb32_DMB, "DMB", "1111001110111111100011110101oooo") -//INST(thumb32_ISB, "ISB", "111100111011----10-0----0110----") +INST(thumb32_ISB, "ISB", "1111001110111111100011110110oooo") //INST(thumb32_BXJ, "BXJ", "111100111100----1000111100000000") //INST(thumb32_ERET, "ERET", "11110011110111101000111100000000") diff --git a/src/frontend/A32/translate/impl/thumb32_control.cpp b/src/frontend/A32/translate/impl/thumb32_control.cpp index 24e099c9..cf7312f5 100644 --- a/src/frontend/A32/translate/impl/thumb32_control.cpp +++ b/src/frontend/A32/translate/impl/thumb32_control.cpp @@ -17,6 +17,13 @@ bool ThumbTranslatorVisitor::thumb32_DSB([[maybe_unused]] Imm<4> option) { return true; } +bool ThumbTranslatorVisitor::thumb32_ISB([[maybe_unused]] Imm<4> option) { + ir.InstructionSynchronizationBarrier(); + ir.BranchWritePC(ir.Imm32(ir.current_location.PC() + 4)); + ir.SetTerm(IR::Term::ReturnToDispatch{}); + return false; +} + bool ThumbTranslatorVisitor::thumb32_UDF() { return thumb16_UDF(); } diff --git a/src/frontend/A32/translate/impl/translate_thumb.h b/src/frontend/A32/translate/impl/translate_thumb.h index 658c129e..b0c4bfbb 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -162,6 +162,7 @@ struct ThumbTranslatorVisitor final { // thumb32 miscellaneous control instructions bool thumb32_DMB(Imm<4> option); bool thumb32_DSB(Imm<4> option); + bool thumb32_ISB(Imm<4> option); bool thumb32_UDF(); // thumb32 branch instructions From 3890590b4f154df415d4faa08e67514c99d288bf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 19 Feb 2021 00:02:57 -0500 Subject: [PATCH 4/4] thumb32: Implement CLREX --- src/frontend/A32/decoder/thumb32.inc | 2 +- src/frontend/A32/translate/impl/thumb32_control.cpp | 5 +++++ src/frontend/A32/translate/impl/translate_thumb.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index e7b0aebf..398fe97e 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -106,7 +106,7 @@ INST(thumb32_EOR_imm, "EOR (imm)", "11110v00100Snnnn0vvvdd //INST(thumb32_ENTERX, "ENTERX", "111100111011----10-0----0001----") //INST(thumb32_LEAVEX, "LEAVEX", "111100111011----10-0----0000----") -//INST(thumb32_CLREX, "CLREX", "111100111011----10-0----0010----") +INST(thumb32_CLREX, "CLREX", "11110011101111111000111100101111") INST(thumb32_DSB, "DSB", "1111001110111111100011110100oooo") INST(thumb32_DMB, "DMB", "1111001110111111100011110101oooo") INST(thumb32_ISB, "ISB", "1111001110111111100011110110oooo") diff --git a/src/frontend/A32/translate/impl/thumb32_control.cpp b/src/frontend/A32/translate/impl/thumb32_control.cpp index cf7312f5..d9a4b0a7 100644 --- a/src/frontend/A32/translate/impl/thumb32_control.cpp +++ b/src/frontend/A32/translate/impl/thumb32_control.cpp @@ -7,6 +7,11 @@ namespace Dynarmic::A32 { +bool ThumbTranslatorVisitor::thumb32_CLREX() { + ir.ClearExclusive(); + return true; +} + bool ThumbTranslatorVisitor::thumb32_DMB([[maybe_unused]] Imm<4> option) { ir.DataMemoryBarrier(); return true; diff --git a/src/frontend/A32/translate/impl/translate_thumb.h b/src/frontend/A32/translate/impl/translate_thumb.h index b0c4bfbb..5fee9591 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -160,6 +160,7 @@ struct ThumbTranslatorVisitor final { bool thumb32_EOR_imm(Imm<1> i, bool S, Reg n, Imm<3> imm3, Reg d, Imm<8> imm8); // thumb32 miscellaneous control instructions + bool thumb32_CLREX(); bool thumb32_DMB(Imm<4> option); bool thumb32_DSB(Imm<4> option); bool thumb32_ISB(Imm<4> option);