OSDN Git Service

csky: Fix syscall_get_arguments() and syscall_set_arguments()
[uclinux-h8/linux.git] / arch / csky / include / asm / syscall.h
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                 n--;
53         } else {
54                 i--;
55         }
56         memcpy(args, &regs->a1 + i, n * sizeof(args[0]));
57 }
58
59 static inline void
60 syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
61                       unsigned int i, unsigned int n, const unsigned long *args)
62 {
63         BUG_ON(i + n > 6);
64         if (i == 0) {
65                 regs->orig_a0 = args[0];
66                 args++;
67                 n--;
68         } else {
69                 i--;
70         }
71         memcpy(&regs->a1 + i, args, n * sizeof(regs->a1));
72 }
73
74 static inline int
75 syscall_get_arch(void)
76 {
77         return AUDIT_ARCH_CSKY;
78 }
79
80 #endif  /* __ASM_SYSCALL_H */