2 * Copyright (C) 2012 - Virtual Open Systems and Columbia University
3 * Author: Christoffer Dall <c.dall@virtualopensystems.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include <linux/linkage.h>
19 #include <asm/vfpmacros.h>
22 .pushsection .hyp.text, "ax"
24 /* void __vfp_save_state(struct vfp_hard_struct *vfp); */
25 ENTRY(__vfp_save_state)
29 @ Make sure *really* VFP is enabled so we can touch the registers.
31 tst r5, #FPEXC_EX @ Check for VFP Subarchitecture
32 bic r5, r5, #FPEXC_EX @ FPEXC_EX disable
39 @ If FPEXC_EX is 0, then FPINST/FPINST2 reads are upredictable, so
40 @ we only need to save them if FPEXC_EX is set.
43 VFPFMRX r4, FPINST2, ne @ vmrsne
45 VFPFSTMIA r0, r5 @ Save VFP registers
46 stm r0, {r1-r4} @ Save FPEXC, FPSCR, FPINST, FPINST2
49 ENDPROC(__vfp_save_state)
51 /* void __vfp_restore_state(struct vfp_hard_struct *vfp);
52 * Assume FPEXC_EN is on and FPEXC_EX is off */
53 ENTRY(__vfp_restore_state)
54 VFPFLDMIA r0, r1 @ Load VFP registers
55 ldm r0, {r0-r3} @ Load FPEXC, FPSCR, FPINST, FPINST2
58 tst r0, #FPEXC_EX @ Check for VFP Subarchitecture
62 VFPFMXR FPINST2, r3, ne
64 VFPFMXR FPEXC, r0 @ FPEXC (last, in case !EN)
66 ENDPROC(__vfp_restore_state)