2 * linux/arch/ppc64/kernel/sys_ppc.c
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
7 * Derived from "arch/i386/kernel/sys_i386.c"
8 * Adapted from the i386 version by Gary Thomas
9 * Modified by Cort Dougan (cort@cs.nmt.edu)
10 * and Paul Mackerras (paulus@cs.anu.edu.au).
12 * This file contains various random system calls that
13 * have a non-standard calling sequence on the Linux/PPC
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version
19 * 2 of the License, or (at your option) any later version.
23 #include <linux/errno.h>
24 #include <linux/sched.h>
25 #include <linux/syscalls.h>
27 #include <linux/smp.h>
28 #include <linux/smp_lock.h>
29 #include <linux/sem.h>
30 #include <linux/msg.h>
31 #include <linux/shm.h>
32 #include <linux/stat.h>
33 #include <linux/mman.h>
34 #include <linux/sys.h>
35 #include <linux/ipc.h>
36 #include <linux/utsname.h>
37 #include <linux/file.h>
38 #include <linux/init.h>
39 #include <linux/personality.h>
41 #include <asm/uaccess.h>
43 #include <asm/semaphore.h>
45 #include <asm/unistd.h>
47 extern unsigned long wall_jiffies;
55 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
57 * This is really horribly ugly.
60 sys_ipc (uint call, int first, unsigned long second, long third,
61 void __user *ptr, long fifth)
65 version = call >> 16; /* hack for backward compatibility */
71 ret = sys_semtimedop(first, (struct sembuf __user *)ptr,
72 (unsigned)second, NULL);
75 ret = sys_semtimedop(first, (struct sembuf __user *)ptr,
77 (const struct timespec __user *) fifth);
80 ret = sys_semget (first, (int)second, third);
88 if ((ret = get_user(fourth.__pad, (void __user * __user *)ptr)))
90 ret = sys_semctl(first, (int)second, third, fourth);
94 ret = sys_msgsnd(first, (struct msgbuf __user *)ptr,
95 (size_t)second, third);
100 struct ipc_kludge tmp;
105 if ((ret = copy_from_user(&tmp,
106 (struct ipc_kludge __user *) ptr,
107 sizeof (tmp)) ? -EFAULT : 0))
109 ret = sys_msgrcv(first, tmp.msgp, (size_t) second,
114 ret = sys_msgrcv (first, (struct msgbuf __user *) ptr,
115 (size_t)second, fifth, third);
120 ret = sys_msgget ((key_t)first, (int)second);
123 ret = sys_msgctl(first, (int)second,
124 (struct msqid_ds __user *)ptr);
130 ret = do_shmat(first, (char __user *) ptr,
131 (int)second, &raddr);
134 ret = put_user (raddr, (ulong __user *) third);
137 case 1: /* iBCS2 emulator entry point */
139 if (!segment_eq(get_fs(), get_ds()))
141 ret = do_shmat(first, (char __user *)ptr,
142 (int)second, (ulong *)third);
147 ret = sys_shmdt ((char __user *)ptr);
150 ret = sys_shmget (first, (size_t)second, third);
153 ret = sys_shmctl(first, (int)second,
154 (struct shmid_ds __user *)ptr);
162 * sys_pipe() is the normal C calling standard for creating
163 * a pipe. It's not the way unix traditionally does this, though.
165 asmlinkage int sys_pipe(int __user *fildes)
172 if (copy_to_user(fildes, fd, 2*sizeof(int)))
179 unsigned long sys_mmap(unsigned long addr, size_t len,
180 unsigned long prot, unsigned long flags,
181 unsigned long fd, off_t offset)
183 struct file * file = NULL;
184 unsigned long ret = -EBADF;
186 if (!(flags & MAP_ANONYMOUS)) {
187 if (!(file = fget(fd)))
191 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
192 down_write(¤t->mm->mmap_sem);
193 ret = do_mmap(file, addr, len, prot, flags, offset);
194 up_write(¤t->mm->mmap_sem);
202 long ppc64_personality(unsigned long personality)
206 if (personality(current->personality) == PER_LINUX32
207 && personality == PER_LINUX)
208 personality = PER_LINUX32;
209 ret = sys_personality(personality);
210 if (ret == PER_LINUX32)
215 long ppc64_newuname(struct new_utsname __user * name)
220 if (copy_to_user(name, &system_utsname, sizeof(*name)))
223 if (!err && personality(current->personality) == PER_LINUX32) {
224 /* change ppc64 to ppc */
225 if (__put_user(0, name->machine + 3)
226 || __put_user(0, name->machine + 4))
232 asmlinkage time_t sys64_time(time_t __user * tloc)
237 long tb_delta = tb_ticks_since(tb_last_stamp);
238 tb_delta += (jiffies - wall_jiffies) * tb_ticks_per_jiffy;
241 usecs = (xtime.tv_nsec/1000) + tb_delta / tb_ticks_per_usec;
242 while (usecs >= USEC_PER_SEC) {
244 usecs -= USEC_PER_SEC;
248 if (put_user(secs,tloc))
255 void do_show_syscall(unsigned long r3, unsigned long r4, unsigned long r5,
256 unsigned long r6, unsigned long r7, unsigned long r8,
257 struct pt_regs *regs)
259 printk("syscall %ld(%lx, %lx, %lx, %lx, %lx, %lx) regs=%p current=%p"
260 " cpu=%d\n", regs->gpr[0], r3, r4, r5, r6, r7, r8, regs,
261 current, smp_processor_id());
264 void do_show_syscall_exit(unsigned long r3)
266 printk(" -> %lx, current=%p cpu=%d\n", r3, current, smp_processor_id());