summaryrefslogtreecommitdiffstats
path: root/linux-user/riscv/cpu_loop.c
diff options
context:
space:
mode:
authorKito Cheng2021-01-08 23:42:53 +0100
committerAlex Bennée2021-01-18 11:05:06 +0100
commit6b80cb25b4165ae2afa525d084366221a2e9b58d (patch)
treea47658827d26826f03bf547ff9bb7d9d514df35b /linux-user/riscv/cpu_loop.c
parentriscv: Add semihosting support (diff)
downloadqemu-6b80cb25b4165ae2afa525d084366221a2e9b58d.tar.gz
qemu-6b80cb25b4165ae2afa525d084366221a2e9b58d.tar.xz
qemu-6b80cb25b4165ae2afa525d084366221a2e9b58d.zip
riscv: Add semihosting support for user mode
This could made testing more easier and ARM/AArch64 has supported on their linux user mode too, so I think it should be reasonable. Verified GCC testsuite with newlib/semihosting. Signed-off-by: Kito Cheng <kito.cheng@sifive.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Keith Packard <keithp@keithp.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20210107170717.2098982-7-keithp@keithp.com> Message-Id: <20210108224256.2321-18-alex.bennee@linaro.org>
Diffstat (limited to 'linux-user/riscv/cpu_loop.c')
-rw-r--r--linux-user/riscv/cpu_loop.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c
index aa9e437875..9665dabb09 100644
--- a/linux-user/riscv/cpu_loop.c
+++ b/linux-user/riscv/cpu_loop.c
@@ -23,6 +23,7 @@
#include "qemu.h"
#include "cpu_loop-common.h"
#include "elf.h"
+#include "hw/semihosting/common-semi.h"
void cpu_loop(CPURISCVState *env)
{
@@ -91,6 +92,10 @@ void cpu_loop(CPURISCVState *env)
sigcode = TARGET_SEGV_MAPERR;
sigaddr = env->badaddr;
break;
+ case RISCV_EXCP_SEMIHOST:
+ env->gpr[xA0] = do_common_semihosting(cs);
+ env->pc += 4;
+ break;
case EXCP_DEBUG:
gdbstep:
signum = TARGET_SIGTRAP;