exceptions.S 1.8 KB

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