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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [or32/] [kernel/] [sys_or32.c] - Blame information for rev 1275

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

Line No. Rev Author Line
1 1275 phoenix
/*
2
 *  linux/arch/or32/kernel/sys_or32.c
3
 *
4
 *  or32 version
5
 *    author(s): Matjaz Breskvar (phoenix@opencores.org)
6
 *
7
 *  derived from cris, i386, m68k, ppc, sh ports.
8
 *
9
 *  changes:
10
 *  18. 11. 2003: Matjaz Breskvar (phoenix@opencores.org)
11
 *    initial port to or32 architecture
12
 *
13
 * based on: linux/arch/cris/kernel/sys_cris.c
14
 *
15
 * This file contains various random system calls that
16
 * have a non-standard calling sequence on some platforms.
17
 * Since we don't have to do any backwards compatibility, our
18
 * versions are done in the most "normal" way possible.
19
 *
20
 */
21
 
22
#include <linux/errno.h>
23
#include <linux/sched.h>
24
#include <linux/mm.h>
25
#include <linux/smp.h>
26
#include <linux/smp_lock.h>
27
#include <linux/sem.h>
28
#include <linux/msg.h>
29
#include <linux/shm.h>
30
#include <linux/stat.h>
31
#include <linux/mman.h>
32
#include <linux/file.h>
33
 
34
#include <asm/uaccess.h>
35
#include <asm/ipc.h>
36
#include <asm/segment.h>
37
 
38
/*
39
 * sys_pipe() is the normal C calling standard for creating
40
 * a pipe. It's not the way Unix traditionally does this, though.
41
 */
42
asmlinkage int sys_pipe(unsigned long * fildes)
43
{
44
        int fd[2];
45
        int error;
46
 
47
        lock_kernel();
48
        error = do_pipe(fd);
49
        unlock_kernel();
50
        if (!error) {
51
                if (copy_to_user(fildes, fd, 2*sizeof(int)))
52
                        error = -EFAULT;
53
        }
54
        return error;
55
}
56
 
57
/* common code for old and new mmaps */
58
static inline long
59
do_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
60
        unsigned long flags, unsigned long fd, unsigned long pgoff)
61
{
62
        int error = -EBADF;
63
        struct file * file = NULL;
64
 
65
        flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
66
        if (!(flags & MAP_ANONYMOUS)) {
67
                file = fget(fd);
68
                if (!file)
69
                        goto out;
70
        }
71
 
72
        down_write(&current->mm->mmap_sem);
73
        error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
74
        up_write(&current->mm->mmap_sem);
75
 
76
        if (file)
77
                fput(file);
78
out:
79
        return error;
80
}
81
 
82
asmlinkage unsigned long old_mmap(unsigned long *args)
83
{
84
        unsigned long buffer[6];
85
        int err = -EFAULT;
86
 
87
        if (copy_from_user(&buffer, args, sizeof(buffer)))
88
                goto out;
89
 
90
        err = -EINVAL;
91
        if (buffer[5] & ~PAGE_MASK) /* verify that offset is on page boundary */
92
                goto out;
93
 
94
        err = do_mmap2(buffer[0], buffer[1], buffer[2], buffer[3],
95
                       buffer[4], buffer[5] >> PAGE_SHIFT);
96
out:
97
        return err;
98
}
99
 
100
asmlinkage long
101
sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
102
          unsigned long flags, unsigned long fd, unsigned long pgoff)
103
{
104
        return do_mmap2(addr, len, prot, flags, fd, pgoff);
105
}
106
 
107
/*
108
 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
109
 *
110
 * This is really horribly ugly. (same as arch/i386)
111
 */
112
 
113
asmlinkage int sys_ipc (uint call, int first, int second,
114
                        int third, void *ptr, long fifth)
115
{
116
        int version, ret;
117
 
118
        version = call >> 16; /* hack for backward compatibility */
119
        call &= 0xffff;
120
 
121
        switch (call) {
122
        case SEMOP:
123
                return sys_semop (first, (struct sembuf *)ptr, second);
124
        case SEMGET:
125
                return sys_semget (first, second, third);
126
        case SEMCTL: {
127
                union semun fourth;
128
                if (!ptr)
129
                        return -EINVAL;
130
                if (get_user(fourth.__pad, (void **) ptr))
131
                        return -EFAULT;
132
                return sys_semctl (first, second, third, fourth);
133
        }
134
 
135
        case MSGSND:
136
                return sys_msgsnd (first, (struct msgbuf *) ptr,
137
                                   second, third);
138
        case MSGRCV:
139
                switch (version) {
140
                case 0: {
141
                        struct ipc_kludge tmp;
142
                        if (!ptr)
143
                                return -EINVAL;
144
 
145
                        if (copy_from_user(&tmp,
146
                                           (struct ipc_kludge *) ptr,
147
                                           sizeof (tmp)))
148
                                return -EFAULT;
149
                        return sys_msgrcv (first, tmp.msgp, second,
150
                                           tmp.msgtyp, third);
151
                }
152
                default:
153
                        return sys_msgrcv (first,
154
                                           (struct msgbuf *) ptr,
155
                                           second, fifth, third);
156
                }
157
        case MSGGET:
158
                return sys_msgget ((key_t) first, second);
159
        case MSGCTL:
160
                return sys_msgctl (first, second, (struct msqid_ds *) ptr);
161
 
162
        case SHMAT: {
163
                ulong raddr;
164
                ret = sys_shmat (first, (char *) ptr, second, &raddr);
165
                if (ret)
166
                        return ret;
167
                return put_user (raddr, (ulong *) third);
168
        }
169
        case SHMDT:
170
                return sys_shmdt ((char *)ptr);
171
        case SHMGET:
172
                return sys_shmget (first, second, third);
173
        case SHMCTL:
174
                return sys_shmctl (first, second,
175
                                   (struct shmid_ds *) ptr);
176
        default:
177
                return -EINVAL;
178
        }
179
}
180
 
181
/* apparently this is legacy - if we don't need this in Linux/CRIS we can remove it. */
182
 
183
asmlinkage int sys_pause(void)
184
{
185
        current->state = TASK_INTERRUPTIBLE;
186
        schedule();
187
        return -ERESTARTNOHAND;
188
}

powered by: WebSVN 2.1.0

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