exceptions.S 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2013
  4. * David Feng <fenghua@phytium.com.cn>
  5. */
  6. #include <asm-offsets.h>
  7. #include <config.h>
  8. #include <asm/ptrace.h>
  9. #include <asm/macro.h>
  10. #include <linux/linkage.h>
  11. /*
  12. * Exception vectors.
  13. */
  14. .align 11
  15. .globl vectors
  16. vectors:
  17. .align 7 /* Current EL Synchronous Thread */
  18. stp x29, x30, [sp, #-16]!
  19. bl _exception_entry
  20. bl do_bad_sync
  21. b exception_exit
  22. .align 7 /* Current EL IRQ Thread */
  23. stp x29, x30, [sp, #-16]!
  24. bl _exception_entry
  25. bl do_bad_irq
  26. b exception_exit
  27. .align 7 /* Current EL FIQ Thread */
  28. stp x29, x30, [sp, #-16]!
  29. bl _exception_entry
  30. bl do_bad_fiq
  31. b exception_exit
  32. .align 7 /* Current EL Error Thread */
  33. stp x29, x30, [sp, #-16]!
  34. bl _exception_entry
  35. bl do_bad_error
  36. b exception_exit
  37. .align 7 /* Current EL Synchronous Handler */
  38. stp x29, x30, [sp, #-16]!
  39. bl _exception_entry
  40. bl do_sync
  41. b exception_exit
  42. .align 7 /* Current EL IRQ Handler */
  43. stp x29, x30, [sp, #-16]!
  44. bl _exception_entry
  45. bl do_irq
  46. b exception_exit
  47. .align 7 /* Current EL FIQ Handler */
  48. stp x29, x30, [sp, #-16]!
  49. bl _exception_entry
  50. bl do_fiq
  51. b exception_exit
  52. .align 7 /* Current EL Error Handler */
  53. stp x29, x30, [sp, #-16]!
  54. bl _exception_entry
  55. bl do_error
  56. b exception_exit
  57. /*
  58. * Enter Exception.
  59. * This will save the processor state that is ELR/X0~X30
  60. * to the stack frame.
  61. */
  62. _exception_entry:
  63. stp x27, x28, [sp, #-16]!
  64. stp x25, x26, [sp, #-16]!
  65. stp x23, x24, [sp, #-16]!
  66. stp x21, x22, [sp, #-16]!
  67. stp x19, x20, [sp, #-16]!
  68. stp x17, x18, [sp, #-16]!
  69. stp x15, x16, [sp, #-16]!
  70. stp x13, x14, [sp, #-16]!
  71. stp x11, x12, [sp, #-16]!
  72. stp x9, x10, [sp, #-16]!
  73. stp x7, x8, [sp, #-16]!
  74. stp x5, x6, [sp, #-16]!
  75. stp x3, x4, [sp, #-16]!
  76. stp x1, x2, [sp, #-16]!
  77. /* Could be running at EL3/EL2/EL1 */
  78. switch_el x11, 3f, 2f, 1f
  79. 3: mrs x1, esr_el3
  80. mrs x2, elr_el3
  81. b 0f
  82. 2: mrs x1, esr_el2
  83. mrs x2, elr_el2
  84. b 0f
  85. 1: mrs x1, esr_el1
  86. mrs x2, elr_el1
  87. 0:
  88. stp x2, x0, [sp, #-16]!
  89. mov x0, sp
  90. ret
  91. exception_exit:
  92. ldp x2, x0, [sp],#16
  93. switch_el x11, 3f, 2f, 1f
  94. 3: msr elr_el3, x2
  95. b 0f
  96. 2: msr elr_el2, x2
  97. b 0f
  98. 1: msr elr_el1, x2
  99. 0:
  100. ldp x1, x2, [sp],#16
  101. ldp x3, x4, [sp],#16
  102. ldp x5, x6, [sp],#16
  103. ldp x7, x8, [sp],#16
  104. ldp x9, x10, [sp],#16
  105. ldp x11, x12, [sp],#16
  106. ldp x13, x14, [sp],#16
  107. ldp x15, x16, [sp],#16
  108. ldp x17, x18, [sp],#16
  109. ldp x19, x20, [sp],#16
  110. ldp x21, x22, [sp],#16
  111. ldp x23, x24, [sp],#16
  112. ldp x25, x26, [sp],#16
  113. ldp x27, x28, [sp],#16
  114. ldp x29, x30, [sp],#16
  115. eret