OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-ppc/] [unistd.h] - Blame information for rev 1633

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef _ASM_PPC_UNISTD_H_
2
#define _ASM_PPC_UNISTD_H_
3
 
4
#define _NR(n) #n
5
#define _lisc(n) "li 0," _NR(n)
6
 
7
/*
8
 * This file contains the system call numbers.
9
 */
10
 
11
#define __NR_setup                0     /* used only by init, to get system going */
12
#define __NR_exit                 1
13
#define __NR_fork                 2
14
#define __NR_read                 3
15
#define __NR_write                4
16
#define __NR_open                 5
17
#define __NR_close                6
18
#define __NR_waitpid              7
19
#define __NR_creat                8
20
#define __NR_link                 9
21
#define __NR_unlink              10
22
#define __NR_execve              11
23
#define __NR_chdir               12
24
#define __NR_time                13
25
#define __NR_mknod               14
26
#define __NR_chmod               15
27
#define __NR_chown               16
28
#define __NR_break               17
29
#define __NR_oldstat             18
30
#define __NR_lseek               19
31
#define __NR_getpid              20
32
#define __NR_mount               21
33
#define __NR_umount              22
34
#define __NR_setuid              23
35
#define __NR_getuid              24
36
#define __NR_stime               25
37
#define __NR_ptrace              26
38
#define __NR_alarm               27
39
#define __NR_oldfstat            28
40
#define __NR_pause               29
41
#define __NR_utime               30
42
#define __NR_stty                31
43
#define __NR_gtty                32
44
#define __NR_access              33
45
#define __NR_nice                34
46
#define __NR_ftime               35
47
#define __NR_sync                36
48
#define __NR_kill                37
49
#define __NR_rename              38
50
#define __NR_mkdir               39
51
#define __NR_rmdir               40
52
#define __NR_dup                 41
53
#define __NR_pipe                42
54
#define __NR_times               43
55
#define __NR_prof                44
56
#define __NR_brk                 45
57
#define __NR_setgid              46
58
#define __NR_getgid              47
59
#define __NR_signal              48
60
#define __NR_geteuid             49
61
#define __NR_getegid             50
62
#define __NR_acct                51
63
#define __NR_phys                52
64
#define __NR_lock                53
65
#define __NR_ioctl               54
66
#define __NR_fcntl               55
67
#define __NR_mpx                 56
68
#define __NR_setpgid             57
69
#define __NR_ulimit              58
70
#define __NR_oldolduname         59
71
#define __NR_umask               60
72
#define __NR_chroot              61
73
#define __NR_ustat               62
74
#define __NR_dup2                63
75
#define __NR_getppid             64
76
#define __NR_getpgrp             65
77
#define __NR_setsid              66
78
#define __NR_sigaction           67
79
#define __NR_sgetmask            68
80
#define __NR_ssetmask            69
81
#define __NR_setreuid            70
82
#define __NR_setregid            71
83
#define __NR_sigsuspend          72
84
#define __NR_sigpending          73
85
#define __NR_sethostname         74
86
#define __NR_setrlimit           75
87
#define __NR_getrlimit           76
88
#define __NR_getrusage           77
89
#define __NR_gettimeofday        78
90
#define __NR_settimeofday        79
91
#define __NR_getgroups           80
92
#define __NR_setgroups           81
93
#define __NR_select              82
94
#define __NR_symlink             83
95
#define __NR_oldlstat            84
96
#define __NR_readlink            85
97
#define __NR_uselib              86
98
#define __NR_swapon              87
99
#define __NR_reboot              88
100
#define __NR_readdir             89
101
#define __NR_mmap                90
102
#define __NR_munmap              91
103
#define __NR_truncate            92
104
#define __NR_ftruncate           93
105
#define __NR_fchmod              94
106
#define __NR_fchown              95
107
#define __NR_getpriority         96
108
#define __NR_setpriority         97
109
#define __NR_profil              98
110
#define __NR_statfs              99
111
#define __NR_fstatfs            100
112
#define __NR_ioperm             101
113
#define __NR_socketcall         102
114
#define __NR_syslog             103
115
#define __NR_setitimer          104
116
#define __NR_getitimer          105
117
#define __NR_stat               106
118
#define __NR_lstat              107
119
#define __NR_fstat              108
120
#define __NR_olduname           109
121
#define __NR_iopl               110
122
#define __NR_vhangup            111
123
#define __NR_idle               112
124
#define __NR_vm86               113
125
#define __NR_wait4              114
126
#define __NR_swapoff            115
127
#define __NR_sysinfo            116
128
#define __NR_ipc                117
129
#define __NR_fsync              118
130
#define __NR_sigreturn          119
131
#define __NR_clone              120
132
#define __NR_setdomainname      121
133
#define __NR_uname              122
134
#define __NR_modify_ldt         123
135
#define __NR_adjtimex           124
136
#define __NR_mprotect           125
137
#define __NR_sigprocmask        126
138
#define __NR_create_module      127
139
#define __NR_init_module        128
140
#define __NR_delete_module      129
141
#define __NR_get_kernel_syms    130
142
#define __NR_quotactl           131
143
#define __NR_getpgid            132
144
#define __NR_fchdir             133
145
#define __NR_bdflush            134
146
#define __NR_sysfs              135
147
#define __NR_personality        136
148
#define __NR_afs_syscall        137 /* Syscall for Andrew File System */
149
#define __NR_setfsuid           138
150
#define __NR_setfsgid           139
151
#define __NR__llseek            140
152
#define __NR_getdents           141
153
#define __NR__newselect         142
154
#define __NR_flock              143
155
#define __NR_msync              144
156
#define __NR_readv              145
157
#define __NR_writev             146
158
#define __NR_getsid             147
159
 
