1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2012 - Virtual Open Systems and Columbia University
4 * Author: Christoffer Dall <c.dall@virtualopensystems.com>
7 #include <linux/linkage.h>
8 #include <asm/vfpmacros.h>
11 .pushsection .hyp.text, "ax"
13 /* void __vfp_save_state(struct vfp_hard_struct *vfp); */
14 ENTRY(__vfp_save_state)
18 @ Make sure *really* VFP is enabled so we can touch the registers.
20 tst r5, #FPEXC_EX @ Check for VFP Subarchitecture
21 bic r5, r5, #FPEXC_EX @ FPEXC_EX disable
28 @ If FPEXC_EX is 0, then FPINST/FPINST2 reads are upredictable, so
29 @ we only need to save them if FPEXC_EX is set.
32 VFPFMRX r4, FPINST2, ne @ vmrsne
34 VFPFSTMIA r0, r5 @ Save VFP registers
35 stm r0, {r1-r4} @ Save FPEXC, FPSCR, FPINST, FPINST2
38 ENDPROC(__vfp_save_state)
40 /* void __vfp_restore_state(struct vfp_hard_struct *vfp);
41 * Assume FPEXC_EN is on and FPEXC_EX is off */
42 ENTRY(__vfp_restore_state)
43 VFPFLDMIA r0, r1 @ Load VFP registers
44 ldm r0, {r0-r3} @ Load FPEXC, FPSCR, FPINST, FPINST2
47 tst r0, #FPEXC_EX @ Check for VFP Subarchitecture
51 VFPFMXR FPINST2, r3, ne
53 VFPFMXR FPEXC, r0 @ FPEXC (last, in case !EN)
55 ENDPROC(__vfp_restore_state)