Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/powerpc Expose fpu_get_fault_code() even if !PPC_HA...



details:   https://anonhg.NetBSD.org/src/rev/3f8a2e9b4fff
branches:  trunk
changeset: 935991:3f8a2e9b4fff
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Jul 15 09:19:49 2020 +0000

description:
Expose fpu_get_fault_code() even if !PPC_HAVE_FPU, and
adjust it to systems without FPU.

diffstat:

 sys/arch/powerpc/include/fpu.h |   6 +++---
 sys/arch/powerpc/powerpc/fpu.c |  11 +++++++----
 2 files changed, 10 insertions(+), 7 deletions(-)

diffs (80 lines):

diff -r cf85a4283afb -r 3f8a2e9b4fff sys/arch/powerpc/include/fpu.h
--- a/sys/arch/powerpc/include/fpu.h    Wed Jul 15 09:16:35 2020 +0000
+++ b/sys/arch/powerpc/include/fpu.h    Wed Jul 15 09:19:49 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.h,v 1.24 2020/07/06 10:52:12 rin Exp $     */
+/*     $NetBSD: fpu.h,v 1.25 2020/07/15 09:19:49 rin Exp $     */
 
 /*-
  * Copyright (C) 1996 Wolfgang Solfrank.
@@ -83,6 +83,8 @@
 void   fpu_restore_from_mcontext(struct lwp *, const mcontext_t *);
 bool   fpu_save_to_mcontext(struct lwp *, mcontext_t *, unsigned int *);
 
+int    fpu_get_fault_code(void);
+
 extern const pcu_ops_t fpu_ops;
 
 /* List of PowerPC architectures that support FPUs. */
@@ -112,8 +114,6 @@
 void   fpu_load_from_fpreg(const struct fpreg *);
 void   fpu_unload_to_fpreg(struct fpreg *);
 
-int    fpu_get_fault_code(void);
-
 #endif /* PPC_HAVE_FPU */
 #endif /* _KERNEL */
 
diff -r cf85a4283afb -r 3f8a2e9b4fff sys/arch/powerpc/powerpc/fpu.c
--- a/sys/arch/powerpc/powerpc/fpu.c    Wed Jul 15 09:16:35 2020 +0000
+++ b/sys/arch/powerpc/powerpc/fpu.c    Wed Jul 15 09:19:49 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.c,v 1.41 2020/07/06 10:52:12 rin Exp $     */
+/*     $NetBSD: fpu.c,v 1.42 2020/07/15 09:19:49 rin Exp $     */
 
 /*
  * Copyright (C) 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.41 2020/07/06 10:52:12 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.42 2020/07/15 09:19:49 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -124,7 +124,6 @@
 #endif
 }
 
-#ifdef PPC_HAVE_FPU
 #define        STICKYBITS      (FPSCR_VX|FPSCR_OX|FPSCR_UX|FPSCR_ZX|FPSCR_XX)
 #define        STICKYSHIFT     25
 #define        MASKBITS        (FPSCR_VE|FPSCR_OE|FPSCR_UE|FPSCR_ZE|FPSCR_XE)
@@ -139,6 +138,7 @@
        uint32_t fpscr, ofpscr;
        int code;
 
+#ifdef PPC_HAVE_FPU
        kpreempt_disable();
 
        struct cpu_info * const ci = curcpu();
@@ -182,6 +182,10 @@
        }
 
        kpreempt_enable();
+#else /* !PPC_HAVE_FPU */
+       fpscr64 = *(uint64_t *)&pcb->pcb_fpu.fpscr;
+       ((uint32_t *)&pcb->pcb_fpu.fpscr)[_QUAD_LOWWORD] &= ~MASKBITS;
+#endif
 
        /*
         * Now determine the fault type.  First we test to see if any of sticky
@@ -207,7 +211,6 @@
        else                            code = 0;
        return code;
 }
-#endif /* PPC_HAVE_FPU */
 
 bool
 fpu_save_to_mcontext(lwp_t *l, mcontext_t *mcp, unsigned int *flagp)



Home | Main Index | Thread Index | Old Index