smccc-call.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2015, Linaro Limited
  3. *
  4. * This software is licensed under the terms of the GNU General Public
  5. * License version 2, as published by the Free Software Foundation, and
  6. * may be copied, distributed, and modified under those terms.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. */
  14. #include <linux/linkage.h>
  15. #include <linux/arm-smccc.h>
  16. #include <asm/asm-offsets.h>
  17. #include <asm/opcodes-sec.h>
  18. #include <asm/opcodes-virt.h>
  19. #include <asm/unwind.h>
  20. /*
  21. * Wrap c macros in asm macros to delay expansion until after the
  22. * SMCCC asm macro is expanded.
  23. */
  24. .macro SMCCC_SMC
  25. __SMC(0)
  26. .endm
  27. .macro SMCCC_HVC
  28. __HVC(0)
  29. .endm
  30. .macro SMCCC instr
  31. UNWIND( .fnstart)
  32. mov r12, sp
  33. push {r4-r7}
  34. UNWIND( .save {r4-r7})
  35. ldm r12, {r4-r7}
  36. \instr
  37. ldr r4, [sp, #36]
  38. cmp r4, #0
  39. beq 1f // No quirk structure
  40. ldr r5, [r4, #ARM_SMCCC_QUIRK_ID_OFFS]
  41. cmp r5, #ARM_SMCCC_QUIRK_QCOM_A6
  42. bne 1f // No quirk present
  43. str r6, [r4, #ARM_SMCCC_QUIRK_STATE_OFFS]
  44. 1: pop {r4-r7}
  45. ldr r12, [sp, #(4 * 4)]
  46. stm r12, {r0-r3}
  47. bx lr
  48. UNWIND( .fnend)
  49. .endm
  50. /*
  51. * void smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2,
  52. * unsigned long a3, unsigned long a4, unsigned long a5,
  53. * unsigned long a6, unsigned long a7, struct arm_smccc_res *res,
  54. * struct arm_smccc_quirk *quirk)
  55. */
  56. ENTRY(__arm_smccc_smc)
  57. SMCCC SMCCC_SMC
  58. ENDPROC(__arm_smccc_smc)
  59. /*
  60. * void smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2,
  61. * unsigned long a3, unsigned long a4, unsigned long a5,
  62. * unsigned long a6, unsigned long a7, struct arm_smccc_res *res,
  63. * struct arm_smccc_quirk *quirk)
  64. */
  65. ENTRY(__arm_smccc_hvc)
  66. SMCCC SMCCC_HVC
  67. ENDPROC(__arm_smccc_hvc)