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>
14 #include <asm/unistd.h>
16 #include "entry-header.S"
19 * We rely on the fact that R0 is at the bottom of the stack (due to
20 * slow/fast restore user regs).
28 * This is the fast syscall return path. We do as little as
29 * possible here, and this includes saving r0 back into the SVC
33 disable_irq r1 @ disable interrupts
34 ldr r1, [tsk, #TI_FLAGS]
35 tst r1, #_TIF_WORK_MASK
37 fast_restore_user_regs
40 * Ok, we need to do extra processing, enter the slow path.
43 str r0, [sp, #S_R0+S_OFF]! @ returned r0
45 tst r1, #_TIF_NEED_RESCHED
47 tst r1, #_TIF_NOTIFY_RESUME | _TIF_SIGPENDING
50 mov r2, why @ 'syscall'
52 disable_irq r1 @ disable interrupts
58 * "slow" syscall return path. "why" tells us if this was a real syscall.
62 disable_irq r1 @ disable interrupts
63 ldr r1, [tsk, #TI_FLAGS]
64 tst r1, #_TIF_WORK_MASK
67 slow_restore_user_regs
70 * This is how we return from a fork.
75 ldr r1, [tsk, #TI_FLAGS] @ check for syscall tracing
77 tst r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
80 mov r0, #1 @ trace exit [IP = 1]
87 /*=============================================================================
89 *-----------------------------------------------------------------------------
92 /* If we're optimising for StrongARM the resulting code won't
93 run on an ARM7 and we can save a couple of instructions.
95 #ifdef CONFIG_CPU_ARM710
96 .macro arm710_bug_check, instr, temp
97 and \temp, \instr, #0x0f000000 @ check for SWI
98 teq \temp, #0x0f000000
103 ldr r0, [sp, #S_PSR] @ Get calling cpsr
107 ldmia sp, {r0 - lr}^ @ Get calling r0 - lr
109 ldr lr, [sp, #S_PC] @ Get PC
110 add sp, sp, #S_FRAME_SIZE
113 .macro arm710_bug_check, instr, temp
122 arm710_bug_check scno, ip
124 #ifdef CONFIG_ALIGNMENT_TRAP
125 ldr ip, __cr_alignment
127 mcr p15, 0, ip, c1, c0 @ update control register
131 str r4, [sp, #-S_OFF]! @ push fifth arg
134 ldr ip, [tsk, #TI_FLAGS] @ check for syscall tracing
135 bic scno, scno, #0xff000000 @ mask off SWI op-code
136 eor scno, scno, #OS_NUMBER << 20 @ check OS number
137 adr tbl, sys_call_table @ load syscall table pointer
138 tst ip, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
141 adr lr, ret_fast_syscall @ return address
142 cmp scno, #NR_syscalls @ check upper syscall limit
143 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
146 2: mov why, #0 @ no longer a real syscall
147 cmp scno, #ARMSWI_OFFSET
148 eor r0, scno, #OS_NUMBER << 20 @ put OS number back
150 b sys_ni_syscall @ not private func
153 * This is the really slow path. We're going to be doing
154 * context switches, and waiting for our parent to respond.
158 mov r0, #0 @ trace entry [IP = 0]
161 adr lr, __sys_trace_return @ return address
162 add r1, sp, #S_R0 + S_OFF @ pointer to regs
163 cmp scno, #NR_syscalls @ check upper syscall limit
164 ldmccia r1, {r0 - r3} @ have to reload r0 - r3
165 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
169 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
171 mov r0, #1 @ trace exit [IP = 1]
176 #ifdef CONFIG_ALIGNMENT_TRAP
177 .type __cr_alignment, #object
182 .type sys_call_table, #object
183 ENTRY(sys_call_table)
186 /*============================================================================
187 * Special system call wrappers
189 @ r0 = syscall number
191 .type sys_syscall, #function
193 eor scno, r0, #OS_NUMBER << 20
194 cmp scno, #__NR_syscall - __NR_SYSCALL_BASE
195 cmpne scno, #NR_syscalls @ check range
196 stmloia sp, {r5, r6} @ shuffle args
201 ldrlo pc, [tbl, scno, lsl #2]
221 sys_sigsuspend_wrapper:
225 sys_rt_sigsuspend_wrapper:
229 sys_sigreturn_wrapper:
233 sys_rt_sigreturn_wrapper:
237 sys_sigaltstack_wrapper:
238 ldr r2, [sp, #S_OFF + S_SP]
242 str r5, [sp, #4] @ push sixth arg
246 * Note: off_4k (r5) is always units of 4K. If we can't do the requested
247 * offset, we return EINVAL.
252 moveq r5, r5, lsr #PAGE_SHIFT - 12