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