Paul Mundt | fb4f87a | 2008-09-12 22:13:13 +0900 | [diff] [blame] | 1 | #ifndef __ASM_SH_SYSCALL_64_H |
| 2 | #define __ASM_SH_SYSCALL_64_H |
| 3 | |
Eric Paris | 37d181b | 2014-03-11 13:41:04 -0400 | [diff] [blame] | 4 | #include <uapi/linux/audit.h> |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 5 | #include <linux/kernel.h> |
| 6 | #include <linux/sched.h> |
| 7 | #include <asm/ptrace.h> |
| 8 | |
| 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) |
| 12 | { |
| 13 | return (regs->syscall_nr >= 0) ? regs->regs[9] : -1L; |
| 14 | } |
| 15 | |
| 16 | static inline void syscall_rollback(struct task_struct *task, |
| 17 | struct pt_regs *regs) |
| 18 | { |
| 19 | /* |
| 20 | * XXX: This needs some thought. On SH we don't |
| 21 | * save away the original R9 value anywhere. |
| 22 | */ |
| 23 | } |
| 24 | |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 25 | static inline long syscall_get_error(struct task_struct *task, |
| 26 | struct pt_regs *regs) |
| 27 | { |
Paul Mundt | 03f0787 | 2009-01-29 11:21:38 +0900 | [diff] [blame] | 28 | return IS_ERR_VALUE(regs->regs[9]) ? regs->regs[9] : 0; |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | static inline long syscall_get_return_value(struct task_struct *task, |
| 32 | struct pt_regs *regs) |
| 33 | { |
| 34 | return regs->regs[9]; |
| 35 | } |
| 36 | |
| 37 | static inline void syscall_set_return_value(struct task_struct *task, |
| 38 | struct pt_regs *regs, |
| 39 | int error, long val) |
| 40 | { |
Paul Mundt | 03f0787 | 2009-01-29 11:21:38 +0900 | [diff] [blame] | 41 | if (error) |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 42 | regs->regs[9] = -error; |
Paul Mundt | 03f0787 | 2009-01-29 11:21:38 +0900 | [diff] [blame] | 43 | else |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 44 | regs->regs[9] = val; |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 45 | } |
| 46 | |
| 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) |
| 51 | { |
| 52 | BUG_ON(i + n > 6); |
Paul Mundt | d7b01f7 | 2008-12-10 20:17:15 +0900 | [diff] [blame] | 53 | memcpy(args, ®s->regs[2 + i], n * sizeof(args[0])); |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 54 | } |
| 55 | |
| 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) |
| 60 | { |
| 61 | BUG_ON(i + n > 6); |
Paul Mundt | d7b01f7 | 2008-12-10 20:17:15 +0900 | [diff] [blame] | 62 | memcpy(®s->regs[2 + i], args, n * sizeof(args[0])); |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 63 | } |
Paul Mundt | fb4f87a | 2008-09-12 22:13:13 +0900 | [diff] [blame] | 64 | |
Eric Paris | 37d181b | 2014-03-11 13:41:04 -0400 | [diff] [blame] | 65 | static inline int syscall_get_arch(void) |
| 66 | { |
| 67 | int arch = AUDIT_ARCH_SH; |
| 68 | |
| 69 | #ifdef CONFIG_64BIT |
| 70 | arch |= __AUDIT_ARCH_64BIT; |
| 71 | #endif |
| 72 | #ifdef CONFIG_CPU_LITTLE_ENDIAN |
| 73 | arch |= __AUDIT_ARCH_LE; |
| 74 | #endif |
| 75 | |
| 76 | return arch; |
| 77 | } |
Paul Mundt | fb4f87a | 2008-09-12 22:13:13 +0900 | [diff] [blame] | 78 | #endif /* __ASM_SH_SYSCALL_64_H */ |