xref: /linux/arch/xtensa/include/asm/syscall.h (revision 7962c2ed)
1367b8112SChris Zankel /*
2367b8112SChris Zankel  * This file is subject to the terms and conditions of the GNU General Public
3367b8112SChris Zankel  * License.  See the file "COPYING" in the main directory of this archive
4367b8112SChris Zankel  * for more details.
5367b8112SChris Zankel  *
6367b8112SChris Zankel  * Copyright (C) 2001 - 2007 Tensilica Inc.
758b17c55SMax Filippov  * Copyright (C) 2018 Cadence Design Systems Inc.
8367b8112SChris Zankel  */
9367b8112SChris Zankel 
1058b17c55SMax Filippov #ifndef _ASM_SYSCALL_H
1158b17c55SMax Filippov #define _ASM_SYSCALL_H
1258b17c55SMax Filippov 
139f24f3c1SMax Filippov #include <linux/err.h>
149f24f3c1SMax Filippov #include <asm/ptrace.h>
1598c3115aSDmitry V. Levin #include <uapi/linux/audit.h>
1698c3115aSDmitry V. Levin 
syscall_get_arch(struct task_struct * task)1716add411SDmitry V. Levin static inline int syscall_get_arch(struct task_struct *task)
1898c3115aSDmitry V. Levin {
1998c3115aSDmitry V. Levin 	return AUDIT_ARCH_XTENSA;
2098c3115aSDmitry V. Levin }
2198c3115aSDmitry V. Levin 
22af5395c2SMax Filippov typedef void (*syscall_t)(void);
23af5395c2SMax Filippov extern syscall_t sys_call_table[];
24af5395c2SMax Filippov 
syscall_get_nr(struct task_struct * task,struct pt_regs * regs)259f24f3c1SMax Filippov static inline long syscall_get_nr(struct task_struct *task,
269f24f3c1SMax Filippov 				  struct pt_regs *regs)
279f24f3c1SMax Filippov {
289f24f3c1SMax Filippov 	return regs->syscall;
299f24f3c1SMax Filippov }
309f24f3c1SMax Filippov 
syscall_rollback(struct task_struct * task,struct pt_regs * regs)319f24f3c1SMax Filippov static inline void syscall_rollback(struct task_struct *task,
329f24f3c1SMax Filippov 				    struct pt_regs *regs)
339f24f3c1SMax Filippov {
349f24f3c1SMax Filippov 	/* Do nothing. */
359f24f3c1SMax Filippov }
369f24f3c1SMax Filippov 
syscall_get_error(struct task_struct * task,struct pt_regs * regs)379f24f3c1SMax Filippov static inline long syscall_get_error(struct task_struct *task,
389f24f3c1SMax Filippov 				     struct pt_regs *regs)
399f24f3c1SMax Filippov {
409f24f3c1SMax Filippov 	/* 0 if syscall succeeded, otherwise -Errorcode */
419f24f3c1SMax Filippov 	return IS_ERR_VALUE(regs->areg[2]) ? regs->areg[2] : 0;
429f24f3c1SMax Filippov }
439f24f3c1SMax Filippov 
syscall_get_return_value(struct task_struct * task,struct pt_regs * regs)449f24f3c1SMax Filippov static inline long syscall_get_return_value(struct task_struct *task,
459f24f3c1SMax Filippov 					    struct pt_regs *regs)
469f24f3c1SMax Filippov {
479f24f3c1SMax Filippov 	return regs->areg[2];
489f24f3c1SMax Filippov }
499f24f3c1SMax Filippov 
syscall_set_return_value(struct task_struct * task,struct pt_regs * regs,int error,long val)509f24f3c1SMax Filippov static inline void syscall_set_return_value(struct task_struct *task,
519f24f3c1SMax Filippov 					    struct pt_regs *regs,
529f24f3c1SMax Filippov 					    int error, long val)
539f24f3c1SMax Filippov {
54c2d9aa3bSMax Filippov 	regs->areg[2] = (long) error ? error : val;
559f24f3c1SMax Filippov }
569f24f3c1SMax Filippov 
579f24f3c1SMax Filippov #define SYSCALL_MAX_ARGS 6
589f24f3c1SMax Filippov #define XTENSA_SYSCALL_ARGUMENT_REGS {6, 3, 4, 5, 8, 9}
599f24f3c1SMax Filippov 
syscall_get_arguments(struct task_struct * task,struct pt_regs * regs,unsigned long * args)609f24f3c1SMax Filippov static inline void syscall_get_arguments(struct task_struct *task,
619f24f3c1SMax Filippov 					 struct pt_regs *regs,
629f24f3c1SMax Filippov 					 unsigned long *args)
639f24f3c1SMax Filippov {
649f24f3c1SMax Filippov 	static const unsigned int reg[] = XTENSA_SYSCALL_ARGUMENT_REGS;
65b35f549dSSteven Rostedt (Red Hat) 	unsigned int i;
669f24f3c1SMax Filippov 
67b35f549dSSteven Rostedt (Red Hat) 	for (i = 0; i < 6; ++i)
68b35f549dSSteven Rostedt (Red Hat) 		args[i] = regs->areg[reg[i]];
699f24f3c1SMax Filippov }
709f24f3c1SMax Filippov 
71*9d9043f6SMax Filippov asmlinkage long xtensa_rt_sigreturn(void);
72367b8112SChris Zankel asmlinkage long xtensa_shmat(int, char __user *, int);
73367b8112SChris Zankel asmlinkage long xtensa_fadvise64_64(int, int,
74367b8112SChris Zankel 				    unsigned long long, unsigned long long);
75367b8112SChris Zankel 
7658b17c55SMax Filippov #endif
77