vfp.S 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) 2012 - Virtual Open Systems and Columbia University
  3. * Author: Christoffer Dall <c.dall@virtualopensystems.com>
  4. *
  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.
  8. *
  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.
  13. *
  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/>.
  16. */
  17. #include <linux/linkage.h>
  18. #include <asm/vfpmacros.h>
  19. .text
  20. .pushsection .hyp.text, "ax"
  21. /* void __vfp_save_state(struct vfp_hard_struct *vfp); */
  22. ENTRY(__vfp_save_state)
  23. push {r4, r5}
  24. VFPFMRX r1, FPEXC
  25. @ Make sure *really* VFP is enabled so we can touch the registers.
  26. orr r5, r1, #FPEXC_EN
  27. tst r5, #FPEXC_EX @ Check for VFP Subarchitecture
  28. bic r5, r5, #FPEXC_EX @ FPEXC_EX disable
  29. VFPFMXR FPEXC, r5
  30. isb
  31. VFPFMRX r2, FPSCR
  32. beq 1f
  33. @ If FPEXC_EX is 0, then FPINST/FPINST2 reads are upredictable, so
  34. @ we only need to save them if FPEXC_EX is set.
  35. VFPFMRX r3, FPINST
  36. tst r5, #FPEXC_FP2V
  37. VFPFMRX r4, FPINST2, ne @ vmrsne
  38. 1:
  39. VFPFSTMIA r0, r5 @ Save VFP registers
  40. stm r0, {r1-r4} @ Save FPEXC, FPSCR, FPINST, FPINST2
  41. pop {r4, r5}
  42. bx lr
  43. ENDPROC(__vfp_save_state)
  44. /* void __vfp_restore_state(struct vfp_hard_struct *vfp);
  45. * Assume FPEXC_EN is on and FPEXC_EX is off */
  46. ENTRY(__vfp_restore_state)
  47. VFPFLDMIA r0, r1 @ Load VFP registers
  48. ldm r0, {r0-r3} @ Load FPEXC, FPSCR, FPINST, FPINST2
  49. VFPFMXR FPSCR, r1
  50. tst r0, #FPEXC_EX @ Check for VFP Subarchitecture
  51. beq 1f
  52. VFPFMXR FPINST, r2
  53. tst r0, #FPEXC_FP2V
  54. VFPFMXR FPINST2, r3, ne
  55. 1:
  56. VFPFMXR FPEXC, r0 @ FPEXC (last, in case !EN)
  57. bx lr
  58. ENDPROC(__vfp_restore_state)
  59. .popsection