target/m68k: call plugin trap callbacks

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 Motorola 68000 targets.

Signed-off-by: Julian Ganz <neither@nut.email>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20251027110344.2289945-18-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
This commit is contained in:
Julian Ganz 2025-10-27 11:03:24 +00:00 committed by Alex Bennée
parent ee0a63d0da
commit b2d8618c21

View file

@ -22,6 +22,7 @@
#include "exec/helper-proto.h"
#include "accel/tcg/cpu-ldst.h"
#include "semihosting/semihost.h"
#include "qemu/plugin.h"
#if !defined(CONFIG_USER_ONLY)
@ -183,6 +184,21 @@ static const char *m68k_exception_name(int index)
return "Unassigned";
}
static void do_plugin_vcpu_interrupt_cb(CPUState *cs, uint64_t from)
{
switch (cs->exception_index) {
case EXCP_SPURIOUS ... EXCP_INT_LEVEL_7:
qemu_plugin_vcpu_interrupt_cb(cs, from);
break;
case EXCP_SEMIHOSTING:
qemu_plugin_vcpu_hostcall_cb(cs, from);
break;
default:
qemu_plugin_vcpu_exception_cb(cs, from);
break;
}
}
static void cf_interrupt_all(CPUM68KState *env, int is_hw)
{
CPUState *cs = env_cpu(env);
@ -203,6 +219,7 @@ static void cf_interrupt_all(CPUM68KState *env, int is_hw)
return;
case EXCP_SEMIHOSTING:
do_m68k_semihosting(env, env->dregs[0]);
qemu_plugin_vcpu_hostcall_cb(cs, retaddr);
return;
}
}
@ -239,6 +256,8 @@ static void cf_interrupt_all(CPUM68KState *env, int is_hw)
env->aregs[7] = sp;
/* Jump to vector. */
env->pc = cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, 0);
do_plugin_vcpu_interrupt_cb(cs, retaddr);
}
static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
@ -277,6 +296,7 @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
uint32_t sp;
uint32_t vector;
uint16_t sr, oldsr;
uint64_t last_pc = env->pc;
if (!is_hw) {
switch (cs->exception_index) {
@ -417,6 +437,8 @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw)
env->aregs[7] = sp;
/* Jump to vector. */
env->pc = cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, 0);
do_plugin_vcpu_interrupt_cb(cs, last_pc);
}
static void do_interrupt_all(CPUM68KState *env, int is_hw)