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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [linux-2.6/] [linux-2.6.24/] [arch/] [or32/] [kernel/] [sys_or32.c] - Blame information for rev 7

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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