Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation, version 2. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or |
| 11 | * NON INFRINGEMENT. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * This file contains various random system calls that |
| 15 | * have a non-standard calling sequence on the Linux/TILE |
| 16 | * platform. |
| 17 | */ |
| 18 | |
| 19 | #include <linux/errno.h> |
| 20 | #include <linux/sched.h> |
| 21 | #include <linux/mm.h> |
| 22 | #include <linux/smp.h> |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 23 | #include <linux/syscalls.h> |
| 24 | #include <linux/mman.h> |
| 25 | #include <linux/file.h> |
| 26 | #include <linux/mempolicy.h> |
| 27 | #include <linux/binfmts.h> |
| 28 | #include <linux/fs.h> |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 29 | #include <linux/compat.h> |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 30 | #include <linux/uaccess.h> |
| 31 | #include <linux/signal.h> |
| 32 | #include <asm/syscalls.h> |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 33 | #include <asm/pgtable.h> |
| 34 | #include <asm/homecache.h> |
Chris Metcalf | cd6f32a | 2012-03-29 15:25:59 -0400 | [diff] [blame^] | 35 | #include <asm/cachectl.h> |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 36 | #include <arch/chip.h> |
| 37 | |
Chris Metcalf | cd6f32a | 2012-03-29 15:25:59 -0400 | [diff] [blame^] | 38 | SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, len, |
| 39 | unsigned long, flags) |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 40 | { |
Chris Metcalf | cd6f32a | 2012-03-29 15:25:59 -0400 | [diff] [blame^] | 41 | if (flags & DCACHE) |
| 42 | homecache_evict(cpumask_of(smp_processor_id())); |
| 43 | if (flags & ICACHE) |
| 44 | flush_remote(0, HV_FLUSH_EVICT_L1I, mm_cpumask(current->mm), |
| 45 | 0, 0, 0, NULL, NULL, 0); |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | /* |
| 50 | * Syscalls that pass 64-bit values on 32-bit systems normally |
| 51 | * pass them as (low,high) word packed into the immediately adjacent |
| 52 | * registers. If the low word naturally falls on an even register, |
| 53 | * our ABI makes it work correctly; if not, we adjust it here. |
| 54 | * Handling it here means we don't have to fix uclibc AND glibc AND |
| 55 | * any other standard libcs we want to support. |
| 56 | */ |
| 57 | |
| 58 | #if !defined(__tilegx__) || defined(CONFIG_COMPAT) |
| 59 | |
| 60 | ssize_t sys32_readahead(int fd, u32 offset_lo, u32 offset_hi, u32 count) |
| 61 | { |
| 62 | return sys_readahead(fd, ((loff_t)offset_hi << 32) | offset_lo, count); |
| 63 | } |
| 64 | |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 65 | int sys32_fadvise64_64(int fd, u32 offset_lo, u32 offset_hi, |
| 66 | u32 len_lo, u32 len_hi, int advice) |
| 67 | { |
| 68 | return sys_fadvise64_64(fd, ((loff_t)offset_hi << 32) | offset_lo, |
| 69 | ((loff_t)len_hi << 32) | len_lo, advice); |
| 70 | } |
| 71 | |
| 72 | #endif /* 32-bit syscall wrappers */ |
| 73 | |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 74 | /* Note: used by the compat code even in 64-bit Linux. */ |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 75 | SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, |
| 76 | unsigned long, prot, unsigned long, flags, |
| 77 | unsigned long, fd, unsigned long, off_4k) |
| 78 | { |
| 79 | #define PAGE_ADJUST (PAGE_SHIFT - 12) |
| 80 | if (off_4k & ((1 << PAGE_ADJUST) - 1)) |
| 81 | return -EINVAL; |
| 82 | return sys_mmap_pgoff(addr, len, prot, flags, fd, |
| 83 | off_4k >> PAGE_ADJUST); |
| 84 | } |
| 85 | |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 86 | #ifdef __tilegx__ |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 87 | SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, |
| 88 | unsigned long, prot, unsigned long, flags, |
Chris Metcalf | 139ef32 | 2010-06-07 08:48:13 -0400 | [diff] [blame] | 89 | unsigned long, fd, off_t, offset) |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 90 | { |
| 91 | if (offset & ((1 << PAGE_SHIFT) - 1)) |
| 92 | return -EINVAL; |
| 93 | return sys_mmap_pgoff(addr, len, prot, flags, fd, |
| 94 | offset >> PAGE_SHIFT); |
| 95 | } |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 96 | #endif |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 97 | |
| 98 | |
| 99 | /* Provide the actual syscall number to call mapping. */ |
| 100 | #undef __SYSCALL |
| 101 | #define __SYSCALL(nr, call) [nr] = (call), |
| 102 | |
| 103 | #ifndef __tilegx__ |
| 104 | /* See comments at the top of the file. */ |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 105 | #define sys_fadvise64_64 sys32_fadvise64_64 |
| 106 | #define sys_readahead sys32_readahead |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 107 | #endif |
| 108 | |
Chris Metcalf | d929b6a | 2010-10-14 14:34:33 -0400 | [diff] [blame] | 109 | /* Call the trampolines to manage pt_regs where necessary. */ |
| 110 | #define sys_execve _sys_execve |
| 111 | #define sys_sigaltstack _sys_sigaltstack |
| 112 | #define sys_rt_sigreturn _sys_rt_sigreturn |
| 113 | #define sys_clone _sys_clone |
| 114 | #ifndef __tilegx__ |
| 115 | #define sys_cmpxchg_badaddr _sys_cmpxchg_badaddr |
| 116 | #endif |
| 117 | |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 118 | /* |
| 119 | * Note that we can't include <linux/unistd.h> here since the header |
| 120 | * guard will defeat us; <asm/unistd.h> checks for __SYSCALL as well. |
| 121 | */ |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 122 | void *sys_call_table[__NR_syscalls] = { |
| 123 | [0 ... __NR_syscalls-1] = sys_ni_syscall, |
| 124 | #include <asm/unistd.h> |
| 125 | }; |