diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-02-18 08:04:51 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-02-18 08:04:51 +0000 |
commit | baa67289df42b1b994092b8312148a6f9e172274 (patch) | |
tree | 9a6a60a10a0db9879671cd923e7307c993cfbd40 /libc/sysdeps/linux/frv/bits/syscalls.h | |
parent | 377c7157a8802c289c5560f1a2ecd1030d571e7d (diff) |
Alexandre Oliva writes:
This patch adds code to uClibc to support a new ABI designed for the
FR-V architecture, that enables text segments of executables and
shared libraries to be shared by multiple processes on an OS such as
uClinux, that can run on FR-V processors without an MMU.
Patches for binutils and GCC have just been posted in the
corresponding mailing lists. The binutils patch was approved,
but there's one additional patch pending review, that I posted
this week. An updated GCC patch will be posted to
gcc-patches@gcc.gnu.org as soon as I complete testing (I used a
known-good compiler to test the uClibc patch below).
Since the existing dynamic loader code didn't support independent
relocation of segments, it required changes that were somewhat
extensive. I've added a number of new machine-specific macros to try
to keep the platform and ABI-specific details outside the generic
code. I hope this is not a problem.
Diffstat (limited to 'libc/sysdeps/linux/frv/bits/syscalls.h')
-rw-r--r-- | libc/sysdeps/linux/frv/bits/syscalls.h | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/frv/bits/syscalls.h b/libc/sysdeps/linux/frv/bits/syscalls.h new file mode 100644 index 000000000..552f7e7c4 --- /dev/null +++ b/libc/sysdeps/linux/frv/bits/syscalls.h @@ -0,0 +1,129 @@ +#ifndef _BITS_SYSCALLS_H +#define _BITS_SYSCALLS_H +#ifndef _SYSCALL_H +# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead." +#endif + +/* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel + * header files. It also defines the traditional `SYS_<name>' macros for older + * programs. */ +#include <bits/sysnum.h> + +#ifndef __set_errno +# define __set_errno(val) ((*__errno_location ()) = (val)) +#endif +#ifndef SYS_ify +# define SYS_ify(syscall_name) (__NR_##syscall_name) +#endif + +#ifndef __ASSEMBLER__ + +/* user-visible error numbers are in the range -1 - -4095: see <asm-frv/errno.h> */ +#define __syscall_return(type, res) \ +do { \ + unsigned long __sr2 = (res); \ + if ((unsigned long)(__sr2) >= (unsigned long)(-4095)) { \ + __set_errno (-(__sr2)); \ + __sr2 = -1; \ + } \ + return (type) (__sr2); \ +} while (0) + +/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */ + +#define _syscall0(type,name) \ +type name(void) \ +{ \ +register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \ +register unsigned long __sc0 __asm__ ("gr8"); \ +__asm__ __volatile__ ("tra gr0,gr0" \ + : "=r" (__sc0) \ + : "r" (__scnum)); \ +__syscall_return(type,__sc0); \ +} + +#define _syscall1(type,name,type1,arg1) \ +type name(type1 arg1) \ +{ \ +register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \ +register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \ +__asm__ __volatile__ ("tra gr0,gr0" \ + : "+r" (__sc0) \ + : "r" (__scnum)); \ +__syscall_return(type,__sc0); \ +} + +#define _syscall2(type,name,type1,arg1,type2,arg2) \ +type name(type1 arg1,type2 arg2) \ +{ \ +register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \ +register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \ +register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \ +__asm__ __volatile__ ("tra gr0,gr0" \ + : "+r" (__sc0) \ + : "r" (__scnum), "r" (__sc1)); \ +__syscall_return(type,__sc0); \ +} + +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ +type name(type1 arg1,type2 arg2,type3 arg3) \ +{ \ +register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \ +register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \ +register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \ +register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \ +__asm__ __volatile__ ("tra gr0,gr0" \ + : "+r" (__sc0) \ + : "r" (__scnum), "r" (__sc1), "r" (__sc2)); \ +__syscall_return(type,__sc0); \ +} + +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ +type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +{ \ +register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \ +register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \ +register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \ +register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \ +register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \ +__asm__ __volatile__ ("tra gr0,gr0" \ + : "+r" (__sc0) \ + : "r" (__scnum), "r" (__sc1), "r" (__sc2), "r" (__sc3)); \ +__syscall_return(type,__sc0); \ +} + +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ +type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ +{ \ +register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \ +register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \ +register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \ +register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \ +register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \ +register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5; \ +__asm__ __volatile__ ("tra gr0,gr0" \ + : "+r" (__sc0) \ + : "r" (__scnum), "r" (__sc1), "r" (__sc2), \ + "r" (__sc3), "r" (__sc4)); \ +__syscall_return(type,__sc0); \ +} + +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \ +type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \ +{ \ +register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \ +register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \ +register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \ +register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \ +register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \ +register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5; \ +register unsigned long __sc5 __asm__ ("gr13") = (unsigned long) arg6; \ +__asm__ __volatile__ ("tra gr0,gr0" \ + : "+r" (__sc0) \ + : "r" (__scnum), "r" (__sc1), "r" (__sc2), \ + "r" (__sc3), "r" (__sc4), "r" (__sc5)); \ +__syscall_return(type,__sc0); \ +} + +#endif /* __ASSEMBLER__ */ +#endif /* _BITS_SYSCALLS_H */ |