patch-2.4.21 linux-2.4.21/include/asm-ppc/unistd.h
Next file: linux-2.4.21/include/asm-ppc/user.h
Previous file: linux-2.4.21/include/asm-ppc/uninorth.h
Back to the patch index
Back to the overall index
- Lines: 265
- Date:
2003-06-13 07:51:38.000000000 -0700
- Orig file:
linux-2.4.20/include/asm-ppc/unistd.h
- Orig date:
2002-11-28 15:53:15.000000000 -0800
diff -urN linux-2.4.20/include/asm-ppc/unistd.h linux-2.4.21/include/asm-ppc/unistd.h
@@ -1,6 +1,3 @@
-/*
- * BK Id: SCCS/s.unistd.h 1.11 10/18/01 17:29:53 trini
- */
#ifndef _ASM_PPC_UNISTD_H_
#define _ASM_PPC_UNISTD_H_
@@ -117,10 +114,10 @@
#define __NR_lstat 107
#define __NR_fstat 108
#define __NR_olduname 109
-#define __NR_iopl 110
+/* 110 was __NR_iopl */
#define __NR_vhangup 111
#define __NR_idle 112
-#define __NR_vm86 113
+/* 113 was __NR_vm86 */
#define __NR_wait4 114
#define __NR_swapoff 115
#define __NR_sysinfo 116
@@ -130,7 +127,7 @@
#define __NR_clone 120
#define __NR_setdomainname 121
#define __NR_uname 122
-#define __NR_modify_ldt 123
+/* 123 was __NR_modify_ldt */
#define __NR_adjtimex 124
#define __NR_mprotect 125
#define __NR_sigprocmask 126
@@ -244,173 +241,102 @@
#define __NR(n) #n
+/* On powerpc a system call basically clobbers the same registers like a
+ * function call, with the exception of LR (which is needed for the
+ * "sc; bnslr" sequence) and CR (where only CR0.SO is clobbered to signal
+ * an error return status).
+ */
-#define __syscall_return(type) \
- return (__sc_err & 0x10000000 ? errno = __sc_ret, __sc_ret = -1 : 0), \
- (type) __sc_ret
-
-#define __syscall_clobbers \
- "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
+#define __syscall_nr(nr, type, name, args...) \
unsigned long __sc_ret, __sc_err; \
{ \
- register unsigned long __sc_0 __asm__ ("r0"); \
- register unsigned long __sc_3 __asm__ ("r3"); \
+ register unsigned long __sc_0 __asm__ ("r0"); \
+ register unsigned long __sc_3 __asm__ ("r3"); \
+ register unsigned long __sc_4 __asm__ ("r4"); \
+ register unsigned long __sc_5 __asm__ ("r5"); \
+ register unsigned long __sc_6 __asm__ ("r6"); \
+ register unsigned long __sc_7 __asm__ ("r7"); \
\
- __sc_0 = __NR_##name; \
+ __sc_loadargs_##nr(name, args); \
__asm__ __volatile__ \
("sc \n\t" \
- "mfcr %1 " \
- : "=&r" (__sc_3), "=&r" (__sc_0) \
- : "0" (__sc_3), "1" (__sc_0) \
- : __syscall_clobbers); \
+ "mfcr %0 " \
+ : "=&r" (__sc_0), \
+ "=&r" (__sc_3), "=&r" (__sc_4), \
+ "=&r" (__sc_5), "=&r" (__sc_6), \
+ "=&r" (__sc_7) \
+ : __sc_asm_input_##nr \
+ : "cr0", "ctr", "memory", \
+ "r8", "r9", "r10","r11", "r12"); \
__sc_ret = __sc_3; \
__sc_err = __sc_0; \
} \
- __syscall_return (type); \
+ if (__sc_err & 0x10000000) \
+ { \
+ errno = __sc_ret; \
+ __sc_ret = -1; \
+ } \
+ return (type) __sc_ret
+
+#define __sc_loadargs_0(name, dummy...) \
+ __sc_0 = __NR_##name
+#define __sc_loadargs_1(name, arg1) \
+ __sc_loadargs_0(name); \
+ __sc_3 = (unsigned long) (arg1)
+#define __sc_loadargs_2(name, arg1, arg2) \
+ __sc_loadargs_1(name, arg1); \
+ __sc_4 = (unsigned long) (arg2)
+#define __sc_loadargs_3(name, arg1, arg2, arg3) \
+ __sc_loadargs_2(name, arg1, arg2); \
+ __sc_5 = (unsigned long) (arg3)
+#define __sc_loadargs_4(name, arg1, arg2, arg3, arg4) \
+ __sc_loadargs_3(name, arg1, arg2, arg3); \
+ __sc_6 = (unsigned long) (arg4)
+#define __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5) \
+ __sc_loadargs_4(name, arg1, arg2, arg3, arg4); \
+ __sc_7 = (unsigned long) (arg5)
+
+#define __sc_asm_input_0 "0" (__sc_0)
+#define __sc_asm_input_1 __sc_asm_input_0, "1" (__sc_3)
+#define __sc_asm_input_2 __sc_asm_input_1, "2" (__sc_4)
+#define __sc_asm_input_3 __sc_asm_input_2, "3" (__sc_5)
+#define __sc_asm_input_4 __sc_asm_input_3, "4" (__sc_6)
+#define __sc_asm_input_5 __sc_asm_input_4, "5" (__sc_7)
+
+#define _syscall0(type,name) \
+type name(void) \
+{ \
+ __syscall_nr(0, type, name); \
}
#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{ \
- unsigned long __sc_ret, __sc_err; \
- { \
- register unsigned long __sc_0 __asm__ ("r0"); \
- register unsigned long __sc_3 __asm__ ("r3"); \
- \
- __sc_3 = (unsigned long) (arg1); \
- __sc_0 = __NR_##name; \
- __asm__ __volatile__ \
- ("sc \n\t" \
- "mfcr %1 " \
- : "=&r" (__sc_3), "=&r" (__sc_0) \
- : "0" (__sc_3), "1" (__sc_0) \
- : __syscall_clobbers); \
- __sc_ret = __sc_3; \
- __sc_err = __sc_0; \
- } \
- __syscall_return (type); \
+ __syscall_nr(1, type, name, arg1); \
}
#define _syscall2(type,name,type1,arg1,type2,arg2) \
type name(type1 arg1, type2 arg2) \
{ \
- unsigned long __sc_ret, __sc_err; \
- { \
- register unsigned long __sc_0 __asm__ ("r0"); \
- register unsigned long __sc_3 __asm__ ("r3"); \
- register unsigned long __sc_4 __asm__ ("r4"); \
- \
- __sc_3 = (unsigned long) (arg1); \
- __sc_4 = (unsigned long) (arg2); \
- __sc_0 = __NR_##name; \
- __asm__ __volatile__ \
- ("sc \n\t" \
- "mfcr %1 " \
- : "=&r" (__sc_3), "=&r" (__sc_0) \
- : "0" (__sc_3), "1" (__sc_0), \
- "r" (__sc_4) \
- : __syscall_clobbers); \
- __sc_ret = __sc_3; \
- __sc_err = __sc_0; \
- } \
- __syscall_return (type); \
+ __syscall_nr(2, type, name, arg1, arg2); \
}
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
type name(type1 arg1, type2 arg2, type3 arg3) \
{ \
- unsigned long __sc_ret, __sc_err; \
- { \
- register unsigned long __sc_0 __asm__ ("r0"); \
- register unsigned long __sc_3 __asm__ ("r3"); \
- register unsigned long __sc_4 __asm__ ("r4"); \
- register unsigned long __sc_5 __asm__ ("r5"); \
- \
- __sc_3 = (unsigned long) (arg1); \
- __sc_4 = (unsigned long) (arg2); \
- __sc_5 = (unsigned long) (arg3); \
- __sc_0 = __NR_##name; \
- __asm__ __volatile__ \
- ("sc \n\t" \
- "mfcr %1 " \
- : "=&r" (__sc_3), "=&r" (__sc_0) \
- : "0" (__sc_3), "1" (__sc_0), \
- "r" (__sc_4), \
- "r" (__sc_5) \
- : __syscall_clobbers); \
- __sc_ret = __sc_3; \
- __sc_err = __sc_0; \
- } \
- __syscall_return (type); \
+ __syscall_nr(3, type, name, arg1, arg2, arg3); \
}
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
{ \
- unsigned long __sc_ret, __sc_err; \
- { \
- register unsigned long __sc_0 __asm__ ("r0"); \
- register unsigned long __sc_3 __asm__ ("r3"); \
- register unsigned long __sc_4 __asm__ ("r4"); \
- register unsigned long __sc_5 __asm__ ("r5"); \
- register unsigned long __sc_6 __asm__ ("r6"); \
- \
- __sc_3 = (unsigned long) (arg1); \
- __sc_4 = (unsigned long) (arg2); \
- __sc_5 = (unsigned long) (arg3); \
- __sc_6 = (unsigned long) (arg4); \
- __sc_0 = __NR_##name; \
- __asm__ __volatile__ \
- ("sc \n\t" \
- "mfcr %1 " \
- : "=&r" (__sc_3), "=&r" (__sc_0) \
- : "0" (__sc_3), "1" (__sc_0), \
- "r" (__sc_4), \
- "r" (__sc_5), \
- "r" (__sc_6) \
- : __syscall_clobbers); \
- __sc_ret = __sc_3; \
- __sc_err = __sc_0; \
- } \
- __syscall_return (type); \
+ __syscall_nr(4, type, name, arg1, arg2, arg3, arg4); \
}
#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) \
{ \
- unsigned long __sc_ret, __sc_err; \
- { \
- register unsigned long __sc_0 __asm__ ("r0"); \
- register unsigned long __sc_3 __asm__ ("r3"); \
- register unsigned long __sc_4 __asm__ ("r4"); \
- register unsigned long __sc_5 __asm__ ("r5"); \
- register unsigned long __sc_6 __asm__ ("r6"); \
- register unsigned long __sc_7 __asm__ ("r7"); \
- \
- __sc_3 = (unsigned long) (arg1); \
- __sc_4 = (unsigned long) (arg2); \
- __sc_5 = (unsigned long) (arg3); \
- __sc_6 = (unsigned long) (arg4); \
- __sc_7 = (unsigned long) (arg5); \
- __sc_0 = __NR_##name; \
- __asm__ __volatile__ \
- ("sc \n\t" \
- "mfcr %1 " \
- : "=&r" (__sc_3), "=&r" (__sc_0) \
- : "0" (__sc_3), "1" (__sc_0), \
- "r" (__sc_4), \
- "r" (__sc_5), \
- "r" (__sc_6), \
- "r" (__sc_7) \
- : __syscall_clobbers); \
- __sc_ret = __sc_3; \
- __sc_err = __sc_0; \
- } \
- __syscall_return (type); \
+ __syscall_nr(5, type, name, arg1, arg2, arg3, arg4, arg5); \
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)