1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef _ASM_METAG_SYSCALL_H
14#define _ASM_METAG_SYSCALL_H
15
16#include <linux/sched.h>
17#include <linux/err.h>
18#include <linux/uaccess.h>
19
20#include <asm/switch.h>
21
22static inline long syscall_get_nr(struct task_struct *task,
23 struct pt_regs *regs)
24{
25 unsigned long insn;
26
27
28
29
30
31
32 if (get_user(insn, (unsigned long *)(regs->ctx.CurrPC - 4)))
33 return -1;
34
35 if (insn == __METAG_SW_ENCODING(SYS))
36 return regs->ctx.DX[0].U1;
37 else
38 return -1L;
39}
40
41static inline void syscall_rollback(struct task_struct *task,
42 struct pt_regs *regs)
43{
44
45}
46
47static inline long syscall_get_error(struct task_struct *task,
48 struct pt_regs *regs)
49{
50 unsigned long error = regs->ctx.DX[0].U0;
51 return IS_ERR_VALUE(error) ? error : 0;
52}
53
54static inline long syscall_get_return_value(struct task_struct *task,
55 struct pt_regs *regs)
56{
57 return regs->ctx.DX[0].U0;
58}
59
60static inline void syscall_set_return_value(struct task_struct *task,
61 struct pt_regs *regs,
62 int error, long val)
63{
64 regs->ctx.DX[0].U0 = (long) error ?: val;
65}
66
67static inline void syscall_get_arguments(struct task_struct *task,
68 struct pt_regs *regs,
69 unsigned int i, unsigned int n,
70 unsigned long *args)
71{
72 unsigned int reg, j;
73 BUG_ON(i + n > 6);
74
75 for (j = i, reg = 6 - i; j < (i + n); j++, reg--) {
76 if (reg % 2)
77 args[j] = regs->ctx.DX[(reg + 1) / 2].U0;
78 else
79 args[j] = regs->ctx.DX[reg / 2].U1;
80 }
81}
82
83static inline void syscall_set_arguments(struct task_struct *task,
84 struct pt_regs *regs,
85 unsigned int i, unsigned int n,
86 const unsigned long *args)
87{
88 unsigned int reg;
89 BUG_ON(i + n > 6);
90
91 for (reg = 6 - i; i < (i + n); i++, reg--) {
92 if (reg % 2)
93 regs->ctx.DX[(reg + 1) / 2].U0 = args[i];
94 else
95 regs->ctx.DX[reg / 2].U1 = args[i];
96 }
97}
98
99#define NR_syscalls __NR_syscalls
100
101
102extern const void *sys_call_table[];
103
104#endif
105