1fc4fb2adSChris Zankel /* 2fc4fb2adSChris Zankel * arch/xtensa/kernel/syscall.c 3fc4fb2adSChris Zankel * 4fc4fb2adSChris Zankel * This file is subject to the terms and conditions of the GNU General Public 5fc4fb2adSChris Zankel * License. See the file "COPYING" in the main directory of this archive 6fc4fb2adSChris Zankel * for more details. 7fc4fb2adSChris Zankel * 8fc4fb2adSChris Zankel * Copyright (C) 2001 - 2005 Tensilica Inc. 9fc4fb2adSChris Zankel * Copyright (C) 2000 Silicon Graphics, Inc. 10fc4fb2adSChris Zankel * Copyright (C) 1995 - 2000 by Ralf Baechle 11fc4fb2adSChris Zankel * 12fc4fb2adSChris Zankel * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com> 13fc4fb2adSChris Zankel * Marc Gauthier <marc@tensilica.com, marc@alumni.uwaterloo.ca> 14fc4fb2adSChris Zankel * Chris Zankel <chris@zankel.net> 15fc4fb2adSChris Zankel * Kevin Chea 16fc4fb2adSChris Zankel * 17fc4fb2adSChris Zankel */ 18fc4fb2adSChris Zankel #include <asm/uaccess.h> 191c0350bdSChris Zankel #include <asm/syscall.h> 20fc4fb2adSChris Zankel #include <asm/unistd.h> 21fc4fb2adSChris Zankel #include <linux/linkage.h> 22fc4fb2adSChris Zankel #include <linux/stringify.h> 23fc4fb2adSChris Zankel #include <linux/errno.h> 24fc4fb2adSChris Zankel #include <linux/syscalls.h> 25fc4fb2adSChris Zankel #include <linux/file.h> 26fc4fb2adSChris Zankel #include <linux/fs.h> 27fc4fb2adSChris Zankel #include <linux/mman.h> 28fc4fb2adSChris Zankel #include <linux/shm.h> 29fc4fb2adSChris Zankel 30fc4fb2adSChris Zankel typedef void (*syscall_t)(void); 31fc4fb2adSChris Zankel 32fc4fb2adSChris Zankel syscall_t sys_call_table[__NR_syscall_count] /* FIXME __cacheline_aligned */= { 33fc4fb2adSChris Zankel [0 ... __NR_syscall_count - 1] = (syscall_t)&sys_ni_syscall, 34fc4fb2adSChris Zankel 35fc4fb2adSChris Zankel #undef __SYSCALL 36fc4fb2adSChris Zankel #define __SYSCALL(nr,symbol,nargs) [ nr ] = (syscall_t)symbol, 37fc4fb2adSChris Zankel #undef _XTENSA_UNISTD_H 38fc4fb2adSChris Zankel #undef __KERNEL_SYSCALLS__ 39fc4fb2adSChris Zankel #include <asm/unistd.h> 40fc4fb2adSChris Zankel }; 41fc4fb2adSChris Zankel 42fc4fb2adSChris Zankel /* 43fc4fb2adSChris Zankel * xtensa_pipe() is the normal C calling standard for creating a pipe. It's not 44fc4fb2adSChris Zankel * the way unix traditional does this, though. 45fc4fb2adSChris Zankel */ 46fc4fb2adSChris Zankel 47fc4fb2adSChris Zankel asmlinkage long xtensa_pipe(int __user *userfds) 48fc4fb2adSChris Zankel { 49fc4fb2adSChris Zankel int fd[2]; 50fc4fb2adSChris Zankel int error; 51fc4fb2adSChris Zankel 52fc4fb2adSChris Zankel error = do_pipe(fd); 53fc4fb2adSChris Zankel if (!error) { 54fc4fb2adSChris Zankel if (copy_to_user(userfds, fd, 2 * sizeof(int))) 55fc4fb2adSChris Zankel error = -EFAULT; 56fc4fb2adSChris Zankel } 57fc4fb2adSChris Zankel return error; 58fc4fb2adSChris Zankel } 59fc4fb2adSChris Zankel 60fc4fb2adSChris Zankel 61fc4fb2adSChris Zankel asmlinkage long xtensa_mmap2(unsigned long addr, unsigned long len, 62fc4fb2adSChris Zankel unsigned long prot, unsigned long flags, 63fc4fb2adSChris Zankel unsigned long fd, unsigned long pgoff) 64fc4fb2adSChris Zankel { 65fc4fb2adSChris Zankel int error = -EBADF; 66fc4fb2adSChris Zankel struct file * file = NULL; 67fc4fb2adSChris Zankel 68fc4fb2adSChris Zankel flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); 69fc4fb2adSChris Zankel if (!(flags & MAP_ANONYMOUS)) { 70fc4fb2adSChris Zankel file = fget(fd); 71fc4fb2adSChris Zankel if (!file) 72fc4fb2adSChris Zankel goto out; 73fc4fb2adSChris Zankel } 74fc4fb2adSChris Zankel 75fc4fb2adSChris Zankel down_write(¤t->mm->mmap_sem); 76fc4fb2adSChris Zankel error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); 77fc4fb2adSChris Zankel up_write(¤t->mm->mmap_sem); 78fc4fb2adSChris Zankel 79fc4fb2adSChris Zankel if (file) 80fc4fb2adSChris Zankel fput(file); 81fc4fb2adSChris Zankel out: 82fc4fb2adSChris Zankel return error; 83fc4fb2adSChris Zankel } 84fc4fb2adSChris Zankel 85fc4fb2adSChris Zankel asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg) 86fc4fb2adSChris Zankel { 87fc4fb2adSChris Zankel unsigned long ret; 88fc4fb2adSChris Zankel long err; 89fc4fb2adSChris Zankel 90fc4fb2adSChris Zankel err = do_shmat(shmid, shmaddr, shmflg, &ret); 91fc4fb2adSChris Zankel if (err) 92fc4fb2adSChris Zankel return err; 93fc4fb2adSChris Zankel return (long)ret; 94fc4fb2adSChris Zankel } 95fc4fb2adSChris Zankel 96bc671aa9SChris Zankel asmlinkage long xtensa_fadvise64_64(int fd, int advice, unsigned long long offset, unsigned long long len) 97bc671aa9SChris Zankel { 98bc671aa9SChris Zankel return sys_fadvise64_64(fd, offset, len, advice); 99bc671aa9SChris Zankel } 100bc671aa9SChris Zankel 101