2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
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.
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
14 * This file contains various random system calls that
15 * have a non-standard calling sequence on the Linux/TILE
19 #include <linux/errno.h>
20 #include <linux/sched.h>
22 #include <linux/smp.h>
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>
29 #include <linux/compat.h>
30 #include <linux/uaccess.h>
31 #include <linux/signal.h>
32 #include <asm/syscalls.h>
33 #include <asm/pgtable.h>
34 #include <asm/homecache.h>
35 #include <asm/cachectl.h>
36 #include <asm/byteorder.h>
37 #include <arch/chip.h>
39 SYSCALL_DEFINE3(cacheflush
, unsigned long, addr
, unsigned long, len
,
42 /* DCACHE is not particularly effective if not bound to one cpu. */
44 homecache_evict(cpumask_of(raw_smp_processor_id()));
47 flush_remote(0, HV_FLUSH_EVICT_L1I
, mm_cpumask(current
->mm
),
48 0, 0, 0, NULL
, NULL
, 0);
53 * Syscalls that pass 64-bit values on 32-bit systems normally
54 * pass them as (low,high) word packed into the immediately adjacent
55 * registers. If the low word naturally falls on an even register,
56 * our ABI makes it work correctly; if not, we adjust it here.
57 * Handling it here means we don't have to fix uclibc AND glibc AND
58 * any other standard libcs we want to support.
61 #if !defined(__tilegx__) || defined(CONFIG_COMPAT)
64 #define SYSCALL_PAIR(name) u32 name ## _hi, u32 name ## _lo
66 #define SYSCALL_PAIR(name) u32 name ## _lo, u32 name ## _hi
69 ssize_t
sys32_readahead(int fd
, SYSCALL_PAIR(offset
), u32 count
)
71 return sys_readahead(fd
, ((loff_t
)offset_hi
<< 32) | offset_lo
, count
);
74 int sys32_fadvise64_64(int fd
, SYSCALL_PAIR(offset
),
75 SYSCALL_PAIR(len
), int advice
)
77 return sys_fadvise64_64(fd
, ((loff_t
)offset_hi
<< 32) | offset_lo
,
78 ((loff_t
)len_hi
<< 32) | len_lo
, advice
);
81 #endif /* 32-bit syscall wrappers */
83 /* Note: used by the compat code even in 64-bit Linux. */
84 SYSCALL_DEFINE6(mmap2
, unsigned long, addr
, unsigned long, len
,
85 unsigned long, prot
, unsigned long, flags
,
86 unsigned long, fd
, unsigned long, off_4k
)
88 #define PAGE_ADJUST (PAGE_SHIFT - 12)
89 if (off_4k
& ((1 << PAGE_ADJUST
) - 1))
91 return sys_mmap_pgoff(addr
, len
, prot
, flags
, fd
,
92 off_4k
>> PAGE_ADJUST
);
96 SYSCALL_DEFINE6(mmap
, unsigned long, addr
, unsigned long, len
,
97 unsigned long, prot
, unsigned long, flags
,
98 unsigned long, fd
, off_t
, offset
)
100 if (offset
& ((1 << PAGE_SHIFT
) - 1))
102 return sys_mmap_pgoff(addr
, len
, prot
, flags
, fd
,
103 offset
>> PAGE_SHIFT
);
108 /* Provide the actual syscall number to call mapping. */
110 #define __SYSCALL(nr, call) [nr] = (call),
113 /* See comments at the top of the file. */
114 #define sys_fadvise64_64 sys32_fadvise64_64
115 #define sys_readahead sys32_readahead
118 /* Call the assembly trampolines where necessary. */
119 #undef sys_rt_sigreturn
120 #define sys_rt_sigreturn _sys_rt_sigreturn
121 #define sys_clone _sys_clone
124 * Note that we can't include <linux/unistd.h> here since the header
125 * guard will defeat us; <asm/unistd.h> checks for __SYSCALL as well.
127 void *sys_call_table
[__NR_syscalls
] = {
128 [0 ... __NR_syscalls
-1] = sys_ni_syscall
,
129 #include <asm/unistd.h>