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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef _ASM_I960_UNISTD_H_
2
#define _ASM_I960_UNISTD_H_
3
 
4
#ifndef __ASSEMBLY__ 
5
#ifdef CONFIG_I960VH
6
#include <asm/i960jx.h>
7
#endif  /* CONFIG_I960VH */
8
#endif  /* __ASSEMBLY__ */
9
 
10
 
11
/*
12
 * This file contains the system call numbers.
13
 */
14
 
15
#define __NR_setup                0     /* used only by init, to get system going */
16
#define __NR_exit                 1
17
#define __NR_fork                 2
18
#define __NR_read                 3
19
#define __NR_write                4
20
#define __NR_open                 5
21
#define __NR_close                6
22
#define __NR_waitpid              7
23
#define __NR_creat                8
24
#define __NR_link                 9
25
#define __NR_unlink              10
26
#define __NR_execve              11
27
#define __NR_chdir               12
28
#define __NR_time                13
29
#define __NR_mknod               14
30
#define __NR_chmod               15
31
#define __NR_chown               16
32
#define __NR_break               17
33
#define __NR_oldstat             18
34
#define __NR_lseek               19
35
#define __NR_getpid              20
36
#define __NR_mount               21
37
#define __NR_umount              22
38
#define __NR_setuid              23
39
#define __NR_getuid              24
40
#define __NR_stime               25
41
#define __NR_ptrace              26
42
#define __NR_alarm               27
43
#define __NR_oldfstat            28
44
#define __NR_pause               29
45
#define __NR_utime               30
46
#define __NR_stty                31
47
#define __NR_gtty                32
48
#define __NR_access              33
49
#define __NR_nice                34
50
#define __NR_ftime               35
51
#define __NR_sync                36
52
#define __NR_kill                37
53
#define __NR_rename              38
54
#define __NR_mkdir               39
55
#define __NR_rmdir               40
56
#define __NR_dup                 41
57
#define __NR_pipe                42
58
#define __NR_times               43
59
#define __NR_prof                44
60
#define __NR_brk                 45
61
#define __NR_setgid              46
62
#define __NR_getgid              47
63
#define __NR_signal              48
64
#define __NR_geteuid             49
65
#define __NR_getegid             50
66
#define __NR_acct                51
67
#define __NR_phys                52
68
#define __NR_lock                53
69
#define __NR_ioctl               54
70
#define __NR_fcntl               55
71
#define __NR_mpx                 56
72
#define __NR_setpgid             57
73
#define __NR_ulimit              58
74
#define __NR_oldolduname         59
75
#define __NR_umask               60
76
#define __NR_chroot              61
77
#define __NR_ustat               62
78
#define __NR_dup2                63
79
#define __NR_getppid             64
80
#define __NR_getpgrp             65
81
#define __NR_setsid              66
82
#define __NR_sigaction           67
83
#define __NR_sgetmask            68
84
#define __NR_ssetmask            69
85
#define __NR_setreuid            70
86
#define __NR_setregid            71
87
#define __NR_sigsuspend          72
88
#define __NR_sigpending          73
89
#define __NR_sethostname         74
90
#define __NR_setrlimit           75
91
#define __NR_getrlimit           76
92
#define __NR_getrusage           77
93
#define __NR_gettimeofday        78
94
#define __NR_settimeofday        79
95
#define __NR_getgroups           80
96
#define __NR_setgroups           81
97
#define __NR_select              82
98
#define __NR_symlink             83
99
#define __NR_oldlstat            84
100
#define __NR_readlink            85
101
#define __NR_uselib              86
102
#define __NR_swapon              87
103
#define __NR_reboot              88
104
#define __NR_readdir             89
105
#define __NR_mmap                90
106
#define __NR_munmap              91
107
#define __NR_truncate            92
108
#define __NR_ftruncate           93
109
#define __NR_fchmod              94
110
#define __NR_fchown              95
111
#define __NR_getpriority         96
112
#define __NR_setpriority         97
113
#define __NR_profil              98
114
#define __NR_statfs              99
115
#define __NR_fstatfs            100
116
#define __NR_ioperm             101
117
#define __NR_socketcall         102
118
#define __NR_syslog             103
119
#define __NR_setitimer          104
120
#define __NR_getitimer          105
121
#define __NR_stat               106
122
#define __NR_lstat              107
123
#define __NR_fstat              108
124
#define __NR_olduname           109
125
#define __NR_iopl               /* 110 */ not supported
126
#define __NR_vhangup            111
127
#define __NR_idle               112
128
#define __NR_vm86               /* 113 */ not supported
129
#define __NR_wait4              114
130
#define __NR_swapoff            115
131
#define __NR_sysinfo            116
132
#define __NR_ipc                117
133
#define __NR_fsync              118
134
#define __NR_sigreturn          119
135
#define __NR_clone              120
136
#define __NR_setdomainname      121
137
#define __NR_uname              122
138
#define __NR_cacheflush         123
139
#define __NR_adjtimex           124
140
#define __NR_mprotect           125
141
#define __NR_sigprocmask        126
142
#define __NR_create_module      127
143
#define __NR_init_module        128
144
#define __NR_delete_module      129
145
#define __NR_get_kernel_syms    130
146
#define __NR_quotactl           131
147
#define __NR_getpgid            132
148
#define __NR_fchdir             133
149
#define __NR_bdflush            134
150
#define __NR_sysfs              135
151
#define __NR_personality        136
152
#define __NR_afs_syscall        137 /* Syscall for Andrew File System */
153
#define __NR_setfsuid           138
154
#define __NR_setfsgid           139
155
#define __NR__llseek            140
156
#define __NR_getdents           141
157
#define __NR__newselect         142
158
#define __NR_flock              143
159
#define __NR_msync              144
160
#define __NR_readv              145
161
#define __NR_writev             146
162
#define __NR_getsid             147
163
#define __NR_fdatasync          148
164
#define __NR__sysctl            149
165
#define __NR_mlock              150
166
#define __NR_munlock            151
167
#define __NR_mlockall           152
168
#define __NR_munlockall         153
169
#define __NR_sched_setparam             154
170
#define __NR_sched_getparam             155
171
#define __NR_sched_setscheduler         156
172
#define __NR_sched_getscheduler         157
173
#define __NR_sched_yield                158
174
#define __NR_sched_get_priority_max     159
175
#define __NR_sched_get_priority_min     160
176
#define __NR_sched_rr_get_interval      161
177
#define __NR_nanosleep          162
178
#define __NR_mremap             163
179
#ifdef DEBUG
180
#define __NR_dbg_break          164
181
#define __NR_dbg_hexprint       165
182
#define __NR_nocall             166
183
#else
184
#define __NR_nocall             164
185
#endif
186
 
