1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef _ASM_TILE_SYSCALL_H
19#define _ASM_TILE_SYSCALL_H
20
21#include <linux/sched.h>
22#include <linux/err.h>
23#include <linux/audit.h>
24#include <linux/compat.h>
25#include <arch/abi.h>
26
27
28extern void *sys_call_table[];
29#ifdef CONFIG_COMPAT
30extern void *compat_sys_call_table[];
31#endif
32
33
34
35
36
37
38static inline int syscall_get_nr(struct task_struct *t, struct pt_regs *regs)
39{
40 return regs->regs[TREG_SYSCALL_NR];
41}
42
43static inline void syscall_rollback(struct task_struct *task,
44 struct pt_regs *regs)
45{
46 regs->regs[0] = regs->orig_r0;
47}
48
49static inline long syscall_get_error(struct task_struct *task,
50 struct pt_regs *regs)
51{
52 unsigned long error = regs->regs[0];
53 return IS_ERR_VALUE(error) ? error : 0;
54}
55
56static inline long syscall_get_return_value(struct task_struct *task,
57 struct pt_regs *regs)
58{
59 return regs->regs[0];
60}
61
62static inline void syscall_set_return_value(struct task_struct *task,
63 struct pt_regs *regs,
64 int error, long val)
65{
66 if (error) {
67
68 regs->regs[0] = error;
69 regs->regs[1] = -error;
70 } else {
71
72 regs->regs[0] = val;
73 regs->regs[1] = 0;
74 }
75}
76
77static inline void syscall_get_arguments(struct task_struct *task,
78 struct pt_regs *regs,
79 unsigned int i, unsigned int n,
80 unsigned long *args)
81{
82 BUG_ON(i + n > 6);
83 memcpy(args, ®s[i], n * sizeof(args[0]));
84}
85
86static inline void syscall_set_arguments(struct task_struct *task,
87 struct pt_regs *regs,
88 unsigned int i, unsigned int n,
89 const unsigned long *args)
90{
91 BUG_ON(i + n > 6);
92 memcpy(®s[i], args, n * sizeof(args[0]));
93}
94
95
96
97
98
99static inline int syscall_get_arch(void)
100{
101 if (is_compat_task())
102 return AUDIT_ARCH_TILEGX32;
103
104#ifdef CONFIG_TILEGX
105 return AUDIT_ARCH_TILEGX;
106#else
107 return AUDIT_ARCH_TILEPRO;
108#endif
109}
110
111#endif
112