sys_sh.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * linux/arch/sh/kernel/sys_sh.c
  4. *
  5. * This file contains various random system calls that
  6. * have a non-standard calling sequence on the Linux/SuperH
  7. * platform.
  8. *
  9. * Taken from i386 version.
  10. */
  11. #include <linux/errno.h>
  12. #include <linux/sched.h>
  13. #include <linux/mm.h>
  14. #include <linux/smp.h>
  15. #include <linux/sem.h>
  16. #include <linux/msg.h>
  17. #include <linux/shm.h>
  18. #include <linux/stat.h>
  19. #include <linux/syscalls.h>
  20. #include <linux/mman.h>
  21. #include <linux/file.h>
  22. #include <linux/utsname.h>
  23. #include <linux/module.h>
  24. #include <linux/fs.h>
  25. #include <linux/ipc.h>
  26. #include <asm/syscalls.h>
  27. #include <linux/uaccess.h>
  28. #include <asm/unistd.h>
  29. #include <asm/cacheflush.h>
  30. #include <asm/cachectl.h>
  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;
  37. return ksys_mmap_pgoff(addr, len, prot, flags, fd, off>>PAGE_SHIFT);
  38. }
  39. asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
  40. unsigned long prot, unsigned long flags,
  41. unsigned long fd, unsigned long pgoff)
  42. {
  43. /*
  44. * The shift for mmap2 is constant, regardless of PAGE_SIZE
  45. * setting.
  46. */
  47. if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1))
  48. return -EINVAL;
  49. pgoff >>= PAGE_SHIFT - 12;
  50. return ksys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
  51. }
  52. /* sys_cacheflush -- flush (part of) the processor cache. */
  53. asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op)
  54. {
  55. struct vm_area_struct *vma;
  56. if ((op <= 0) || (op > (CACHEFLUSH_D_PURGE|CACHEFLUSH_I)))
  57. return -EINVAL;
  58. /*
  59. * Verify that the specified address region actually belongs
  60. * to this process.
  61. */
  62. if (addr + len < addr)
  63. return -EFAULT;
  64. mmap_read_lock(current->mm);
  65. vma = find_vma (current->mm, addr);
  66. if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end) {
  67. mmap_read_unlock(current->mm);
  68. return -EFAULT;
  69. }
  70. switch (op & CACHEFLUSH_D_PURGE) {
  71. case CACHEFLUSH_D_INVAL:
  72. __flush_invalidate_region((void *)addr, len);
  73. break;
  74. case CACHEFLUSH_D_WB:
  75. __flush_wback_region((void *)addr, len);
  76. break;
  77. case CACHEFLUSH_D_PURGE:
  78. __flush_purge_region((void *)addr, len);
  79. break;
  80. }
  81. if (op & CACHEFLUSH_I)
  82. flush_icache_range(addr, addr+len);
  83. mmap_read_unlock(current->mm);
  84. return 0;
  85. }