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 <asm/unistd.h>
19 #include <asm/setup.h>
20 #include <asm/segment.h>
21 #include <asm/linkage.h>
22 #include <asm/asm-offsets.h>
23 #include <asm/thread_info.h>
24 #include <asm/errno.h>
28 /* CPU context save/restore macros. */
33 stc ccr,r0l /* check kernel mode */
38 mov.l sp,@SYMBOL_NAME(sw_usp) /* user mode */
40 mov.l @SYMBOL_NAME(sw_ksp),sp
41 sub.l #(LRET-LORIG),sp /* allocate LORIG - LRET */
43 mov.l @SYMBOL_NAME(sw_usp),er0
44 mov.l @(10:16,er0),er1 /* copy the RET addr */
45 mov.l er1,@(LRET-LER3:16,sp)
47 mov.w r1,@(LEXR-LER3:16,sp) /* copy EXR */
49 mov.w e1,r1 /* e1 highbyte = ccr */
50 and #0xef,r1h /* mask mode? flag */
53 mov.w r0,@(LCCR-LER3:16,sp) /* copy ccr */
54 mov.l @(LORIG-LER3:16,sp),er0
55 mov.l er0,@(LER0-LER3:16,sp) /* copy ER0 */
58 mov.l @sp,er0 /* kernel mode */
59 subs #2,sp /* dummy ccr */
61 mov.w @(LRET-LER3:16,sp),r1 /* copy old ccr */
64 mov.w r1,@(LCCR-LER3:16,sp)
66 mov.l er6,@-sp /* syscall arg #6 */
67 mov.l er5,@-sp /* syscall arg #5 */
68 mov.l er4,@-sp /* syscall arg #4 */
76 mov.w @(LCCR-LER1:16,sp),r0 /* check kernel mode */
81 mov.l @SYMBOL_NAME(sw_usp),er0
82 mov.l @(LER0-LER1:16,sp),er1 /* restore ER0 */
84 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_interrupt)
113 .globl SYMBOL_NAME(interrupt_redirect_table)
114 .globl SYMBOL_NAME(sw_ksp),SYMBOL_NAME(sw_usp)
115 .globl SYMBOL_NAME(resume)
116 .globl SYMBOL_NAME(trace_break)
117 .globl SYMBOL_NAME(interrupt_entry)
120 #if defined(CONFIG_ROMKERNEL)
121 .section .int_redirect,"ax"
122 SYMBOL_NAME_LABEL(interrupt_redirect_table)
126 jsr @SYMBOL_NAME(interrupt_entry) /* NMI */
127 jmp @SYMBOL_NAME(system_call) /* TRAPA #0 (System call) */
130 jmp @SYMBOL_NAME(trace_break) /* TRAPA #3 (breakpoint) */
132 jsr @SYMBOL_NAME(interrupt_entry)
135 #if defined(CONFIG_RAMKERNEL)
136 .globl SYMBOL_NAME(interrupt_redirect_table)
138 SYMBOL_NAME_LABEL(interrupt_redirect_table)
144 SYMBOL_NAME_LABEL(interrupt_entry)
149 mov.l @SYMBOL_NAME(sw_usp),er0
150 mov.l @(4:16,er0),er0
153 mov.l @(LVEC:16,sp),er0
155 #if defined(CONFIG_ROMKERNEL)
156 sub.l #SYMBOL_NAME(interrupt_redirect_table),er0
158 #if defined(CONFIG_RAMKERNEL)
159 mov.l @SYMBOL_NAME(interrupt_redirect_table),er1
165 subs #4,er1 /* adjust ret_pc */
166 jsr @SYMBOL_NAME(process_int)
167 mov.l @SYMBOL_NAME(irq_stat)+CPUSTAT_SOFTIRQ_PENDING,er0
169 jsr @SYMBOL_NAME(do_softirq)
171 jmp @SYMBOL_NAME(ret_from_exception)
173 SYMBOL_NAME_LABEL(system_call)
174 subs #4,sp /* dummy LVEC */
176 mov.w @(LCCR:16,sp),r1
178 ldc r1l,ccr /* restore ccr */
181 mov.l er0,@(LER0:16,sp)
183 /* save top of frame */
185 jsr @SYMBOL_NAME(set_esp0)
186 cmp.l #NR_syscalls,er4
187 bcc SYMBOL_NAME(ret_from_exception):16
189 mov.l #SYMBOL_NAME(sys_call_table),er0
193 beq SYMBOL_NAME(ret_from_exception):16
196 mov.b @((TASK_FLAGS+3-(TIF_SYSCALL_TRACE >> 3)):16,er2),r2l
197 btst #(TIF_SYSCALL_TRACE & 7),r2l
198 mov.l @(LER1:16,sp),er0
199 mov.l @(LER2:16,sp),er1
200 mov.l @(LER3:16,sp),er2
202 mov.l er0,@(LER0:16,sp) /* save the return value */
203 #if defined(CONFIG_SYSCALL_PRINT)
204 jsr @SYMBOL_NAME(syscall_print)
206 bra SYMBOL_NAME(ret_from_exception):8
208 jsr SYMBOL_NAME(syscall_trace)
209 mov.l @(LER1:16,sp),er0
210 mov.l @(LER2:16,sp),er1
211 mov.l @(LER3:16,sp),er2
213 mov.l er0,@(LER0:16,sp) /* save the return value */
214 jsr @SYMBOL_NAME(syscall_trace)
215 bra SYMBOL_NAME(ret_from_exception):8
217 SYMBOL_NAME_LABEL(ret_from_fork)
219 jsr @SYMBOL_NAME(schedule_tail)
220 bra SYMBOL_NAME(ret_from_exception):8
222 SYMBOL_NAME_LABEL(reschedule)
223 /* save top of frame */
225 jsr @SYMBOL_NAME(set_esp0)
226 jsr @SYMBOL_NAME(schedule)
228 SYMBOL_NAME_LABEL(ret_from_exception)
229 #if defined(CONFIG_PREEMPT)
232 SYMBOL_NAME_LABEL(ret_from_interrupt)
233 mov.b @(LCCR+1:16,sp),r0l
234 btst #4,r0l /* check if returning to kernel */
235 bne done:8 /* if so, skip resched, signals */
239 mov.l @(TI_FLAGS:16,er4),er1
240 and.l #_TIF_WORK_MASK,er1
243 mov.l @(TI_FLAGS:16,er4),er1
244 btst #TIF_NEED_RESCHED,r1l
245 bne SYMBOL_NAME(reschedule):16
247 subs #4,er0 /* adjust retpc */
249 jsr @SYMBOL_NAME(do_signal)
250 #if defined(CONFIG_PREEMPT)
251 bra done:8 /* userspace thoru */
254 beq done:8 /* userspace thoru */
256 mov.l @(TI_PRE_COUNT:16,er4),er1
258 mov.l @(TI_FLAGS:16,er4),er1
259 btst #TIF_NEED_RESCHED,r1l
262 bpl done:8 /* interrupt off (exception path?) */
263 mov.l #PREEMPT_ACTIVE,er1
264 mov.l er1,@(TI_PRE_COUNT:16,er4)
266 jsr @SYMBOL_NAME(schedule)
268 mov.l er1,@(TI_PRE_COUNT:16,er4)
273 RESTORE_ALL /* Does RTE */
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)
327 SYMBOL_NAME_LABEL(sw_ksp)
329 SYMBOL_NAME_LABEL(sw_usp)