context_gcc.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2006-2024, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-03-25 Shell Trimming unecessary ops and
  9. * improve the performance of ctx switch
  10. */
  11. #ifndef __ARM64_CONTEXT_H__
  12. #define __ARM64_CONTEXT_H__
  13. #include "../include/context_gcc.h"
  14. #include <rtconfig.h>
  15. #include <asm-generic.h>
  16. #include <asm-fpu.h>
  17. #include <armv8.h>
  18. .macro RESTORE_CONTEXT_SWITCH
  19. _RESTORE_CONTEXT_SWITCH
  20. .endm
  21. .macro RESTORE_IRQ_CONTEXT
  22. ldp x2, x3, [sp], #0x10 /* SPSR and ELR. */
  23. tst x3, #0x1f
  24. msr spsr_el1, x3
  25. msr elr_el1, x2
  26. ldp x29, x30, [sp], #0x10
  27. msr sp_el0, x29
  28. ldp x28, x29, [sp], #0x10
  29. msr fpcr, x28
  30. msr fpsr, x29
  31. ldp x28, x29, [sp], #0x10
  32. ldp x26, x27, [sp], #0x10
  33. ldp x24, x25, [sp], #0x10
  34. ldp x22, x23, [sp], #0x10
  35. ldp x20, x21, [sp], #0x10
  36. ldp x18, x19, [sp], #0x10
  37. ldp x16, x17, [sp], #0x10
  38. ldp x14, x15, [sp], #0x10
  39. ldp x12, x13, [sp], #0x10
  40. ldp x10, x11, [sp], #0x10
  41. ldp x8, x9, [sp], #0x10
  42. ldp x6, x7, [sp], #0x10
  43. ldp x4, x5, [sp], #0x10
  44. ldp x2, x3, [sp], #0x10
  45. ldp x0, x1, [sp], #0x10
  46. RESTORE_FPU sp
  47. #ifdef RT_USING_SMART
  48. beq arch_ret_to_user
  49. #endif
  50. eret
  51. .endm
  52. #endif /* __ARM64_CONTEXT_H__ */