3 * linux/arch/h8300/platform/h8s/entry.S
5 * Yoshinori Sato <ysato@users.sourceforge.jp>
7 * fairly heavy changes to fix syscall args and signal processing
8 * by David McCullough <davidm@snapgear.com>
13 * include exception/interrupt gateway
17 #include <linux/sys.h>
18 #include <linux/config.h>
19 #include <asm/unistd.h>
20 #include <asm/setup.h>
21 #include <asm/segment.h>
22 #include <asm/linkage.h>
23 #include <asm/asm-offsets.h>
24 #include <asm/thread_info.h>
32 /* the following macro is used when enabling interrupts */
49 /* CPU context save/restore macros. */
54 stc ccr,r0l /* check kernel mode */
59 mov.l sp,@SYMBOL_NAME(sw_usp) /* user mode */
61 mov.l @SYMBOL_NAME(sw_ksp),sp
62 sub.l #(LRET-LORIG),sp /* allocate LORIG - LRET */
64 mov.l @SYMBOL_NAME(sw_usp),er0
65 mov.l @(10:16,er0),er1 /* copy the RET addr */
66 mov.l er1,@(LRET-LER3:16,sp)
68 mov.w r1,@(LEXR-LER3:16,sp) /* copy EXR */
70 mov.w e1,r1 /* e1 highbyte = ccr */
71 and #0xef,r1h /* mask mode? flag */
74 mov.w r0,@(LCCR-LER3:16,sp) /* copy ccr */
75 mov.l @(LORIG-LER3:16,sp),er0
76 mov.l er0,@(LER0-LER3:16,sp) /* copy ER0 */
79 mov.l @sp,er0 /* kernel mode */
80 subs #2,sp /* dummy ccr */
82 mov.w @(LRET-LER3:16,sp),r1 /* copy old ccr */
85 mov.w r1,@(LCCR-LER3:16,sp)
87 mov.l er6,@-sp /* syscall arg #6 */
88 mov.l er5,@-sp /* syscall arg #5 */
89 mov.l er4,@-sp /* syscall arg #4 */
97 mov.w @(LCCR-LER1:16,sp),r0 /* check kernel mode */
102 mov.l @SYMBOL_NAME(sw_usp),er0
103 mov.l @(LER0-LER1:16,sp),er1 /* restore ER0 */
105 mov.w @(LEXR-LER1:16,sp),r1 /* restore EXR */
107 mov.w @(LCCR-LER1:16,sp),r1 /* restore the RET addr */
109 mov.b @(LRET+1-LER1:16,sp),r1l
111 mov.w @(LRET+2-LER1:16,sp),r1
112 mov.l er1,@(10:16,er0)
115 add.l #(LRET-LORIG),sp /* remove LORIG - LRET */
116 mov.l sp,@SYMBOL_NAME(sw_ksp)
125 adds #4,sp /* remove the sw created LVEC */
129 .globl SYMBOL_NAME(system_call)
130 .globl SYMBOL_NAME(ret_from_exception)
131 .globl SYMBOL_NAME(ret_from_fork)
132 .globl SYMBOL_NAME(ret_from_signal)
133 .globl SYMBOL_NAME(ret_from_interrupt)
134 .globl SYMBOL_NAME(interrupt_redirect_table)
135 .globl SYMBOL_NAME(sw_ksp),SYMBOL_NAME(sw_usp)
136 .globl SYMBOL_NAME(resume)
137 .globl SYMBOL_NAME(syscall_trampoline)
138 .globl SYMBOL_NAME(trace_break)
139 .globl SYMBOL_NAME(interrupt_entry)
142 #if defined(CONFIG_ROMKERNEL)
143 .section .int_redirect,"ax"
144 SYMBOL_NAME_LABEL(interrupt_redirect_table)
148 jsr @SYMBOL_NAME(interrupt_entry) /* NMI */
149 jmp @SYMBOL_NAME(system_call) /* TRAPA #0 (System call) */
152 jmp @SYMBOL_NAME(trace_break) /* TRAPA #3 (breakpoint) */
154 jsr @SYMBOL_NAME(interrupt_entry)
157 #if defined(CONFIG_RAMKERNEL)
158 .globl SYMBOL_NAME(interrupt_redirect_table)
160 SYMBOL_NAME_LABEL(interrupt_redirect_table)
166 SYMBOL_NAME_LABEL(interrupt_entry)
171 mov.l @SYMBOL_NAME(sw_usp),er0
172 mov.l @(4:16,er0),er0
175 mov.l @(LVEC:16,sp),er0
177 #if defined(CONFIG_ROMKERNEL)
178 sub.l #SYMBOL_NAME(interrupt_redirect_table),er0
180 #if defined(CONFIG_RAMKERNEL)
181 mov.l @SYMBOL_NAME(interrupt_redirect_table),er1
187 subs #4,er1 /* adjust ret_pc */
188 jsr @SYMBOL_NAME(process_int)
189 mov.l @SYMBOL_NAME(irq_stat)+SOFTIRQ_PENDING,er0
191 jsr @SYMBOL_NAME(do_softirq)
193 jmp @SYMBOL_NAME(ret_from_exception)
195 SYMBOL_NAME_LABEL(system_call)
196 subs #4,sp /* dummy LVEC */
198 mov.w @(LCCR:16,sp),r1
200 ldc r1l,ccr /* restore ccr */
203 mov.l er0,@(LER0:16,sp)
205 /* save top of frame */
207 jsr @SYMBOL_NAME(set_esp0)
208 cmp.l #NR_syscalls,er4
209 bcc SYMBOL_NAME(ret_from_exception):16
211 mov.l #SYMBOL_NAME(sys_call_table),er0
215 beq SYMBOL_NAME(ret_from_exception):16
218 mov.b @((TASK_FLAGS+3-(TIF_SYSCALL_TRACE >> 3)):16,er2),r2l
219 btst #(TIF_SYSCALL_TRACE & 7),r2l
220 mov.l @(LER1:16,sp),er0
221 mov.l @(LER2:16,sp),er1
222 mov.l @(LER3:16,sp),er2
224 mov.l er0,@(LER0,sp) /* save the return value */
225 #if defined(CONFIG_SYSCALL_PRINT)
226 jsr @SYMBOL_NAME(syscall_print)
228 jmp @SYMBOL_NAME(ret_from_exception)
230 jsr SYMBOL_NAME(syscall_trace)
231 mov.l @(LER1:16,sp),er0
232 mov.l @(LER2:16,sp),er1
233 mov.l @(LER3:16,sp),er2
235 mov.l er0,@(LER0:16,sp) /* save the return value */
236 jsr SYMBOL_NAME(syscall_trace)
238 SYMBOL_NAME_LABEL(ret_from_signal)
240 SYMBOL_NAME_LABEL(ret_from_exception)
241 mov.b @(LCCR+1:16,sp),r0l
242 btst #4,r0l /* check if returning to kernel */
243 bne 3f /* if so, skip resched, signals */
247 mov.l @(TI_FLAGS:16,er2),er1
248 and.l #_TIF_WORK_MASK,er1
251 mov.l @(TI_FLAGS:16,er2),er1
252 btst #TIF_NEED_RESCHED,r1l
253 bne @SYMBOL_NAME(reschedule):16
256 jsr @SYMBOL_NAME(do_signal)
258 RESTORE_ALL /* Does RTE */
260 SYMBOL_NAME_LABEL(reschedule)
261 /* save top of frame */
263 jsr @SYMBOL_NAME(set_esp0)
265 mov.l #SYMBOL_NAME(ret_from_exception),er0
267 jmp @SYMBOL_NAME(schedule)
269 SYMBOL_NAME_LABEL(ret_from_fork)
271 jsr @SYMBOL_NAME(schedule_tail)
272 jmp @SYMBOL_NAME_LABEL(ret_from_exception)
275 SYMBOL_NAME_LABEL(resume)
286 mov.w r3,@(THREAD_CCR+2:16,er0)
288 /* disable interrupts */
290 mov.l @SYMBOL_NAME(sw_usp),er3
291 mov.l er3,@(THREAD_USP:16,er0)
292 mov.l sp,@(THREAD_KSP:16,er0)
294 /* Skip address space switching if they are the same. */
295 /* FIXME: what did we hack out of here, this does nothing! */
297 mov.l @(THREAD_USP:16,er1),er0
298 mov.l er0,@SYMBOL_NAME(sw_usp)
299 mov.l @(THREAD_KSP:16,er1),sp
301 /* restore status register */
302 mov.w @(THREAD_CCR+2:16,er1),r3
309 SYMBOL_NAME_LABEL(trace_break)
310 subs #4,sp /* dummy LVEC */
314 mov.l er1,@(LORIG,sp)
316 jsr @SYMBOL_NAME(set_esp0)
317 mov.l @SYMBOL_NAME(sw_usp),er0
323 jsr @SYMBOL_NAME(trace_trap)
324 jmp @SYMBOL_NAME(ret_from_exception)
326 SYMBOL_NAME_LABEL(syscall_trampoline)
332 SYMBOL_NAME_LABEL(sw_ksp)
334 SYMBOL_NAME_LABEL(sw_usp)