Linux 4.8-rc8
[linux/fpc-iii.git] / arch / sh / include / asm / syscall_64.h
blobc6a797b90b8052f1dfc879a41f722c2fabac8c63
1 #ifndef __ASM_SH_SYSCALL_64_H
2 #define __ASM_SH_SYSCALL_64_H
4 #include <uapi/linux/audit.h>
5 #include <linux/kernel.h>
6 #include <linux/sched.h>
7 #include <asm/ptrace.h>
9 /* The system call number is given by the user in R9 */
10 static inline long syscall_get_nr(struct task_struct *task,
11 struct pt_regs *regs)
13 return (regs->syscall_nr >= 0) ? regs->regs[9] : -1L;
16 static inline void syscall_rollback(struct task_struct *task,
17 struct pt_regs *regs)
20 * XXX: This needs some thought. On SH we don't
21 * save away the original R9 value anywhere.
25 static inline long syscall_get_error(struct task_struct *task,
26 struct pt_regs *regs)
28 return IS_ERR_VALUE(regs->regs[9]) ? regs->regs[9] : 0;
31 static inline long syscall_get_return_value(struct task_struct *task,
32 struct pt_regs *regs)
34 return regs->regs[9];
37 static inline void syscall_set_return_value(struct task_struct *task,
38 struct pt_regs *regs,
39 int error, long val)
41 if (error)
42 regs->regs[9] = -error;
43 else
44 regs->regs[9] = val;
47 static inline void syscall_get_arguments(struct task_struct *task,
48 struct pt_regs *regs,
49 unsigned int i, unsigned int n,
50 unsigned long *args)
52 BUG_ON(i + n > 6);
53 memcpy(args, &regs->regs[2 + i], n * sizeof(args[0]));
56 static inline void syscall_set_arguments(struct task_struct *task,
57 struct pt_regs *regs,
58 unsigned int i, unsigned int n,
59 const unsigned long *args)
61 BUG_ON(i + n > 6);
62 memcpy(&regs->regs[2 + i], args, n * sizeof(args[0]));
65 static inline int syscall_get_arch(void)
67 int arch = AUDIT_ARCH_SH;
69 #ifdef CONFIG_64BIT
70 arch |= __AUDIT_ARCH_64BIT;
71 #endif
72 #ifdef CONFIG_CPU_LITTLE_ENDIAN
73 arch |= __AUDIT_ARCH_LE;
74 #endif
76 return arch;
78 #endif /* __ASM_SH_SYSCALL_64_H */