187
/*
188
 * The interrupt vector used for system calls. We will map XINT1 to this vector
189
 * via the IMAP registers.
190
 */
191
#define SYSCALL_VEC     2
192
#ifndef __ASSEMBLY__
193
#include <linux/pidhash.h>
194
/*
195
 * This is always the same; the arguments are in global regs, so we don't need
196
 * to do anything special to marshall them. Notice that linux doesn't use the
197
 * i960's standard convention for syscalls; instead, we use interrupt XINT1
198
 * and place the real syscall vector number in register g13.
199
 */
200
 
201
#ifdef __KERNEL__
202
#define __SYSCALL_RETURN(res,type)      do { return (type)res; } while(0)
203
#else
204
#define __SYSCALL_RETURN(res,type) do { \
205
        if (res >= 0) \
206
                return (type) res; \
207
        errno = -res; \
208
        return (type) -1; \
209
} while(0)
210
#endif
211
 
212
#define __SYSCALL_BODY(type,name) \
213
{ \
214
        long res; \
215
        asm volatile("ldconst   %1, g13\n\t"    \
216
                     "calls     0\n\t"   \
217
                     "mov       g0, %0\n\t" \
218
                     : "=r"(res) : "n"(__NR_##name)     \
219
                     : "g0", "g13", "memory");  \
220
        __SYSCALL_RETURN(res,type);     \
221
}
222
 
223
/* since these are all inline, the only code we explicitly need to write
224
 * puts them in the g-regs; if these were normal functions, we wouldn't even
225
 * need that */
226
#define _syscall0(type,name) \
227
type name(void) \
228
{       \
229
        __SYSCALL_BODY(type,name)       \
230
}
231
 
232
#define _syscall1(type,name,atype,a) \
233
type name(atype a)      \
234
{       \
235
        asm("mov        %0, g0" : :"l"(a):"g0");        \
236
        __SYSCALL_BODY(type,name)       \
237
}
238
 
239
#define _syscall2(type,name,atype,a,btype,b) \
240
type name(atype a, btype b)     \
241
{       \
242
        asm("mov        %0, g0\n\t"     \
243
            "mov        %1, g1\n\t"     \
244
            : :"l"(a), "l"(b) : "g0", "g1");    \
245
        __SYSCALL_BODY(type,name)       \
246
}
247
 
248
#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
249
type name(atype a, btype b, ctype c)    \
250
{       \
251
        asm("mov        %0, g0\n\t"     \
252
            "mov        %1, g1\n\t"     \
253
            "mov        %2, g2\n\t"     \
254
            : :"l"(a), "l"(b), "l"(c) : "g0", "g1", "g2");      \
255
        __SYSCALL_BODY(type,name)       \
256
}
257
 
258
#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
259
type name(atype a, btype b, ctype c, dtype d)   \
260
{       \
261
        asm("mov        %0, g0\n\t"     \
262
            "mov        %1, g1\n\t"     \
263
            "mov        %2, g2\n\t"     \
264
            "mov        %3, g3\n\t"     \
265
            : :"l"(a), "l"(b), "l"(c), "l"(d) : "g0", "g1", "g2", "g3");\
266
        __SYSCALL_BODY(type,name)       \
267
}
268
 
269
#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
270
type name(atype a, btype b, ctype c, dtype d, etype e)  \
271
{       \
272
        asm("mov        %0, g0\n\t"     \
273
            "mov        %1, g1\n\t"     \
274
            "mov        %2, g2\n\t"     \
275
            "mov        %3, g3\n\t"     \
276
            "mov        %4, g4\n\t"     \
277
            : :"l"(a), "l"(b), "l"(c), "l"(d), "l"(e)\
278
            : "g0", "g1", "g2", "g3", "g4");\
279
        __SYSCALL_BODY(type,name)       \
280
}
281
 
282
 
283
#define __NR__exit __NR_exit
284
#ifdef __KERNEL_SYSCALLS__
285
static inline _syscall0(int,idle)
286
static inline _syscall0(int,fork)
287
static inline _syscall2(int,clone,unsigned long,flags,char *,usp)
288
static inline _syscall0(int,pause)
289
static inline _syscall0(int,setup)
290
static inline _syscall0(int,sync)
291
static inline _syscall0(pid_t,setsid)
292
static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
293
static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
294
static inline _syscall1(int,dup,int,fd)
295
static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
296
static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
297
static inline _syscall1(int,close,int,fd)
298
static inline _syscall1(int,_exit,int,exitcode)
299
static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
300
 
301
static inline pid_t wait(int * wait_stat)
302
{
303
        return waitpid(-1,wait_stat,0);
304
}
305
 
306
static inline struct task_struct* pid_to_task(pid_t pid)
307
{
308
        int ii;
309
        struct task_struct *p = 0;
310
 
311
        for (ii=1; ii < NR_TASKS; ii++) {
312
                p = task[ii];
313
                if (p && p->pid == pid)
314
                        break;
315
        }
316
 
317
        return p;
318
}
319
/*
320
 * This is the mechanism for creating a new kernel thread.
321
 *
322
 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
323
 * who haven't done an "execve()") should use this: it will work within
324
 * a system call from a "real" process, but the process memory space will
325
 * not be free'd until both the parent and the child have exited.
326
 */
327
static inline pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
328
{
329
        pid_t childpid = 0;
330
        struct task_struct* child;
331
        struct frametop {
332
                unsigned long pfp;
333
                void*   sp;
334
                void*   rip;
335
                void*   r[13];  /* r3-15 */
336
        } *childframe;
337
 
338
        extern void kthread_trampoline(void);
339
        extern void stack_trace_from(unsigned long pfp);
340
 
341
#if 0
342
        printk("kernel_thread: ksp: 0x%8x\n", current->kernel_stack_page);
343
        printk("ipl: %d\n", get_ipl());
344
#endif
345
        childpid = do_fork(flags | CLONE_VM, 0, 0);
346
#if 0
347
        printk("after do_fork: ipl: %d\n", get_ipl());
348
#endif
349
 
350
        child = pid_to_task(childpid);
351
#if 0
352
        printk("kernel_thread: child stack: 0x%8x\n", child->kernel_stack_page);
353
#endif
354
        childframe = (struct frametop*) child->kernel_stack_page;
355
        childframe->pfp = 0;
356
        childframe->sp = childframe + 1;
357
#if 0
358
        printk("setting return to %p\n", fn);
359
#endif
360
        childframe->rip = kthread_trampoline;
361
        childframe->r[0] = fn;
362
        childframe->r[1] = arg;
363
        child->tss.pfp = (unsigned long) childframe;
364
 
365
#if 0
366
        printk("child stack trace:\n");
367
        stack_trace_from(child->tss.pfp);
368
 
369
        printk("returning %d\n", childpid);
370
#endif
371
        return childpid;
372
}
373
 
374
#endif  /* __KERNEL_SYSCALLS__ */
375
#endif  /* __ASSEMBLY__ */
376
 
377
#endif /* _ASM_I960_UNISTD_H_ */

powered by: WebSVN 2.1.0

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