root/include/asm-sparc/unistd.h

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

INCLUDED FROM


DEFINITIONS

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

   1 #ifndef _SPARC_UNISTD_H
   2 #define _SPARC_UNISTD_H
   3 
   4 /*
   5  * System calls under the Sparc.
   6  *
   7  * Don't be scared by the ugly clobbers, it is the only way I can
   8  * think of right now to force the arguments into fixed registers
   9  * before the trap into the system call with gcc 'asm' statements.
  10  *
  11  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  12  */
  13 
  14 /* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
  15 #define _syscall0(type,name) \
  16 type name(void) \
  17 { \
  18 long __res; \
  19 __asm__ volatile ("or %%g0, %0, %%o0\n\t" \
  20                   "t 0x10\n\t" \
  21                   "nop\n\t" \
  22                   "or %%g0, %%o0, %0\n\t" \
  23                   : "=r" (__res) \
  24                   : "0" (__NR_##name) \
  25                   : "o0"); \
  26 if (__res >= 0) \
  27     return (type) __res; \
  28 errno = -__res; \
  29 return -1; \
  30 }
  31 
  32 #define _syscall1(type,name,type1,arg1) \
  33 type name(type1 arg1) \
  34 { \
  35 long __res; \
  36 __asm__ volatile ("or %%g0, %0, %%o0\n\t" \
  37                   "or %%g0, %1, %%o1\n\t" \
  38                   "t 0x10\n\t" \
  39                   "nop\n\t" \
  40                   "or %%g0, %%o0, %0\n\t" \
  41                   : "=r" (__res), "=r" ((long)(arg1)) \
  42                   : "0" (__NR_##name),"1" ((long)(arg1)) \
  43                   : "o0", "o1"); \
  44 if (__res >= 0) \
  45         return (type) __res; \
  46 errno = -__res; \
  47 return -1; \
  48 }
  49 
  50 #define _syscall2(type,name,type1,arg1,type2,arg2) \
  51 type name(type1 arg1,type2 arg2) \
  52 { \
  53 long __res; \
  54 __asm__ volatile ("or %%g0, %0, %%o0\n\t" \
  55                   "or %%g0, %1, %%o1\n\t" \
  56                   "or %%g0, %2, %%o2\n\t" \
  57                   "t 0x10\n\t" \
  58                   "nop\n\t" \
  59                   "or %%g0, %%o0, %0\n\t" \
  60                   : "=r" (__res), "=r" ((long)(arg1)), "=r" ((long)(args)) \
  61                   : "0" (__NR_##name),"1" ((long)(arg1)),"2" ((long)(arg2)) \
  62                   : "o0", "o1", "o2"); \
  63 if (__res >= 0) \
  64         return (type) __res; \
  65 errno = -__res; \
  66 return -1; \
  67 }
  68 
  69 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
  70 type name(type1 arg1,type2 arg2,type3 arg3) \
  71 { \
  72 long __res; \
  73 __asm__ volatile ("or %%g0, %0, %%o0\n\t" \
  74                   "or %%g0, %1, %%o1\n\t" \
  75                   "or %%g0, %2, %%o2\n\t" \
  76                   "or %%g0, %3, %%o3\n\t" \
  77                   "t 0x10\n\t" \
  78                   "nop\n\t" \
  79                   "or %%g0, %%o0, %0\n\t" \
  80                   : "=r" (__res), "=r" ((long)(arg1)), "=r" ((long)(arg2)), \
  81                     "=r" ((long)(arg3)) \
  82                   : "0" (__NR_##name), "1" ((long)(arg1)), "2" ((long)(arg2)), \
  83                     "3" ((long)(arg3)) \
  84                   : "o0", "o1", "o2", "o3"); \
  85 if (__res>=0) \
  86         return (type) __res; \
  87 errno=-__res; \
  88 return -1; \
  89 }
  90 
  91 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  92 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
  93 { \
  94 long __res; \
  95 __asm__ volatile ("or %%g0, %0, %%o0\n\t" \
  96                   "or %%g0, %1, %%o1\n\t" \
  97                   "or %%g0, %2, %%o2\n\t" \
  98                   "or %%g0, %3, %%o3\n\t" \
  99                   "or %%g0, %4, %%o4\n\t" \
 100                   "t 0x10\n\t" \
 101                   "nop\n\t" \
 102                   "or %%g0, %%o0, %0\n\t" \
 103                   : "=r" (__res), "=r" ((long)(arg1)), "=r" ((long)(arg2)), \
 104                     "=r" ((long)(arg3)), "=r" ((long)(arg4)) \
 105                   : "0" (__NR_##name),"1" ((long)(arg1)),"2" ((long)(arg2)), \
 106                     "3" ((long)(arg3)),"4" ((long)(arg4)) \
 107                   : "o0", "o1", "o2", "o3", "o4"); \
 108 if (__res>=0) \
 109         return (type) __res; \
 110 errno=-__res; \
 111 return -1; \
 112 } 
 113 
 114 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
 115           type5,arg5) \
 116 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
 117 { \
 118 long __res; \
 119 __asm__ volatile ("or %%g0, %0, %%o0\n\t" \
 120                   "or %%g0, %1, %%o1\n\t" \
 121                   "or %%g0, %2, %%o2\n\t" \
 122                   "or %%g0, %3, %%o3\n\t" \
 123                   "or %%g0, %4, %%o4\n\t" \
 124                   "or %%g0, %5, %%o5\n\t" \
 125                   "t 0x10\n\t" \
 126                   "nop\n\t" \
 127                   "or %%g0, %%o0, %0\n\t" \
 128                   : "=r" (__res), "=r" ((long)(arg1)), "=r" ((long)(arg2)), \
 129                     "=r" ((long)(arg3)), "=r" ((long)(arg4)), "=r" ((long)(arg5)) \
 130                   : "0" (__NR_##name),"1" ((long)(arg1)),"2" ((long)(arg2)), \
 131                     "3" ((long)(arg3)),"4" ((long)(arg4)),"5" ((long)(arg5)) \
 132                   : "o0", "o1", "o2", "o3", "o4", "o5"); \
 133 if (__res>=0) \
 134         return (type) __res; \
 135 errno=-__res; \
 136 return -1; \
 137 }
 138 
 139 #ifdef __KERNEL_SYSCALLS__
 140 
 141 /*
 142  * we need this inline - forking from kernel space will result
 143  * in NO COPY ON WRITE (!!!), until an execve is executed. This
 144  * is no problem, but for the stack. This is handled by not letting
 145  * main() use the stack at all after fork(). Thus, no function
 146  * calls - which means inline code for fork too, as otherwise we
 147  * would use the stack upon exit from 'fork()'.
 148  *
 149  * Actually only pause and fork are needed inline, so that there
 150  * won't be any messing with the stack from main(), but we define
 151  * some others too.
 152  */
 153 #define __NR__exit __NR_exit
 154 /* static inline _syscall0(int,idle) */
 155 static inline _syscall0(int,fork)
     /* [previous][next][first][last][top][bottom][index][help] */
 156 static inline _syscall0(int,pause)
 157 /* static inline _syscall0(int,setup) */
 158 static inline _syscall0(int,sync)
 159 static inline _syscall0(pid_t,setsid)
 160 static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
 161 static inline _syscall1(int,dup,int,fd)
 162 static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
 163 static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
 164 static inline _syscall1(int,close,int,fd)
 165 static inline _syscall1(int,_exit,int,exitcode)
 166 static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
 167 
 168 extern void sys_idle(void);
 169 static inline void idle(void)
 170 {
 171         printk("[%d]idle()\n",current->pid);
 172         sys_idle();
 173         for(;;);
 174 }
 175 
 176 extern int sys_setup(void);
 177 static inline int setup(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 178 {
 179         int retval;
 180 
 181         printk("[%d]setup()\n",current->pid);
 182         retval = sys_setup();
 183         printk("[%d]setup() returned %d\n",current->pid, retval);
 184 }
 185 
 186 extern int sys_waitpid(int, int *, int);
 187 static inline pid_t wait(int * wait_stat)
     /* [previous][next][first][last][top][bottom][index][help] */
 188 {
 189         long retval, i;
 190         printk("[%d]wait(%p)\n", current->pid, wait_stat);
 191         retval = waitpid(-1,wait_stat,0);
 192         printk("[%d]wait(%p) returned %ld\n", current->pid, wait_stat, retval);
 193         for (i = 0; i < 1000000000; i++);
 194         return retval;
 195 }
 196 
 197 #endif
 198 
 199 #endif /* _SPARC_UNISTD_H */

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