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)
39 mov.l @sp,er0 /* restore saved er0 */
40 orc #0x10,ccr /* switch kernel stack */
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 */
60 mov.l @sp,er0 /* restore saved er0 */
61 subs #2,sp /* set dummy ccr */
63 mov.w @(LRET-LER3:16,sp),r1 /* copy old ccr */
66 mov.w r1,@(LCCR-LER3:16,sp)
68 mov.l er6,@-sp /* syscall arg #6 */
69 mov.l er5,@-sp /* syscall arg #5 */
70 mov.l er4,@-sp /* syscall arg #4 */
78 mov.w @(LCCR-LER1:16,sp),r0 /* check kernel mode */
83 mov.l @SYMBOL_NAME(sw_usp),er0
84 mov.l @(LER0-LER1:16,sp),er1 /* restore ER0 */
86 mov.w @(LEXR-LER1:16,sp),r1 /* restore EXR */
89 mov.w @(LCCR-LER1:16,sp),r1 /* restore the RET addr */
91 mov.b @(LRET+1-LER1:16,sp),r1l
93 mov.w @(LRET+2-LER1:16,sp),r1
94 mov.l er1,@(10:16,er0)
97 add.l #(LRET-LER1),sp /* remove LORIG - LRET */
98 mov.l sp,@SYMBOL_NAME(sw_ksp)
99 andc #0xef,ccr /* switch to user mode */
108 adds #4,sp /* remove the sw created LVEC */
112 .globl SYMBOL_NAME(system_call)
113 .globl SYMBOL_NAME(ret_from_exception)
114 .globl SYMBOL_NAME(ret_from_fork)
115 .globl SYMBOL_NAME(ret_from_interrupt)
116 .globl SYMBOL_NAME(interrupt_redirect_table)
117 .globl SYMBOL_NAME(sw_ksp),SYMBOL_NAME(sw_usp)
118 .globl SYMBOL_NAME(resume)
119 .globl SYMBOL_NAME(trace_break)
120 .globl SYMBOL_NAME(interrupt_entry)
123 #if defined(CONFIG_ROMKERNEL)
124 .section .int_redirect,"ax"
125 SYMBOL_NAME_LABEL(interrupt_redirect_table)
129 jsr @SYMBOL_NAME(interrupt_entry) /* NMI */
130 jmp @SYMBOL_NAME(system_call) /* TRAPA #0 (System call) */
133 jmp @SYMBOL_NAME(trace_break) /* TRAPA #3 (breakpoint) */
135 jsr @SYMBOL_NAME(interrupt_entry)
138 #if defined(CONFIG_RAMKERNEL)
139 .globl SYMBOL_NAME(interrupt_redirect_table)
141 SYMBOL_NAME_LABEL(interrupt_redirect_table)
147 SYMBOL_NAME_LABEL(interrupt_entry)
152 mov.l @SYMBOL_NAME(sw_usp),er0
153 mov.l @(4:16,er0),er0
156 mov.l @(LVEC:16,sp),er0
158 #if defined(CONFIG_ROMKERNEL)
159 sub.l #SYMBOL_NAME(interrupt_redirect_table),er0
161 #if defined(CONFIG_RAMKERNEL)
162 mov.l @SYMBOL_NAME(interrupt_redirect_table),er1
168 subs #4,er1 /* adjust ret_pc */
169 jsr @SYMBOL_NAME(process_int)
170 mov.l @SYMBOL_NAME(irq_stat)+CPUSTAT_SOFTIRQ_PENDING,er0
172 jsr @SYMBOL_NAME(do_softirq)
174 jmp @SYMBOL_NAME(ret_from_exception)
176 SYMBOL_NAME_LABEL(system_call)
177 subs #4,sp /* dummy LVEC */
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
203 mov.l er0,@(LER0:16,sp) /* save the return value */
204 #if defined(CONFIG_SYSCALL_PRINT)
205 jsr @SYMBOL_NAME(syscall_print)
207 bra SYMBOL_NAME(ret_from_exception):8
209 jsr SYMBOL_NAME(syscall_trace)
210 mov.l @(LER1:16,sp),er0
211 mov.l @(LER2:16,sp),er1
212 mov.l @(LER3:16,sp),er2
214 mov.l er0,@(LER0:16,sp) /* save the return value */
215 jsr @SYMBOL_NAME(syscall_trace)
216 bra SYMBOL_NAME(ret_from_exception):8
218 SYMBOL_NAME_LABEL(ret_from_fork)
220 jsr @SYMBOL_NAME(schedule_tail)
221 bra SYMBOL_NAME(ret_from_exception):8
223 SYMBOL_NAME_LABEL(reschedule)
224 /* save top of frame */
226 jsr @SYMBOL_NAME(set_esp0)
227 jsr @SYMBOL_NAME(schedule)
229 SYMBOL_NAME_LABEL(ret_from_exception)
230 #if defined(CONFIG_PREEMPT)
233 SYMBOL_NAME_LABEL(ret_from_interrupt)
234 mov.b @(LCCR+1:16,sp),r0l
235 btst #4,r0l /* check if returning to kernel */
236 bne done:8 /* if so, skip resched, signals */
240 mov.l @(TI_FLAGS:16,er4),er1
241 and.l #_TIF_WORK_MASK,er1
244 mov.l @(TI_FLAGS:16,er4),er1
245 btst #TIF_NEED_RESCHED,r1l
246 bne SYMBOL_NAME(reschedule):16
248 subs #4,er0 /* adjust retpc */
250 jsr @SYMBOL_NAME(do_signal)
251 #if defined(CONFIG_PREEMPT)
252 bra done:8 /* userspace thoru */
255 beq done:8 /* userspace thoru */
257 mov.l @(TI_PRE_COUNT:16,er4),er1
259 mov.l @(TI_FLAGS:16,er4),er1
260 btst #TIF_NEED_RESCHED,r1l
263 bpl done:8 /* interrupt off (exception path?) */
264 mov.l #PREEMPT_ACTIVE,er1
265 mov.l er1,@(TI_PRE_COUNT:16,er4)
267 jsr @SYMBOL_NAME(schedule)
269 mov.l er1,@(TI_PRE_COUNT:16,er4)
274 RESTORE_ALL /* Does RTE */
276 SYMBOL_NAME_LABEL(resume)
287 mov.w r3,@(THREAD_CCR+2:16,er0)
289 /* disable interrupts */
291 mov.l @SYMBOL_NAME(sw_usp),er3
292 mov.l er3,@(THREAD_USP:16,er0)
293 mov.l sp,@(THREAD_KSP:16,er0)
295 /* Skip address space switching if they are the same. */
296 /* FIXME: what did we hack out of here, this does nothing! */
298 mov.l @(THREAD_USP:16,er1),er0
299 mov.l er0,@SYMBOL_NAME(sw_usp)
300 mov.l @(THREAD_KSP:16,er1),sp
302 /* restore status register */
303 mov.w @(THREAD_CCR+2:16,er1),r3
310 SYMBOL_NAME_LABEL(trace_break)
311 subs #4,sp /* dummy LVEC */
315 mov.l er1,@(LORIG,sp)
317 jsr @SYMBOL_NAME(set_esp0)
318 mov.l @SYMBOL_NAME(sw_usp),er0
324 jsr @SYMBOL_NAME(trace_trap)
325 jmp @SYMBOL_NAME(ret_from_exception)
328 SYMBOL_NAME_LABEL(sw_ksp)
330 SYMBOL_NAME_LABEL(sw_usp)