target/m68k: Map FPU exceptions to FPSR register

Add helpers for reading/writing the 68881 FPSR register so that
changes in floating point exception state can be seen by the
application.

Call these helpers in pre_load/post_load hooks to synchronize
exception state.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230803035231.429697-1-keithp@keithp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Keith Packard 2023-08-02 20:52:31 -07:00 committed by Richard Henderson
parent b754cb2dcd
commit 5888357942
6 changed files with 90 additions and 7 deletions

View file

@ -390,12 +390,19 @@ static const VMStateDescription vmstate_freg = {
}
};
static int fpu_pre_save(void *opaque)
{
M68kCPU *s = opaque;
s->env.fpsr = cpu_m68k_get_fpsr(&s->env);
return 0;
}
static int fpu_post_load(void *opaque, int version)
{
M68kCPU *s = opaque;
cpu_m68k_restore_fp_status(&s->env);
cpu_m68k_set_fpsr(&s->env, s->env.fpsr);
return 0;
}
@ -404,6 +411,7 @@ const VMStateDescription vmmstate_fpu = {
.version_id = 1,
.minimum_version_id = 1,
.needed = fpu_needed,
.pre_save = fpu_pre_save,
.post_load = fpu_post_load,
.fields = (const VMStateField[]) {
VMSTATE_UINT32(env.fpcr, M68kCPU),