1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (C) 2020-2021 Loongson Technology Corporation Limited 4 */ 5 #include <asm/asm.h> 6 #include <asm/asmmacro.h> 7 #include <asm/regdef.h> 8 #include <asm/fpregdef.h> 9 #include <asm/loongarchregs.h> 10 #include <asm/stackframe.h> 11 #include <asm/thread_info.h> 12 #include <asm/unwind_hints.h> 13 14 .align 5 15 SYM_FUNC_START(__arch_cpu_idle) 16 /* start of rollback region */ 17 LONG_L t0, tp, TI_FLAGS 18 nop 19 andi t0, t0, _TIF_NEED_RESCHED 20 bnez t0, 1f 21 nop 22 nop 23 nop 24 idle 0 25 /* end of rollback region */ 26 1: jirl zero, ra, 0 27 SYM_FUNC_END(__arch_cpu_idle) 28 29 SYM_CODE_START(handle_vint) 30 BACKUP_T0T1 31 SAVE_ALL 32 UNWIND_HINT_REGS 33 la.abs t1, __arch_cpu_idle 34 LONG_L t0, sp, PT_ERA 35 /* 32 byte rollback region */ 36 ori t0, t0, 0x1f 37 xori t0, t0, 0x1f 38 bne t0, t1, 1f 39 LONG_S t0, sp, PT_ERA 40 1: move a0, sp 41 move a1, sp 42 la.abs t0, do_vint 43 jirl ra, t0, 0 44 UNWIND_HINT_REGS 45 RESTORE_ALL_AND_RET 46 SYM_CODE_END(handle_vint) 47 48 SYM_CODE_START(except_vec_cex) 49 b cache_parity_error 50 SYM_CODE_END(except_vec_cex) 51 52 .macro build_prep_badv 53 csrrd t0, LOONGARCH_CSR_BADV 54 PTR_S t0, sp, PT_BVADDR 55 .endm 56 57 .macro build_prep_fcsr 58 movfcsr2gr a1, fcsr0 59 .endm 60 61 .macro build_prep_none 62 .endm 63 64 .macro BUILD_HANDLER exception handler prep 65 .align 5 66 SYM_CODE_START(handle_\exception) 67 BACKUP_T0T1 68 SAVE_ALL 69 build_prep_\prep 70 move a0, sp 71 la.abs t0, do_\handler 72 jirl ra, t0, 0 73 UNWIND_HINT_REGS 74 RESTORE_ALL_AND_RET 75 SYM_CODE_END(handle_\exception) 76 .endm 77 78 BUILD_HANDLER ade ade badv 79 BUILD_HANDLER ale ale badv 80 BUILD_HANDLER bce bce none 81 BUILD_HANDLER bp bp none 82 BUILD_HANDLER fpe fpe fcsr 83 BUILD_HANDLER fpu fpu none 84 BUILD_HANDLER lsx lsx none 85 BUILD_HANDLER lasx lasx none 86 BUILD_HANDLER lbt lbt none 87 BUILD_HANDLER ri ri none 88 BUILD_HANDLER watch watch none 89 BUILD_HANDLER reserved reserved none /* others */ 90 91 SYM_CODE_START(handle_sys) 92 la.abs t0, handle_syscall 93 jirl zero, t0, 0 94 SYM_CODE_END(handle_sys) 95