sys_nios2.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (C) 2013 Altera Corporation
  3. * Copyright (C) 2011-2012 Tobias Klauser <[email protected]>
  4. * Copyright (C) 2004 Microtronix Datacom Ltd.
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/export.h>
  11. #include <linux/file.h>
  12. #include <linux/fs.h>
  13. #include <linux/slab.h>
  14. #include <linux/syscalls.h>
  15. #include <asm/cacheflush.h>
  16. #include <asm/traps.h>
  17. /* sys_cacheflush -- flush the processor cache. */
  18. asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len,
  19. unsigned int op)
  20. {
  21. struct vm_area_struct *vma;
  22. struct mm_struct *mm = current->mm;
  23. if (len == 0)
  24. return 0;
  25. /* We only support op 0 now, return error if op is non-zero.*/
  26. if (op)
  27. return -EINVAL;
  28. /* Check for overflow */
  29. if (addr + len < addr)
  30. return -EFAULT;
  31. if (mmap_read_lock_killable(mm))
  32. return -EINTR;
  33. /*
  34. * Verify that the specified address region actually belongs
  35. * to this process.
  36. */
  37. vma = find_vma(mm, addr);
  38. if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end) {
  39. mmap_read_unlock(mm);
  40. return -EFAULT;
  41. }
  42. flush_cache_range(vma, addr, addr + len);
  43. mmap_read_unlock(mm);
  44. return 0;
  45. }
  46. asmlinkage int sys_getpagesize(void)
  47. {
  48. return PAGE_SIZE;
  49. }