1 #define __NR_SYSCALL_BASE 0x900000
2 #define __NR_exit1 (__NR_SYSCALL_BASE+ 1)
3 #define __NR_write (__NR_SYSCALL_BASE+ 4)
6 #define __sys1(x) __sys2(x)
9 #define __syscall(name) "swi\t" __sys1(__NR_##name) "\n\t"
12 #define __syscall_return(type, res) \
14 return (type) (res); \
17 #define _syscall0(type,name) \
20 __asm__ __volatile__ ( \
23 :"=r" (__res) : : "r0","lr"); \
24 __syscall_return(type,__res); \
27 #define _syscall1(type,name,type1,arg1) \
28 type name(type1 arg1) { \
30 __asm__ __volatile__ ( \
35 : "r" ((long)(arg1)) \
37 __syscall_return(type,__res); \
40 #define _syscall2(type,name,type1,arg1,type2,arg2) \
41 type name(type1 arg1,type2 arg2) { \
43 __asm__ __volatile__ ( \
49 : "r" ((long)(arg1)),"r" ((long)(arg2)) \
51 __syscall_return(type,__res); \
55 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
56 type name(type1 arg1,type2 arg2,type3 arg3) { \
58 __asm__ __volatile__ ( \
65 : "r" ((long)(arg1)),"r" ((long)(arg2)),"r" ((long)(arg3)) \
66 : "r0","r1","r2","lr"); \
67 __syscall_return(type,__res); \
71 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
72 type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
74 __asm__ __volatile__ ( \
82 : "r" ((long)(arg1)),"r" ((long)(arg2)),"r" ((long)(arg3)),"r" ((long)(arg4)) \
83 : "r0","r1","r2","r3","lr"); \
84 __syscall_return(type,__res); \
88 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
89 type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \
91 __asm__ __volatile__ ( \
100 : "r" ((long)(arg1)),"r" ((long)(arg2)),"r" ((long)(arg3)),"r" ((long)(arg4)), \
102 : "r0","r1","r2","r3","r4","lr"); \
103 __syscall_return(type,__res); \
106 _syscall1(int,exit1
,int,status
);
107 _syscall3(int,write
,int,fd
,const char *,buf
, int, len
);
111 write(1, "Hello World\n", 12);