[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 65/74] target/xtensa: Use an exception for semihosting
From: |
Richard Henderson |
Subject: |
[PATCH v2 65/74] target/xtensa: Use an exception for semihosting |
Date: |
Tue, 3 May 2022 12:48:34 -0700 |
Within do_interrupt, we hold the iothread lock, which
is required for Chardev access for the console, and for
the round trip for use_gdb_syscalls().
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/xtensa/cpu.h | 2 ++
target/xtensa/helper.h | 3 ---
target/xtensa/exc_helper.c | 4 ++++
target/xtensa/translate.c | 3 ++-
target/xtensa/xtensa-semi.c | 3 +--
5 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index d4b8268146..411a128f60 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -259,6 +259,7 @@ enum {
EXC_USER,
EXC_DOUBLE,
EXC_DEBUG,
+ EXC_SEMIHOST,
EXC_MAX
};
@@ -574,6 +575,7 @@ void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr
physaddr, vaddr addr,
unsigned size, MMUAccessType access_type,
int mmu_idx, MemTxAttrs attrs,
MemTxResult response, uintptr_t retaddr);
+void xtensa_semihosting(CPUXtensaState *env);
#endif
void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
diff --git a/target/xtensa/helper.h b/target/xtensa/helper.h
index ae938ceedb..531679cd86 100644
--- a/target/xtensa/helper.h
+++ b/target/xtensa/helper.h
@@ -11,9 +11,6 @@ DEF_HELPER_2(retw, void, env, i32)
DEF_HELPER_3(window_check, noreturn, env, i32, i32)
DEF_HELPER_1(restore_owb, void, env)
DEF_HELPER_2(movsp, void, env, i32)
-#ifndef CONFIG_USER_ONLY
-DEF_HELPER_1(simcall, void, env)
-#endif
#ifndef CONFIG_USER_ONLY
DEF_HELPER_3(waiti, void, env, i32, i32)
diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c
index d4823a65cd..d54a518875 100644
--- a/target/xtensa/exc_helper.c
+++ b/target/xtensa/exc_helper.c
@@ -219,6 +219,10 @@ void xtensa_cpu_do_interrupt(CPUState *cs)
}
switch (cs->exception_index) {
+ case EXC_SEMIHOST:
+ xtensa_semihosting(env);
+ return;
+
case EXC_WINDOW_OVERFLOW4:
case EXC_WINDOW_UNDERFLOW4:
case EXC_WINDOW_OVERFLOW8:
diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
index 1485df2f22..6ddb2e112e 100644
--- a/target/xtensa/translate.c
+++ b/target/xtensa/translate.c
@@ -2416,7 +2416,8 @@ static void translate_simcall(DisasContext *dc, const
OpcodeArg arg[],
{
#ifndef CONFIG_USER_ONLY
if (semihosting_enabled()) {
- gen_helper_simcall(cpu_env);
+ tcg_gen_movi_i32(cpu_pc, dc->base.pc_next);
+ gen_exception(dc, EXC_SEMIHOST);
}
#endif
}
diff --git a/target/xtensa/xtensa-semi.c b/target/xtensa/xtensa-semi.c
index fa21b7e11f..5375f106fc 100644
--- a/target/xtensa/xtensa-semi.c
+++ b/target/xtensa/xtensa-semi.c
@@ -28,7 +28,6 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "chardev/char-fe.h"
-#include "exec/helper-proto.h"
#include "semihosting/semihost.h"
#include "qapi/error.h"
#include "qemu/log.h"
@@ -188,7 +187,7 @@ void xtensa_sim_open_console(Chardev *chr)
sim_console = &console;
}
-void HELPER(simcall)(CPUXtensaState *env)
+void xtensa_semihosting(CPUXtensaState *env)
{
CPUState *cs = env_cpu(env);
uint32_t *regs = env->regs;
--
2.34.1
- [PATCH v2 50/74] target/m68k: Use semihosting/syscalls.h, (continued)
- [PATCH v2 50/74] target/m68k: Use semihosting/syscalls.h, Richard Henderson, 2022/05/03
- [PATCH v2 51/74] target/nios2: Eliminate nios2_semi_is_lseek, Richard Henderson, 2022/05/03
- [PATCH v2 57/74] target/mips: Drop link syscall from semihosting, Richard Henderson, 2022/05/03
- [PATCH v2 53/74] target/nios2: Use semihosting/syscalls.h, Richard Henderson, 2022/05/03
- [PATCH v2 54/74] target/mips: Use an exception for semihosting, Richard Henderson, 2022/05/03
- [PATCH v2 60/74] target/mips: Avoid qemu_semihosting_log_out for UHI_plog, Richard Henderson, 2022/05/03
- [PATCH v2 56/74] target/mips: Create report_fault for semihosting, Richard Henderson, 2022/05/03
- [PATCH v2 58/74] target/mips: Drop pread and pwrite syscalls from semihosting, Richard Henderson, 2022/05/03
- [PATCH v2 59/74] target/mips: Use semihosting/syscalls.h, Richard Henderson, 2022/05/03
- [PATCH v2 63/74] target/mips: Simplify UHI_argnlen and UHI_argn, Richard Henderson, 2022/05/03
- [PATCH v2 65/74] target/xtensa: Use an exception for semihosting,
Richard Henderson <=
- [PATCH v2 61/74] target/mips: Use error_report for UHI_assert, Richard Henderson, 2022/05/03
- [PATCH v2 67/74] tests/docker: Add debian-rx-cross image, Richard Henderson, 2022/05/03
- [PATCH v2 64/74] target/mips: Remove GET_TARGET_STRING and FREE_TARGET_STRING, Richard Henderson, 2022/05/03
- [PATCH v2 69/74] target/rx: Fix the base of the fixed vector table, Richard Henderson, 2022/05/03
- [PATCH v2 73/74] target/rx: Implement libgloss semihosting, Richard Henderson, 2022/05/03
- [PATCH v2 71/74] target/rx: Consolidate exception helpers, Richard Henderson, 2022/05/03
- [PATCH v2 74/74] tests/tcg/rx: Enable semihosting multiarch tests, Richard Henderson, 2022/05/03
- [PATCH v2 62/74] semihosting: Remove qemu_semihosting_log_out, Richard Henderson, 2022/05/03
- [PATCH v2 66/74] target/xtensa: Use semihosting/syscalls.h, Richard Henderson, 2022/05/03
- [PATCH v2 68/74] hw/rx: Handle a kernel file that is ELF, Richard Henderson, 2022/05/03