exceptions.S 1.8 KB

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