3 * linux/arch/h8300/platform/h8300h/entry.S
5 * Yoshinori Sato <ysato@users.sourceforge.jp>
6 * David McCullough <davidm@snapgear.com>
12 * include exception/interrupt gateway
16 #include <linux/sys.h>
17 #include <asm/unistd.h>
18 #include <asm/setup.h>
19 #include <asm/segment.h>
20 #include <asm/linkage.h>
21 #include <asm/asm-offsets.h>
22 #include <asm/thread_info.h>
23 #include <asm/errno.h>
25 #if defined(CONFIG_CPU_H8300H)
52 #if defined(CONFIG_CPU_H8S)
70 mov.w @(USEREXR:16,er0),r1
71 mov.w r1,@(LEXR-LER3:16,sp) /* copy EXR */
74 mov.w @(LEXR-LER1:16,sp),r1 /* restore EXR */
76 mov.w r1,@(USEREXR:16,er0)
81 /* CPU context save/restore macros. */
85 stc ccr,r0l /* check kernel mode */
90 mov.l sp,@SYMBOL_NAME(sw_usp)
91 mov.l @sp,er0 /* restore saved er0 */
92 orc #0x10,ccr /* switch kernel stack */
93 mov.l @SYMBOL_NAME(sw_ksp),sp
94 sub.l #(LRET-LORIG),sp /* allocate LORIG - LRET */
96 mov.l @SYMBOL_NAME(sw_usp),er0
97 mov.l @(USERRET:16,er0),er1 /* copy the RET addr */
98 mov.l er1,@(LRET-LER3:16,sp)
101 mov.l @(LORIG-LER3:16,sp),er0
102 mov.l er0,@(LER0-LER3:16,sp) /* copy ER0 */
103 mov.w e1,r1 /* e1 highbyte = ccr */
104 and #0xef,r1h /* mask mode? flag */
108 mov.l @sp,er0 /* restore saved er0 */
109 subs #2,sp /* set dummy ccr */
111 mov.w @(LRET-LER3:16,sp),r1 /* copy old ccr */
115 mov.w r1,@(LCCR-LER3:16,sp) /* set ccr */
116 mov.l er6,@-sp /* syscall arg #6 */
117 mov.l er5,@-sp /* syscall arg #5 */
118 mov.l er4,@-sp /* syscall arg #4 */
126 mov.w @(LCCR-LER1:16,sp),r0 /* check kernel mode */
131 mov.l @SYMBOL_NAME(sw_usp),er0
132 mov.l @(LER0-LER1:16,sp),er1 /* restore ER0 */
135 mov.w @(LCCR-LER1:16,sp),r1 /* restore the RET addr */
137 mov.b @(LRET+1-LER1:16,sp),r1l
139 mov.w @(LRET+2-LER1:16,sp),r1
140 mov.l er1,@(USERRET:16,er0)
143 add.l #(LRET-LER1),sp /* remove LORIG - LRET */
144 mov.l sp,@SYMBOL_NAME(sw_ksp)
145 andc #0xef,ccr /* switch to user mode */
154 adds #4,sp /* remove the sw created LVEC */
158 .globl SYMBOL_NAME(system_call)
159 .globl SYMBOL_NAME(ret_from_exception)
160 .globl SYMBOL_NAME(ret_from_fork)
161 .globl SYMBOL_NAME(ret_from_interrupt)
162 .globl SYMBOL_NAME(interrupt_redirect_table)
163 .globl SYMBOL_NAME(sw_ksp),SYMBOL_NAME(sw_usp)
164 .globl SYMBOL_NAME(resume)
165 .globl SYMBOL_NAME(interrupt_entry)
166 .globl SYMBOL_NAME(trace_break)
168 #if defined(CONFIG_ROMKERNEL)
169 .section .int_redirect,"ax"
170 SYMBOL_NAME_LABEL(interrupt_redirect_table)
171 #if defined(CONFIG_CPU_H8300H)
176 #if defined(CONFIG_CPU_H8S)
180 jmp @SYMBOL_NAME(trace_break)
184 jsr @SYMBOL_NAME(interrupt_entry) /* NMI */
185 jmp @SYMBOL_NAME(system_call) /* TRAPA #0 (System call) */
188 jmp @SYMBOL_NAME(trace_break) /* TRAPA #3 (breakpoint) */
190 jsr @SYMBOL_NAME(interrupt_entry)
193 #if defined(CONFIG_RAMKERNEL)
194 .globl SYMBOL_NAME(interrupt_redirect_table)
196 SYMBOL_NAME_LABEL(interrupt_redirect_table)
202 SYMBOL_NAME_LABEL(interrupt_entry)
209 mov.l @SYMBOL_NAME(sw_usp),er0
212 mov.l @er0,er0 /* LVEC address */
213 #if defined(CONFIG_ROMKERNEL)
214 sub.l #SYMBOL_NAME(interrupt_redirect_table),er0
216 #if defined(CONFIG_RAMKERNEL)
217 mov.l @SYMBOL_NAME(interrupt_redirect_table),er1
223 subs #4,er1 /* adjust ret_pc */
224 jsr @SYMBOL_NAME(do_IRQ)
225 jmp @SYMBOL_NAME(ret_from_interrupt)
227 SYMBOL_NAME_LABEL(system_call)
228 subs #4,sp /* dummy LVEC */
233 /* save top of frame */
235 jsr @SYMBOL_NAME(set_esp0)
238 mov.b @((TI_FLAGS+3-(TIF_SYSCALL_TRACE >> 3)):16,er2),r2l
239 btst #(TIF_SYSCALL_TRACE & 7),r2l
241 jsr @SYMBOL_NAME(do_syscall_trace)
243 cmp.l #NR_syscalls,er4
246 mov.l #SYMBOL_NAME(sys_call_table),er0
249 beq SYMBOL_NAME(ret_from_exception):16
250 mov.l @(LER1:16,sp),er0
251 mov.l @(LER2:16,sp),er1
252 mov.l @(LER3:16,sp),er2
254 mov.l er0,@(LER0:16,sp) /* save the return value */
257 mov.b @((TI_FLAGS+3-(TIF_SYSCALL_TRACE >> 3)):16,er2),r2l
258 btst #(TIF_SYSCALL_TRACE & 7),r2l
260 jsr @SYMBOL_NAME(do_syscall_trace)
262 #if defined(CONFIG_SYSCALL_PRINT)
263 jsr @SYMBOL_NAME(syscall_print)
270 mov.l er0,@(LER0:16,sp)
273 #if !defined(CONFIG_PREEMPT)
274 #define resume_kernel restore_all
277 SYMBOL_NAME_LABEL(ret_from_exception)
278 #if defined(CONFIG_PREEMPT)
281 SYMBOL_NAME_LABEL(ret_from_interrupt)
282 mov.b @(LCCR+1:16,sp),r0l
284 bne resume_kernel:8 /* return from kernel */
288 and.w #0xe000,r4 /* er4 <- current thread info */
289 mov.l @(TI_FLAGS:16,er4),er1
290 and.l #_TIF_WORK_MASK,er1
293 btst #TIF_NEED_RESCHED,r1l
297 subs #4,er0 /* er0: pt_regs */
298 jsr @SYMBOL_NAME(do_notify_resume)
302 jsr @SYMBOL_NAME(set_esp0)
303 jsr @SYMBOL_NAME(schedule)
304 bra resume_userspace:8
306 RESTORE_ALL /* Does RTE */
308 #if defined(CONFIG_PREEMPT)
310 mov.l @(TI_PRE_COUNT:16,er4),er0
313 mov.l @(TI_FLAGS:16,er4),er0
314 btst #TIF_NEED_RESCHED,r0l
316 mov.b @(LCCR+1:16,sp),r0l /* Interrupt Enabled? */
318 mov.l #PREEMPT_ACTIVE,er0
319 mov.l er0,@(TI_PRE_COUNT:16,er4)
322 jsr @SYMBOL_NAME(set_esp0)
323 jsr @SYMBOL_NAME(schedule)
328 SYMBOL_NAME_LABEL(ret_from_fork)
330 jsr @SYMBOL_NAME(schedule_tail)
331 jmp @SYMBOL_NAME(ret_from_exception)
333 SYMBOL_NAME_LABEL(resume)
335 * Beware - when entering resume, offset of tss is in d1,
336 * prev (the current task) is in a0, next (the new task)
337 * is in a1 and d2.b is non-zero if the mm structure is
338 * shared between the tasks, so don't change these
339 * registers until their contents are no longer needed.
345 mov.w r3,@(THREAD_CCR+2:16,er0)
347 /* disable interrupts */
349 mov.l @SYMBOL_NAME(sw_usp),er3
350 mov.l er3,@(THREAD_USP:16,er0)
351 mov.l sp,@(THREAD_KSP:16,er0)
353 /* Skip address space switching if they are the same. */
354 /* FIXME: what did we hack out of here, this does nothing! */
356 mov.l @(THREAD_USP:16,er1),er0
357 mov.l er0,@SYMBOL_NAME(sw_usp)
358 mov.l @(THREAD_KSP:16,er1),sp
360 /* restore status register */
361 mov.w @(THREAD_CCR+2:16,er1),r3
366 SYMBOL_NAME_LABEL(trace_break)
371 mov.l er1,@(LORIG,sp)
373 jsr @SYMBOL_NAME(set_esp0)
374 mov.l @SYMBOL_NAME(sw_usp),er0
376 mov.w @(-2:16,er1),r2
384 jsr @SYMBOL_NAME(trace_trap)
385 jmp @SYMBOL_NAME(ret_from_exception)
388 SYMBOL_NAME_LABEL(sw_ksp)
390 SYMBOL_NAME_LABEL(sw_usp)