1 /* 2 * Based on arm/bits/syscalls.h 3 */ 4 5 #ifndef _BITS_SYSCALLS_H 6 #define _BITS_SYSCALLS_H 7 #ifndef _SYSCALL_H 8 # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead." 9 #endif 10 11 /* 12 Some of the sneaky macros in the code were taken from 13 glibc-2.3.2/sysdeps/unix/sysv/linux/arm/sysdep.h 14 */ 15 16 #ifdef __ASSEMBLER__ 17 18 /* TODO: recheck this */ 19 20 /* Call a given syscall, with arguments loaded. Unlike the DO_CALL 21 macro in glibc, this macro does not load syscall arguments. */ 22 #undef DO_CALL 23 #define DO_CALL(syscall_name) \ 24 l.lwz r11, =SYS_ify (syscall_name); \ 25 l.sys 1 \ 26 l.nop 27 28 #else 29 30 #include <errno.h> 31 32 #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ 33 ({ unsigned long __sys_result; \ 34 { \ 35 register long __sc_ret __asm__ ("r11") = name; \ 36 LOAD_ARGS_##nr (args) \ 37 __asm__ __volatile__ ("l.sys 1" \ 38 : "=r" (__sc_ret) ASM_ARGS_OUT_##nr \ 39 : "0" (__sc_ret) ASM_ARGS_IN_##nr \ 40 : ASM_CLOBBERS_##nr \ 41 "r12", "r13", "r15", "r17", "r19", \ 42 "r21", "r23", "r25", "r27", "r29", \ 43 "r31"); \ 44 __asm__ __volatile__ ("l.nop"); \ 45 __sys_result = __sc_ret; \ 46 } \ 47 (long) __sys_result; }) 48 49 /* : "0", "1", "2", "3", "4", "5", "6", \ */ 50 /* : ASM_CLOBBERS_##nr, \ */ 51 52 #define LOAD_ARGS_0() 53 54 #define ASM_ARGS_OUT_0 55 #define ASM_ARGS_IN_0 56 #define ASM_CLOBBERS_0 "r3", ASM_CLOBBERS_1 57 58 #define LOAD_ARGS_1(a) \ 59 LOAD_ARGS_0 () \ 60 register long __a __asm__ ("r3") = (long)(a); 61 #define ASM_ARGS_OUT_1 ASM_ARGS_OUT_0, "=r" (__a) 62 #define ASM_ARGS_IN_1 ASM_ARGS_IN_0, "1" (__a) 63 #define ASM_CLOBBERS_1 "r4", ASM_CLOBBERS_2 64 65 #define LOAD_ARGS_2(a, b) \ 66 LOAD_ARGS_1 (a) \ 67 register long __b __asm__ ("r4") = (long)(b); 68 #define ASM_ARGS_OUT_2 ASM_ARGS_OUT_1, "=r" (__b) 69 #define ASM_ARGS_IN_2 ASM_ARGS_IN_1, "2" (__b) 70 #define ASM_CLOBBERS_2 "r5", ASM_CLOBBERS_3 71 72 #define LOAD_ARGS_3(a, b, c) \ 73 LOAD_ARGS_2 (a, b) \ 74 register long __c __asm__ ("r5") = (long)(c); 75 #define ASM_ARGS_OUT_3 ASM_ARGS_OUT_2, "=r" (__c) 76 #define ASM_ARGS_IN_3 ASM_ARGS_IN_2, "3" (__c) 77 #define ASM_CLOBBERS_3 "r6", ASM_CLOBBERS_4 78 79 #define LOAD_ARGS_4(a, b, c, d) \ 80 LOAD_ARGS_3 (a, b, c) \ 81 register long __d __asm__ ("r6") = (long)(d); 82 #define ASM_ARGS_OUT_4 ASM_ARGS_OUT_3, "=r" (__d) 83 #define ASM_ARGS_IN_4 ASM_ARGS_IN_3, "4" (__d) 84 #define ASM_CLOBBERS_4 "r7", ASM_CLOBBERS_5 85 86 #define LOAD_ARGS_5(a, b, c, d, e) \ 87 LOAD_ARGS_4 (a, b, c, d) \ 88 register long __e __asm__ ("r7") = (long)(e); 89 #define ASM_ARGS_OUT_5 ASM_ARGS_OUT_4, "=r" (__e) 90 #define ASM_ARGS_IN_5 ASM_ARGS_IN_4, "5" (__e) 91 #define ASM_CLOBBERS_5 "r8", ASM_CLOBBERS_6 92 93 #define LOAD_ARGS_6(a, b, c, d, e, f) \ 94 LOAD_ARGS_5 (a, b, c, d, e) \ 95 register long __f __asm__ ("r8") = (long)(f); 96 #define ASM_ARGS_OUT_6 ASM_ARGS_OUT_5, "=r" (__f) 97 #define ASM_ARGS_IN_6 ASM_ARGS_IN_5, "6" (__f) 98 #define ASM_CLOBBERS_6 99 100 #endif /* __ASSEMBLER__ */ 101 #endif /* _BITS_SYSCALLS_H */ 102