160
#define __NR_mlock              150
161
#define __NR_munlock            151
162
#define __NR_mlockall           152
163
#define __NR_munlockall         153
164
 
165
 
166
#define _syscall0(type,name) \
167
type name(void) \
168
{ \
169
    long retval; \
170
    __asm__  ( \
171
              "li 0, %0 \n\t" \
172
              "sc \n\t" \
173
              "mr 31,3 \n\t" \
174
              "bns 10f \n\t" \
175
              "mr 0,3 \n\t" \
176
              "lis 3,errno@ha \n\t" \
177
              "stw 0,errno@l(3) \n\t" \
178
              "li 3,-1 \n\t" \
179
              "10: \n\t" \
180
              : \
181
              : "i" (__NR_##name) \
182
              : "0", "31", "3", "cc", "memory" \
183
              );  \
184
    return(retval);\
185
}
186
 
187
#define _syscall1(type,name,type1,arg1) \
188
type name(type1 arg1) \
189
{ \
190
    long retval; \
191
    __asm__  ( \
192
              "li 0, %0 \n\t" \
193
              "sc \n\t" \
194
              "mr 31,3 \n\t" \
195
              "bns 10f \n\t" \
196
              "mr 0,3 \n\t" \
197
              "lis 3,errno@ha \n\t" \
198
              "stw 0,errno@l(3) \n\t" \
199
              "li 3,-1 \n\t" \
200
              "10: \n\t" \
201
              : \
202
              : "i" (__NR_##name) \
203
              : "0", "31", "3", "cc", "memory" \
204
              );  \
205
    return(retval); \
206
}
207
 
208
#define _syscall2(type,name,type1,arg1,type2,arg2) \
209
type name(type1 arg1,type2 arg2) \
210
{ \
211
    long retval; \
212
    __asm__  ( \
213
              "li 0, %0 \n\t" \
214
              "sc \n\t" \
215
              "mr 31,3 \n\t" \
216
              "bns 10f \n\t" \
217
              "mr 0,3 \n\t" \
218
              "lis 3,errno@ha \n\t" \
219
              "stw 0,errno@l(3) \n\t" \
220
              "li 3,-1 \n\t" \
221
              "10: \n\t" \
222
              : \
223
              : "i" (__NR_##name) \
224
              : "0", "31", "3", "cc", "memory" \
225
              );  \
226
    return(retval); \
227
}
228
 
229
 
230
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
231
type name(type1 arg1,type2 arg2, type3 arg3) \
232
{ \
233
    long retval; \
234
    __asm__  ( \
235
              "li 0, %0 \n\t" \
236
              "sc \n\t" \
237
              "mr 31,3 \n\t" \
238
              "bns 10f \n\t" \
239
              "mr 0,3 \n\t" \
240
              "lis 3,errno@ha \n\t" \
241
              "stw 0,errno@l(3) \n\t" \
242
              "li 3,-1 \n\t" \
243
              "10: \n\t" \
244
              : \
245
              : "i" (__NR_##name) \
246
              : "0", "31", "3", "cc", "memory" \
247
              );  \
248
    return(retval); \
249
}
250
 
251
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
252
type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
253
{ \
254
    long retval; \
255
    __asm__  ( \
256
              "li 0, %0 \n\t" \
257
              "sc \n\t" \
258
              "mr 31,3 \n\t" \
259
              "bns 10f \n\t" \
260
              "mr 0,3 \n\t" \
261
              "lis 3,errno@ha \n\t" \
262
              "stw 0,errno@l(3) \n\t" \
263
              "li 3,-1 \n\t" \
264
              "10: \n\t" \
265
              : \
266
              : "i" (__NR_##name) \
267
              : "0", "31", "3", "cc", "memory" \
268
              );  \
269
    return(retval); \
270
}
271
 
272
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
273
          type5,arg5) \
274
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
275
{ \
276
    long retval; \
277
    __asm__  ( \
278
              "li 0, %0 \n\t" \
279
              "sc \n\t" \
280
              "mr 31,3 \n\t" \
281
              "bns 10f \n\t" \
282
              "mr 0,3 \n\t" \
283
              "lis 3,errno@ha \n\t" \
284
              "stw 0,errno@l(3) \n\t" \
285
              "li 3,-1 \n\t" \
286
              "10: \n\t" \
287
              : \
288
              : "i" (__NR_##name) \
289
              : "0", "31", "3", "cc", "memory" \
290
              );  \
291
    return(retval); \
292
}
293
 
294
#ifdef __KERNEL_SYSCALLS__
295
/*
296
 * we need this inline - forking from kernel space will result
297
 * in NO COPY ON WRITE (!!!), until an execve is executed. This
298
 * is no problem, but for the stack. This is handled by not letting
299
 * main() use the stack at all after fork(). Thus, no function
300
 * calls - which means inline code for fork too, as otherwise we
301
 * would use the stack upon exit from 'fork()'.
302
 *
303
 * Actually only pause and fork are needed inline, so that there
304
 * won't be any messing with the stack from main(), but we define
305
 * some others too.
306
 */
307
 
308
/*
309
   some of these had problems getting the right arguments (namely sys_clone())
310
   when they were inline so I made them non-inline until we get problems with gcc
311
   worked out.  I need to check with Linus to find out which he wants inline now
312
   since the above comment was written a long time ago.
313
 
314
   Once I understand the macro language better this should go away.
315
             -- Cort
316
 */
317
 
318
#define __NR__exit __NR_exit
319
static /*__inline__*/ _syscall0(int,setup)
320
static __inline__ _syscall0(int,idle)
321
static /*__inline__*/ _syscall0(int,fork)
322
static __inline__ _syscall0(int,pause)
323
static __inline__ _syscall0(int,sync)
324
static __inline__ _syscall0(pid_t,setsid)
325
static __inline__ _syscall3(int,write,int,fd,const char *,buf,off_t,count)
326
static /*__inline__*/ _syscall1(int,dup,int,fd)
327
static /*__inline__*/ _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
328
static __inline__ _syscall3(int,open,const char *,file,int,flag,int,mode)
329
static /*__inline__*/ _syscall1(int,close,int,fd)
330
static /*__inline__*/ _syscall1(int,_exit,int,exitcode)
331
static __inline__ _syscall2(int,clone,unsigned long,flags,char *,esp)
332
static __inline__ _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
333
 
334
static __inline__ pid_t wait(int * wait_stat)
335
{
336
        return waitpid(-1,wait_stat,0);
337
}
338
 
339
/*
340
   This is the mechanism for creating a new kernel thread.
341
   For the time being it only behaves the same as clone().
342
   It should be changed very soon to work properly and cleanly.  This
343
   gets us going for now, though.
344
     -- Cort
345
 */
346
static __inline__ long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
347
{
348
  long retval;
349
  __asm__  (
350
        "li 0, 120 \n\t"        /* __NR_clone */
351
        "li 3, %5 \n\t"         /* load flags as arg to clone */
352
        /*"mr 1,7 \n\t"*/               /* save kernel stack */
353
        "sc \n\t"               /* syscall */
354
        /*"cmp 0,1,7 \n\t"*/    /* if kernel stack changes -- child */
355
        "cmpi   0,3,0 \n\t"
356
        "bne 1f \n\t"           /* return if parent */
357
        /* this is in child */
358
        "li 3, %3 \n\t"         /* child -- load args and call fn */
359
        "mtlr %4 \n\t"
360
        "blrl \n\t"
361
        "li 0, %2 \n\t"         /* exit after child exits */
362
        "li 3, 0 \n\t"
363
        "sc \n\t"
364
        /* parent */
365
        "1: \n\t"
366
        :"=3" (retval)
367
        :"i" (__NR_clone), "i" (__NR_exit),
368
         "r" (arg), "r" (fn), "g" (CLONE_VM|flags)
369
        :"cc", "1", "0", "3", "7", "31", "memory" );
370
  return retval;
371
}
372
 
373
 
374
#endif /* __KERNEL_SYSCALLS__ */
375
 
376
#endif /* _ASM_PPC_UNISTD_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.