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>
12 #include <asm/arch/entry-macro.S>
14 #include "entry-header.S"
16 #if !defined(CONFIG_MMU)
17 #define sys_madvise sys_ni_syscall
18 #define sys_readahead sys_ni_syscall
19 #define sys_mprotect sys_ni_syscall
20 #define sys_msync sys_ni_syscall
21 #define sys_mlock sys_ni_syscall
22 #define sys_munlock sys_ni_syscall
23 #define sys_mlockall sys_ni_syscall
24 #define sys_munlockall sys_ni_syscall
25 #define sys_mremap sys_ni_syscall
26 #define sys_mincore sys_ni_syscall
27 #define sys_remap_file_pages sys_ni_syscall
28 #endif /* CONFIG_MMU */
32 * This is the fast syscall return path. We do as little as
33 * possible here, and this includes saving r0 back into the SVC
37 disable_irq @ disable interrupts
38 ldr r1, [tsk, #TI_FLAGS]
39 tst r1, #_TIF_WORK_MASK
42 @ fast_restore_user_regs
43 ldr r1, [sp, #S_OFF + S_PSR] @ get calling cpsr
44 ldr lr, [sp, #S_OFF + S_PC]! @ get pc
45 msr spsr_cxsf, r1 @ save in spsr_svc
46 ldmdb sp, {r1 - lr}^ @ get calling r1 - lr
48 add sp, sp, #S_FRAME_SIZE - S_PC
49 movs pc, lr @ return & move spsr_svc into cpsr
52 * Ok, we need to do extra processing, enter the slow path.
55 str r0, [sp, #S_R0+S_OFF]! @ returned r0
57 tst r1, #_TIF_NEED_RESCHED
59 tst r1, #_TIF_NOTIFY_RESUME | _TIF_SIGPENDING
62 mov r2, why @ 'syscall'
64 b ret_slow_syscall @ Check work again
69 * "slow" syscall return path. "why" tells us if this was a real syscall.
73 disable_irq @ disable interrupts
74 ldr r1, [tsk, #TI_FLAGS]
75 tst r1, #_TIF_WORK_MASK
78 @ slow_restore_user_regs
79 ldr r1, [sp, #S_PSR] @ get calling cpsr
80 ldr lr, [sp, #S_PC]! @ get pc
81 msr spsr_cxsf, r1 @ save in spsr_svc
82 ldmdb sp, {r0 - lr}^ @ get calling r1 - lr
84 add sp, sp, #S_FRAME_SIZE - S_PC
85 movs pc, lr @ return & move spsr_svc into cpsr
88 * This is how we return from a fork.
93 ldr r1, [tsk, #TI_FLAGS] @ check for syscall tracing
95 tst r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
98 mov r0, #1 @ trace exit [IP = 1]
104 #define CALL(x) .equ NR_syscalls,NR_syscalls+1
107 #define CALL(x) .long x
109 /*=============================================================================
111 *-----------------------------------------------------------------------------
114 /* If we're optimising for StrongARM the resulting code won't
115 run on an ARM7 and we can save a couple of instructions.
117 #ifdef CONFIG_CPU_ARM710
118 #define A710(code...) code
120 ldmia sp, {r0 - lr}^ @ Get calling r0 - lr
122 add sp, sp, #S_FRAME_SIZE
125 #define A710(code...)
130 sub sp, sp, #S_FRAME_SIZE
131 stmia sp, {r0 - r12} @ Calling r0 - r12
133 stmdb r8, {sp, lr}^ @ Calling sp, lr
134 mrs r8, spsr @ called from non-FIQ mode, so ok.
135 str lr, [sp, #S_PC] @ Save calling PC
136 str r8, [sp, #S_PSR] @ Save CPSR
137 str r0, [sp, #S_OLD_R0] @ Save OLD_R0
141 * Get the system call number.
144 #if defined(CONFIG_OABI_COMPAT)
147 * If we have CONFIG_OABI_COMPAT then we need to look at the swi
148 * value to determine if it is an EABI or an old ABI call.
150 #ifdef CONFIG_ARM_THUMB
152 movne r10, #0 @ no thumb OABI emulation
153 ldreq r10, [lr, #-4] @ get SWI instruction
155 ldr r10, [lr, #-4] @ get SWI instruction
156 A710( and ip, r10, #0x0f000000 @ check for SWI )
157 A710( teq ip, #0x0f000000 )
158 A710( bne .Larm710bug )
161 #elif defined(CONFIG_AEABI)
164 * Pure EABI user space always put syscall number into scno (r7).
166 A710( ldr ip, [lr, #-4] @ get SWI instruction )
167 A710( and ip, ip, #0x0f000000 @ check for SWI )
168 A710( teq ip, #0x0f000000 )
169 A710( bne .Larm710bug )
171 #elif defined(CONFIG_ARM_THUMB)
173 /* Legacy ABI only, possibly thumb mode. */
174 tst r8, #PSR_T_BIT @ this is SPSR from save_user_regs
175 addne scno, r7, #__NR_SYSCALL_BASE @ put OS number in
176 ldreq scno, [lr, #-4]
180 /* Legacy ABI only. */
181 ldr scno, [lr, #-4] @ get SWI instruction
182 A710( and ip, scno, #0x0f000000 @ check for SWI )
183 A710( teq ip, #0x0f000000 )
184 A710( bne .Larm710bug )
188 #ifdef CONFIG_ALIGNMENT_TRAP
189 ldr ip, __cr_alignment
191 mcr p15, 0, ip, c1, c0 @ update control register
196 adr tbl, sys_call_table @ load syscall table pointer
197 ldr ip, [tsk, #TI_FLAGS] @ check for syscall tracing
199 #if defined(CONFIG_OABI_COMPAT)
201 * If the swi argument is zero, this is an EABI call and we do nothing.
203 * If this is an old ABI call, get the syscall number into scno and
204 * get the old ABI syscall table address.
206 bics r10, r10, #0xff000000
207 eorne scno, r10, #__NR_OABI_SYSCALL_BASE
208 ldrne tbl, =sys_oabi_call_table
209 #elif !defined(CONFIG_AEABI)
210 bic scno, scno, #0xff000000 @ mask off SWI op-code
211 eor scno, scno, #__NR_SYSCALL_BASE @ check OS number
214 stmdb sp!, {r4, r5} @ push fifth and sixth args
215 tst ip, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
218 cmp scno, #NR_syscalls @ check upper syscall limit
219 adr lr, ret_fast_syscall @ return address
220 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
223 2: mov why, #0 @ no longer a real syscall
224 cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE)
225 eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back
227 b sys_ni_syscall @ not private func
230 * This is the really slow path. We're going to be doing
231 * context switches, and waiting for our parent to respond.
236 mov r0, #0 @ trace entry [IP = 0]
239 adr lr, __sys_trace_return @ return address
240 mov scno, r0 @ syscall number (possibly new)
241 add r1, sp, #S_R0 + S_OFF @ pointer to regs
242 cmp scno, #NR_syscalls @ check upper syscall limit
243 ldmccia r1, {r0 - r3} @ have to reload r0 - r3
244 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
248 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
251 mov r0, #1 @ trace exit [IP = 1]
256 #ifdef CONFIG_ALIGNMENT_TRAP
257 .type __cr_alignment, #object
264 * This is the syscall table declaration for native ABI syscalls.
265 * With EABI a couple syscalls are obsolete and defined as sys_ni_syscall.
267 #define ABI(native, compat) native
269 #define OBSOLETE(syscall) sys_ni_syscall
271 #define OBSOLETE(syscall) syscall
274 .type sys_call_table, #object
275 ENTRY(sys_call_table)
280 /*============================================================================
281 * Special system call wrappers
283 @ r0 = syscall number
285 .type sys_syscall, #function
287 bic scno, r0, #__NR_OABI_SYSCALL_BASE
288 cmp scno, #__NR_syscall - __NR_SYSCALL_BASE
289 cmpne scno, #NR_syscalls @ check range
290 stmloia sp, {r5, r6} @ shuffle args
295 ldrlo pc, [tbl, scno, lsl #2]
315 sys_sigsuspend_wrapper:
319 sys_rt_sigsuspend_wrapper:
323 sys_sigreturn_wrapper:
327 sys_rt_sigreturn_wrapper:
331 sys_sigaltstack_wrapper:
332 ldr r2, [sp, #S_OFF + S_SP]
335 sys_statfs64_wrapper:
340 sys_fstatfs64_wrapper:
346 * Note: off_4k (r5) is always units of 4K. If we can't do the requested
347 * offset, we return EINVAL.
352 moveq r5, r5, lsr #PAGE_SHIFT - 12
362 #ifdef CONFIG_OABI_COMPAT
365 * These are syscalls with argument register differences
381 sys_oabi_ftruncate64:
393 * Let's declare a second syscall table for old ABI binaries
394 * using the compatibility syscall entries.
396 #define ABI(native, compat) compat
397 #define OBSOLETE(syscall) syscall
399 .type sys_oabi_call_table, #object
400 ENTRY(sys_oabi_call_table)