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.
11 #include <asm/unistd.h>
13 #include "entry-header.S"
18 * This is the fast syscall return path. We do as little as
19 * possible here, and this includes saving r0 back into the SVC
23 disable_irq @ disable interrupts
24 ldr r1, [tsk, #TI_FLAGS]
25 tst r1, #_TIF_WORK_MASK
28 @ fast_restore_user_regs
29 ldr r1, [sp, #S_OFF + S_PSR] @ get calling cpsr
30 ldr lr, [sp, #S_OFF + S_PC]! @ get pc
31 msr spsr_cxsf, r1 @ save in spsr_svc
32 ldmdb sp, {r1 - lr}^ @ get calling r1 - lr
34 add sp, sp, #S_FRAME_SIZE - S_PC
35 movs pc, lr @ return & move spsr_svc into cpsr
38 * Ok, we need to do extra processing, enter the slow path.
41 str r0, [sp, #S_R0+S_OFF]! @ returned r0
43 tst r1, #_TIF_NEED_RESCHED
45 tst r1, #_TIF_NOTIFY_RESUME | _TIF_SIGPENDING
48 mov r2, why @ 'syscall'
50 b ret_slow_syscall @ Check work again
55 * "slow" syscall return path. "why" tells us if this was a real syscall.
59 disable_irq @ disable interrupts
60 ldr r1, [tsk, #TI_FLAGS]
61 tst r1, #_TIF_WORK_MASK
64 @ slow_restore_user_regs
65 ldr r1, [sp, #S_PSR] @ get calling cpsr
66 ldr lr, [sp, #S_PC]! @ get pc
67 msr spsr_cxsf, r1 @ save in spsr_svc
68 ldmdb sp, {r0 - lr}^ @ get calling r1 - lr
70 add sp, sp, #S_FRAME_SIZE - S_PC
71 movs pc, lr @ return & move spsr_svc into cpsr
74 * This is how we return from a fork.
79 ldr r1, [tsk, #TI_FLAGS] @ check for syscall tracing
81 tst r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
84 mov r0, #1 @ trace exit [IP = 1]
90 #define CALL(x) .equ NR_syscalls,NR_syscalls+1
93 #define CALL(x) .long x
95 /*=============================================================================
97 *-----------------------------------------------------------------------------
100 /* If we're optimising for StrongARM the resulting code won't
101 run on an ARM7 and we can save a couple of instructions.
103 #ifdef CONFIG_CPU_ARM710
104 #define A710(code...) code
106 ldmia sp, {r0 - lr}^ @ Get calling r0 - lr
108 add sp, sp, #S_FRAME_SIZE
111 #define A710(code...)
116 sub sp, sp, #S_FRAME_SIZE
117 stmia sp, {r0 - r12} @ Calling r0 - r12
119 stmdb r8, {sp, lr}^ @ Calling sp, lr
120 mrs r8, spsr @ called from non-FIQ mode, so ok.
121 str lr, [sp, #S_PC] @ Save calling PC
122 str r8, [sp, #S_PSR] @ Save CPSR
123 str r0, [sp, #S_OLD_R0] @ Save OLD_R0
127 * Get the system call number.
130 #if defined(CONFIG_OABI_COMPAT)
133 * If we have CONFIG_OABI_COMPAT then we need to look at the swi
134 * value to determine if it is an EABI or an old ABI call.
136 #ifdef CONFIG_ARM_THUMB
138 movne r10, #0 @ no thumb OABI emulation
139 ldreq r10, [lr, #-4] @ get SWI instruction
141 ldr r10, [lr, #-4] @ get SWI instruction
142 A710( and ip, r10, #0x0f000000 @ check for SWI )
143 A710( teq ip, #0x0f000000 )
144 A710( bne .Larm710bug )
147 #elif defined(CONFIG_AEABI)
150 * Pure EABI user space always put syscall number into scno (r7).
152 A710( ldr ip, [lr, #-4] @ get SWI instruction )
153 A710( and ip, ip, #0x0f000000 @ check for SWI )
154 A710( teq ip, #0x0f000000 )
155 A710( bne .Larm710bug )
157 #elif defined(CONFIG_ARM_THUMB)
159 /* Legacy ABI only, possibly thumb mode. */
160 tst r8, #PSR_T_BIT @ this is SPSR from save_user_regs
161 addne scno, r7, #__NR_SYSCALL_BASE @ put OS number in
162 ldreq scno, [lr, #-4]
166 /* Legacy ABI only. */
167 ldr scno, [lr, #-4] @ get SWI instruction
168 A710( and ip, scno, #0x0f000000 @ check for SWI )
169 A710( teq ip, #0x0f000000 )
170 A710( bne .Larm710bug )
174 #ifdef CONFIG_ALIGNMENT_TRAP
175 ldr ip, __cr_alignment
177 mcr p15, 0, ip, c1, c0 @ update control register
182 adr tbl, sys_call_table @ load syscall table pointer
183 ldr ip, [tsk, #TI_FLAGS] @ check for syscall tracing
185 #if defined(CONFIG_OABI_COMPAT)
187 * If the swi argument is zero, this is an EABI call and we do nothing.
189 * If this is an old ABI call, get the syscall number into scno and
190 * get the old ABI syscall table address.
192 bics r10, r10, #0xff000000
193 eorne scno, r10, #__NR_OABI_SYSCALL_BASE
194 ldrne tbl, =sys_oabi_call_table
195 #elif !defined(CONFIG_AEABI)
196 bic scno, scno, #0xff000000 @ mask off SWI op-code
197 eor scno, scno, #__NR_SYSCALL_BASE @ check OS number
200 stmdb sp!, {r4, r5} @ push fifth and sixth args
201 tst ip, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
204 cmp scno, #NR_syscalls @ check upper syscall limit
205 adr lr, ret_fast_syscall @ return address
206 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
209 2: mov why, #0 @ no longer a real syscall
210 cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE)
211 eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back
213 b sys_ni_syscall @ not private func
216 * This is the really slow path. We're going to be doing
217 * context switches, and waiting for our parent to respond.
222 mov r0, #0 @ trace entry [IP = 0]
225 adr lr, __sys_trace_return @ return address
226 mov scno, r0 @ syscall number (possibly new)
227 add r1, sp, #S_R0 + S_OFF @ pointer to regs
228 cmp scno, #NR_syscalls @ check upper syscall limit
229 ldmccia r1, {r0 - r3} @ have to reload r0 - r3
230 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
234 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
237 mov r0, #1 @ trace exit [IP = 1]
242 #ifdef CONFIG_ALIGNMENT_TRAP
243 .type __cr_alignment, #object
250 * This is the syscall table declaration for native ABI syscalls.
251 * With EABI a couple syscalls are obsolete and defined as sys_ni_syscall.
253 #define ABI(native, compat) native
255 #define OBSOLETE(syscall) sys_ni_syscall
257 #define OBSOLETE(syscall) syscall
260 .type sys_call_table, #object
261 ENTRY(sys_call_table)
266 /*============================================================================
267 * Special system call wrappers
269 @ r0 = syscall number
271 .type sys_syscall, #function
273 bic scno, r0, #__NR_OABI_SYSCALL_BASE
274 cmp scno, #__NR_syscall - __NR_SYSCALL_BASE
275 cmpne scno, #NR_syscalls @ check range
276 stmloia sp, {r5, r6} @ shuffle args
281 ldrlo pc, [tbl, scno, lsl #2]
301 sys_sigsuspend_wrapper:
305 sys_rt_sigsuspend_wrapper:
309 sys_sigreturn_wrapper:
313 sys_rt_sigreturn_wrapper:
317 sys_sigaltstack_wrapper:
318 ldr r2, [sp, #S_OFF + S_SP]
321 sys_statfs64_wrapper:
326 sys_fstatfs64_wrapper:
332 * Note: off_4k (r5) is always units of 4K. If we can't do the requested
333 * offset, we return EINVAL.
338 moveq r5, r5, lsr #PAGE_SHIFT - 12
348 #ifdef CONFIG_OABI_COMPAT
351 * These are syscalls with argument register differences
367 sys_oabi_ftruncate64:
379 * Let's declare a second syscall table for old ABI binaries
380 * using the compatibility syscall entries.
382 #define ABI(native, compat) compat
383 #define OBSOLETE(syscall) syscall
385 .type sys_oabi_call_table, #object
386 ENTRY(sys_oabi_call_table)