]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/tile/kernel/sys.c
arch/tile: core support for Tilera 32-bit chips.
[mirror_ubuntu-bionic-kernel.git] / arch / tile / kernel / sys.c
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>
23 #include <linux/smp_lock.h>
24 #include <linux/syscalls.h>
25 #include <linux/mman.h>
26 #include <linux/file.h>
27 #include <linux/mempolicy.h>
28 #include <linux/binfmts.h>
29 #include <linux/fs.h>
30 #include <linux/syscalls.h>
31 #include <linux/uaccess.h>
32 #include <linux/signal.h>
33 #include <asm/syscalls.h>
34
35 #include <asm/pgtable.h>
36 #include <asm/homecache.h>
37 #include <arch/chip.h>
38
39 SYSCALL_DEFINE0(flush_cache)
40 {
41 homecache_evict(cpumask_of(smp_processor_id()));
42 return 0;
43 }
44
45 /*
46 * Syscalls that pass 64-bit values on 32-bit systems normally
47 * pass them as (low,high) word packed into the immediately adjacent
48 * registers. If the low word naturally falls on an even register,
49 * our ABI makes it work correctly; if not, we adjust it here.
50 * Handling it here means we don't have to fix uclibc AND glibc AND
51 * any other standard libcs we want to support.
52 */
53
54 #if !defined(__tilegx__) || defined(CONFIG_COMPAT)
55
56 ssize_t sys32_readahead(int fd, u32 offset_lo, u32 offset_hi, u32 count)
57 {
58 return sys_readahead(fd, ((loff_t)offset_hi << 32) | offset_lo, count);
59 }
60
61 long sys32_fadvise64(int fd, u32 offset_lo, u32 offset_hi,
62 u32 len, int advice)
63 {
64 return sys_fadvise64_64(fd, ((loff_t)offset_hi << 32) | offset_lo,
65 len, advice);
66 }
67
68 int sys32_fadvise64_64(int fd, u32 offset_lo, u32 offset_hi,
69 u32 len_lo, u32 len_hi, int advice)
70 {
71 return sys_fadvise64_64(fd, ((loff_t)offset_hi << 32) | offset_lo,
72 ((loff_t)len_hi << 32) | len_lo, advice);
73 }
74
75 #endif /* 32-bit syscall wrappers */
76
77 /*
78 * This API uses a 4KB-page-count offset into the file descriptor.
79 * It is likely not the right API to use on a 64-bit platform.
80 */
81 SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
82 unsigned long, prot, unsigned long, flags,
83 unsigned long, fd, unsigned long, off_4k)
84 {
85 #define PAGE_ADJUST (PAGE_SHIFT - 12)
86 if (off_4k & ((1 << PAGE_ADJUST) - 1))
87 return -EINVAL;
88 return sys_mmap_pgoff(addr, len, prot, flags, fd,
89 off_4k >> PAGE_ADJUST);
90 }
91
92 /*
93 * This API uses a byte offset into the file descriptor.
94 * It is likely not the right API to use on a 32-bit platform.
95 */
96 SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
97 unsigned long, prot, unsigned long, flags,
98 unsigned long, fd, unsigned long, offset)
99 {
100 if (offset & ((1 << PAGE_SHIFT) - 1))
101 return -EINVAL;
102 return sys_mmap_pgoff(addr, len, prot, flags, fd,
103 offset >> PAGE_SHIFT);
104 }
105
106
107 /* Provide the actual syscall number to call mapping. */
108 #undef __SYSCALL
109 #define __SYSCALL(nr, call) [nr] = (call),
110
111 #ifndef __tilegx__
112 /* See comments at the top of the file. */
113 #define sys_fadvise64 sys32_fadvise64
114 #define sys_fadvise64_64 sys32_fadvise64_64
115 #define sys_readahead sys32_readahead
116 #define sys_sync_file_range sys_sync_file_range2
117 #endif
118
119 void *sys_call_table[__NR_syscalls] = {
120 [0 ... __NR_syscalls-1] = sys_ni_syscall,
121 #include <asm/unistd.h>
122 };