1
2
3
4
5
6
7
8#include <linux/syscalls.h>
9#include <asm/unistd.h>
10#include <asm/cacheflush.h>
11
12static long riscv_sys_mmap(unsigned long addr, unsigned long len,
13 unsigned long prot, unsigned long flags,
14 unsigned long fd, off_t offset,
15 unsigned long page_shift_offset)
16{
17 if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))
18 return -EINVAL;
19 return ksys_mmap_pgoff(addr, len, prot, flags, fd,
20 offset >> (PAGE_SHIFT - page_shift_offset));
21}
22
23#ifdef CONFIG_64BIT
24SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
25 unsigned long, prot, unsigned long, flags,
26 unsigned long, fd, off_t, offset)
27{
28 return riscv_sys_mmap(addr, len, prot, flags, fd, offset, 0);
29}
30#else
31SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
32 unsigned long, prot, unsigned long, flags,
33 unsigned long, fd, off_t, offset)
34{
35
36
37
38
39 return riscv_sys_mmap(addr, len, prot, flags, fd, offset, 12);
40}
41#endif
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57SYSCALL_DEFINE3(riscv_flush_icache, uintptr_t, start, uintptr_t, end,
58 uintptr_t, flags)
59{
60
61 if (unlikely(flags & ~SYS_RISCV_FLUSH_ICACHE_ALL))
62 return -EINVAL;
63
64 flush_icache_mm(current->mm, flags & SYS_RISCV_FLUSH_ICACHE_LOCAL);
65
66 return 0;
67}
68