xref: /linux/arch/csky/include/asm/syscall.h (revision 2f7932b011e7fb9f98732f95a68f6017d4d8c542)
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 extern void *sys_call_table[];
12 
13 static inline int
14 syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
15 {
16 	return regs_syscallid(regs);
17 }
18 
19 static inline void
20 syscall_rollback(struct task_struct *task, struct pt_regs *regs)
21 {
22 	regs->a0 = regs->orig_a0;
23 }
24 
25 static inline long
26 syscall_get_error(struct task_struct *task, struct pt_regs *regs)
27 {
28 	unsigned long error = regs->a0;
29 
30 	return IS_ERR_VALUE(error) ? error : 0;
31 }
32 
33 static inline long
34 syscall_get_return_value(struct task_struct *task, struct pt_regs *regs)
35 {
36 	return regs->a0;
37 }
38 
39 static inline void
40 syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
41 		int error, long val)
42 {
43 	regs->a0 = (long) error ?: val;
44 }
45 
46 static inline void
47 syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
48 		      unsigned long *args)
49 {
50 	args[0] = regs->orig_a0;
51 	args++;
52 	memcpy(args, &regs->a1, 5 * sizeof(args[0]));
53 }
54 
55 static inline void
56 syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
57 		      const unsigned long *args)
58 {
59 	regs->orig_a0 = args[0];
60 	args++;
61 	memcpy(&regs->a1, args, 5 * sizeof(regs->a1));
62 }
63 
64 static inline int
65 syscall_get_arch(void)
66 {
67 	return AUDIT_ARCH_CSKY;
68 }
69 
70 #endif	/* __ASM_SYSCALL_H */
71