aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m32r/kernel/sys_m32r.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/m32r/kernel/sys_m32r.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/m32r/kernel/sys_m32r.c')
-rw-r--r--arch/m32r/kernel/sys_m32r.c217
1 files changed, 217 insertions, 0 deletions
diff --git a/arch/m32r/kernel/sys_m32r.c b/arch/m32r/kernel/sys_m32r.c
new file mode 100644
index 000000000000..e0500e12c5fb
--- /dev/null
+++ b/arch/m32r/kernel/sys_m32r.c
@@ -0,0 +1,217 @@
1/*
2 * linux/arch/m32r/kernel/sys_m32r.c
3 *
4 * This file contains various random system calls that
5 * have a non-standard calling sequence on the Linux/M32R platform.
6 *
7 * Taken from i386 version.
8 */
9
10#include <linux/config.h>
11#include <linux/errno.h>
12#include <linux/sched.h>
13#include <linux/mm.h>
14#include <linux/smp.h>
15#include <linux/smp_lock.h>
16#include <linux/sem.h>
17#include <linux/msg.h>
18#include <linux/shm.h>
19#include <linux/stat.h>
20#include <linux/syscalls.h>
21#include <linux/mman.h>
22#include <linux/file.h>
23#include <linux/utsname.h>
24
25#include <asm/uaccess.h>
26#include <asm/cachectl.h>
27#include <asm/cacheflush.h>
28#include <asm/ipc.h>
29
30/*
31 * sys_tas() - test-and-set
32 * linuxthreads testing version
33 */
34#ifndef CONFIG_SMP
35asmlinkage int sys_tas(int *addr)
36{
37 int oldval;
38 unsigned long flags;
39
40 if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
41 return -EFAULT;
42 local_irq_save(flags);
43 oldval = *addr;
44 *addr = 1;
45 local_irq_restore(flags);
46 return oldval;
47}
48#else /* CONFIG_SMP */
49#include <linux/spinlock.h>
50
51static DEFINE_SPINLOCK(tas_lock);
52
53asmlinkage int sys_tas(int *addr)
54{
55 int oldval;
56
57 if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
58 return -EFAULT;
59
60 _raw_spin_lock(&tas_lock);
61 oldval = *addr;
62 *addr = 1;
63 _raw_spin_unlock(&tas_lock);
64
65 return oldval;
66}
67#endif /* CONFIG_SMP */
68
69/*
70 * sys_pipe() is the normal C calling standard for creating
71 * a pipe. It's not the way Unix traditionally does this, though.
72 */
73asmlinkage int
74sys_pipe(unsigned long r0, unsigned long r1, unsigned long r2,
75 unsigned long r3, unsigned long r4, unsigned long r5,
76 unsigned long r6, struct pt_regs regs)
77{
78 int fd[2];
79 int error;
80
81 error = do_pipe(fd);
82 if (!error) {
83 if (copy_to_user((void *)r0, (void *)fd, 2*sizeof(int)))
84 error = -EFAULT;
85 }
86 return error;
87}
88
89asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
90 unsigned long prot, unsigned long flags,
91 unsigned long fd, unsigned long pgoff)
92{
93 int error = -EBADF;
94 struct file *file = NULL;
95
96 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
97 if (!(flags & MAP_ANONYMOUS)) {
98 file = fget(fd);
99 if (!file)
100 goto out;
101 }
102
103 down_write(&current->mm->mmap_sem);
104 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
105 up_write(&current->mm->mmap_sem);
106
107 if (file)
108 fput(file);
109out:
110 return error;
111}
112
113/*
114 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
115 *
116 * This is really horribly ugly.
117 */
118asmlinkage int sys_ipc(uint call, int first, int second,
119 int third, void __user *ptr, long fifth)
120{
121 int version, ret;
122
123 version = call >> 16; /* hack for backward compatibility */
124 call &= 0xffff;
125
126 switch (call) {
127 case SEMOP:
128 return sys_semtimedop(first, (struct sembuf __user *)ptr,
129 second, NULL);
130 case SEMTIMEDOP:
131 return sys_semtimedop(first, (struct sembuf __user *)ptr,
132 second, (const struct timespec __user *)fifth);
133 case SEMGET:
134 return sys_semget (first, second, third);
135 case SEMCTL: {
136 union semun fourth;
137 if (!ptr)
138 return -EINVAL;
139 if (get_user(fourth.__pad, (void __user * __user *) ptr))
140 return -EFAULT;
141 return sys_semctl (first, second, third, fourth);
142 }
143
144 case MSGSND:
145 return sys_msgsnd (first, (struct msgbuf __user *) ptr,
146 second, third);
147 case MSGRCV:
148 switch (version) {
149 case 0: {
150 struct ipc_kludge tmp;
151 if (!ptr)
152 return -EINVAL;
153
154 if (copy_from_user(&tmp,
155 (struct ipc_kludge __user *) ptr,
156 sizeof (tmp)))
157 return -EFAULT;
158 return sys_msgrcv (first, tmp.msgp, second,
159 tmp.msgtyp, third);
160 }
161 default:
162 return sys_msgrcv (first,
163 (struct msgbuf __user *) ptr,
164 second, fifth, third);
165 }
166 case MSGGET:
167 return sys_msgget ((key_t) first, second);
168 case MSGCTL:
169 return sys_msgctl (first, second,
170 (struct msqid_ds __user *) ptr);
171 case SHMAT: {
172 ulong raddr;
173
174 if (!access_ok(VERIFY_WRITE, (ulong __user *) third,
175 sizeof(ulong)))
176 return -EFAULT;
177 ret = do_shmat (first, (char __user *) ptr, second, &raddr);
178 if (ret)
179 return ret;
180 return put_user (raddr, (ulong __user *) third);
181 }
182 case SHMDT:
183 return sys_shmdt ((char __user *)ptr);
184 case SHMGET:
185 return sys_shmget (first, second, third);
186 case SHMCTL:
187 return sys_shmctl (first, second,
188 (struct shmid_ds __user *) ptr);
189 default:
190 return -ENOSYS;
191 }
192}
193
194asmlinkage int sys_uname(struct old_utsname * name)
195{
196 int err;
197 if (!name)
198 return -EFAULT;
199 down_read(&uts_sem);
200 err=copy_to_user(name, &system_utsname, sizeof (*name));
201 up_read(&uts_sem);
202 return err?-EFAULT:0;
203}
204
205asmlinkage int sys_cacheflush(void *addr, int bytes, int cache)
206{
207 /* This should flush more selectivly ... */
208 _flush_cache_all();
209 return 0;
210}
211
212asmlinkage int sys_cachectl(char *addr, int nbytes, int op)
213{
214 /* Not implemented yet. */
215 return -ENOSYS;
216}
217