1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2017 Andes Technology Corporation
4 #include <linux/linkage.h>
5 #include <asm/memory.h>
8 #include <asm/asm-offsets.h>
19 .macro skip_save_fucop_ctl
20 #if defined(CONFIG_FPU)
22 smw.adm $p0, [$sp], $p0, #0x1
28 #if defined(CONFIG_FPU)
29 sethi $p0, hi20(has_fpu)
30 lbsi $p0, [$p0+lo12(has_fpu)]
31 beqz $p0, skip_fucop_ctl
33 smw.adm $p0, [$sp], $p0, #0x1
34 bclr $p0, $p0, #FUCOP_CTL_offCP0EN
37 /* move $SP to the bottom of pt_regs */
38 addi $sp, $sp, -FUCOP_CTL_OFFSET
40 smw.adm $sp, [$sp], $sp, #0x1
41 /* move $SP to the bottom of pt_regs */
42 addi $sp, $sp, -OSP_OFFSET
46 smw.bim $r0, [$sp], $r25
47 /* push $fp, $gp, $lp */
48 smw.bim $sp, [$sp], $sp, #0xe
63 smw.bim $r12, [$sp], $r24, #0
64 addi $sp, $sp, -FUCOP_CTL_OFFSET
66 /* Initialize kernel space $fp */
67 andi $p0, $r20, #PSW_mskPOM
71 andi $r16, $r19, #PSW_mskINTL
78 /* If it was superuser mode, we don't need to update $r25 */
91 .long unhandled_exceptions !Reset/NMI
92 .long unhandled_exceptions !TLB fill
93 .long do_page_fault !PTE not present
94 .long do_dispatch_tlb_misc !TLB misc
95 .long unhandled_exceptions !TLB VLPT
96 .long unhandled_exceptions !Machine Error
97 .long do_debug_trap !Debug related
98 .long do_dispatch_general !General exception
99 .long eh_syscall !Syscall
100 .long asm_do_IRQ !IRQ
103 common_exception_handler:
106 andi $p0, $p0, #ITYPE_mskVECTOR
107 srli $p0, $p0, #ITYPE_offVECTOR
108 andi $p1, $p0, #NDS32_VECTOR_mskNONEXCEPTION
110 sethi $lp, hi20(ret_from_exception)
111 ori $lp, $lp, lo12(ret_from_exception)
112 sethi $p1, hi20(exception_handlers)
113 ori $p1, $p1, lo12(exception_handlers)
120 /* enable gie if it is enabled in IPSW. */
122 andi $r20, $r20, #PSW_mskGIE /* r20 is $IPSW*/
129 addi $p1, $p0, #-NDS32_VECTOR_offEXCEPTION
131 sethi $lp, hi20(ret_from_exception)
132 ori $lp, $lp, lo12(ret_from_exception)
133 sethi $p1, hi20(exception_handlers)
134 ori $p1, $p1, lo12(exception_handlers)
135 lwi $p1, [$p1+#NDS32_VECTOR_offEXCEPTION<<2]
140 #ifdef CONFIG_TRACE_IRQFLAGS
141 jal __trace_hardirqs_off
144 sethi $lp, hi20(ret_from_intr)
145 ori $lp, $lp, lo12(ret_from_intr)
146 sethi $p0, hi20(exception_handlers)
147 ori $p0, $p0, lo12(exception_handlers)
148 lwi $p0, [$p0+#NDS32_VECTOR_offINTERRUPT<<2]
151 .macro EXCEPTION_VECTOR_DEBUG
154 andi $p0, $p0, EDM_CTL_mskV3_EDM_MODE
155 tnez $p0, SWID_RAISE_INTERRUPT_LEVEL
158 .macro EXCEPTION_VECTOR
160 sethi $p0, hi20(common_exception_handler)
161 ori $p0, $p0, lo12(common_exception_handler)
165 .section ".text.init", #alloc, #execinstr
166 .global exception_vector
171 EXCEPTION_VECTOR_DEBUG
176 .global exception_vector_end
177 exception_vector_end: