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

Subversion Repositories or1k

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

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

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

powered by: WebSVN 2.1.0

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