2 * linux/arch/sh/kernel/sys_sh.c
4 * This file contains various random system calls that
5 * have a non-standard calling sequence on the Linux/SuperH
8 * Taken from i386 version.
10 #include <linux/errno.h>
11 #include <linux/sched.h>
13 #include <linux/smp.h>
14 #include <linux/sem.h>
15 #include <linux/msg.h>
16 #include <linux/shm.h>
17 #include <linux/stat.h>
18 #include <linux/syscalls.h>
19 #include <linux/mman.h>
20 #include <linux/file.h>
21 #include <linux/utsname.h>
22 #include <linux/module.h>
24 #include <linux/ipc.h>
25 #include <asm/syscalls.h>
26 #include <asm/uaccess.h>
27 #include <asm/unistd.h>
28 #include <asm/cacheflush.h>
29 #include <asm/cachectl.h>
31 asmlinkage int old_mmap(unsigned long addr, unsigned long len,
32 unsigned long prot, unsigned long flags,
33 int fd, unsigned long off)
37 return sys_mmap_pgoff(addr, len, prot, flags, fd, off>>PAGE_SHIFT);
40 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
41 unsigned long prot, unsigned long flags,
42 unsigned long fd, unsigned long pgoff)
45 * The shift for mmap2 is constant, regardless of PAGE_SIZE
48 if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1))
51 pgoff >>= PAGE_SHIFT - 12;
53 return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
57 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
59 * This is really horribly ugly.
61 asmlinkage int sys_ipc(uint call, int first, int second,
62 int third, void __user *ptr, long fifth)
66 version = call >> 16; /* hack for backward compatibility */
69 if (call <= SEMTIMEDOP)
72 return sys_semtimedop(first,
73 (struct sembuf __user *)ptr,
76 return sys_semtimedop(first,
77 (struct sembuf __user *)ptr, second,
78 (const struct timespec __user *)fifth);
80 return sys_semget (first, second, third);
85 if (get_user(fourth.__pad, (void __user * __user *) ptr))
87 return sys_semctl (first, second, third, fourth);
96 return sys_msgsnd (first, (struct msgbuf __user *) ptr,
102 struct ipc_kludge tmp;
107 if (copy_from_user(&tmp,
108 (struct ipc_kludge __user *) ptr,
112 return sys_msgrcv (first, tmp.msgp, second,
116 return sys_msgrcv (first,
117 (struct msgbuf __user *) ptr,
118 second, fifth, third);
121 return sys_msgget ((key_t) first, second);
123 return sys_msgctl (first, second,
124 (struct msqid_ds __user *) ptr);
134 ret = do_shmat (first, (char __user *) ptr,
138 return put_user (raddr, (ulong __user *) third);
140 case 1: /* iBCS2 emulator entry point */
141 if (!segment_eq(get_fs(), get_ds()))
143 return do_shmat (first, (char __user *) ptr,
144 second, (ulong *) third);
147 return sys_shmdt ((char __user *)ptr);
149 return sys_shmget (first, second, third);
151 return sys_shmctl (first, second,
152 (struct shmid_ds __user *) ptr);
160 /* sys_cacheflush -- flush (part of) the processor cache. */
161 asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op)
163 struct vm_area_struct *vma;
165 if ((op <= 0) || (op > (CACHEFLUSH_D_PURGE|CACHEFLUSH_I)))
169 * Verify that the specified address region actually belongs
172 if (addr + len < addr)
175 down_read(¤t->mm->mmap_sem);
176 vma = find_vma (current->mm, addr);
177 if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end) {
178 up_read(¤t->mm->mmap_sem);
182 switch (op & CACHEFLUSH_D_PURGE) {
183 case CACHEFLUSH_D_INVAL:
184 __flush_invalidate_region((void *)addr, len);
186 case CACHEFLUSH_D_WB:
187 __flush_wback_region((void *)addr, len);
189 case CACHEFLUSH_D_PURGE:
190 __flush_purge_region((void *)addr, len);
194 if (op & CACHEFLUSH_I)
197 up_read(¤t->mm->mmap_sem);
201 asmlinkage int sys_uname(struct old_utsname __user *name)
207 err = copy_to_user(name, utsname(), sizeof(*name));
209 return err?-EFAULT:0;