Skip to content

Commit

Permalink
target/sparc: call plugin trap callbacks
Browse files Browse the repository at this point in the history
We recently introduced API for registering callbacks for trap related
events as well as the corresponding hook functions. Due to differences
between architectures, the latter need to be called from target specific
code.

This change places hooks for SPARC (32bit and 64bit) targets. We treat
any interrupt other than EXTINT and IVEC as exceptions as they appear to
be synchroneous events.
  • Loading branch information
neithernut authored and pbo-linaro committed Dec 4, 2024
1 parent 180ecba commit 8745434
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions target/sparc/int32_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "exec/cpu_ldst.h"
#include "exec/log.h"
#include "sysemu/runstate.h"
#include "qemu/plugin.h"

static const char * const excp_names[0x80] = {
[TT_TFAULT] = "Instruction Access Fault",
Expand Down Expand Up @@ -172,4 +173,10 @@ void sparc_cpu_do_interrupt(CPUState *cs)
env->qemu_irq_ack(env, intno);
}
#endif

if (intno == TT_EXTINT) {
qemu_plugin_vcpu_interrupt_cb(cs, env->regwptr[9], env->pc);
} else {
qemu_plugin_vcpu_exception_cb(cs, env->regwptr[9], env->pc);
}
}
10 changes: 10 additions & 0 deletions target/sparc/int64_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "exec/helper-proto.h"
#include "exec/log.h"
#include "trace.h"
#include "qemu/plugin.h"

#define DEBUG_PCALL

Expand Down Expand Up @@ -253,6 +254,15 @@ void sparc_cpu_do_interrupt(CPUState *cs)
}
env->npc = env->pc + 4;
cs->exception_index = -1;

switch (intno) {
case TT_EXTINT:
case TT_IVEC:
qemu_plugin_vcpu_interrupt_cb(cs, tsptr->tpc, env->pc);
break;
default:
qemu_plugin_vcpu_exception_cb(cs, tsptr->tpc, env->pc);
}
}

trap_state *cpu_tsptr(CPUSPARCState* env)
Expand Down

0 comments on commit 8745434

Please sign in to comment.