aboutsummaryrefslogtreecommitdiff
path: root/target/nios2/helper.c
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2019-04-03 13:53:05 -0600
committerPeter Maydell <peter.maydell@linaro.org>2019-04-29 16:09:51 +0100
commit413a99a92c13ec408dcf2adaa87918dc81e890c8 (patch)
tree464dba82fd644eea860bd991c4c1dc9f15b1a15a /target/nios2/helper.c
parented960ba90549aca1735df128c6b454fe0a5dec2a (diff)
Add Nios II semihosting support.
This patch adds support for libgloss semihosting to Nios II bare-metal emulation. The specification for the protocol can be found in the libgloss sources. Signed-off-by: Sandra Loosemore <sandra@codesourcery.com> Signed-off-by: Julian Brown <julian@codesourcery.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1554321185-2825-3-git-send-email-sandra@codesourcery.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'target/nios2/helper.c')
-rw-r--r--target/nios2/helper.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/target/nios2/helper.c b/target/nios2/helper.c
index a633fa03ee..e01fc1ff3e 100644
--- a/target/nios2/helper.c
+++ b/target/nios2/helper.c
@@ -23,8 +23,10 @@
#include "cpu.h"
#include "qemu/host-utils.h"
#include "exec/exec-all.h"
+#include "exec/cpu_ldst.h"
#include "exec/log.h"
#include "exec/helper-proto.h"
+#include "exec/semihost.h"
#if defined(CONFIG_USER_ONLY)
@@ -169,6 +171,17 @@ void nios2_cpu_do_interrupt(CPUState *cs)
break;
case EXCP_BREAK:
+ qemu_log_mask(CPU_LOG_INT, "BREAK exception at pc=%x\n",
+ env->regs[R_PC]);
+ /* The semihosting instruction is "break 1". */
+ if (semihosting_enabled() &&
+ cpu_ldl_code(env, env->regs[R_PC]) == 0x003da07a) {
+ qemu_log_mask(CPU_LOG_INT, "Entering semihosting\n");
+ env->regs[R_PC] += 4;
+ do_nios2_semihosting(env);
+ break;
+ }
+
if ((env->regs[CR_STATUS] & CR_STATUS_EH) == 0) {
env->regs[CR_BSTATUS] = env->regs[CR_STATUS];
env->regs[R_BA] = env->regs[R_PC] + 4;