| |
| |
| |
| |
| |
| |
| |
| #include <linux/syscalls.h> |
| #include <asm/unistd.h> |
| #include <asm/cacheflush.h> |
| #include <asm-generic/mman-common.h> |
| |
| static long riscv_sys_mmap(unsigned long addr, unsigned long len, |
| <------><------><------> unsigned long prot, unsigned long flags, |
| <------><------><------> unsigned long fd, off_t offset, |
| <------><------><------> unsigned long page_shift_offset) |
| { |
| <------>if (unlikely(offset & (~PAGE_MASK >> page_shift_offset))) |
| <------><------>return -EINVAL; |
| |
| <------>if ((prot & PROT_WRITE) && (prot & PROT_EXEC)) |
| <------><------>if (unlikely(!(prot & PROT_READ))) |
| <------><------><------>return -EINVAL; |
| |
| <------>return ksys_mmap_pgoff(addr, len, prot, flags, fd, |
| <------><------><------> offset >> (PAGE_SHIFT - page_shift_offset)); |
| } |
| |
| #ifdef CONFIG_64BIT |
| SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, |
| <------>unsigned long, prot, unsigned long, flags, |
| <------>unsigned long, fd, off_t, offset) |
| { |
| <------>return riscv_sys_mmap(addr, len, prot, flags, fd, offset, 0); |
| } |
| #else |
| SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, |
| <------>unsigned long, prot, unsigned long, flags, |
| <------>unsigned long, fd, off_t, offset) |
| { |
| <------> |
| <------> * Note that the shift for mmap2 is constant (12), |
| <------> * regardless of PAGE_SIZE |
| <------> */ |
| <------>return riscv_sys_mmap(addr, len, prot, flags, fd, offset, 12); |
| } |
| #endif |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| SYSCALL_DEFINE3(riscv_flush_icache, uintptr_t, start, uintptr_t, end, |
| <------>uintptr_t, flags) |
| { |
| <------> |
| <------>if (unlikely(flags & ~SYS_RISCV_FLUSH_ICACHE_ALL)) |
| <------><------>return -EINVAL; |
| |
| <------>flush_icache_mm(current->mm, flags & SYS_RISCV_FLUSH_ICACHE_LOCAL); |
| |
| <------>return 0; |
| } |
| |