1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun #include <linux/syscalls.h>
5*4882a593Smuzhiyun
SYSCALL_DEFINE1(set_thread_area,unsigned long,addr)6*4882a593Smuzhiyun SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
7*4882a593Smuzhiyun {
8*4882a593Smuzhiyun struct thread_info *ti = task_thread_info(current);
9*4882a593Smuzhiyun struct pt_regs *reg = current_pt_regs();
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun reg->tls = addr;
12*4882a593Smuzhiyun ti->tp_value = addr;
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun return 0;
15*4882a593Smuzhiyun }
16*4882a593Smuzhiyun
SYSCALL_DEFINE6(mmap2,unsigned long,addr,unsigned long,len,unsigned long,prot,unsigned long,flags,unsigned long,fd,off_t,offset)17*4882a593Smuzhiyun SYSCALL_DEFINE6(mmap2,
18*4882a593Smuzhiyun unsigned long, addr,
19*4882a593Smuzhiyun unsigned long, len,
20*4882a593Smuzhiyun unsigned long, prot,
21*4882a593Smuzhiyun unsigned long, flags,
22*4882a593Smuzhiyun unsigned long, fd,
23*4882a593Smuzhiyun off_t, offset)
24*4882a593Smuzhiyun {
25*4882a593Smuzhiyun if (unlikely(offset & (~PAGE_MASK >> 12)))
26*4882a593Smuzhiyun return -EINVAL;
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun return ksys_mmap_pgoff(addr, len, prot, flags, fd,
29*4882a593Smuzhiyun offset >> (PAGE_SHIFT - 12));
30*4882a593Smuzhiyun }
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun /*
33*4882a593Smuzhiyun * for abiv1 the 64bits args should be even th, So we need mov the advice
34*4882a593Smuzhiyun * forward.
35*4882a593Smuzhiyun */
SYSCALL_DEFINE4(csky_fadvise64_64,int,fd,int,advice,loff_t,offset,loff_t,len)36*4882a593Smuzhiyun SYSCALL_DEFINE4(csky_fadvise64_64,
37*4882a593Smuzhiyun int, fd,
38*4882a593Smuzhiyun int, advice,
39*4882a593Smuzhiyun loff_t, offset,
40*4882a593Smuzhiyun loff_t, len)
41*4882a593Smuzhiyun {
42*4882a593Smuzhiyun return ksys_fadvise64_64(fd, offset, len, advice);
43*4882a593Smuzhiyun }
44