[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH rc2 08/25] target/avr: Add instruction translation - MCU Control
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH rc2 08/25] target/avr: Add instruction translation - MCU Control Instructions |
Date: |
Fri, 24 Jan 2020 01:51:14 +0100 |
From: Michael Rolnik <address@hidden>
This includes:
- BREAK
- NOP
- SLEEP
- WDR
Signed-off-by: Michael Rolnik <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
---
target/avr/translate.c | 68 ++++++++++++++++++++++++++++++++++++++++++
target/avr/insn.decode | 8 +++++
2 files changed, 76 insertions(+)
diff --git a/target/avr/translate.c b/target/avr/translate.c
index 58775af17c..4c680070e2 100644
--- a/target/avr/translate.c
+++ b/target/avr/translate.c
@@ -2681,3 +2681,71 @@ static bool trans_BCLR(DisasContext *ctx, arg_BCLR *a)
return true;
}
+
+/*
+ * MCU Control Instructions
+ */
+
+/*
+ * The BREAK instruction is used by the On-chip Debug system, and is
+ * normally not used in the application software. When the BREAK instruction
is
+ * executed, the AVR CPU is set in the Stopped Mode. This gives the On-chip
+ * Debugger access to internal resources. If any Lock bits are set, or either
+ * the JTAGEN or OCDEN Fuses are unprogrammed, the CPU will treat the BREAK
+ * instruction as a NOP and will not enter the Stopped mode. This instruction
+ * is not available in all devices. Refer to the device specific instruction
+ * set summary.
+ */
+static bool trans_BREAK(DisasContext *ctx, arg_BREAK *a)
+{
+ if (!avr_have_feature(ctx, AVR_FEATURE_BREAK)) {
+ return true;
+ }
+
+#ifdef BREAKPOINT_ON_BREAK
+ tcg_gen_movi_tl(cpu_pc, ctx->npc - 1);
+ gen_helper_debug(cpu_env);
+ ctx->bstate = DISAS_EXIT;
+#else
+ /* NOP */
+#endif
+
+ return true;
+}
+
+
+/*
+ * This instruction performs a single cycle No Operation.
+ */
+static bool trans_NOP(DisasContext *ctx, arg_NOP *a)
+{
+
+ /* NOP */
+
+ return true;
+}
+
+
+/*
+ * This instruction sets the circuit in sleep mode defined by the MCU
+ * Control Register.
+ */
+static bool trans_SLEEP(DisasContext *ctx, arg_SLEEP *a)
+{
+ gen_helper_sleep(cpu_env);
+ ctx->bstate = DISAS_NORETURN;
+ return true;
+}
+
+
+/*
+ * This instruction resets the Watchdog Timer. This instruction must be
+ * executed within a limited time given by the WD prescaler. See the Watchdog
+ * Timer hardware specification.
+ */
+static bool trans_WDR(DisasContext *ctx, arg_WDR *a)
+{
+ gen_helper_wdr(cpu_env);
+
+ return true;
+}
diff --git a/target/avr/insn.decode b/target/avr/insn.decode
index 4ee55862b2..f8d32f2258 100644
--- a/target/avr/insn.decode
+++ b/target/avr/insn.decode
@@ -172,3 +172,11 @@ BST 1111 101 rd:5 0 bit:3
BLD 1111 100 rd:5 0 bit:3
BSET 1001 0100 0 bit:3 1000
BCLR 1001 0100 1 bit:3 1000
+
+#
+# MCU Control Instructions
+#
+BREAK 1001 0101 1001 1000
+NOP 0000 0000 0000 0000
+SLEEP 1001 0101 1000 1000
+WDR 1001 0101 1010 1000
--
2.21.1
- [PATCH rc2 00/25] target/avr merger, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 02/25] target/avr: Add instruction helpers, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 03/25] target/avr: Add instruction translation - Registers definition, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 01/25] target/avr: Add outward facing interfaces and core CPU logic, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 04/25] target/avr: Add instruction translation - Arithmetic and Logic Instructions, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 05/25] target/avr: Add instruction translation - Branch Instructions, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 07/25] target/avr: Add instruction translation - Bit and Bit-test Instructions, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 08/25] target/avr: Add instruction translation - MCU Control Instructions,
Philippe Mathieu-Daudé <=
- [PATCH rc2 06/25] target/avr: Add instruction translation - Data Transfer Instructions, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 09/25] target/avr: Add instruction translation - CPU main translation function, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 10/25] target/avr: Add instruction disassembly function, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 11/25] hw/char: Add limited support for Atmel USART peripheral, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 13/25] hw/misc: Add Atmel power device, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 14/25] target/avr: Add section about AVR into QEMU documentation, Philippe Mathieu-Daudé, 2020/01/23
- [PATCH rc2 12/25] hw/timer: Add limited support for Atmel 16 bit timer peripheral, Philippe Mathieu-Daudé, 2020/01/23