sec_firmware_asm.S 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 2016 NXP Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <config.h>
  7. #include <linux/linkage.h>
  8. #include <asm/system.h>
  9. #include <asm/macro.h>
  10. WEAK(_sec_firmware_entry)
  11. /*
  12. * x0: Secure Firmware entry point
  13. * x1: Exception return address Low
  14. * x2: Exception return address High
  15. */
  16. /* Save stack pointer for EL2 */
  17. mov x3, sp
  18. msr sp_el2, x3
  19. /* Set exception return address hold pointer */
  20. adr x4, 1f
  21. mov x3, x4
  22. #ifdef SEC_FIRMWARE_ERET_ADDR_REVERT
  23. rev w3, w3
  24. #endif
  25. str w3, [x1]
  26. lsr x3, x4, #32
  27. #ifdef SEC_FIRMWARE_ERET_ADDR_REVERT
  28. rev w3, w3
  29. #endif
  30. str w3, [x2]
  31. /* Call SEC monitor */
  32. br x0
  33. 1:
  34. mov x0, #0
  35. ret
  36. ENDPROC(_sec_firmware_entry)
  37. #ifdef CONFIG_ARMV8_PSCI
  38. ENTRY(_sec_firmware_support_psci_version)
  39. mov x0, 0x84000000
  40. mov x1, 0x0
  41. mov x2, 0x0
  42. mov x3, 0x0
  43. smc #0
  44. ret
  45. ENDPROC(_sec_firmware_support_psci_version)
  46. /*
  47. * Switch from AArch64 EL2 to AArch32 EL2
  48. * @param inputs:
  49. * x0: argument, zero
  50. * x1: machine nr
  51. * x2: fdt address
  52. * x3: kernel entry point
  53. * @param outputs for secure firmware:
  54. * x0: function id
  55. * x1: kernel entry point
  56. * x2: machine nr
  57. * x3: fdt address
  58. */
  59. ENTRY(armv8_el2_to_aarch32)
  60. mov x0, x3
  61. mov x3, x2
  62. mov x2, x1
  63. mov x1, x0
  64. ldr x0, =0xc000ff04
  65. smc #0
  66. ret
  67. ENDPROC(armv8_el2_to_aarch32)
  68. #endif