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;
51 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
53 * This is really horribly ugly.
56 sys_ipc (uint call, int first, unsigned long second, long third,
57 void __user *ptr, long fifth)
61 version = call >> 16; /* hack for backward compatibility */
67 ret = sys_semtimedop(first, (struct sembuf __user *)ptr,
68 (unsigned)second, NULL);
71 ret = sys_semtimedop(first, (struct sembuf __user *)ptr,
73 (const struct timespec __user *) fifth);
76 ret = sys_semget (first, (int)second, third);
84 if ((ret = get_user(fourth.__pad, (void __user * __user *)ptr)))
86 ret = sys_semctl(first, (int)second, third, fourth);
90 ret = sys_msgsnd(first, (struct msgbuf __user *)ptr,
91 (size_t)second, third);
96 struct ipc_kludge tmp;
101 if ((ret = copy_from_user(&tmp,
102 (struct ipc_kludge __user *) ptr,
103 sizeof (tmp)) ? -EFAULT : 0))
105 ret = sys_msgrcv(first, tmp.msgp, (size_t) second,
110 ret = sys_msgrcv (first, (struct msgbuf __user *) ptr,
111 (size_t)second, fifth, third);
116 ret = sys_msgget ((key_t)first, (int)second);
119 ret = sys_msgctl(first, (int)second,
120 (struct msqid_ds __user *)ptr);
126 ret = do_shmat(first, (char __user *) ptr,
127 (int)second, &raddr);
130 ret = put_user (raddr, (ulong __user *) third);
133 case 1: /* iBCS2 emulator entry point */
135 if (!segment_eq(get_fs(), get_ds()))
137 ret = do_shmat(first, (char __user *)ptr,
138 (int)second, (ulong *)third);
143 ret = sys_shmdt ((char __user *)ptr);
146 ret = sys_shmget (first, (size_t)second, third);
149 ret = sys_shmctl(first, (int)second,
150 (struct shmid_ds __user *)ptr);
158 * sys_pipe() is the normal C calling standard for creating
159 * a pipe. It's not the way unix traditionally does this, though.
161 asmlinkage int sys_pipe(int __user *fildes)
168 if (copy_to_user(fildes, fd, 2*sizeof(int)))
175 unsigned long sys_mmap(unsigned long addr, size_t len,
176 unsigned long prot, unsigned long flags,
177 unsigned long fd, off_t offset)
179 struct file * file = NULL;
180 unsigned long ret = -EBADF;
182 if (!(flags & MAP_ANONYMOUS)) {
183 if (!(file = fget(fd)))
187 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
188 down_write(¤t->mm->mmap_sem);
189 ret = do_mmap(file, addr, len, prot, flags, offset);
190 up_write(¤t->mm->mmap_sem);
198 long ppc64_personality(unsigned long personality)
202 if (personality(current->personality) == PER_LINUX32
203 && personality == PER_LINUX)
204 personality = PER_LINUX32;
205 ret = sys_personality(personality);
206 if (ret == PER_LINUX32)
211 long ppc64_newuname(struct new_utsname __user * name)
216 if (copy_to_user(name, &system_utsname, sizeof(*name)))
219 if (!err && personality(current->personality) == PER_LINUX32) {
220 /* change ppc64 to ppc */
221 if (__put_user(0, name->machine + 3)
222 || __put_user(0, name->machine + 4))
228 asmlinkage time_t sys64_time(time_t __user * tloc)
233 long tb_delta = tb_ticks_since(tb_last_stamp);
234 tb_delta += (jiffies - wall_jiffies) * tb_ticks_per_jiffy;
237 usecs = (xtime.tv_nsec/1000) + tb_delta / tb_ticks_per_usec;
238 while (usecs >= USEC_PER_SEC) {
240 usecs -= USEC_PER_SEC;
244 if (put_user(secs,tloc))
251 void do_show_syscall(unsigned long r3, unsigned long r4, unsigned long r5,
252 unsigned long r6, unsigned long r7, unsigned long r8,
253 struct pt_regs *regs)
255 printk("syscall %ld(%lx, %lx, %lx, %lx, %lx, %lx) regs=%p current=%p"
256 " cpu=%d\n", regs->gpr[0], r3, r4, r5, r6, r7, r8, regs,
257 current, smp_processor_id());
260 void do_show_syscall_exit(unsigned long r3)
262 printk(" -> %lx, current=%p cpu=%d\n", r3, current, smp_processor_id());