Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/sh/kernel/sys_sh.c |
| 3 | * |
| 4 | * This file contains various random system calls that |
| 5 | * have a non-standard calling sequence on the Linux/SuperH |
| 6 | * platform. |
| 7 | * |
| 8 | * Taken from i386 version. |
| 9 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/errno.h> |
| 11 | #include <linux/sched.h> |
| 12 | #include <linux/mm.h> |
| 13 | #include <linux/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/sem.h> |
| 15 | #include <linux/msg.h> |
| 16 | #include <linux/shm.h> |
| 17 | #include <linux/stat.h> |
| 18 | #include <linux/syscalls.h> |
| 19 | #include <linux/mman.h> |
| 20 | #include <linux/file.h> |
| 21 | #include <linux/utsname.h> |
Paul Mundt | f3c2575 | 2006-09-27 18:36:17 +0900 | [diff] [blame] | 22 | #include <linux/module.h> |
Paul Mundt | e06c4e5 | 2007-07-31 13:01:43 +0900 | [diff] [blame] | 23 | #include <linux/fs.h> |
Adrian Bunk | cba4fbb | 2007-10-16 23:29:24 -0700 | [diff] [blame] | 24 | #include <linux/ipc.h> |
Paul Mundt | fa43972 | 2008-09-04 18:53:58 +0900 | [diff] [blame] | 25 | #include <asm/syscalls.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <asm/uaccess.h> |
Arnd Bergmann | fe74290 | 2006-10-02 02:18:34 -0700 | [diff] [blame] | 27 | #include <asm/unistd.h> |
Stuart Menefy | 6d243dd | 2009-08-24 18:16:56 +0900 | [diff] [blame] | 28 | #include <asm/cacheflush.h> |
| 29 | #include <asm/cachectl.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | asmlinkage int old_mmap(unsigned long addr, unsigned long len, |
| 32 | unsigned long prot, unsigned long flags, |
| 33 | int fd, unsigned long off) |
| 34 | { |
| 35 | if (off & ~PAGE_MASK) |
| 36 | return -EINVAL; |
Al Viro | f8b7256 | 2009-11-30 17:37:04 -0500 | [diff] [blame] | 37 | return sys_mmap_pgoff(addr, len, prot, flags, fd, off>>PAGE_SHIFT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, |
| 41 | unsigned long prot, unsigned long flags, |
| 42 | unsigned long fd, unsigned long pgoff) |
| 43 | { |
Toshinobu Sugioka | 8c31813 | 2009-04-21 07:34:53 +0900 | [diff] [blame] | 44 | /* |
| 45 | * The shift for mmap2 is constant, regardless of PAGE_SIZE |
| 46 | * setting. |
| 47 | */ |
| 48 | if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1)) |
| 49 | return -EINVAL; |
| 50 | |
| 51 | pgoff >>= PAGE_SHIFT - 12; |
| 52 | |
Al Viro | f8b7256 | 2009-11-30 17:37:04 -0500 | [diff] [blame] | 53 | return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Stuart Menefy | 6d243dd | 2009-08-24 18:16:56 +0900 | [diff] [blame] | 56 | /* sys_cacheflush -- flush (part of) the processor cache. */ |
| 57 | asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op) |
| 58 | { |
| 59 | struct vm_area_struct *vma; |
| 60 | |
Giuseppe Cavallaro | 788e6af | 2009-08-24 18:59:09 +0900 | [diff] [blame] | 61 | if ((op <= 0) || (op > (CACHEFLUSH_D_PURGE|CACHEFLUSH_I))) |
Stuart Menefy | 6d243dd | 2009-08-24 18:16:56 +0900 | [diff] [blame] | 62 | return -EINVAL; |
| 63 | |
| 64 | /* |
| 65 | * Verify that the specified address region actually belongs |
| 66 | * to this process. |
| 67 | */ |
| 68 | if (addr + len < addr) |
| 69 | return -EFAULT; |
| 70 | |
| 71 | down_read(¤t->mm->mmap_sem); |
| 72 | vma = find_vma (current->mm, addr); |
| 73 | if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end) { |
| 74 | up_read(¤t->mm->mmap_sem); |
| 75 | return -EFAULT; |
| 76 | } |
| 77 | |
| 78 | switch (op & CACHEFLUSH_D_PURGE) { |
| 79 | case CACHEFLUSH_D_INVAL: |
| 80 | __flush_invalidate_region((void *)addr, len); |
| 81 | break; |
| 82 | case CACHEFLUSH_D_WB: |
| 83 | __flush_wback_region((void *)addr, len); |
| 84 | break; |
| 85 | case CACHEFLUSH_D_PURGE: |
| 86 | __flush_purge_region((void *)addr, len); |
| 87 | break; |
| 88 | } |
| 89 | |
| 90 | if (op & CACHEFLUSH_I) |
| 91 | flush_cache_all(); |
| 92 | |
| 93 | up_read(¤t->mm->mmap_sem); |
| 94 | return 0; |
| 95 | } |