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>
21 smw.adm $sp, [$sp], $sp, #0x1
22 /* move $SP to the bottom of pt_regs */
23 addi $sp, $sp, -OSP_OFFSET
26 smw.bim $r0, [$sp], $r25
27 /* push $fp, $gp, $lp */
28 smw.bim $sp, [$sp], $sp, #0xe
43 smw.bim $r12, [$sp], $r24, #0
44 addi $sp, $sp, -FUCOP_CTL_OFFSET
46 /* Initialize kernel space $fp */
47 andi $p0, $r20, #PSW_mskPOM
51 andi $r16, $r19, #PSW_mskINTL
58 /* If it was superuser mode, we don't need to update $r25 */
71 .long unhandled_exceptions !Reset/NMI
72 .long unhandled_exceptions !TLB fill
73 .long do_page_fault !PTE not present
74 .long do_dispatch_tlb_misc !TLB misc
75 .long unhandled_exceptions !TLB VLPT
76 .long unhandled_exceptions !Machine Error
77 .long do_debug_trap !Debug related
78 .long do_dispatch_general !General exception
79 .long eh_syscall !Syscall
82 common_exception_handler:
85 andi $p0, $p0, #ITYPE_mskVECTOR
86 srli $p0, $p0, #ITYPE_offVECTOR
87 andi $p1, $p0, #NDS32_VECTOR_mskNONEXCEPTION
89 sethi $lp, hi20(ret_from_exception)
90 ori $lp, $lp, lo12(ret_from_exception)
91 sethi $p1, hi20(exception_handlers)
92 ori $p1, $p1, lo12(exception_handlers)
99 /* enable gie if it is enabled in IPSW. */
101 andi $r20, $r20, #PSW_mskGIE /* r20 is $IPSW*/
109 addi $p1, $p0, #-NDS32_VECTOR_offEXCEPTION
111 sethi $lp, hi20(ret_from_exception)
112 ori $lp, $lp, lo12(ret_from_exception)
113 sethi $p1, hi20(exception_handlers)
114 ori $p1, $p1, lo12(exception_handlers)
115 lwi $p1, [$p1+#NDS32_VECTOR_offEXCEPTION<<2]
120 #ifdef CONFIG_TRACE_IRQFLAGS
121 jal trace_hardirqs_off
124 sethi $lp, hi20(ret_from_intr)
125 ori $lp, $lp, lo12(ret_from_intr)
126 sethi $p0, hi20(exception_handlers)
127 ori $p0, $p0, lo12(exception_handlers)
128 lwi $p0, [$p0+#NDS32_VECTOR_offINTERRUPT<<2]
131 .macro EXCEPTION_VECTOR_DEBUG
134 andi $p0, $p0, EDM_CTL_mskV3_EDM_MODE
135 tnez $p0, SWID_RAISE_INTERRUPT_LEVEL
138 .macro EXCEPTION_VECTOR
140 sethi $p0, hi20(common_exception_handler)
141 ori $p0, $p0, lo12(common_exception_handler)
145 .section ".text.init", #alloc, #execinstr
146 .global exception_vector
151 EXCEPTION_VECTOR_DEBUG
156 .global exception_vector_end
157 exception_vector_end: