3 * linux/arch/h8300/kernel/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 */
91 mov.l @sp,er0 /* restore saved er0 */
92 orc #0x10,ccr /* switch kernel stack */
94 sub.l #(LRET-LORIG),sp /* allocate LORIG - LRET */
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 */
110 subs #4,sp /* set dummp sp */
112 mov.w @(LRET-LER3:16,sp),r1 /* copy old ccr */
116 mov.w r1,@(LCCR-LER3:16,sp) /* set ccr */
118 mov.l er2,@(LSP-LER3:16,sp) /* set usp */
119 mov.l er6,@-sp /* syscall arg #6 */
120 mov.l er5,@-sp /* syscall arg #5 */
121 mov.l er4,@-sp /* syscall arg #4 */
129 mov.w @(LCCR-LER1:16,sp),r0 /* check kernel mode */
134 mov.l @(LSP-LER1:16,sp),er0
135 mov.l @(LER0-LER1:16,sp),er1 /* restore ER0 */
138 mov.w @(LCCR-LER1:16,sp),r1 /* restore the RET addr */
140 mov.b @(LRET+1-LER1:16,sp),r1l
142 mov.w @(LRET+2-LER1:16,sp),r1
143 mov.l er1,@(USERRET:16,er0)
146 add.l #(LRET-LER1),sp /* remove LORIG - LRET */
148 andc #0xef,ccr /* switch to user mode */
156 adds #4,sp /* remove the sw created LVEC */
161 .globl ret_from_exception
163 .globl ret_from_kernel_thread
164 .globl ret_from_interrupt
165 .globl _interrupt_redirect_table
166 .globl _sw_ksp,_sw_usp
168 .globl _interrupt_entry
172 #if defined(CONFIG_ROMKERNEL)
173 .section .int_redirect,"ax"
174 _interrupt_redirect_table:
175 #if defined(CONFIG_CPU_H8300H)
180 #if defined(CONFIG_CPU_H8S)
188 jsr @_interrupt_entry /* NMI */
189 jmp @_system_call /* TRAPA #0 (System call) */
192 jmp @_trace_break /* TRAPA #3 (breakpoint) */
194 jsr @_interrupt_entry
197 #if defined(CONFIG_RAMKERNEL)
198 .globl _interrupt_redirect_table
200 _interrupt_redirect_table:
208 /* r1l is saved ccr */
217 mov.l @er0,er0 /* LVEC address */
218 #if defined(CONFIG_ROMKERNEL)
219 sub.l #_interrupt_redirect_table,er0
221 #if defined(CONFIG_RAMKERNEL)
222 mov.l @_interrupt_redirect_table,er1
228 subs #4,er1 /* adjust ret_pc */
229 #if defined(CONFIG_CPU_H8S)
233 jmp @ret_from_interrupt
236 subs #4,sp /* dummy LVEC */
238 /* er0: syscall nr */
242 /* save top of frame */
247 mov.l @(TI_FLAGS:16,er2),er2
248 and.w #_TIF_WORK_SYSCALL_MASK,r2
251 jsr @do_syscall_trace_enter
253 cmp.l #__NR_syscalls,er4
256 mov.l #_sys_call_table,er0
259 beq ret_from_exception:16
260 mov.l @(LER1:16,sp),er0
261 mov.l @(LER2:16,sp),er1
262 mov.l @(LER3:16,sp),er2
264 mov.l er0,@(LER0:16,sp) /* save the return value */
267 mov.l @(TI_FLAGS:16,er2),er2
268 and.w #_TIF_WORK_SYSCALL_MASK,r2
271 jsr @do_syscall_trace_leave
278 mov.l er0,@(LER0:16,sp)
281 #if !defined(CONFIG_PREEMPT)
282 #define resume_kernel restore_all
286 #if defined(CONFIG_PREEMPT)
290 mov.b @(LCCR+1:16,sp),r0l
292 bne resume_kernel:16 /* return from kernel */
296 and.w #0xe000,r4 /* er4 <- current thread info */
297 mov.l @(TI_FLAGS:16,er4),er1
298 and.l #_TIF_WORK_MASK,er1
301 btst #TIF_NEED_RESCHED,r1l
305 subs #4,er0 /* er0: pt_regs */
306 jsr @do_notify_resume
307 bra resume_userspace:8
312 bra resume_userspace:8
314 RESTORE_ALL /* Does RTE */
316 #if defined(CONFIG_PREEMPT)
318 mov.l @(TI_PRE_COUNT:16,er4),er0
321 mov.l @(TI_FLAGS:16,er4),er0
322 btst #TIF_NEED_RESCHED,r0l
324 mov.b @(LCCR+1:16,sp),r0l /* Interrupt Enabled? */
328 jsr @preempt_schedule_irq
335 jmp @ret_from_exception
337 ret_from_kernel_thread:
340 mov.l @(LER4:16,sp),er0
341 mov.l @(LER5:16,sp),er1
343 jmp @ret_from_exception
347 * Beware - when entering resume, offset of tss is in d1,
348 * prev (the current task) is in a0, next (the new task)
349 * is in a1 and d2.b is non-zero if the mm structure is
350 * shared between the tasks, so don't change these
351 * registers until their contents are no longer needed.
357 mov.w r3,@(THREAD_CCR+2:16,er0)
359 /* disable interrupts */
362 mov.l er3,@(THREAD_USP:16,er0)
363 mov.l sp,@(THREAD_KSP:16,er0)
365 /* Skip address space switching if they are the same. */
366 /* FIXME: what did we hack out of here, this does nothing! */
368 mov.l @(THREAD_USP:16,er1),er0
370 mov.l @(THREAD_KSP:16,er1),sp
372 /* restore status register */
373 mov.w @(THREAD_CCR+2:16,er1),r3
383 mov.l er1,@(LORIG,sp)
388 mov.w @(-2:16,er1),r2
397 jmp @ret_from_exception
402 mov.l @_interrupt_redirect_table, er0
406 jmp @_interrupt_entry