2 * arch/sh/kernel/cpu/sh2/entry.S
4 * The SH-2 exception entry
6 * Copyright (C) 2005,2006 Yoshinori Sato
7 * Copyright (C) 2005 AXE,Inc.
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
14 #include <linux/linkage.h>
15 #include <asm/asm-offsets.h>
16 #include <asm/thread_info.h>
17 #include <asm/cpu/mmu_context.h>
18 #include <asm/unistd.h>
19 #include <asm/errno.h>
22 /* Offsets to the stack */
23 OFF_R0 = 0 /* Return value. New ABI also arg4 */
24 OFF_R1 = 4 /* New ABI: arg5 */
25 OFF_R2 = 8 /* New ABI: arg6 */
26 OFF_R3 = 12 /* New ABI: syscall_nr */
27 OFF_R4 = 16 /* New ABI: arg0 */
28 OFF_R5 = 20 /* New ABI: arg1 */
29 OFF_R6 = 24 /* New ABI: arg2 */
30 OFF_R7 = 28 /* New ABI: arg3 */
36 #include <asm/entry-macros.S>
38 ENTRY(exception_handler)
46 mov.l @(5*4,r15),r3 ! previous SR
47 shll2 r3 ! set "S" flag
48 rotl r0 ! T <- "S" flag
49 rotl r0 ! "S" flag is LSB
50 rotcr r3 ! T -> r3:b30
54 mov.l r3,@(5*4,r15) ! copy cpu mode to SR
55 ! switch to kernel mode
59 mov.l r0,@r2 ! enter kernel mode
60 mov.l $current_thread_info,r2
65 mov r15,r2 ! r2 = user stack top
66 mov r0,r15 ! switch kernel stack
74 mov.l r1,@-r15 ! original SR
76 mov.l r0,@-r15 ! original PC
78 add #(4+2)*4,r3 ! rewind r0 - r3 + exception frame
79 mov.l r3,@-r15 ! original SP
91 mov r2,r8 ! copy user -> kernel stack
102 ! in kernel exception
103 mov #(22-4-4-1)*4+4,r0
106 mov.l @r2+,r0 ! old R3
108 mov.l @r2+,r0 ! old R2
110 mov.l @r2+,r0 ! old R1
112 mov.l @r2+,r0 ! old R0
114 mov.l @r2+,r3 ! old PC
115 mov.l @r2+,r0 ! old SR
116 add #-4,r2 ! exception frame stub (sr)
121 mov.l r0,@-r2 ! save old SR
123 mov.l r3,@-r2 ! save old PC
126 mov.l r0,@-r2 ! save old SP
138 mov.l @(OFF_R0,r15),r0
139 mov.l @(OFF_R1,r15),r1
140 mov.l @(OFF_R2,r15),r2
141 mov.l @(OFF_R3,r15),r3
148 bt interrupt_entry ! vec >= 64 is interrupt
151 bt trap_entry ! 64 > vec >= 32 is trap
153 #if defined(CONFIG_SH_FPU)
168 mov.l 8f,r8 ! unhandled exception
169 #if defined(CONFIG_SH_FPU)
171 mov.l 9f, r8 ! unhandled exception
187 4: .long exception_handling_table
188 5: .long ret_from_exception
189 6: .long ret_from_irq
191 8: .long do_exception_error
193 9: .long fpu_error_trap_handler
198 cmp/ge r8,r9 ! vector 0x20-0x2f is systemcall
200 add #-0x10,r9 ! convert SH2 to SH3/4 ABI
207 #ifdef CONFIG_TRACE_IRQFLAGS
217 #ifdef CONFIG_TRACE_IRQFLAGS
218 2: .long trace_hardirqs_on
221 #if defined(CONFIG_SH_STANDARD_BIOS)
222 /* Unwind the stack and jmp to the debug entry */
223 ENTRY(sh_bios_handler)
230 mov.l @(OFF_SP,r0),r1
265 1: .long gdb_vbr_vector
266 #endif /* CONFIG_SH_STANDARD_BIOS */
268 ENTRY(address_error_trap_handler)
272 mov.l @(r0,r15),r6 ! pc
275 mov #0,r5 ! writeaccess is unknown
278 1: .long do_address_error
282 #ifdef CONFIG_TRACE_IRQFLAGS
292 shll2 r1 ! clear MD bit
294 mov.l @(OFF_SP,r0),r2
296 mov.l r2,@(OFF_SP,r0) ! point exception frame top
297 mov.l r1,@(4,r2) ! set sr
300 mov.l r1,@r2 ! set pc
307 get_current_thread_info r0, r1
308 mov.l $current_thread_info,r1
330 #ifdef CONFIG_TRACE_IRQFLAGS
331 1: .long trace_hardirqs_off
333 $current_thread_info:
334 .long __current_thread_info
338 ! common exception handler
339 #include "../../entry-common.S"
343 ! bit30 = MD (compatible SH3/4)
348 __current_thread_info:
351 ENTRY(exception_handling_table)