GNU Linux-libre 4.19.281-gnu1
[releases.git] / arch / nds32 / kernel / sys_nds32.c
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2017 Andes Technology Corporation
3
4 #include <linux/syscalls.h>
5 #include <linux/uaccess.h>
6
7 #include <asm/cachectl.h>
8 #include <asm/proc-fns.h>
9
10 SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
11                unsigned long, prot, unsigned long, flags,
12                unsigned long, fd, unsigned long, pgoff)
13 {
14         if (pgoff & (~PAGE_MASK >> 12))
15                 return -EINVAL;
16
17         return sys_mmap_pgoff(addr, len, prot, flags, fd,
18                               pgoff >> (PAGE_SHIFT - 12));
19 }
20
21 SYSCALL_DEFINE4(fadvise64_64_wrapper,int, fd, int, advice, loff_t, offset,
22                                          loff_t, len)
23 {
24         return sys_fadvise64_64(fd, offset, len, advice);
25 }
26
27 SYSCALL_DEFINE3(cacheflush, unsigned int, start, unsigned int, end, int, cache)
28 {
29         struct vm_area_struct *vma;
30         bool flushi = true, wbd = true;
31
32         vma = find_vma(current->mm, start);
33         if (!vma)
34                 return -EFAULT;
35         switch (cache) {
36         case ICACHE:
37                 wbd = false;
38                 break;
39         case DCACHE:
40                 flushi = false;
41                 break;
42         case BCACHE:
43                 break;
44         default:
45                 return -EINVAL;
46         }
47         cpu_cache_wbinval_range_check(vma, start, end, flushi, wbd);
48
49         return 0;
50 }