[PATCH] ARM: 2760/1: Add a warning on dynamic tick timekeeping on some platforms
[linux-2.6/linux-loongson.git] / include / asm-xtensa / unistd.h
blob64c64dd83ba45129ad6239e6dfc0ce983a3c5736
1 /*
2 * include/asm-xtensa/unistd.h
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
11 #ifndef _XTENSA_UNISTD_H
12 #define _XTENSA_UNISTD_H
14 #include <linux/linkage.h>
16 //#define __NR_setup 0 /* used only by init, to get system going */
17 #define __NR_spill 0
18 #define __NR_exit 1
19 #define __NR_fork 2
20 #define __NR_read 3
21 #define __NR_write 4
22 #define __NR_open 5
23 #define __NR_close 6
24 #define __NR_waitpid 7
25 #define __NR_creat 8
26 #define __NR_link 9
27 #define __NR_unlink 10
28 #define __NR_execve 11
29 #define __NR_chdir 12
30 #define __NR_time 13
31 #define __NR_mknod 14
32 #define __NR_chmod 15
33 #define __NR_lchown 16
34 #define __NR_break 17
35 #define __NR_oldstat 18
36 #define __NR_lseek 19
37 #define __NR_getpid 20
38 #define __NR_mount 21
39 #define __NR_oldumount 22
40 #define __NR_setuid 23
41 #define __NR_getuid 24
42 #define __NR_stime 25
43 #define __NR_ptrace 26
44 #define __NR_alarm 27
45 #define __NR_oldfstat 28
46 #define __NR_pause 29
47 #define __NR_utime 30
48 #define __NR_stty 31
49 #define __NR_gtty 32
50 #define __NR_access 33
51 #define __NR_nice 34
52 #define __NR_ftime 35
53 #define __NR_sync 36
54 #define __NR_kill 37
55 #define __NR_rename 38
56 #define __NR_mkdir 39
57 #define __NR_rmdir 40
58 #define __NR_dup 41
59 #define __NR_pipe 42
60 #define __NR_times 43
61 #define __NR_prof 44
62 #define __NR_brk 45
63 #define __NR_setgid 46
64 #define __NR_getgid 47
65 #define __NR_signal 48
66 #define __NR_geteuid 49
67 #define __NR_getegid 50
68 #define __NR_acct 51
69 #define __NR_umount 52
70 #define __NR_lock 53
71 #define __NR_ioctl 54
72 #define __NR_fcntl 55
73 #define __NR_mpx 56
74 #define __NR_setpgid 57
75 #define __NR_ulimit 58
76 #define __NR_oldolduname 59
77 #define __NR_umask 60
78 #define __NR_chroot 61
79 #define __NR_ustat 62
80 #define __NR_dup2 63
81 #define __NR_getppid 64
82 #define __NR_getpgrp 65
83 #define __NR_setsid 66
84 #define __NR_sigaction 67
85 #define __NR_sgetmask 68
86 #define __NR_ssetmask 69
87 #define __NR_setreuid 70
88 #define __NR_setregid 71
89 #define __NR_sigsuspend 72
90 #define __NR_sigpending 73
91 #define __NR_sethostname 74
92 #define __NR_setrlimit 75
93 #define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */
94 #define __NR_getrusage 77
95 #define __NR_gettimeofday 78
96 #define __NR_settimeofday 79
97 #define __NR_getgroups 80
98 #define __NR_setgroups 81
99 #define __NR_select 82
100 #define __NR_symlink 83
101 #define __NR_oldlstat 84
102 #define __NR_readlink 85
103 #define __NR_uselib 86
104 #define __NR_swapon 87
105 #define __NR_reboot 88
106 #define __NR_readdir 89
107 #define __NR_mmap 90
108 #define __NR_munmap 91
109 #define __NR_truncate 92
110 #define __NR_ftruncate 93
111 #define __NR_fchmod 94
112 #define __NR_fchown 95
113 #define __NR_getpriority 96
114 #define __NR_setpriority 97
115 #define __NR_profil 98
116 #define __NR_statfs 99
117 #define __NR_fstatfs 100
118 #define __NR_ioperm 101
119 #define __NR_socketcall 102
120 #define __NR_syslog 103
121 #define __NR_setitimer 104
122 #define __NR_getitimer 105
123 #define __NR_stat 106
124 #define __NR_lstat 107
125 #define __NR_fstat 108
126 #define __NR_olduname 109
127 #define __NR_iopl 110
128 #define __NR_vhangup 111
129 #define __NR_idle 112
130 #define __NR_vm86 113
131 #define __NR_wait4 114
132 #define __NR_swapoff 115
133 #define __NR_sysinfo 116
134 #define __NR_ipc 117
135 #define __NR_fsync 118
136 #define __NR_sigreturn 119
137 #define __NR_clone 120
138 #define __NR_setdomainname 121
139 #define __NR_uname 122
140 #define __NR_modify_ldt 123
141 #define __NR_adjtimex 124
142 #define __NR_mprotect 125
143 #define __NR_sigprocmask 126
144 #define __NR_create_module 127
145 #define __NR_init_module 128
146 #define __NR_delete_module 129
147 #define __NR_get_kernel_syms 130
148 #define __NR_quotactl 131
149 #define __NR_getpgid 132
150 #define __NR_fchdir 133
151 #define __NR_bdflush 134
152 #define __NR_sysfs 135
153 #define __NR_personality 136
154 #define __NR_afs_syscall 137 /* Syscall for Andrew File System */
155 #define __NR_setfsuid 138
156 #define __NR_setfsgid 139
157 #define __NR__llseek 140
158 #define __NR_getdents 141
159 #define __NR__newselect 142
160 #define __NR_flock 143
161 #define __NR_msync 144
162 #define __NR_readv 145
163 #define __NR_writev 146
164 #define __NR_cacheflush 147
165 #define __NR_cachectl 148
166 #define __NR_sysxtensa 149
167 #define __NR_sysdummy 150
168 #define __NR_getsid 151
169 #define __NR_fdatasync 152
170 #define __NR__sysctl 153
171 #define __NR_mlock 154
172 #define __NR_munlock 155
173 #define __NR_mlockall 156
174 #define __NR_munlockall 157
175 #define __NR_sched_setparam 158
176 #define __NR_sched_getparam 159
177 #define __NR_sched_setscheduler 160
178 #define __NR_sched_getscheduler 161
179 #define __NR_sched_yield 162
180 #define __NR_sched_get_priority_max 163
181 #define __NR_sched_get_priority_min 164
182 #define __NR_sched_rr_get_interval 165
183 #define __NR_nanosleep 166
184 #define __NR_mremap 167
185 #define __NR_accept 168
186 #define __NR_bind 169
187 #define __NR_connect 170
188 #define __NR_getpeername 171
189 #define __NR_getsockname 172
190 #define __NR_getsockopt 173
191 #define __NR_listen 174
192 #define __NR_recv 175
193 #define __NR_recvfrom 176
194 #define __NR_recvmsg 177
195 #define __NR_send 178
196 #define __NR_sendmsg 179
197 #define __NR_sendto 180
198 #define __NR_setsockopt 181
199 #define __NR_shutdown 182
200 #define __NR_socket 183
201 #define __NR_socketpair 184
202 #define __NR_setresuid 185
203 #define __NR_getresuid 186
204 #define __NR_query_module 187
205 #define __NR_poll 188
206 #define __NR_nfsservctl 189
207 #define __NR_setresgid 190
208 #define __NR_getresgid 191
209 #define __NR_prctl 192
210 #define __NR_rt_sigreturn 193
211 #define __NR_rt_sigaction 194
212 #define __NR_rt_sigprocmask 195
213 #define __NR_rt_sigpending 196
214 #define __NR_rt_sigtimedwait 197
215 #define __NR_rt_sigqueueinfo 198
216 #define __NR_rt_sigsuspend 199
217 #define __NR_pread 200
218 #define __NR_pwrite 201
219 #define __NR_chown 202
220 #define __NR_getcwd 203
221 #define __NR_capget 204
222 #define __NR_capset 205
223 #define __NR_sigaltstack 206
224 #define __NR_sendfile 207
225 #define __NR_streams1 208 /* some people actually want it */
226 #define __NR_streams2 209 /* some people actually want it */
227 #define __NR_mmap2 210
228 #define __NR_truncate64 211
229 #define __NR_ftruncate64 212
230 #define __NR_stat64 213
231 #define __NR_lstat64 214
232 #define __NR_fstat64 215
233 #define __NR_pivot_root 216
234 #define __NR_mincore 217
235 #define __NR_madvise 218
236 #define __NR_getdents64 219
237 #define __NR_vfork 220
239 /* Keep this last; should always equal the last valid call number. */
240 #define __NR_Linux_syscalls 220
242 /* user-visible error numbers are in the range -1 - -125: see
243 * <asm-xtensa/errno.h> */
245 #define SYSXTENSA_RESERVED 0 /* don't use this */
246 #define SYSXTENSA_ATOMIC_SET 1 /* set variable */
247 #define SYSXTENSA_ATOMIC_EXG_ADD 2 /* exchange memory and add */
248 #define SYSXTENSA_ATOMIC_ADD 3 /* add to memory */
249 #define SYSXTENSA_ATOMIC_CMP_SWP 4 /* compare and swap */
251 #define SYSXTENSA_COUNT 5 /* count of syscall0 functions*/
253 #ifdef __KERNEL__
254 #define __syscall_return(type, res) return ((type)(res))
255 #else
256 #define __syscall_return(type, res) \
257 do { \
258 if ((unsigned long)(res) >= (unsigned long)(-125)) { \
259 /* Avoid using "res" which is declared to be in register r2; \
260 * errno might expand to a function call and clobber it. */ \
261 int __err = -(res); \
262 errno = __err; \
263 res = -1; \
265 return (type) (res); \
266 } while (0)
267 #endif
270 /* Tensilica's xt-xcc compiler is much more agressive at code
271 * optimization than gcc. Multiple __asm__ statements are
272 * insufficient for xt-xcc because subsequent optimization passes
273 * (beyond the front-end that knows of __asm__ statements and other
274 * such GNU Extensions to C) can modify the register selection for
275 * containment of C variables.
277 * xt-xcc cannot modify the contents of a single __asm__ statement, so
278 * we create single-asm versions of the syscall macros that are
279 * suitable and optimal for both xt-xcc and gcc.
281 * Linux takes system-call arguments in registers. The following
282 * design is optimized for user-land apps (e.g., glibc) which
283 * typically have a function wrapper around the "syscall" assembly
284 * instruction. It satisfies the Xtensa ABI while minizing argument
285 * shifting.
287 * The Xtensa ABI and software conventions require the system-call
288 * number in a2. If an argument exists in a2, we move it to the next
289 * available register. Note that for improved efficiency, we do NOT
290 * shift all parameters down one register to maintain the original
291 * order.
293 * At best case (zero arguments), we just write the syscall number to
294 * a2. At worst case (1 to 6 arguments), we move the argument in a2
295 * to the next available register, then write the syscall number to
296 * a2.
298 * For clarity, the following truth table enumerates all possibilities.
300 * arguments syscall number arg0, arg1, arg2, arg3, arg4, arg5
301 * --------- -------------- ----------------------------------
302 * 0 a2
303 * 1 a2 a3
304 * 2 a2 a4, a3
305 * 3 a2 a5, a3, a4
306 * 4 a2 a6, a3, a4, a5
307 * 5 a2 a7, a3, a4, a5, a6
308 * 6 a2 a8, a3, a4, a5, a6, a7
311 #define _syscall0(type,name) \
312 type name(void) \
314 long __res; \
315 __asm__ __volatile__ ( \
316 " movi a2, %1 \n" \
317 " syscall \n" \
318 " mov %0, a2 \n" \
319 : "=a" (__res) \
320 : "i" (__NR_##name) \
321 : "a2" \
322 ); \
323 __syscall_return(type,__res); \
326 #define _syscall1(type,name,type0,arg0) \
327 type name(type0 arg0) \
329 long __res; \
330 __asm__ __volatile__ ( \
331 " mov a3, %2 \n" \
332 " movi a2, %1 \n" \
333 " syscall \n" \
334 " mov %0, a2 \n" \
335 : "=a" (__res) \
336 : "i" (__NR_##name), "a" (arg0) \
337 : "a2", "a3" \
338 ); \
339 __syscall_return(type,__res); \
342 #define _syscall2(type,name,type0,arg0,type1,arg1) \
343 type name(type0 arg0,type1 arg1) \
345 long __res; \
346 __asm__ __volatile__ ( \
347 " mov a4, %2 \n" \
348 " mov a3, %3 \n" \
349 " movi a2, %1 \n" \
350 " syscall \n" \
351 " mov %0, a2 \n" \
352 : "=a" (__res) \
353 : "i" (__NR_##name), "a" (arg0), "a" (arg1) \
354 : "a2", "a3", "a4" \
355 ); \
356 __syscall_return(type,__res); \
359 #define _syscall3(type,name,type0,arg0,type1,arg1,type2,arg2) \
360 type name(type0 arg0,type1 arg1,type2 arg2) \
362 long __res; \
363 __asm__ __volatile__ ( \
364 " mov a5, %2 \n" \
365 " mov a4, %4 \n" \
366 " mov a3, %3 \n" \
367 " movi a2, %1 \n" \
368 " syscall \n" \
369 " mov %0, a2 \n" \
370 : "=a" (__res) \
371 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2) \
372 : "a2", "a3", "a4", "a5" \
373 ); \
374 __syscall_return(type,__res); \
377 #define _syscall4(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3) \
378 type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3) \
380 long __res; \
381 __asm__ __volatile__ ( \
382 " mov a6, %2 \n" \
383 " mov a5, %5 \n" \
384 " mov a4, %4 \n" \
385 " mov a3, %3 \n" \
386 " movi a2, %1 \n" \
387 " syscall \n" \
388 " mov %0, a2 \n" \
389 : "=a" (__res) \
390 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), "a" (arg3) \
391 : "a2", "a3", "a4", "a5", "a6" \
392 ); \
393 __syscall_return(type,__res); \
396 /* Note that we save and restore the a7 frame pointer.
397 * Including a7 in the clobber list doesn't do what you'd expect.
399 #define _syscall5(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
400 type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
402 long __res; \
403 __asm__ __volatile__ ( \
404 " mov a9, a7 \n" \
405 " mov a7, %2 \n" \
406 " mov a6, %6 \n" \
407 " mov a5, %5 \n" \
408 " mov a4, %4 \n" \
409 " mov a3, %3 \n" \
410 " movi a2, %1 \n" \
411 " syscall \n" \
412 " mov a7, a9 \n" \
413 " mov %0, a2 \n" \
414 : "=a" (__res) \
415 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), \
416 "a" (arg3), "a" (arg4) \
417 : "a2", "a3", "a4", "a5", "a6", "a9" \
418 ); \
419 __syscall_return(type,__res); \
422 /* Note that we save and restore the a7 frame pointer.
423 * Including a7 in the clobber list doesn't do what you'd expect.
425 #define _syscall6(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
426 type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
428 long __res; \
429 __asm__ __volatile__ ( \
430 " mov a9, a7 \n" \
431 " mov a8, %2 \n" \
432 " mov a7, %7 \n" \
433 " mov a6, %6 \n" \
434 " mov a5, %5 \n" \
435 " mov a4, %4 \n" \
436 " mov a3, %3 \n" \
437 " movi a2, %1 \n" \
438 " syscall \n" \
439 " mov a7, a9 \n" \
440 " mov %0, a2 \n" \
441 : "=a" (__res) \
442 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), \
443 "a" (arg3), "a" (arg4), "a" (arg5) \
444 : "a2", "a3", "a4", "a5", "a6", "a8", "a9" \
445 ); \
446 __syscall_return(type,__res); \
450 #ifdef __KERNEL_SYSCALLS__
452 #include <linux/compiler.h>
453 #include <linux/types.h>
454 #include <linux/syscalls.h>
457 * we need this inline - forking from kernel space will result
458 * in NO COPY ON WRITE (!!!), until an execve is executed. This
459 * is no problem, but for the stack. This is handled by not letting
460 * main() use the stack at all after fork(). Thus, no function
461 * calls - which means inline code for fork too, as otherwise we
462 * would use the stack upon exit from 'fork()'.
464 * Actually only pause and fork are needed inline, so that there
465 * won't be any messing with the stack from main(), but we define
466 * some others too.
469 #define __NR__exit __NR_exit
471 static __inline__ _syscall0(int,pause)
472 //static __inline__ _syscall1(int,setup,int,magic) FIXME
473 static __inline__ _syscall0(int,sync)
474 static __inline__ _syscall0(pid_t,setsid)
475 static __inline__ _syscall3(int,write,int,fd,const char *,buf,off_t,count)
476 static __inline__ _syscall3(int,read,int,fd,char *,buf,off_t,count)
477 static __inline__ _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
478 static __inline__ _syscall1(int,dup,int,fd)
479 static __inline__ _syscall3(int,execve,const char*,file,char**,argv,char**,envp)
480 static __inline__ _syscall3(int,open,const char *,file,int,flag,int,mode)
481 static __inline__ _syscall1(int,close,int,fd)
482 static __inline__ _syscall1(int,_exit,int,exitcode)
483 static __inline__ _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
484 static __inline__ _syscall1(int,delete_module,const char *,name)
486 struct stat;
487 static __inline__ _syscall2(int,fstat,int,fd,struct stat *,buf)
488 static __inline__ _syscall0(pid_t,getpid)
489 static __inline__ _syscall2(int,kill,int,pid,int,sig)
490 static __inline__ _syscall2(int,stat,const char *, path,struct stat *,buf)
491 static __inline__ _syscall1(int,unlink,char *,pathname)
495 extern pid_t waitpid(int, int*, int );
496 static __inline__ pid_t wait(int * wait_stat)
498 return waitpid(-1,wait_stat,0);
500 #endif
503 * "Conditional" syscalls
505 * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
506 * but it doesn't work on all toolchains, so we just do it by hand
508 #define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall");
510 #ifdef __KERNEL__
511 #define __ARCH_WANT_IPC_PARSE_VERSION
512 #define __ARCH_WANT_OLD_READDIR
513 #define __ARCH_WANT_OLD_STAT
514 #define __ARCH_WANT_STAT64
515 #define __ARCH_WANT_SYS_ALARM
516 #define __ARCH_WANT_SYS_GETHOSTNAME
517 #define __ARCH_WANT_SYS_PAUSE
518 #define __ARCH_WANT_SYS_SGETMASK
519 #define __ARCH_WANT_SYS_SIGNAL
520 #define __ARCH_WANT_SYS_TIME
521 #define __ARCH_WANT_SYS_UTIME
522 #define __ARCH_WANT_SYS_WAITPID
523 #define __ARCH_WANT_SYS_SOCKETCALL
524 #define __ARCH_WANT_SYS_FADVISE64
525 #define __ARCH_WANT_SYS_GETPGRP
526 #define __ARCH_WANT_SYS_LLSEEK
527 #define __ARCH_WANT_SYS_NICE
528 #define __ARCH_WANT_SYS_OLD_GETRLIMIT
529 #define __ARCH_WANT_SYS_OLDUMOUNT
530 #define __ARCH_WANT_SYS_SIGPENDING
531 #define __ARCH_WANT_SYS_SIGPROCMASK
532 #define __ARCH_WANT_SYS_RT_SIGACTION
533 #endif
537 #endif /* _XTENSA_UNISTD_H */