1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Copyright (C) 2012 Regents of the University of California 4 * Copyright (C) 2017 SiFive 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation, version 2. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 */ 15 16#include <linux/linkage.h> 17 18#include <asm/asm.h> 19#include <asm/csr.h> 20#include <asm/asm-offsets.h> 21 22ENTRY(__fstate_save) 23 li a2, TASK_THREAD_F0 24 add a0, a0, a2 25 li t1, SR_FS 26 csrs CSR_STATUS, t1 27 frcsr t0 28 fsd f0, TASK_THREAD_F0_F0(a0) 29 fsd f1, TASK_THREAD_F1_F0(a0) 30 fsd f2, TASK_THREAD_F2_F0(a0) 31 fsd f3, TASK_THREAD_F3_F0(a0) 32 fsd f4, TASK_THREAD_F4_F0(a0) 33 fsd f5, TASK_THREAD_F5_F0(a0) 34 fsd f6, TASK_THREAD_F6_F0(a0) 35 fsd f7, TASK_THREAD_F7_F0(a0) 36 fsd f8, TASK_THREAD_F8_F0(a0) 37 fsd f9, TASK_THREAD_F9_F0(a0) 38 fsd f10, TASK_THREAD_F10_F0(a0) 39 fsd f11, TASK_THREAD_F11_F0(a0) 40 fsd f12, TASK_THREAD_F12_F0(a0) 41 fsd f13, TASK_THREAD_F13_F0(a0) 42 fsd f14, TASK_THREAD_F14_F0(a0) 43 fsd f15, TASK_THREAD_F15_F0(a0) 44 fsd f16, TASK_THREAD_F16_F0(a0) 45 fsd f17, TASK_THREAD_F17_F0(a0) 46 fsd f18, TASK_THREAD_F18_F0(a0) 47 fsd f19, TASK_THREAD_F19_F0(a0) 48 fsd f20, TASK_THREAD_F20_F0(a0) 49 fsd f21, TASK_THREAD_F21_F0(a0) 50 fsd f22, TASK_THREAD_F22_F0(a0) 51 fsd f23, TASK_THREAD_F23_F0(a0) 52 fsd f24, TASK_THREAD_F24_F0(a0) 53 fsd f25, TASK_THREAD_F25_F0(a0) 54 fsd f26, TASK_THREAD_F26_F0(a0) 55 fsd f27, TASK_THREAD_F27_F0(a0) 56 fsd f28, TASK_THREAD_F28_F0(a0) 57 fsd f29, TASK_THREAD_F29_F0(a0) 58 fsd f30, TASK_THREAD_F30_F0(a0) 59 fsd f31, TASK_THREAD_F31_F0(a0) 60 sw t0, TASK_THREAD_FCSR_F0(a0) 61 csrc CSR_STATUS, t1 62 ret 63ENDPROC(__fstate_save) 64 65ENTRY(__fstate_restore) 66 li a2, TASK_THREAD_F0 67 add a0, a0, a2 68 li t1, SR_FS 69 lw t0, TASK_THREAD_FCSR_F0(a0) 70 csrs CSR_STATUS, t1 71 fld f0, TASK_THREAD_F0_F0(a0) 72 fld f1, TASK_THREAD_F1_F0(a0) 73 fld f2, TASK_THREAD_F2_F0(a0) 74 fld f3, TASK_THREAD_F3_F0(a0) 75 fld f4, TASK_THREAD_F4_F0(a0) 76 fld f5, TASK_THREAD_F5_F0(a0) 77 fld f6, TASK_THREAD_F6_F0(a0) 78 fld f7, TASK_THREAD_F7_F0(a0) 79 fld f8, TASK_THREAD_F8_F0(a0) 80 fld f9, TASK_THREAD_F9_F0(a0) 81 fld f10, TASK_THREAD_F10_F0(a0) 82 fld f11, TASK_THREAD_F11_F0(a0) 83 fld f12, TASK_THREAD_F12_F0(a0) 84 fld f13, TASK_THREAD_F13_F0(a0) 85 fld f14, TASK_THREAD_F14_F0(a0) 86 fld f15, TASK_THREAD_F15_F0(a0) 87 fld f16, TASK_THREAD_F16_F0(a0) 88 fld f17, TASK_THREAD_F17_F0(a0) 89 fld f18, TASK_THREAD_F18_F0(a0) 90 fld f19, TASK_THREAD_F19_F0(a0) 91 fld f20, TASK_THREAD_F20_F0(a0) 92 fld f21, TASK_THREAD_F21_F0(a0) 93 fld f22, TASK_THREAD_F22_F0(a0) 94 fld f23, TASK_THREAD_F23_F0(a0) 95 fld f24, TASK_THREAD_F24_F0(a0) 96 fld f25, TASK_THREAD_F25_F0(a0) 97 fld f26, TASK_THREAD_F26_F0(a0) 98 fld f27, TASK_THREAD_F27_F0(a0) 99 fld f28, TASK_THREAD_F28_F0(a0) 100 fld f29, TASK_THREAD_F29_F0(a0) 101 fld f30, TASK_THREAD_F30_F0(a0) 102 fld f31, TASK_THREAD_F31_F0(a0) 103 fscsr t0 104 csrc CSR_STATUS, t1 105 ret 106ENDPROC(__fstate_restore) 107