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>
25 #include <asm/errno.h>
29 /* CPU context save/restore macros. */
34 stc ccr,r0l /* check kernel mode */
39 mov.l sp,@SYMBOL_NAME(sw_usp) /* user mode */
41 mov.l @SYMBOL_NAME(sw_ksp),sp
42 sub.l #(LRET-LORIG),sp /* allocate LORIG - LRET */
44 mov.l @SYMBOL_NAME(sw_usp),er0
45 mov.l @(10:16,er0),er1 /* copy the RET addr */
46 mov.l er1,@(LRET-LER3:16,sp)
48 mov.w r1,@(LEXR-LER3:16,sp) /* copy EXR */
50 mov.w e1,r1 /* e1 highbyte = ccr */
51 and #0xef,r1h /* mask mode? flag */
54 mov.w r0,@(LCCR-LER3:16,sp) /* copy ccr */
55 mov.l @(LORIG-LER3:16,sp),er0
56 mov.l er0,@(LER0-LER3:16,sp) /* copy ER0 */
59 mov.l @sp,er0 /* kernel mode */
60 subs #2,sp /* dummy ccr */
62 mov.w @(LRET-LER3:16,sp),r1 /* copy old ccr */
65 mov.w r1,@(LCCR-LER3:16,sp)
67 mov.l er6,@-sp /* syscall arg #6 */
68 mov.l er5,@-sp /* syscall arg #5 */
69 mov.l er4,@-sp /* syscall arg #4 */
77 mov.w @(LCCR-LER1:16,sp),r0 /* check kernel mode */
82 mov.l @SYMBOL_NAME(sw_usp),er0
83 mov.l @(LER0-LER1:16,sp),er1 /* restore ER0 */
85 mov.w @(LEXR-LER1:16,sp),r1 /* restore EXR */
87 mov.w @(LCCR-LER1:16,sp),r1 /* restore the RET addr */
89 mov.b @(LRET+1-LER1:16,sp),r1l
91 mov.w @(LRET+2-LER1:16,sp),r1
92 mov.l er1,@(10:16,er0)
95 add.l #(LRET-LER1),sp /* remove LORIG - LRET */
96 mov.l sp,@SYMBOL_NAME(sw_ksp)
105 adds #4,sp /* remove the sw created LVEC */
109 .globl SYMBOL_NAME(system_call)
110 .globl SYMBOL_NAME(ret_from_exception)
111 .globl SYMBOL_NAME(ret_from_fork)
112 .globl SYMBOL_NAME(ret_from_signal)
113 .globl SYMBOL_NAME(ret_from_interrupt)
114 .globl SYMBOL_NAME(interrupt_redirect_table)
115 .globl SYMBOL_NAME(sw_ksp),SYMBOL_NAME(sw_usp)
116 .globl SYMBOL_NAME(resume)
117 .globl SYMBOL_NAME(syscall_trampoline)
118 .globl SYMBOL_NAME(trace_break)
119 .globl SYMBOL_NAME(interrupt_entry)
122 #if defined(CONFIG_ROMKERNEL)
123 .section .int_redirect,"ax"
124 SYMBOL_NAME_LABEL(interrupt_redirect_table)
128 jsr @SYMBOL_NAME(interrupt_entry) /* NMI */
129 jmp @SYMBOL_NAME(system_call) /* TRAPA #0 (System call) */
132 jmp @SYMBOL_NAME(trace_break) /* TRAPA #3 (breakpoint) */
134 jsr @SYMBOL_NAME(interrupt_entry)
137 #if defined(CONFIG_RAMKERNEL)
138 .globl SYMBOL_NAME(interrupt_redirect_table)
140 SYMBOL_NAME_LABEL(interrupt_redirect_table)
146 SYMBOL_NAME_LABEL(interrupt_entry)
151 mov.l @SYMBOL_NAME(sw_usp),er0
152 mov.l @(4:16,er0),er0
155 mov.l @(LVEC:16,sp),er0
157 #if defined(CONFIG_ROMKERNEL)
158 sub.l #SYMBOL_NAME(interrupt_redirect_table),er0
160 #if defined(CONFIG_RAMKERNEL)
161 mov.l @SYMBOL_NAME(interrupt_redirect_table),er1
167 subs #4,er1 /* adjust ret_pc */
168 jsr @SYMBOL_NAME(process_int)
169 mov.l @SYMBOL_NAME(irq_stat)+CPUSTAT_SOFTIRQ_PENDING,er0
171 jsr @SYMBOL_NAME(do_softirq)
173 jmp @SYMBOL_NAME(ret_from_exception)
175 SYMBOL_NAME_LABEL(system_call)
176 subs #4,sp /* dummy LVEC */
178 mov.w @(LCCR:16,sp),r1
180 ldc r1l,ccr /* restore ccr */
183 mov.l er0,@(LER0:16,sp)
185 /* save top of frame */
187 jsr @SYMBOL_NAME(set_esp0)
188 cmp.l #NR_syscalls,er4
189 bcc SYMBOL_NAME(ret_from_exception):16
191 mov.l #SYMBOL_NAME(sys_call_table),er0
195 beq SYMBOL_NAME(ret_from_exception):16
198 mov.b @((TASK_FLAGS+3-(TIF_SYSCALL_TRACE >> 3)):16,er2),r2l
199 btst #(TIF_SYSCALL_TRACE & 7),r2l
200 mov.l @(LER1:16,sp),er0
201 mov.l @(LER2:16,sp),er1
202 mov.l @(LER3:16,sp),er2
204 mov.l er0,@(LER0,sp) /* save the return value */
205 #if defined(CONFIG_SYSCALL_PRINT)
206 jsr @SYMBOL_NAME(syscall_print)
208 jmp @SYMBOL_NAME(ret_from_exception)
210 jsr SYMBOL_NAME(syscall_trace)
211 mov.l @(LER1:16,sp),er0
212 mov.l @(LER2:16,sp),er1
213 mov.l @(LER3:16,sp),er2
215 mov.l er0,@(LER0:16,sp) /* save the return value */
216 jsr @SYMBOL_NAME(syscall_trace)
218 SYMBOL_NAME_LABEL(ret_from_signal)
220 SYMBOL_NAME_LABEL(ret_from_exception)
221 mov.b @(LCCR+1:16,sp),r0l
222 btst #4,r0l /* check if returning to kernel */
223 bne 3f /* if so, skip resched, signals */
227 mov.l @(TI_FLAGS:16,er2),er1
228 and.l #_TIF_WORK_MASK,er1
231 mov.l @(TI_FLAGS:16,er2),er1
232 btst #TIF_NEED_RESCHED,r1l
233 bne SYMBOL_NAME(reschedule):16
235 subs #4,er1 /* adjust retpc */
237 jsr @SYMBOL_NAME(do_signal)
239 RESTORE_ALL /* Does RTE */
241 SYMBOL_NAME_LABEL(reschedule)
242 /* save top of frame */
244 jsr @SYMBOL_NAME(set_esp0)
246 mov.l #SYMBOL_NAME(ret_from_exception),er0
248 jmp @SYMBOL_NAME(schedule)
250 SYMBOL_NAME_LABEL(ret_from_fork)
252 jsr @SYMBOL_NAME(schedule_tail)
253 jmp @SYMBOL_NAME(ret_from_exception)
256 SYMBOL_NAME_LABEL(resume)
267 mov.w r3,@(THREAD_CCR+2:16,er0)
269 /* disable interrupts */
271 mov.l @SYMBOL_NAME(sw_usp),er3
272 mov.l er3,@(THREAD_USP:16,er0)
273 mov.l sp,@(THREAD_KSP:16,er0)
275 /* Skip address space switching if they are the same. */
276 /* FIXME: what did we hack out of here, this does nothing! */
278 mov.l @(THREAD_USP:16,er1),er0
279 mov.l er0,@SYMBOL_NAME(sw_usp)
280 mov.l @(THREAD_KSP:16,er1),sp
282 /* restore status register */
283 mov.w @(THREAD_CCR+2:16,er1),r3
290 SYMBOL_NAME_LABEL(trace_break)
291 subs #4,sp /* dummy LVEC */
295 mov.l er1,@(LORIG,sp)
297 jsr @SYMBOL_NAME(set_esp0)
298 mov.l @SYMBOL_NAME(sw_usp),er0
304 jsr @SYMBOL_NAME(trace_trap)
305 jmp @SYMBOL_NAME(ret_from_exception)
307 SYMBOL_NAME_LABEL(syscall_trampoline)
313 SYMBOL_NAME_LABEL(sw_ksp)
315 SYMBOL_NAME_LABEL(sw_usp)