[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / m32r / kernel / sys_m32r.c
blobe0500e12c5fbbb934c7debc9dc84dd1d7d1300dc
1 /*
2 * linux/arch/m32r/kernel/sys_m32r.c
4 * This file contains various random system calls that
5 * have a non-standard calling sequence on the Linux/M32R platform.
7 * Taken from i386 version.
8 */
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>
25 #include <asm/uaccess.h>
26 #include <asm/cachectl.h>
27 #include <asm/cacheflush.h>
28 #include <asm/ipc.h>
31 * sys_tas() - test-and-set
32 * linuxthreads testing version
34 #ifndef CONFIG_SMP
35 asmlinkage int sys_tas(int *addr)
37 int oldval;
38 unsigned long flags;
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;
48 #else /* CONFIG_SMP */
49 #include <linux/spinlock.h>
51 static DEFINE_SPINLOCK(tas_lock);
53 asmlinkage int sys_tas(int *addr)
55 int oldval;
57 if (!access_ok(VERIFY_WRITE, addr, sizeof (int)))
58 return -EFAULT;
60 _raw_spin_lock(&tas_lock);
61 oldval = *addr;
62 *addr = 1;
63 _raw_spin_unlock(&tas_lock);
65 return oldval;
67 #endif /* CONFIG_SMP */
70 * sys_pipe() is the normal C calling standard for creating
71 * a pipe. It's not the way Unix traditionally does this, though.
73 asmlinkage int
74 sys_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)
78 int fd[2];
79 int error;
81 error = do_pipe(fd);
82 if (!error) {
83 if (copy_to_user((void *)r0, (void *)fd, 2*sizeof(int)))
84 error = -EFAULT;
86 return error;
89 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
90 unsigned long prot, unsigned long flags,
91 unsigned long fd, unsigned long pgoff)
93 int error = -EBADF;
94 struct file *file = NULL;
96 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
97 if (!(flags & MAP_ANONYMOUS)) {
98 file = fget(fd);
99 if (!file)
100 goto out;
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);
107 if (file)
108 fput(file);
109 out:
110 return error;
114 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
116 * This is really horribly ugly.
118 asmlinkage int sys_ipc(uint call, int first, int second,
119 int third, void __user *ptr, long fifth)
121 int version, ret;
123 version = call >> 16; /* hack for backward compatibility */
124 call &= 0xffff;
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);
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;
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);
161 default:
162 return sys_msgrcv (first,
163 (struct msgbuf __user *) ptr,
164 second, fifth, third);
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;
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);
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;
194 asmlinkage int sys_uname(struct old_utsname * name)
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;
205 asmlinkage int sys_cacheflush(void *addr, int bytes, int cache)
207 /* This should flush more selectivly ... */
208 _flush_cache_all();
209 return 0;
212 asmlinkage int sys_cachectl(char *addr, int nbytes, int op)
214 /* Not implemented yet. */
215 return -ENOSYS;