2017-10-25 10:37:49 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
// Copyright (C) 2005-2017 Andes Technology Corporation
|
|
|
|
|
|
|
|
#include <linux/syscalls.h>
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
|
|
|
|
#include <asm/cachectl.h>
|
|
|
|
#include <asm/proc-fns.h>
|
2018-11-22 11:14:36 +08:00
|
|
|
#include <asm/fpu.h>
|
2019-05-20 09:21:12 +08:00
|
|
|
#include <asm/fp_udfiex_crtl.h>
|
2017-10-25 10:37:49 +08:00
|
|
|
|
|
|
|
SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
|
|
|
|
unsigned long, prot, unsigned long, flags,
|
|
|
|
unsigned long, fd, unsigned long, pgoff)
|
|
|
|
{
|
|
|
|
if (pgoff & (~PAGE_MASK >> 12))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return sys_mmap_pgoff(addr, len, prot, flags, fd,
|
|
|
|
pgoff >> (PAGE_SHIFT - 12));
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCALL_DEFINE4(fadvise64_64_wrapper,int, fd, int, advice, loff_t, offset,
|
|
|
|
loff_t, len)
|
|
|
|
{
|
|
|
|
return sys_fadvise64_64(fd, offset, len, advice);
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSCALL_DEFINE3(cacheflush, unsigned int, start, unsigned int, end, int, cache)
|
|
|
|
{
|
|
|
|
struct vm_area_struct *vma;
|
|
|
|
bool flushi = true, wbd = true;
|
|
|
|
|
|
|
|
vma = find_vma(current->mm, start);
|
|
|
|
if (!vma)
|
|
|
|
return -EFAULT;
|
|
|
|
switch (cache) {
|
|
|
|
case ICACHE:
|
|
|
|
wbd = false;
|
|
|
|
break;
|
|
|
|
case DCACHE:
|
|
|
|
flushi = false;
|
|
|
|
break;
|
|
|
|
case BCACHE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
cpu_cache_wbinval_range_check(vma, start, end, flushi, wbd);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-11-22 11:14:36 +08:00
|
|
|
|
2019-05-20 09:21:12 +08:00
|
|
|
SYSCALL_DEFINE2(fp_udfiex_crtl, unsigned int, cmd, unsigned int, act)
|
2018-11-22 11:14:36 +08:00
|
|
|
{
|
|
|
|
#if IS_ENABLED(CONFIG_SUPPORT_DENORMAL_ARITHMETIC)
|
2019-05-20 09:21:12 +08:00
|
|
|
int old_udf_iex;
|
2018-11-22 11:14:36 +08:00
|
|
|
|
|
|
|
if (!used_math()) {
|
|
|
|
load_fpu(&init_fpuregs);
|
2019-05-20 09:21:12 +08:00
|
|
|
current->thread.fpu.UDF_IEX_trap = init_fpuregs.UDF_IEX_trap;
|
2018-11-22 11:14:36 +08:00
|
|
|
set_used_math();
|
|
|
|
}
|
|
|
|
|
2019-05-20 09:21:12 +08:00
|
|
|
old_udf_iex = current->thread.fpu.UDF_IEX_trap;
|
|
|
|
act &= (FPCSR_mskUDFE | FPCSR_mskIEXE);
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case DISABLE_UDF_IEX_TRAP:
|
|
|
|
current->thread.fpu.UDF_IEX_trap &= ~act;
|
2018-11-22 11:14:36 +08:00
|
|
|
break;
|
2019-05-20 09:21:12 +08:00
|
|
|
case ENABLE_UDF_IEX_TRAP:
|
|
|
|
current->thread.fpu.UDF_IEX_trap |= act;
|
2018-11-22 11:14:36 +08:00
|
|
|
break;
|
2019-05-20 09:21:12 +08:00
|
|
|
case GET_UDF_IEX_TRAP:
|
2018-11-22 11:14:36 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2019-05-20 09:21:12 +08:00
|
|
|
return old_udf_iex;
|
2018-11-22 11:14:36 +08:00
|
|
|
#else
|
|
|
|
return -ENOTSUPP;
|
|
|
|
#endif
|
|
|
|
}
|