diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-11-29 16:10:36 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-11-29 16:10:41 +0100 |
commit | 5dbc6990b16a969e470392abe48e8ff9552780b3 (patch) | |
tree | 1083b9189aace9dc2fd06e011df515e72d79f4af /i386/i386/fpu.c | |
parent | 231bd7fdc04517389135a4958294cf7630617385 (diff) |
x86: Factorize fpu save/restore
* i386/i386/fpu.h (fpu_save, fpu_rstor): New macros.
(fpu_save_context): Use fpu_save macro.
* i386/i386/fpu.c (fp_save): Use fpu_save macro.
(fp_load): Use fpu_rstor macro.
Diffstat (limited to 'i386/i386/fpu.c')
-rw-r--r-- | i386/i386/fpu.c | 42 |
1 files changed, 3 insertions, 39 deletions
diff --git a/i386/i386/fpu.c b/i386/i386/fpu.c index b177dad2..03f43f9d 100644 --- a/i386/i386/fpu.c +++ b/i386/i386/fpu.c @@ -825,30 +825,9 @@ fp_save(thread_t thread) pcb_t pcb = thread->pcb; struct i386_fpsave_state *ifps = pcb->ims.ifps; - if (ifps != 0 && !ifps->fp_valid) { + if (ifps != 0 && !ifps->fp_valid) /* registers are in FPU */ - ifps->fp_valid = TRUE; - switch (fp_save_kind) { - case FP_XSAVE: - xsave(&ifps->xfp_save_state); - break; - case FP_XSAVEOPT: - xsaveopt(&ifps->xfp_save_state); - break; - case FP_XSAVEC: - xsavec(&ifps->xfp_save_state); - break; - case FP_XSAVES: - xsaves(&ifps->xfp_save_state); - break; - case FP_FXSAVE: - fxsave(&ifps->xfp_save_state); - break; - case FP_FNSAVE: - fnsave(&ifps->fp_save_state); - break; - } - } + fpu_save(ifps); } /* @@ -896,22 +875,7 @@ ASSERT_IPL(SPL0); printf("fp_load: invalid FPU state!\n"); fninit (); } else { - switch (fp_save_kind) { - case FP_XSAVE: - case FP_XSAVEOPT: - case FP_XSAVEC: - xrstor(ifps->xfp_save_state); - break; - case FP_XSAVES: - xrstors(ifps->xfp_save_state); - break; - case FP_FXSAVE: - fxrstor(ifps->xfp_save_state); - break; - case FP_FNSAVE: - frstor(ifps->fp_save_state); - break; - } + fpu_rstor(ifps); } ifps->fp_valid = FALSE; /* in FPU */ } |