2 * linux/arch/arm/kernel/entry-common.S
4 * Copyright (C) 2000 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 #include <linux/config.h>
12 #include <asm/thread_info.h>
13 #include <asm/ptrace.h>
15 #include "entry-header.S"
18 * We rely on the fact that R0 is at the bottom of the stack (due to
19 * slow/fast restore user regs).
27 * This is the fast syscall return path. We do as little as
28 * possible here, and this includes saving r0 back into the SVC
32 disable_irq r1 @ disable interrupts
33 ldr r1, [tsk, #TI_FLAGS]
34 tst r1, #_TIF_WORK_MASK
36 fast_restore_user_regs
39 * Ok, we need to do extra processing, enter the slow path.
42 str r0, [sp, #S_R0+S_OFF]! @ returned r0
44 tst r1, #_TIF_NEED_RESCHED
46 tst r1, #_TIF_NOTIFY_RESUME | _TIF_SIGPENDING
49 mov r2, why @ 'syscall'
51 disable_irq r1 @ disable interrupts
57 * "slow" syscall return path. "why" tells us if this was a real syscall.
61 disable_irq r1 @ disable interrupts
62 ldr r1, [tsk, #TI_FLAGS]
63 tst r1, #_TIF_WORK_MASK
66 slow_restore_user_regs
69 * This is how we return from a fork.
74 ldr r1, [tsk, #TI_FLAGS] @ check for syscall tracing
76 tst r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
79 mov r0, #1 @ trace exit [IP = 1]
86 /*=============================================================================
88 *-----------------------------------------------------------------------------
91 /* If we're optimising for StrongARM the resulting code won't
92 run on an ARM7 and we can save a couple of instructions.
94 #ifdef CONFIG_CPU_ARM710
95 .macro arm710_bug_check, instr, temp
96 and \temp, \instr, #0x0f000000 @ check for SWI
97 teq \temp, #0x0f000000
102 ldr r0, [sp, #S_PSR] @ Get calling cpsr
106 ldmia sp, {r0 - lr}^ @ Get calling r0 - lr
108 ldr lr, [sp, #S_PC] @ Get PC
109 add sp, sp, #S_FRAME_SIZE
112 .macro arm710_bug_check, instr, temp
121 arm710_bug_check scno, ip
123 #ifdef CONFIG_ALIGNMENT_TRAP
124 ldr ip, __cr_alignment
126 mcr p15, 0, ip, c1, c0 @ update control register
130 str r4, [sp, #-S_OFF]! @ push fifth arg
133 ldr ip, [tsk, #TI_FLAGS] @ check for syscall tracing
134 bic scno, scno, #0xff000000 @ mask off SWI op-code
135 eor scno, scno, #OS_NUMBER << 20 @ check OS number
136 adr tbl, sys_call_table @ load syscall table pointer
137 tst ip, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
140 adrsvc al, lr, ret_fast_syscall @ return address
141 cmp scno, #NR_syscalls @ check upper syscall limit
142 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
145 2: mov why, #0 @ no longer a real syscall
146 cmp scno, #ARMSWI_OFFSET
147 eor r0, scno, #OS_NUMBER << 20 @ put OS number back
149 b sys_ni_syscall @ not private func
152 * This is the really slow path. We're going to be doing
153 * context switches, and waiting for our parent to respond.
157 mov r0, #0 @ trace entry [IP = 0]
160 adrsvc al, lr, __sys_trace_return @ return address
161 add r1, sp, #S_R0 + S_OFF @ pointer to regs
162 cmp scno, #NR_syscalls @ check upper syscall limit
163 ldmccia r1, {r0 - r3} @ have to reload r0 - r3
164 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
168 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
170 mov r0, #1 @ trace exit [IP = 1]
175 #ifdef CONFIG_ALIGNMENT_TRAP
176 .type __cr_alignment, #object
181 .type sys_call_table, #object
182 ENTRY(sys_call_table)
185 /*============================================================================
186 * Special system call wrappers
188 @ r0 = syscall number
190 .type sys_syscall, #function
192 eor scno, r0, #OS_NUMBER << 20
193 cmp scno, #NR_syscalls @ check range
194 stmleia sp, {r5, r6} @ shuffle args
199 ldrle pc, [tbl, scno, lsl #2]
218 sys_sigsuspend_wrapper:
222 sys_rt_sigsuspend_wrapper:
226 sys_sigreturn_wrapper:
230 sys_rt_sigreturn_wrapper:
234 sys_sigaltstack_wrapper:
235 ldr r2, [sp, #S_OFF + S_SP]
239 * Note: off_4k (r5) is always units of 4K. If we can't do the requested
240 * offset, we return EINVAL.
245 moveq r5, r5, lsr #PAGE_SHIFT - 12