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 | |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 4 | #include <linux/kernel.h> |
| 5 | #include <linux/sched.h> |
| 6 | #include <asm/ptrace.h> |
| 7 | |
| 8 | /* The system call number is given by the user in R9 */ |
| 9 | static inline long syscall_get_nr(struct task_struct *task, |
| 10 | struct pt_regs *regs) |
| 11 | { |
| 12 | return (regs->syscall_nr >= 0) ? regs->regs[9] : -1L; |
| 13 | } |
| 14 | |
| 15 | static inline void syscall_rollback(struct task_struct *task, |
| 16 | struct pt_regs *regs) |
| 17 | { |
| 18 | /* |
| 19 | * XXX: This needs some thought. On SH we don't |
| 20 | * save away the original R9 value anywhere. |
| 21 | */ |
| 22 | } |
| 23 | |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 24 | static inline long syscall_get_error(struct task_struct *task, |
| 25 | struct pt_regs *regs) |
| 26 | { |
Paul Mundt | 03f0787 | 2009-01-29 11:21:38 +0900 | [diff] [blame] | 27 | return IS_ERR_VALUE(regs->regs[9]) ? regs->regs[9] : 0; |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | static inline long syscall_get_return_value(struct task_struct *task, |
| 31 | struct pt_regs *regs) |
| 32 | { |
| 33 | return regs->regs[9]; |
| 34 | } |
| 35 | |
| 36 | static inline void syscall_set_return_value(struct task_struct *task, |
| 37 | struct pt_regs *regs, |
| 38 | int error, long val) |
| 39 | { |
Paul Mundt | 03f0787 | 2009-01-29 11:21:38 +0900 | [diff] [blame] | 40 | if (error) |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 41 | regs->regs[9] = -error; |
Paul Mundt | 03f0787 | 2009-01-29 11:21:38 +0900 | [diff] [blame] | 42 | else |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 43 | regs->regs[9] = val; |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | static inline void syscall_get_arguments(struct task_struct *task, |
| 47 | struct pt_regs *regs, |
| 48 | unsigned int i, unsigned int n, |
| 49 | unsigned long *args) |
| 50 | { |
| 51 | BUG_ON(i + n > 6); |
Paul Mundt | d7b01f7 | 2008-12-10 20:17:15 +0900 | [diff] [blame] | 52 | memcpy(args, ®s->regs[2 + i], n * sizeof(args[0])); |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | static inline void syscall_set_arguments(struct task_struct *task, |
| 56 | struct pt_regs *regs, |
| 57 | unsigned int i, unsigned int n, |
| 58 | const unsigned long *args) |
| 59 | { |
| 60 | BUG_ON(i + n > 6); |
Paul Mundt | d7b01f7 | 2008-12-10 20:17:15 +0900 | [diff] [blame] | 61 | memcpy(®s->regs[2 + i], args, n * sizeof(args[0])); |
Paul Mundt | 94e2fb3 | 2008-12-10 19:46:18 +0900 | [diff] [blame] | 62 | } |
Paul Mundt | fb4f87a | 2008-09-12 22:13:13 +0900 | [diff] [blame] | 63 | |
| 64 | #endif /* __ASM_SH_SYSCALL_64_H */ |