vector_gcc.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) 2006-2020, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-03-28 Shell Move vector handling codes from context_gcc.S
  9. * 2024-04-08 Shell Optimizing exception switch between u-space/kernel,
  10. */
  11. #ifndef __ARM64_INC_VECTOR_H__
  12. #define __ARM64_INC_VECTOR_H__
  13. #include "asm-generic.h"
  14. #include <rtconfig.h>
  15. #include <asm-fpu.h>
  16. #include <armv8.h>
  17. .macro SAVE_IRQ_CONTEXT
  18. /* Save the entire context. */
  19. SAVE_FPU sp
  20. stp x0, x1, [sp, #-0x10]!
  21. stp x2, x3, [sp, #-0x10]!
  22. stp x4, x5, [sp, #-0x10]!
  23. stp x6, x7, [sp, #-0x10]!
  24. stp x8, x9, [sp, #-0x10]!
  25. stp x10, x11, [sp, #-0x10]!
  26. stp x12, x13, [sp, #-0x10]!
  27. stp x14, x15, [sp, #-0x10]!
  28. stp x16, x17, [sp, #-0x10]!
  29. stp x18, x19, [sp, #-0x10]!
  30. stp x20, x21, [sp, #-0x10]!
  31. stp x22, x23, [sp, #-0x10]!
  32. stp x24, x25, [sp, #-0x10]!
  33. stp x26, x27, [sp, #-0x10]!
  34. stp x28, x29, [sp, #-0x10]!
  35. mrs x28, fpcr
  36. mrs x29, fpsr
  37. stp x28, x29, [sp, #-0x10]!
  38. mrs x29, sp_el0
  39. stp x29, x30, [sp, #-0x10]!
  40. mrs x3, spsr_el1
  41. mrs x2, elr_el1
  42. stp x2, x3, [sp, #-0x10]!
  43. .endm
  44. #ifdef RT_USING_SMP
  45. #include "../mp/context_gcc.h"
  46. #else
  47. #include "../up/context_gcc.h"
  48. #endif
  49. .macro SAVE_USER_CTX, eframex, tmpx
  50. #ifdef RT_USING_SMART
  51. mrs \tmpx, spsr_el1
  52. and \tmpx, \tmpx, 0xf
  53. cbz \tmpx, 1f
  54. b 2f
  55. 1:
  56. mov x0, \eframex
  57. bl lwp_uthread_ctx_save
  58. 2:
  59. #endif /* RT_USING_SMART */
  60. .endm
  61. .macro RESTORE_USER_CTX, eframex, tmpx
  62. #ifdef RT_USING_SMART
  63. ldr \tmpx, [\eframex, #CONTEXT_OFFSET_SPSR_EL1]
  64. and \tmpx, \tmpx, 0x1f
  65. cbz \tmpx, 1f
  66. b 2f
  67. 1:
  68. bl lwp_uthread_ctx_restore
  69. 2:
  70. #endif /* RT_USING_SMART */
  71. .endm
  72. #endif /* __ARM64_INC_VECTOR_H__ */