root/include/asm-ppc/unistd.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. _syscall0
  2. wait

   1 /* * Last edited: Nov 17 16:28 1995 (cort) */
   2 #ifndef _ASM_PPC_UNISTD_H_
   3 #define _ASM_PPC_UNISTD_H_
   4 
   5 #define _NR(n) #n
   6 #define _lisc(n) "li 0," _NR(n)
   7 
   8 /*
   9  * This file contains the system call numbers.
  10  */
  11 
  12 #define __NR_setup                0     /* used only by init, to get system going */
  13 #define __NR_exit                 1
  14 #define __NR_fork                 2
  15 #define __NR_read                 3
  16 #define __NR_write                4
  17 #define __NR_open                 5
  18 #define __NR_close                6
  19 #define __NR_waitpid              7
  20 #define __NR_creat                8
  21 #define __NR_link                 9
  22 #define __NR_unlink              10
  23 #define __NR_execve              11
  24 #define __NR_chdir               12
  25 #define __NR_time                13
  26 #define __NR_mknod               14
  27 #define __NR_chmod               15
  28 #define __NR_chown               16
  29 #define __NR_break               17
  30 #define __NR_oldstat             18
  31 #define __NR_lseek               19
  32 #define __NR_getpid              20
  33 #define __NR_mount               21
  34 #define __NR_umount              22
  35 #define __NR_setuid              23
  36 #define __NR_getuid              24
  37 #define __NR_stime               25
  38 #define __NR_ptrace              26
  39 #define __NR_alarm               27
  40 #define __NR_oldfstat            28
  41 #define __NR_pause               29
  42 #define __NR_utime               30
  43 #define __NR_stty                31
  44 #define __NR_gtty                32
  45 #define __NR_access              33
  46 #define __NR_nice                34
  47 #define __NR_ftime               35
  48 #define __NR_sync                36
  49 #define __NR_kill                37
  50 #define __NR_rename              38
  51 #define __NR_mkdir               39
  52 #define __NR_rmdir               40
  53 #define __NR_dup                 41
  54 #define __NR_pipe                42
  55 #define __NR_times               43
  56 #define __NR_prof                44
  57 #define __NR_brk                 45
  58 #define __NR_setgid              46
  59 #define __NR_getgid              47
  60 #define __NR_signal              48
  61 #define __NR_geteuid             49
  62 #define __NR_getegid             50
  63 #define __NR_acct                51
  64 #define __NR_phys                52
  65 #define __NR_lock                53
  66 #define __NR_ioctl               54
  67 #define __NR_fcntl               55
  68 #define __NR_mpx                 56
  69 #define __NR_setpgid             57
  70 #define __NR_ulimit              58
  71 #define __NR_oldolduname         59
  72 #define __NR_umask               60
  73 #define __NR_chroot              61
  74 #define __NR_ustat               62
  75 #define __NR_dup2                63
  76 #define __NR_getppid             64
  77 #define __NR_getpgrp             65
  78 #define __NR_setsid              66
  79 #define __NR_sigaction           67
  80 #define __NR_sgetmask            68
  81 #define __NR_ssetmask            69
  82 #define __NR_setreuid            70
  83 #define __NR_setregid            71
  84 #define __NR_sigsuspend          72
  85 #define __NR_sigpending          73
  86 #define __NR_sethostname         74
  87 #define __NR_setrlimit           75
  88 #define __NR_getrlimit           76
  89 #define __NR_getrusage           77
  90 #define __NR_gettimeofday        78
  91 #define __NR_settimeofday        79
  92 #define __NR_getgroups           80
  93 #define __NR_setgroups           81
  94 #define __NR_select              82
  95 #define __NR_symlink             83
  96 #define __NR_oldlstat            84
  97 #define __NR_readlink            85
  98 #define __NR_uselib              86
  99 #define __NR_swapon              87
 100 #define __NR_reboot              88
 101 #define __NR_readdir             89
 102 #define __NR_mmap                90
 103 #define __NR_munmap              91
 104 #define __NR_truncate            92
 105 #define __NR_ftruncate           93
 106 #define __NR_fchmod              94
 107 #define __NR_fchown              95
 108 #define __NR_getpriority         96
 109 #define __NR_setpriority         97
 110 #define __NR_profil              98
 111 #define __NR_statfs              99
 112 #define __NR_fstatfs            100
 113 #define __NR_ioperm             101
 114 #define __NR_socketcall         102
 115 #define __NR_syslog             103
 116 #define __NR_setitimer          104
 117 #define __NR_getitimer          105
 118 #define __NR_stat               106
 119 #define __NR_lstat              107
 120 #define __NR_fstat              108
 121 #define __NR_olduname           109
 122 #define __NR_iopl               110
 123 #define __NR_vhangup            111
 124 #define __NR_idle               112
 125 #define __NR_vm86               113
 126 #define __NR_wait4              114
 127 #define __NR_swapoff            115
 128 #define __NR_sysinfo            116
 129 #define __NR_ipc                117
 130 #define __NR_fsync              118
 131 #define __NR_sigreturn          119
 132 #define __NR_clone              120
 133 #define __NR_setdomainname      121
 134 #define __NR_uname              122
 135 #define __NR_modify_ldt         123
 136 #define __NR_adjtimex           124
 137 #define __NR_mprotect           125
 138 #define __NR_sigprocmask        126
 139 #define __NR_create_module      127
 140 #define __NR_init_module        128
 141 #define __NR_delete_module      129
 142 #define __NR_get_kernel_syms    130
 143 #define __NR_quotactl           131
 144 #define __NR_getpgid            132
 145 #define __NR_fchdir             133
 146 #define __NR_bdflush            134
 147 #define __NR_sysfs              135
 148 #define __NR_personality        136
 149 #define __NR_afs_syscall        137 /* Syscall for Andrew File System */
 150 #define __NR_setfsuid           138
 151 #define __NR_setfsgid           139
 152 #define __NR__llseek            140
 153 #define __NR_getdents           141
 154 #define __NR__newselect         142
 155 #define __NR_flock              143
 156 #define __NR_msync              144
 157 /*#define __NR_kclone           145*/
 158 
 159 
 160 /* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
 161 #define _syscall0(type,name) \
 162 type name(void) \
 163 { \
 164  __asm__ (_lisc(__NR_##name)); \
 165  __asm__ ("sc"); \
 166  __asm__ ("mr 31,3"); \
 167  __asm__ ("bns 10f"); \
 168  __asm__ ("mr 0,3"); \
 169  __asm__ ("lis 3,errno@ha"); \
 170  __asm__ ("stw 0,errno@l(3)"); \
 171  __asm__ ("li 3,-1"); \
 172  __asm__ ("10:"); \
 173 }
 174 
 175 #define _syscall1(type,name,type1,arg1) \
 176 type name(type1 arg1) \
 177 { \
 178  __asm__ (_lisc(__NR_##name)); \
 179  __asm__ ("sc"); \
 180  __asm__ ("mr 31,3"); \
 181  __asm__ ("bns 10f"); \
 182  __asm__ ("mr 0,3"); \
 183  __asm__ ("lis 3,errno@ha"); \
 184  __asm__ ("stw 0,errno@l(3)"); \
 185  __asm__ ("li 3,-1"); \
 186  __asm__ ("10:"); \
 187 }
 188 
 189 #define _syscall2(type,name,type1,arg1,type2,arg2) \
 190 type name(type1 arg1,type2 arg2) \
 191 { \
 192  __asm__ (_lisc(__NR_##name)); \
 193  __asm__ ("sc"); \
 194  __asm__ ("mr 31,3"); \
 195  __asm__ ("bns 10f"); \
 196  __asm__ ("mr 0,3"); \
 197  __asm__ ("lis 3,errno@ha"); \
 198  __asm__ ("stw 0,errno@l(3)"); \
 199  __asm__ ("li 3,-1"); \
 200  __asm__ ("10:"); \
 201 }
 202 
 203 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
 204 type name(type1 arg1,type2 arg2,type3 arg3) \
 205 { \
 206  __asm__ (_lisc(__NR_##name)); \
 207  __asm__ ("sc"); \
 208  __asm__ ("mr 31,3"); \
 209  __asm__ ("bns 10f"); \
 210  __asm__ ("mr 0,3"); \
 211  __asm__ ("lis 3,errno@ha"); \
 212  __asm__ ("stw 0,errno@l(3)"); \
 213  __asm__ ("li 3,-1"); \
 214  __asm__ ("10:"); \
 215 }
 216 
 217 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
 218 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
 219 { \
 220  __asm__ (_lisc(__NR_##name)); \
 221  __asm__ ("sc"); \
 222  __asm__ ("mr 31,3"); \
 223  __asm__ ("bns 10f"); \
 224  __asm__ ("mr 0,3"); \
 225  __asm__ ("lis 3,errno@ha"); \
 226  __asm__ ("stw 0,errno@l(3)"); \
 227  __asm__ ("li 3,-1"); \
 228  __asm__ ("10:"); \
 229 } 
 230 
 231 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
 232           type5,arg5) \
 233 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
 234 { \
 235  __asm__ (_lisc(__NR_##name)); \
 236  __asm__ ("sc"); \
 237  __asm__ ("mr 31,3"); \
 238  __asm__ ("bns 10f"); \
 239  __asm__ ("mr 0,3"); \
 240  __asm__ ("lis 3,errno@ha"); \
 241  __asm__ ("stw 0,errno@l(3)"); \
 242  __asm__ ("li 3,-1"); \
 243  __asm__ ("10:"); \
 244 }
 245 
 246 #ifdef __KERNEL_SYSCALLS__
 247 
 248 /*
 249  * we need this inline - forking from kernel space will result
 250  * in NO COPY ON WRITE (!!!), until an execve is executed. This
 251  * is no problem, but for the stack. This is handled by not letting
 252  * main() use the stack at all after fork(). Thus, no function
 253  * calls - which means inline code for fork too, as otherwise we
 254  * would use the stack upon exit from 'fork()'.
 255  *
 256  * Actually only pause and fork are needed inline, so that there
 257  * won't be any messing with the stack from main(), but we define
 258  * some others too.
 259  */
 260 /*
 261    some of these had problems getting the right arguments (namely sys_clone())
 262    when they were inline.
 263              -- Cort
 264  */
 265 #define __NR__exit __NR_exit
 266 static inline _syscall0(int,idle) /* made inline "just in case" -- Cort */
     /* [previous][next][first][last][top][bottom][index][help] */
 267 static inline _syscall0(int,fork) /* needs to be inline */
 268 static inline _syscall0(int,pause) /* needs to be inline */
 269 static inline _syscall0(int,setup) /* called in init before execve */
 270 static inline _syscall0(int,sync)
 271 static inline _syscall0(pid_t,setsid)
 272 static /*inline*/ _syscall3(int,write,int,fd,const char *,buf,off_t,count)
 273 static /*inline*/ _syscall1(int,dup,int,fd)
 274 static /*inline*/ _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
 275 static /*inline*/ _syscall3(int,open,const char *,file,int,flag,int,mode)
 276 static inline _syscall1(int,close,int,fd)
 277 static /*inline*/ _syscall1(int,_exit,int,exitcode)
 278 static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
 279 /*static inline _syscall2(int,clone,unsigned long,flags,char *,esp)*/
 280 
 281 /*
 282    syscalls from kernel mode is a little strange and I can't get used to
 283    the idea -- this makes me feel better.   -- Cort
 284  */
 285 /*static inline int kclone (void)
 286 {
 287  __asm__ (_lisc(__NR_kclone)); 
 288  __asm__ ("sc"); 
 289  __asm__ ("mr 31,3"); 
 290  __asm__ ("bns 10f"); 
 291  __asm__ ("mr 0,3"); 
 292  __asm__ ("lis 3,errno@ha"); 
 293  __asm__ ("stw 0,errno@l(3)"); 
 294  __asm__ ("li 3,-1"); 
 295  __asm__ ("10:");   
 296 }*/
 297 
 298 static inline int clone (unsigned long flags,char *esp)
 299 {
 300 /*  printk("unistd.h: clone(): flags = %x, esp = %x\n", flags, esp);*/
 301  __asm__ (_lisc(__NR_clone)); 
 302  __asm__ ("sc");
 303  __asm__ ("mr 31,3"); 
 304 
 305 /* this is a hack to get the damned thing to return something even though inlined
 306    -- Cort
 307    */
 308  __asm__ ("mr 0,3"); 
 309  __asm__ ("lis 3,errno@ha"); 
 310  __asm__ ("stw 0,errno@l(3)"); 
 311  
 312  __asm__ ("bns 10f"); 
 313  __asm__ ("mr 0,3"); 
 314  __asm__ ("lis 3,errno@ha"); 
 315  __asm__ ("stw 0,errno@l(3)"); 
 316  __asm__ ("li 3,-1"); 
 317  __asm__ ("10:");
 318  return errno;
 319 }
 320 
 321 
 322 /* called from init before execve -- need to be inline? -- Cort */
 323 static inline pid_t wait(int * wait_stat) 
     /* [previous][next][first][last][top][bottom][index][help] */
 324 {
 325         return waitpid(-1,wait_stat,0);
 326 }
 327 
 328 #endif
 329 
 330 #endif /* _ASM_PPC_UNISTD_H_ */
 331 
 332 

/* [previous][next][first][last][top][bottom][index][help] */