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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [or32/] [kernel/] [syscalls.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1624 jcastillo
/*
2
 * linux/arch/or32/kernel/syscalls.c
3
 *
4
 * Based on:
5
 *
6
 * linux/arch/m68knommu/kernel/sys_m68k.c
7
 *
8
 * This file contains various random system calls that
9
 * have a non-standard calling sequence on the Linux/or32
10
 * platform.
11
 */
12
 
13
#include <linux/errno.h>
14
#include <linux/sched.h>
15
#include <linux/mm.h>
16
#include <linux/sem.h>
17
#include <linux/msg.h>
18
#include <linux/shm.h>
19
#include <linux/stat.h>
20
#include <linux/mman.h>
21
 
22
#include <asm/segment.h>
23
#include <asm/traps.h>
24
 
25
/*
26
 * sys_pipe() is the normal C calling standard for creating
27
 * a pipe. It's not the way unix traditionally does this, though.
28
 */
29
asmlinkage int sys_pipe(unsigned long * fildes)
30
{
31
        int fd[2];
32
        int error;
33
 
34
        error = verify_area(VERIFY_WRITE,fildes,8);
35
        if (error)
36
                return error;
37
        error = do_pipe(fd);
38
        if (error)
39
                return error;
40
        put_user(fd[0],0+fildes);
41
        put_user(fd[1],1+fildes);
42
        return 0;
43
}
44
 
45
/*
46
 * Perform the select(nd, in, out, ex, tv) and mmap() system
47
 * calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
48
 * handle more than 4 system call parameters, so these system calls
49
 * used a memory block for parameter passing..
50
 */
51
 
52
asmlinkage int old_mmap(unsigned long *buffer)
53
{
54
        int error;
55
        unsigned long flags;
56
        struct file * file = NULL;
57
 
58
        error = verify_area(VERIFY_READ, buffer, 6*sizeof(long));
59
        if (error)
60
                return error;
61
        flags = get_user(buffer+3);
62
        if (!(flags & MAP_ANONYMOUS)) {
63
                unsigned long fd = get_user(buffer+4);
64
                if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
65
                        return -EBADF;
66
        }
67
        flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
68
        return do_mmap(file, get_user(buffer), get_user(buffer+1),
69
                       get_user(buffer+2), flags, get_user(buffer+5));
70
}
71
 
72
 
73
extern asmlinkage int sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
74
 
75
asmlinkage int old_select(unsigned long *buffer)
76
{
77
        int n;
78
        fd_set *inp;
79
        fd_set *outp;
80
        fd_set *exp;
81
        struct timeval *tvp;
82
 
83
        n = verify_area(VERIFY_READ, buffer, 5*sizeof(unsigned long));
84
        if (n)
85
          return n;
86
 
87
        n = get_user(buffer);
88
        inp = (fd_set *) get_user(buffer+1);
89
        outp = (fd_set *) get_user(buffer+2);
90
        exp = (fd_set *) get_user(buffer+3);
91
        tvp = (struct timeval *) get_user(buffer+4);
92
        return sys_select(n, inp, outp, exp, tvp);
93
}
94
 
95
/*
96
 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
97
 *
98
 * This is really horribly ugly.
99
 */
100
asmlinkage int sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth)
101
{
102
        int version;
103
 
104
        version = call >> 16; /* hack for backward compatibility */
105
        call &= 0xffff;
106
 
107
        if (call <= SEMCTL)
108
                switch (call) {
109
                case SEMOP:
110
                        return sys_semop (first, (struct sembuf *)ptr, second);
111
                case SEMGET:
112
                        return sys_semget (first, second, third);
113
                case SEMCTL: {
114
                        union semun fourth;
115
                        int err;
116
                        if (!ptr)
117
                                return -EINVAL;
118
                        if ((err = verify_area (VERIFY_READ, ptr, sizeof(long))))
119
                                return err;
120
                        fourth.__pad = get_user((void **)ptr);
121
                        return sys_semctl (first, second, third, fourth);
122
                        }
123
                default:
124
                        return -EINVAL;
125
                }
126
        if (call <= MSGCTL)
127
                switch (call) {
128
                case MSGSND:
129
                        return sys_msgsnd (first, (struct msgbuf *) ptr,
130
                                           second, third);
131
                case MSGRCV:
132
                        switch (version) {
133
                        case 0: {
134
                                struct ipc_kludge tmp;
135
                                int err;
136
                                if (!ptr)
137
                                        return -EINVAL;
138
                                if ((err = verify_area (VERIFY_READ, ptr, sizeof(tmp))))
139
                                        return err;
140
                                memcpy_fromfs (&tmp,(struct ipc_kludge *) ptr,
141
                                               sizeof (tmp));
142
                                return sys_msgrcv (first, tmp.msgp, second, tmp.msgtyp, third);
143
                                }
144
                        case 1: default:
145
                                return sys_msgrcv (first, (struct msgbuf *) ptr, second, fifth, third);
146
                        }
147
                case MSGGET:
148
                        return sys_msgget ((key_t) first, second);
149
                case MSGCTL:
150
                        return sys_msgctl (first, second, (struct msqid_ds *) ptr);
151
                default:
152
                        return -EINVAL;
153
                }
154
        if (call <= SHMCTL)
155
                switch (call) {
156
                case SHMAT:
157
                        switch (version) {
158
                        case 0: default: {
159
                                ulong raddr;
160
                                int err;
161
                                if ((err = verify_area(VERIFY_WRITE, (ulong*) third, sizeof(ulong))))
162
                                        return err;
163
                                err = sys_shmat (first, (char *) ptr, second, &raddr);
164
                                if (err)
165
                                        return err;
166
                                put_user (raddr, (ulong *) third);
167
                                return 0;
168
                                }
169
                        case 1: /* iBCS2 emulator entry point */
170
                                if (get_fs() != get_ds())
171
                                        return -EINVAL;
172
                                return sys_shmat (first, (char *) ptr, second, (ulong *) third);
173
                        }
174
                case SHMDT:
175
                        return sys_shmdt ((char *)ptr);
176
                case SHMGET:
177
                        return sys_shmget (first, second, third);
178
                case SHMCTL:
179
                        return sys_shmctl (first, second, (struct shmid_ds *) ptr);
180
                default:
181
                        return -EINVAL;
182
                }
183
        return -EINVAL;
184
}
185
 
186
asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on)
187
{
188
  return -ENOSYS;
189
}
190
 
191
/* sys_cacheflush -- flush (part of) the processor cache.  */
192
asmlinkage int
193
sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
194
{
195
        return 0;
196
}

powered by: WebSVN 2.1.0

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