^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <asm/sfp-machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <math-emu/soft-fp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) mcrfs(u32 *ccr, u32 crfD, u32 crfS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) u32 value, clear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) printk("%s: %p (%08x) %d %d\n", __func__, ccr, *ccr, crfD, crfS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) clear = 15 << ((7 - crfS) << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) if (!crfS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) clear = 0x90000000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) value = (__FPU_FPSCR >> ((7 - crfS) << 2)) & 15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) __FPU_FPSCR &= ~(clear);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *ccr &= ~(15 << ((7 - crfD) << 2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) *ccr |= (value << ((7 - crfD) << 2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) printk("CR: %08x\n", __func__, *ccr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }