smccc-call.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015, Linaro Limited
  4. */
  5. #include <linux/linkage.h>
  6. #include <linux/arm-smccc.h>
  7. #include <asm/asm-offsets.h>
  8. #include <asm/assembler.h>
  9. .macro SMCCC instr
  10. \instr #0
  11. ldr x4, [sp]
  12. stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS]
  13. stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS]
  14. ldr x4, [sp, #8]
  15. cbz x4, 1f /* no quirk structure */
  16. ldr x9, [x4, #ARM_SMCCC_QUIRK_ID_OFFS]
  17. cmp x9, #ARM_SMCCC_QUIRK_QCOM_A6
  18. b.ne 1f
  19. str x6, [x4, ARM_SMCCC_QUIRK_STATE_OFFS]
  20. 1: ret
  21. .endm
  22. /*
  23. * void arm_smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2,
  24. * unsigned long a3, unsigned long a4, unsigned long a5,
  25. * unsigned long a6, unsigned long a7, struct arm_smccc_res *res,
  26. * struct arm_smccc_quirk *quirk)
  27. */
  28. SYM_FUNC_START(__arm_smccc_smc)
  29. SMCCC smc
  30. SYM_FUNC_END(__arm_smccc_smc)
  31. EXPORT_SYMBOL(__arm_smccc_smc)
  32. /*
  33. * void arm_smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2,
  34. * unsigned long a3, unsigned long a4, unsigned long a5,
  35. * unsigned long a6, unsigned long a7, struct arm_smccc_res *res,
  36. * struct arm_smccc_quirk *quirk)
  37. */
  38. SYM_FUNC_START(__arm_smccc_hvc)
  39. SMCCC hvc
  40. SYM_FUNC_END(__arm_smccc_hvc)
  41. EXPORT_SYMBOL(__arm_smccc_hvc)
  42. .macro SMCCC_1_2 instr
  43. /* Save `res` and free a GPR that won't be clobbered */
  44. stp x1, x19, [sp, #-16]!
  45. /* Ensure `args` won't be clobbered while loading regs in next step */
  46. mov x19, x0
  47. /* Load the registers x0 - x17 from the struct arm_smccc_1_2_regs */
  48. ldp x0, x1, [x19, #ARM_SMCCC_1_2_REGS_X0_OFFS]
  49. ldp x2, x3, [x19, #ARM_SMCCC_1_2_REGS_X2_OFFS]
  50. ldp x4, x5, [x19, #ARM_SMCCC_1_2_REGS_X4_OFFS]
  51. ldp x6, x7, [x19, #ARM_SMCCC_1_2_REGS_X6_OFFS]
  52. ldp x8, x9, [x19, #ARM_SMCCC_1_2_REGS_X8_OFFS]
  53. ldp x10, x11, [x19, #ARM_SMCCC_1_2_REGS_X10_OFFS]
  54. ldp x12, x13, [x19, #ARM_SMCCC_1_2_REGS_X12_OFFS]
  55. ldp x14, x15, [x19, #ARM_SMCCC_1_2_REGS_X14_OFFS]
  56. ldp x16, x17, [x19, #ARM_SMCCC_1_2_REGS_X16_OFFS]
  57. \instr #0
  58. /* Load the `res` from the stack */
  59. ldr x19, [sp]
  60. /* Store the registers x0 - x17 into the result structure */
  61. stp x0, x1, [x19, #ARM_SMCCC_1_2_REGS_X0_OFFS]
  62. stp x2, x3, [x19, #ARM_SMCCC_1_2_REGS_X2_OFFS]
  63. stp x4, x5, [x19, #ARM_SMCCC_1_2_REGS_X4_OFFS]
  64. stp x6, x7, [x19, #ARM_SMCCC_1_2_REGS_X6_OFFS]
  65. stp x8, x9, [x19, #ARM_SMCCC_1_2_REGS_X8_OFFS]
  66. stp x10, x11, [x19, #ARM_SMCCC_1_2_REGS_X10_OFFS]
  67. stp x12, x13, [x19, #ARM_SMCCC_1_2_REGS_X12_OFFS]
  68. stp x14, x15, [x19, #ARM_SMCCC_1_2_REGS_X14_OFFS]
  69. stp x16, x17, [x19, #ARM_SMCCC_1_2_REGS_X16_OFFS]
  70. /* Restore original x19 */
  71. ldp xzr, x19, [sp], #16
  72. ret
  73. .endm
  74. /*
  75. * void arm_smccc_1_2_hvc(const struct arm_smccc_1_2_regs *args,
  76. * struct arm_smccc_1_2_regs *res);
  77. */
  78. SYM_FUNC_START(arm_smccc_1_2_hvc)
  79. SMCCC_1_2 hvc
  80. SYM_FUNC_END(arm_smccc_1_2_hvc)
  81. EXPORT_SYMBOL(arm_smccc_1_2_hvc)
  82. /*
  83. * void arm_smccc_1_2_smc(const struct arm_smccc_1_2_regs *args,
  84. * struct arm_smccc_1_2_regs *res);
  85. */
  86. SYM_FUNC_START(arm_smccc_1_2_smc)
  87. SMCCC_1_2 smc
  88. SYM_FUNC_END(arm_smccc_1_2_smc)
  89. EXPORT_SYMBOL(arm_smccc_1_2_smc)