home *** CD-ROM | disk | FTP | other *** search
- #ifndef _ARM_SYSCALL_H
- #define _ARM_SYSCALL_H
-
- #define __sys2(x) #x
- #define __sys1(x) __sys2(x)
- #define __syscall(name) "swi " __sys1(SYS_##name) "\n\t"
-
- #define _syscall0(type,name) \
- type name(void) \
- { \
- long __res; \
- __asm__ __volatile__ ( \
- __syscall(name) \
- "mov %0,r0\n\t" \
- :"=r" (__res) : : "r0","r1","r2","r3"); \
- if (__check_errno(__res)) \
- return (type) __res; \
- errno = -__res; \
- return -1; \
- }
-
- #define _syscall1(type,name,atype,a) \
- type name(atype a) \
- { \
- long __res; \
- __asm__ __volatile__ ( \
- "mov r0,%1\n\t" \
- __syscall(name) \
- "mov %0,r0\n\t" \
- : "=r" (__res) \
- : "r" ((long)(a)) : "r0","r1","r2","r3"); \
- if(__check_errno(__res)) \
- return (type) __res; \
- errno = -__res; \
- return -1; \
- }
-
- #define _syscall2(type,name,atype,a,btype,b) \
- type name(atype a,btype b) \
- { \
- long __res; \
- __asm__ __volatile__ ( \
- "mov r0,%1\n\t" \
- "mov r1,%2\n\t" \
- __syscall(name) \
- "mov %0,r0\n\t" \
- : "=r" (__res) \
- : "r" ((long)(a)),"r" ((long)(b)) : "r0","r1","r2","r3"); \
- if (__check_errno(__res)) \
- return (type) __res; \
- errno = -__res; \
- return -1; \
- }
-
- #define _syscall3(type,name,atype,a,btype,b,ctype,c) \
- type name(atype a,btype b,ctype c) \
- { \
- long __res; \
- __asm__ __volatile__ ( \
- "mov r0,%1\n\t" \
- "mov r1,%2\n\t" \
- "mov r2,%3\n\t" \
- __syscall(name) \
- "mov %0,r0\n\t" \
- : "=r" (__res) \
- : "r" ((long)(a)),"r" ((long)(b)),"r" ((long)(c)) \
- : "r0","r1","r2","r3"); \
- if (__check_errno(__res)) \
- return (type) __res; \
- errno=-__res; \
- return -1; \
- }
-
- #define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
- type name (atype a, btype b, ctype c, dtype d) \
- { \
- long __res; \
- __asm__ __volatile__ ( \
- "mov r0,%1\n\t" \
- "mov r1,%2\n\t" \
- "mov r2,%3\n\t" \
- "mov r3,%4\n\t" \
- __syscall(name) \
- "mov %0,r0\n\t" \
- : "=r" (__res) \
- : "r" ((long)(a)),"r" ((long)(b)), \
- "r" ((long)(c)),"r" ((long)(d)) \
- : "r0","r1","r2","r3"); \
- if (__check_errno(__res)) \
- return (type) __res; \
- errno=-__res; \
- return -1; \
- }
-
- #define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
- type name (atype a,btype b,ctype c,dtype d,etype e) \
- { \
- long __res; \
- __asm__ __volatile__ ( \
- "mov r0,%1\n\t" \
- "mov r1,%2\n\t" \
- "mov r2,%3\n\t" \
- "str %5,[sp,#-4]!\n\t" \
- "str %4,[sp,#-4]!\n\t" \
- "mov r3,sp\n\t" \
- __syscall(name) \
- "mov %0,r0\n\t" \
- "add sp,sp,#8\n\t" \
- : "=r" (__res) \
- : "r" ((long)(a)),"r" ((long)(b)), \
- "r" ((long)(c)),"r" ((long)(d)),"r" ((long)(e)) \
- : "r0","r1","r2","r3"); \
- if (__check_errno(__res)) \
- return (type) __res; \
- errno=-__res; \
- return -1; \
- }
-
- #endif /* _ARM_SYSCALL_H */
-