sys_nios2.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (C) 2013 Altera Corporation
  3. * Copyright (C) 2011-2012 Tobias Klauser <tklauser@distanz.ch>
  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. if (len == 0)
  23. return 0;
  24. /* We only support op 0 now, return error if op is non-zero.*/
  25. if (op)
  26. return -EINVAL;
  27. /* Check for overflow */
  28. if (addr + len < addr)
  29. return -EFAULT;
  30. /*
  31. * Verify that the specified address region actually belongs
  32. * to this process.
  33. */
  34. vma = find_vma(current->mm, addr);
  35. if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end)
  36. return -EFAULT;
  37. flush_cache_range(vma, addr, addr + len);
  38. return 0;
  39. }
  40. asmlinkage int sys_getpagesize(void)
  41. {
  42. return PAGE_SIZE;
  43. }