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 <linux/config.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 */
44 mov.l @SYMBOL_NAME(sw_usp),er0
45 mov.l @(8:16,er0),er1 /* copy the RET addr */
46 mov.l er1,@(LRET-LER1:16,sp)
48 mov.w e1,r1 /* e1 highbyte = ccr */
49 and #0xef,r1h /* mask mode? flag */
52 mov.w r0,@(LCCR-LER1:16,sp) /* copy ccr */
53 mov.l @(LORIG-LER1:16,sp),er0
54 mov.l er0,@(LER0-LER1:16,sp) /* copy ER0 */
57 mov.l @sp,er0 /* kernel mode */
58 subs #2,sp /* dummy ccr */
61 mov.w @(LRET-LER1:16,sp),r1 /* copy old ccr */
64 mov.w r1,@(LCCR-LER1:16,sp) /* set ccr */
68 mov.l er6,@-sp /* syscall arg #6 */
69 mov.l er5,@-sp /* syscall arg #5 */
70 mov.l er4,@-sp /* syscall arg #4 */
79 mov.w @(LCCR-LER1:16,sp),r0 /* check kernel mode */
84 mov.l @SYMBOL_NAME(sw_usp),er0
85 mov.l @(LER0-LER1:16,sp),er1 /* restore ER0 */
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
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(interrupt_redirect_table)
117 .globl SYMBOL_NAME(interrupt_entry)
118 .globl SYMBOL_NAME(system_call)
119 .globl SYMBOL_NAME(trace_break)
121 #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
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
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_interrupt)
176 SYMBOL_NAME_LABEL(system_call)
177 subs #4,sp /* dummy LVEC */
179 mov.w @(LCCR:16,sp),r1
184 mov.l er0,@(LER0:16,sp)
186 /* save top of frame */
188 jsr @SYMBOL_NAME(set_esp0)
189 cmp.l #NR_syscalls,er4
190 bcc SYMBOL_NAME(ret_from_exception):16
193 mov.l #SYMBOL_NAME(sys_call_table),er0
196 beq SYMBOL_NAME(ret_from_exception):16
199 mov.b @((TASK_FLAGS+3-(TIF_SYSCALL_TRACE >> 3)):16,er2),r2l
200 btst #(TIF_SYSCALL_TRACE & 7),r2l
202 mov.l @(LER1:16,sp),er0
203 mov.l @(LER2:16,sp),er1
204 mov.l @(LER3:16,sp),er2
206 mov.l er0,@(LER0:16,sp) /* save the return value */
207 #if defined(CONFIG_SYSCALL_PRINT)
208 jsr @SYMBOL_NAME(syscall_print)
210 bra SYMBOL_NAME(ret_from_exception):8
212 jsr SYMBOL_NAME(syscall_trace)
213 mov.l @(LER1:16,sp),er0
214 mov.l @(LER2:16,sp),er1
215 mov.l @(LER3:16,sp),er2
217 mov.l er0,@(LER0:16,sp) /* save the return value */
218 jsr @SYMBOL_NAME(syscall_trace)
219 bra SYMBOL_NAME(ret_from_exception):8
221 SYMBOL_NAME_LABEL(ret_from_fork)
223 jsr @SYMBOL_NAME(schedule_tail)
224 bra SYMBOL_NAME(ret_from_exception):8
226 SYMBOL_NAME_LABEL(reschedule)
227 /* save top of frame */
229 jsr @SYMBOL_NAME(set_esp0)
230 jsr @SYMBOL_NAME(schedule)
232 SYMBOL_NAME_LABEL(ret_from_exception)
233 #if defined(CONFIG_PREEMPT)
236 SYMBOL_NAME_LABEL(ret_from_interrupt)
237 mov.b @(LCCR+1:16,sp),r0l
238 btst #4,r0l /* check if returning to kernel */
239 bne done:8 /* if so, skip resched, signals */
243 mov.l @(TI_FLAGS:16,er4),er1
244 and.l #_TIF_WORK_MASK,er1
247 mov.l @(TI_FLAGS:16,er4),er1
248 btst #TIF_NEED_RESCHED,r1l
249 bne SYMBOL_NAME(reschedule):16
251 subs #4,er0 /* adjust retpc */
253 jsr @SYMBOL_NAME(do_signal)
254 #if defined(CONFIG_PREEMPT)
255 bra done:8 /* userspace thoru */
258 beq done:8 /* userspace thoru */
260 mov.l @(TI_PRE_COUNT:16,er4),er1
262 mov.l @(TI_FLAGS:16,er4),er1
263 btst #TIF_NEED_RESCHED,r1l
266 bpl done:8 /* interrupt off (exception path?) */
267 mov.l #PREEMPT_ACTIVE,er1
268 mov.l er1,@(TI_PRE_COUNT:16,er4)
270 jsr @SYMBOL_NAME(schedule)
272 mov.l er1,@(TI_PRE_COUNT:16,er4)
277 RESTORE_ALL /* Does RTE */
279 SYMBOL_NAME_LABEL(resume)
281 * Beware - when entering resume, offset of tss is in d1,
282 * prev (the current task) is in a0, next (the new task)
283 * is in a1 and d2.b is non-zero if the mm structure is
284 * shared between the tasks, so don't change these
285 * registers until their contents are no longer needed.
291 mov.w r3,@(THREAD_CCR+2:16,er0)
293 /* disable interrupts */
295 mov.l @SYMBOL_NAME(sw_usp),er3
296 mov.l er3,@(THREAD_USP:16,er0)
297 mov.l sp,@(THREAD_KSP:16,er0)
299 /* Skip address space switching if they are the same. */
300 /* FIXME: what did we hack out of here, this does nothing! */
302 mov.l @(THREAD_USP:16,er1),er0
303 mov.l er0,@SYMBOL_NAME(sw_usp)
304 mov.l @(THREAD_KSP:16,er1),sp
306 /* restore status register */
307 mov.w @(THREAD_CCR+2:16,er1),r3
312 SYMBOL_NAME_LABEL(trace_break)
317 mov.l er1,@(LORIG,sp)
319 jsr @SYMBOL_NAME(set_esp0)
320 mov.l @SYMBOL_NAME(sw_usp),er0
326 jsr @SYMBOL_NAME(trace_trap)
327 jmp @SYMBOL_NAME(ret_from_exception)
330 SYMBOL_NAME_LABEL(sw_ksp)
332 SYMBOL_NAME_LABEL(sw_usp)