psci.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C) 2013,2014 - ARM Ltd
  3. * Author: Marc Zyngier <marc.zyngier@arm.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 <config.h>
  18. #include <linux/linkage.h>
  19. #include <asm/psci.h>
  20. .pushsection ._secure.text, "ax"
  21. .arch_extension sec
  22. .align 5
  23. .globl _psci_vectors
  24. _psci_vectors:
  25. b default_psci_vector @ reset
  26. b default_psci_vector @ undef
  27. b _smc_psci @ smc
  28. b default_psci_vector @ pabort
  29. b default_psci_vector @ dabort
  30. b default_psci_vector @ hyp
  31. b default_psci_vector @ irq
  32. b psci_fiq_enter @ fiq
  33. ENTRY(psci_fiq_enter)
  34. movs pc, lr
  35. ENDPROC(psci_fiq_enter)
  36. .weak psci_fiq_enter
  37. ENTRY(default_psci_vector)
  38. movs pc, lr
  39. ENDPROC(default_psci_vector)
  40. .weak default_psci_vector
  41. ENTRY(psci_cpu_suspend)
  42. ENTRY(psci_cpu_off)
  43. ENTRY(psci_cpu_on)
  44. ENTRY(psci_migrate)
  45. mov r0, #ARM_PSCI_RET_NI @ Return -1 (Not Implemented)
  46. mov pc, lr
  47. ENDPROC(psci_migrate)
  48. ENDPROC(psci_cpu_on)
  49. ENDPROC(psci_cpu_off)
  50. ENDPROC(psci_cpu_suspend)
  51. .weak psci_cpu_suspend
  52. .weak psci_cpu_off
  53. .weak psci_cpu_on
  54. .weak psci_migrate
  55. _psci_table:
  56. .word ARM_PSCI_FN_CPU_SUSPEND
  57. .word psci_cpu_suspend
  58. .word ARM_PSCI_FN_CPU_OFF
  59. .word psci_cpu_off
  60. .word ARM_PSCI_FN_CPU_ON
  61. .word psci_cpu_on
  62. .word ARM_PSCI_FN_MIGRATE
  63. .word psci_migrate
  64. .word 0
  65. .word 0
  66. _smc_psci:
  67. push {r4-r7,lr}
  68. @ Switch to secure
  69. mrc p15, 0, r7, c1, c1, 0
  70. bic r4, r7, #1
  71. mcr p15, 0, r4, c1, c1, 0
  72. isb
  73. adr r4, _psci_table
  74. 1: ldr r5, [r4] @ Load PSCI function ID
  75. ldr r6, [r4, #4] @ Load target PC
  76. cmp r5, #0 @ If reach the end, bail out
  77. moveq r0, #ARM_PSCI_RET_INVAL @ Return -2 (Invalid)
  78. beq 2f
  79. cmp r0, r5 @ If not matching, try next entry
  80. addne r4, r4, #8
  81. bne 1b
  82. blx r6 @ Execute PSCI function
  83. @ Switch back to non-secure
  84. 2: mcr p15, 0, r7, c1, c1, 0
  85. pop {r4-r7, lr}
  86. movs pc, lr @ Return to the kernel
  87. .popsection