WIP FPC-III support
[linux/fpc-iii.git] / arch / powerpc / math-emu / mcrfs.c
blob9c4fdaace475b9daa66d738ab850bcb789bb4337
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/types.h>
3 #include <linux/errno.h>
4 #include <linux/uaccess.h>
6 #include <asm/sfp-machine.h>
7 #include <math-emu/soft-fp.h>
9 int
10 mcrfs(u32 *ccr, u32 crfD, u32 crfS)
12 u32 value, clear;
14 #ifdef DEBUG
15 printk("%s: %p (%08x) %d %d\n", __func__, ccr, *ccr, crfD, crfS);
16 #endif
18 clear = 15 << ((7 - crfS) << 2);
19 if (!crfS)
20 clear = 0x90000000;
22 value = (__FPU_FPSCR >> ((7 - crfS) << 2)) & 15;
23 __FPU_FPSCR &= ~(clear);
25 *ccr &= ~(15 << ((7 - crfD) << 2));
26 *ccr |= (value << ((7 - crfD) << 2));
28 #ifdef DEBUG
29 printk("CR: %08x\n", __func__, *ccr);
30 #endif
32 return 0;