0001
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
0010 int
0011 fcmpo(u32 *ccr, int crfD, void *frA, void *frB)
0012 {
0013 FP_DECL_D(A);
0014 FP_DECL_D(B);
0015 FP_DECL_EX;
0016 int code[4] = { (1 << 3), (1 << 1), (1 << 2), (1 << 0) };
0017 long cmp;
0018
0019 #ifdef DEBUG
0020 printk("%s: %p (%08x) %d %p %p\n", __func__, ccr, *ccr, crfD, frA, frB);
0021 #endif
0022
0023 FP_UNPACK_DP(A, frA);
0024 FP_UNPACK_DP(B, frB);
0025
0026 #ifdef DEBUG
0027 printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
0028 printk("B: %ld %lu %lu %ld (%ld)\n", B_s, B_f1, B_f0, B_e, B_c);
0029 #endif
0030
0031 if (A_c == FP_CLS_NAN || B_c == FP_CLS_NAN)
0032 FP_SET_EXCEPTION(EFLAG_VXVC);
0033
0034 FP_CMP_D(cmp, A, B, 2);
0035 cmp = code[(cmp + 1) & 3];
0036
0037 __FPU_FPSCR &= ~(0x1f000);
0038 __FPU_FPSCR |= (cmp << 12);
0039
0040 *ccr &= ~(15 << ((7 - crfD) << 2));
0041 *ccr |= (cmp << ((7 - crfD) << 2));
0042
0043 #ifdef DEBUG
0044 printk("CR: %08x\n", *ccr);
0045 #endif
0046
0047 return FP_CUR_EXCEPTIONS;
0048 }