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