1 /* MN10300 Weird system calls
3 * Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
11 #include <linux/errno.h>
12 #include <linux/sched.h>
13 #include <linux/syscalls.h>
15 #include <linux/smp.h>
16 #include <linux/sem.h>
17 #include <linux/msg.h>
18 #include <linux/shm.h>
19 #include <linux/stat.h>
20 #include <linux/mman.h>
21 #include <linux/file.h>
22 #include <linux/utsname.h>
23 #include <linux/syscalls.h>
24 #include <linux/tty.h>
26 #include <asm/uaccess.h>
28 #define MIN_MAP_ADDR PAGE_SIZE /* minimum fixed mmap address */
31 * memory mapping syscall
33 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
34 unsigned long prot, unsigned long flags,
35 unsigned long fd, unsigned long pgoff)
37 struct file *file = NULL;
40 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
42 if (flags & MAP_FIXED && addr < MIN_MAP_ADDR)
46 if (!(flags & MAP_ANONYMOUS)) {
52 down_write(¤t->mm->mmap_sem);
53 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
54 up_write(¤t->mm->mmap_sem);
62 asmlinkage long old_mmap(unsigned long addr, unsigned long len,
63 unsigned long prot, unsigned long flags,
64 unsigned long fd, unsigned long offset)
66 if (offset & ~PAGE_MASK)
68 return sys_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
71 struct sel_arg_struct {
79 asmlinkage int old_select(struct sel_arg_struct __user *arg)
81 struct sel_arg_struct a;
83 if (copy_from_user(&a, arg, sizeof(a)))
85 /* sys_select() does the appropriate kernel locking */
86 return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
90 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
92 * This is really horribly ugly.
94 asmlinkage long sys_ipc(uint call, int first, int second,
95 int third, void __user *ptr, long fifth)
99 version = call >> 16; /* hack for backward compatibility */
104 return sys_semtimedop(first, (struct sembuf __user *)ptr,
107 return sys_semtimedop(first, (struct sembuf __user *)ptr,
109 (const struct timespec __user *)fifth);
111 return sys_semget(first, second, third);
116 if (get_user(fourth.__pad, (void __user * __user *) ptr))
118 return sys_semctl(first, second, third, fourth);
122 return sys_msgsnd(first, (struct msgbuf __user *) ptr,
127 struct ipc_kludge tmp;
131 if (copy_from_user(&tmp,
132 (struct ipc_kludge __user *) ptr,
135 return sys_msgrcv(first, tmp.msgp, second,
139 return sys_msgrcv(first,
140 (struct msgbuf __user *) ptr,
141 second, fifth, third);
144 return sys_msgget((key_t) first, second);
146 return sys_msgctl(first, second,
147 (struct msqid_ds __user *) ptr);
153 ret = do_shmat(first, (char __user *) ptr, second,
157 return put_user(raddr, (ulong *) third);
159 case 1: /* iBCS2 emulator entry point */
160 if (!segment_eq(get_fs(), get_ds()))
162 return do_shmat(first, (char __user *) ptr, second,
166 return sys_shmdt((char __user *)ptr);
168 return sys_shmget(first, second, third);
170 return sys_shmctl(first, second,
171 (struct shmid_ds __user *) ptr);