Commit | Line | Data |
---|---|---|
4859bfca GR |
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> | |
d770b256 | 9 | #include <uapi/linux/audit.h> |
4859bfca GR |
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, | |
b35f549d | 46 | unsigned long *args) |
4859bfca | 47 | { |
b35f549d SRRH |
48 | args[0] = regs->orig_a0; |
49 | args++; | |
50 | memcpy(args, ®s->a1, 5 * sizeof(args[0])); | |
4859bfca GR |
51 | } |
52 | ||
53 | static inline void | |
54 | syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, | |
55 | unsigned int i, unsigned int n, const unsigned long *args) | |
56 | { | |
57 | BUG_ON(i + n > 6); | |
58 | if (i == 0) { | |
59 | regs->orig_a0 = args[0]; | |
60 | args++; | |
4859bfca | 61 | n--; |
ed3bb007 DL |
62 | } else { |
63 | i--; | |
4859bfca | 64 | } |
ed3bb007 | 65 | memcpy(®s->a1 + i, args, n * sizeof(regs->a1)); |
4859bfca GR |
66 | } |
67 | ||
d770b256 DL |
68 | static inline int |
69 | syscall_get_arch(void) | |
70 | { | |
71 | return AUDIT_ARCH_CSKY; | |
72 | } | |
73 | ||
4859bfca | 74 | #endif /* __ASM_SYSCALL_H */ |