Back to index

glibc  2.9
sysdep.h
Go to the documentation of this file.
00001 /* Copyright (C) 2005, 2006, 2007
00002    Free Software Foundation, Inc.
00003 
00004    This file is part of the GNU C Library.
00005 
00006    Contributed by Daniel Jacobowitz <dan@codesourcery.com>, Oct 2005.
00007 
00008    The GNU C Library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Lesser General Public
00010    License as published by the Free Software Foundation; either
00011    version 2.1 of the License, or (at your option) any later version.
00012 
00013    The GNU C Library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Lesser General Public License for more details.
00017 
00018    You should have received a copy of the GNU Lesser General Public
00019    License along with the GNU C Library; if not, write to the Free
00020    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00021    02111-1307 USA.  */
00022 
00023 #ifndef _LINUX_ARM_EABI_SYSDEP_H
00024 #define _LINUX_ARM_EABI_SYSDEP_H 1
00025 
00026 #include <arm/sysdep.h>
00027 
00028 #include <tls.h>
00029 
00030 #if __NR_SYSCALL_BASE != 0
00031 # error Kernel headers are too old
00032 #endif
00033 
00034 /* Don't use stime, even if the kernel headers define it.  We have
00035    settimeofday, and some EABI kernels have removed stime.  Similarly
00036    use setitimer to implement alarm.  */
00037 #undef __NR_stime
00038 #undef __NR_alarm
00039 
00040 /* The ARM EABI user interface passes the syscall number in r7, instead
00041    of in the swi.  This is more efficient, because the kernel does not need
00042    to fetch the swi from memory to find out the number; which can be painful
00043    with separate I-cache and D-cache.  Make sure to use 0 for the SWI
00044    argument; otherwise the (optional) compatibility code for APCS binaries
00045    may be invoked.  */
00046 
00047 #undef INTERNAL_SYSCALL_RAW
00048 #define INTERNAL_SYSCALL_RAW(name, err, nr, args...)           \
00049   ({                                                    \
00050        register int _a1 asm ("r0"), _nr asm ("r7");            \
00051        LOAD_ARGS_##nr (args)                                   \
00052        _nr = name;                                      \
00053        asm volatile ("swi   0x0    @ syscall " #name    \
00054                    : "=r" (_a1)                         \
00055                    : "r" (_nr) ASM_ARGS_##nr                   \
00056                    : "memory");                         \
00057        _a1; })
00058 
00059 /* For EABI, non-constant syscalls are actually pretty easy...  */
00060 #undef INTERNAL_SYSCALL_NCS
00061 #define INTERNAL_SYSCALL_NCS(number, err, nr, args...)          \
00062   INTERNAL_SYSCALL_RAW (number, err, nr, args)
00063 
00064 /* We must save and restore r7 (call-saved) for the syscall number.
00065    We never make function calls from inside here (only potentially
00066    signal handlers), so we do not bother with doubleword alignment.
00067 
00068    Just like the APCS syscall convention, the EABI syscall convention uses
00069    r0 through r6 for up to seven syscall arguments.  None are ever passed to
00070    the kernel on the stack, although incoming arguments are on the stack for
00071    syscalls with five or more arguments.
00072 
00073    The assembler will convert the literal pool load to a move for most
00074    syscalls.  */
00075 
00076 #undef DO_CALL
00077 #define DO_CALL(syscall_name, args)              \
00078     DOARGS_##args                         \
00079     mov ip, r7;                                  \
00080     ldr r7, =SYS_ify (syscall_name);             \
00081     swi 0x0;                              \
00082     mov r7, ip;                                  \
00083     UNDOARGS_##args
00084 
00085 #endif /* _LINUX_ARM_EABI_SYSDEP_H */