xref: /openbmc/linux/arch/powerpc/math-emu/mcrfs.c (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
25cd27208SKumar Gala #include <linux/types.h>
35cd27208SKumar Gala #include <linux/errno.h>
47c0f6ba6SLinus Torvalds #include <linux/uaccess.h>
55cd27208SKumar Gala 
6d2b194edSKumar Gala #include <asm/sfp-machine.h>
7d2b194edSKumar Gala #include <math-emu/soft-fp.h>
85cd27208SKumar Gala 
95cd27208SKumar Gala int
mcrfs(u32 * ccr,u32 crfD,u32 crfS)105cd27208SKumar Gala mcrfs(u32 *ccr, u32 crfD, u32 crfS)
115cd27208SKumar Gala {
125cd27208SKumar Gala 	u32 value, clear;
135cd27208SKumar Gala 
145cd27208SKumar Gala #ifdef DEBUG
15e48b1b45SHarvey Harrison 	printk("%s: %p (%08x) %d %d\n", __func__, ccr, *ccr, crfD, crfS);
165cd27208SKumar Gala #endif
175cd27208SKumar Gala 
185cd27208SKumar Gala 	clear = 15 << ((7 - crfS) << 2);
195cd27208SKumar Gala 	if (!crfS)
205cd27208SKumar Gala 		clear = 0x90000000;
215cd27208SKumar Gala 
225cd27208SKumar Gala 	value = (__FPU_FPSCR >> ((7 - crfS) << 2)) & 15;
235cd27208SKumar Gala 	__FPU_FPSCR &= ~(clear);
245cd27208SKumar Gala 
255cd27208SKumar Gala 	*ccr &= ~(15 << ((7 - crfD) << 2));
265cd27208SKumar Gala 	*ccr |= (value << ((7 - crfD) << 2));
275cd27208SKumar Gala 
285cd27208SKumar Gala #ifdef DEBUG
29e48b1b45SHarvey Harrison 	printk("CR: %08x\n", __func__, *ccr);
305cd27208SKumar Gala #endif
315cd27208SKumar Gala 
325cd27208SKumar Gala 	return 0;
335cd27208SKumar Gala }
34