sys_sh.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. */
  10. #include <linux/errno.h>
  11. #include <linux/sched.h>
  12. #include <linux/mm.h>
  13. #include <linux/smp.h>
  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>
  22. #include <linux/module.h>
  23. #include <linux/fs.h>
  24. #include <linux/ipc.h>
  25. #include <asm/syscalls.h>
  26. #include <asm/uaccess.h>
  27. #include <asm/unistd.h>
  28. #include <asm/cacheflush.h>
  29. #include <asm/cachectl.h>
  30. asmlinkage int old_mmap(unsigned long addr, unsigned long len,
  31. unsigned long prot, unsigned long flags,
  32. int fd, unsigned long off)
  33. {
  34. if (off & ~PAGE_MASK)
  35. return -EINVAL;
  36. return sys_mmap_pgoff(addr, len, prot, flags, fd, off>>PAGE_SHIFT);
  37. }
  38. asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
  39. unsigned long prot, unsigned long flags,
  40. unsigned long fd, unsigned long pgoff)
  41. {
  42. /*
  43. * The shift for mmap2 is constant, regardless of PAGE_SIZE
  44. * setting.
  45. */
  46. if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1))
  47. return -EINVAL;
  48. pgoff >>= PAGE_SHIFT - 12;
  49. return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
  50. }
  51. /* sys_cacheflush -- flush (part of) the processor cache. */
  52. asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op)
  53. {
  54. struct vm_area_struct *vma;
  55. if ((op <= 0) || (op > (CACHEFLUSH_D_PURGE|CACHEFLUSH_I)))
  56. return -EINVAL;
  57. /*
  58. * Verify that the specified address region actually belongs
  59. * to this process.
  60. */
  61. if (addr + len < addr)
  62. return -EFAULT;
  63. down_read(&current->mm->mmap_sem);
  64. vma = find_vma (current->mm, addr);
  65. if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end) {
  66. up_read(&current->mm->mmap_sem);
  67. return -EFAULT;
  68. }
  69. switch (op & CACHEFLUSH_D_PURGE) {
  70. case CACHEFLUSH_D_INVAL:
  71. __flush_invalidate_region((void *)addr, len);
  72. break;
  73. case CACHEFLUSH_D_WB:
  74. __flush_wback_region((void *)addr, len);
  75. break;
  76. case CACHEFLUSH_D_PURGE:
  77. __flush_purge_region((void *)addr, len);
  78. break;
  79. }
  80. if (op & CACHEFLUSH_I)
  81. flush_icache_range(addr, addr+len);
  82. up_read(&current->mm->mmap_sem);
  83. return 0;
  84. }