.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * fpu.c - save/restore of Floating Point Unit Registers on task switch |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License version 2 as |
---|
8 | | - * published by the Free Software Foundation. |
---|
9 | 6 | */ |
---|
10 | 7 | |
---|
11 | 8 | #include <linux/sched.h> |
---|
12 | | -#include <asm/switch_to.h> |
---|
| 9 | +#include <asm/fpu.h> |
---|
| 10 | + |
---|
| 11 | +#ifdef CONFIG_ISA_ARCOMPACT |
---|
13 | 12 | |
---|
14 | 13 | /* |
---|
15 | 14 | * To save/restore FPU regs, simplest scheme would use LR/SR insns. |
---|
.. | .. |
---|
53 | 52 | : "r" (zero), "r" (*(readfrom + 3)), "r" (*(readfrom + 2)) |
---|
54 | 53 | ); |
---|
55 | 54 | } |
---|
| 55 | + |
---|
| 56 | +#else |
---|
| 57 | + |
---|
| 58 | +void fpu_init_task(struct pt_regs *regs) |
---|
| 59 | +{ |
---|
| 60 | + const unsigned int fwe = 0x80000000; |
---|
| 61 | + |
---|
| 62 | + /* default rounding mode */ |
---|
| 63 | + write_aux_reg(ARC_REG_FPU_CTRL, 0x100); |
---|
| 64 | + |
---|
| 65 | + /* Initialize to zero: setting requires FWE be set */ |
---|
| 66 | + write_aux_reg(ARC_REG_FPU_STATUS, fwe); |
---|
| 67 | +} |
---|
| 68 | + |
---|
| 69 | +void fpu_save_restore(struct task_struct *prev, struct task_struct *next) |
---|
| 70 | +{ |
---|
| 71 | + struct arc_fpu *save = &prev->thread.fpu; |
---|
| 72 | + struct arc_fpu *restore = &next->thread.fpu; |
---|
| 73 | + const unsigned int fwe = 0x80000000; |
---|
| 74 | + |
---|
| 75 | + save->ctrl = read_aux_reg(ARC_REG_FPU_CTRL); |
---|
| 76 | + save->status = read_aux_reg(ARC_REG_FPU_STATUS); |
---|
| 77 | + |
---|
| 78 | + write_aux_reg(ARC_REG_FPU_CTRL, restore->ctrl); |
---|
| 79 | + write_aux_reg(ARC_REG_FPU_STATUS, (fwe | restore->status)); |
---|
| 80 | +} |
---|
| 81 | + |
---|
| 82 | +#endif |
---|