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 12 #ifndef __ARM64_CONTEXT_H__ 13 #define __ARM64_CONTEXT_H__ 14 15 #include "../include/context_gcc.h" 16 17 #include <rtconfig.h> 18 #include <asm-generic.h> 19 #include <asm-fpu.h> 20 #include <armv8.h> 21 22 .macro RESTORE_CONTEXT_SWITCH 23 _RESTORE_CONTEXT_SWITCH 24 .endm 25 26 .macro RESTORE_IRQ_CONTEXT 27 ldp x2, x3, [sp], #0x10 /* SPSR and ELR. */ 28 29 tst x3, #0x1f 30 msr spsr_el1, x3 31 msr elr_el1, x2 32 33 ldp x29, x30, [sp], #0x10 34 msr sp_el0, x29 35 ldp x28, x29, [sp], #0x10 36 msr fpcr, x28 37 msr fpsr, x29 38 ldp x28, x29, [sp], #0x10 39 ldp x26, x27, [sp], #0x10 40 ldp x24, x25, [sp], #0x10 41 ldp x22, x23, [sp], #0x10 42 ldp x20, x21, [sp], #0x10 43 ldp x18, x19, [sp], #0x10 44 ldp x16, x17, [sp], #0x10 45 ldp x14, x15, [sp], #0x10 46 ldp x12, x13, [sp], #0x10 47 ldp x10, x11, [sp], #0x10 48 ldp x8, x9, [sp], #0x10 49 ldp x6, x7, [sp], #0x10 50 ldp x4, x5, [sp], #0x10 51 ldp x2, x3, [sp], #0x10 52 ldp x0, x1, [sp], #0x10 53 RESTORE_FPU sp 54 #ifdef RT_USING_SMART 55 beq arch_ret_to_user 56 #endif 57 eret 58 .endm 59 60 #endif /* __ARM64_CONTEXT_H__ */ 61