Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __ASM_ALPHA_FPU_H
0003 #define __ASM_ALPHA_FPU_H
0004 
0005 #include <asm/special_insns.h>
0006 #include <uapi/asm/fpu.h>
0007 
0008 /* The following two functions don't need trapb/excb instructions
0009    around the mf_fpcr/mt_fpcr instructions because (a) the kernel
0010    never generates arithmetic faults and (b) call_pal instructions
0011    are implied trap barriers.  */
0012 
0013 static inline unsigned long
0014 rdfpcr(void)
0015 {
0016     unsigned long tmp, ret;
0017 
0018 #if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67)
0019     __asm__ __volatile__ (
0020         "ftoit $f0,%0\n\t"
0021         "mf_fpcr $f0\n\t"
0022         "ftoit $f0,%1\n\t"
0023         "itoft %0,$f0"
0024         : "=r"(tmp), "=r"(ret));
0025 #else
0026     __asm__ __volatile__ (
0027         "stt $f0,%0\n\t"
0028         "mf_fpcr $f0\n\t"
0029         "stt $f0,%1\n\t"
0030         "ldt $f0,%0"
0031         : "=m"(tmp), "=m"(ret));
0032 #endif
0033 
0034     return ret;
0035 }
0036 
0037 static inline void
0038 wrfpcr(unsigned long val)
0039 {
0040     unsigned long tmp;
0041 
0042 #if defined(CONFIG_ALPHA_EV6) || defined(CONFIG_ALPHA_EV67)
0043     __asm__ __volatile__ (
0044         "ftoit $f0,%0\n\t"
0045         "itoft %1,$f0\n\t"
0046         "mt_fpcr $f0\n\t"
0047         "itoft %0,$f0"
0048         : "=&r"(tmp) : "r"(val));
0049 #else
0050     __asm__ __volatile__ (
0051         "stt $f0,%0\n\t"
0052         "ldt $f0,%1\n\t"
0053         "mt_fpcr $f0\n\t"
0054         "ldt $f0,%0"
0055         : "=m"(tmp) : "m"(val));
0056 #endif
0057 }
0058 
0059 static inline unsigned long
0060 swcr_update_status(unsigned long swcr, unsigned long fpcr)
0061 {
0062     /* EV6 implements most of the bits in hardware.  Collect
0063        the acrued exception bits from the real fpcr.  */
0064     if (implver() == IMPLVER_EV6) {
0065         swcr &= ~IEEE_STATUS_MASK;
0066         swcr |= (fpcr >> 35) & IEEE_STATUS_MASK;
0067     }
0068     return swcr;
0069 }
0070 
0071 extern unsigned long alpha_read_fp_reg (unsigned long reg);
0072 extern void alpha_write_fp_reg (unsigned long reg, unsigned long val);
0073 extern unsigned long alpha_read_fp_reg_s (unsigned long reg);
0074 extern void alpha_write_fp_reg_s (unsigned long reg, unsigned long val);
0075 
0076 #endif /* __ASM_ALPHA_FPU_H */