Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/types.h>
0003 #include <linux/errno.h>
0004 #include <linux/uaccess.h>
0005 
0006 #include <asm/sfp-machine.h>
0007 #include <math-emu/soft-fp.h>
0008 #include <math-emu/double.h>
0009 #include <math-emu/single.h>
0010 
0011 int
0012 lfs(void *frD, void *ea)
0013 {
0014     FP_DECL_D(R);
0015     FP_DECL_S(A);
0016     FP_DECL_EX;
0017     float f;
0018 
0019 #ifdef DEBUG
0020     printk("%s: D %p, ea %p\n", __func__, frD, ea);
0021 #endif
0022 
0023     if (copy_from_user(&f, ea, sizeof(float)))
0024         return -EFAULT;
0025 
0026     FP_UNPACK_S(A, f);
0027 
0028 #ifdef DEBUG
0029     printk("A: %ld %lu %ld (%ld) [%08lx]\n", A_s, A_f, A_e, A_c,
0030            *(unsigned long *)&f);
0031 #endif
0032 
0033     FP_CONV(D, S, 2, 1, R, A);
0034 
0035 #ifdef DEBUG
0036     printk("R: %ld %lu %lu %ld (%ld)\n", R_s, R_f1, R_f0, R_e, R_c);
0037 #endif
0038 
0039     if (R_c == FP_CLS_NAN) {
0040         R_e = _FP_EXPMAX_D;
0041         _FP_PACK_RAW_2_P(D, frD, R);
0042     } else {
0043         __FP_PACK_D(frD, R);
0044     }
0045 
0046     return 0;
0047 }