/*1* Copyright (C) 2013 Altera Corporation2* Copyright (C) 2011-2012 Tobias Klauser <[email protected]>3* Copyright (C) 2004 Microtronix Datacom Ltd.4*5* This file is subject to the terms and conditions of the GNU General Public6* License. See the file "COPYING" in the main directory of this archive7* for more details.8*/910#include <linux/export.h>11#include <linux/file.h>12#include <linux/fs.h>13#include <linux/slab.h>14#include <linux/syscalls.h>1516#include <asm/cacheflush.h>17#include <asm/traps.h>1819/* sys_cacheflush -- flush the processor cache. */20asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len,21unsigned int op)22{23struct vm_area_struct *vma;24struct mm_struct *mm = current->mm;2526if (len == 0)27return 0;2829/* We only support op 0 now, return error if op is non-zero.*/30if (op)31return -EINVAL;3233/* Check for overflow */34if (addr + len < addr)35return -EFAULT;3637if (mmap_read_lock_killable(mm))38return -EINTR;3940/*41* Verify that the specified address region actually belongs42* to this process.43*/44vma = find_vma(mm, addr);45if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end) {46mmap_read_unlock(mm);47return -EFAULT;48}4950flush_cache_range(vma, addr, addr + len);5152mmap_read_unlock(mm);53return 0;54}5556asmlinkage int sys_getpagesize(void)57{58return PAGE_SIZE;59}606162