1 /* SPDX-License-Identifier: GPL-2.0 */ 2 3 #ifndef __ASM_SYSCALL_H 4 #define __ASM_SYSCALL_H 5 6 #include <linux/sched.h> 7 #include <linux/err.h> 8 #include <abi/regdef.h> 9 #include <uapi/linux/audit.h> 10 11 static inline int 12 syscall_get_nr(struct task_struct *task, struct pt_regs *regs) 13 { 14 return regs_syscallid(regs); 15 } 16 17 static inline void 18 syscall_rollback(struct task_struct *task, struct pt_regs *regs) 19 { 20 regs->a0 = regs->orig_a0; 21 } 22 23 static inline long 24 syscall_get_error(struct task_struct *task, struct pt_regs *regs) 25 { 26 unsigned long error = regs->a0; 27 28 return IS_ERR_VALUE(error) ? error : 0; 29 } 30 31 static inline long 32 syscall_get_return_value(struct task_struct *task, struct pt_regs *regs) 33 { 34 return regs->a0; 35 } 36 37 static inline void 38 syscall_set_return_value(struct task_struct *task, struct pt_regs *regs, 39 int error, long val) 40 { 41 regs->a0 = (long) error ?: val; 42 } 43 44 static inline void 45 syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, 46 unsigned int i, unsigned int n, unsigned long *args) 47 { 48 BUG_ON(i + n > 6); 49 if (i == 0) { 50 args[0] = regs->orig_a0; 51 args++; 52 i++; 53 n--; 54 } 55 memcpy(args, ®s->a1 + i * sizeof(regs->a1), n * sizeof(args[0])); 56 } 57 58 static inline void 59 syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, 60 unsigned int i, unsigned int n, const unsigned long *args) 61 { 62 BUG_ON(i + n > 6); 63 if (i == 0) { 64 regs->orig_a0 = args[0]; 65 args++; 66 i++; 67 n--; 68 } 69 memcpy(®s->a1 + i * sizeof(regs->a1), args, n * sizeof(regs->a0)); 70 } 71 72 static inline int 73 syscall_get_arch(void) 74 { 75 return AUDIT_ARCH_CSKY; 76 } 77 78 #endif /* __ASM_SYSCALL_H */ 79