diff options
| author | Michal Simek <monstr@monstr.eu> | 2009-08-24 07:25:16 -0400 |
|---|---|---|
| committer | Michal Simek <monstr@monstr.eu> | 2009-09-21 08:29:21 -0400 |
| commit | d5b37092aae1edaa638b156b16d09854ad6a1ec0 (patch) | |
| tree | 47495597445dec478ddb83e969201d7fc8c5e87e /arch/microblaze/include | |
| parent | 9002062ff52696888847224a778a3279bc8c1cb5 (diff) | |
microblaze: Implement include/asm/syscall.h.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch/microblaze/include')
| -rw-r--r-- | arch/microblaze/include/asm/syscall.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/arch/microblaze/include/asm/syscall.h b/arch/microblaze/include/asm/syscall.h new file mode 100644 index 000000000000..048dfcd8d89d --- /dev/null +++ b/arch/microblaze/include/asm/syscall.h | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | #ifndef __ASM_MICROBLAZE_SYSCALL_H | ||
| 2 | #define __ASM_MICROBLAZE_SYSCALL_H | ||
| 3 | |||
| 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 R12 */ | ||
| 9 | static inline long syscall_get_nr(struct task_struct *task, | ||
| 10 | struct pt_regs *regs) | ||
| 11 | { | ||
| 12 | return regs->r12; | ||
| 13 | } | ||
| 14 | |||
| 15 | static inline void syscall_rollback(struct task_struct *task, | ||
| 16 | struct pt_regs *regs) | ||
| 17 | { | ||
| 18 | /* TODO. */ | ||
| 19 | } | ||
| 20 | |||
| 21 | static inline long syscall_get_error(struct task_struct *task, | ||
| 22 | struct pt_regs *regs) | ||
| 23 | { | ||
| 24 | return IS_ERR_VALUE(regs->r3) ? regs->r3 : 0; | ||
| 25 | } | ||
| 26 | |||
| 27 | static inline long syscall_get_return_value(struct task_struct *task, | ||
| 28 | struct pt_regs *regs) | ||
| 29 | { | ||
| 30 | return regs->r3; | ||
| 31 | } | ||
| 32 | |||
| 33 | static inline void syscall_set_return_value(struct task_struct *task, | ||
| 34 | struct pt_regs *regs, | ||
| 35 | int error, long val) | ||
| 36 | { | ||
| 37 | if (error) | ||
| 38 | regs->r3 = -error; | ||
| 39 | else | ||
| 40 | regs->r3 = val; | ||
| 41 | } | ||
| 42 | |||
| 43 | static inline microblaze_reg_t microblaze_get_syscall_arg(struct pt_regs *regs, | ||
| 44 | unsigned int n) | ||
| 45 | { | ||
| 46 | switch (n) { | ||
| 47 | case 5: return regs->r10; | ||
| 48 | case 4: return regs->r9; | ||
| 49 | case 3: return regs->r8; | ||
| 50 | case 2: return regs->r7; | ||
| 51 | case 1: return regs->r6; | ||
| 52 | case 0: return regs->r5; | ||
| 53 | default: | ||
| 54 | BUG(); | ||
| 55 | } | ||
| 56 | return ~0; | ||
| 57 | } | ||
| 58 | |||
| 59 | static inline void microblaze_set_syscall_arg(struct pt_regs *regs, | ||
| 60 | unsigned int n, | ||
| 61 | unsigned long val) | ||
| 62 | { | ||
| 63 | switch (n) { | ||
| 64 | case 5: | ||
| 65 | regs->r10 = val; | ||
| 66 | case 4: | ||
| 67 | regs->r9 = val; | ||
| 68 | case 3: | ||
| 69 | regs->r8 = val; | ||
| 70 | case 2: | ||
| 71 | regs->r7 = val; | ||
| 72 | case 1: | ||
| 73 | regs->r6 = val; | ||
| 74 | case 0: | ||
| 75 | regs->r5 = val; | ||
| 76 | default: | ||
| 77 | BUG(); | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | static inline void syscall_get_arguments(struct task_struct *task, | ||
| 82 | struct pt_regs *regs, | ||
| 83 | unsigned int i, unsigned int n, | ||
| 84 | unsigned long *args) | ||
| 85 | { | ||
| 86 | while (n--) | ||
| 87 | *args++ = microblaze_get_syscall_arg(regs, i++); | ||
| 88 | } | ||
| 89 | |||
| 90 | static inline void syscall_set_arguments(struct task_struct *task, | ||
| 91 | struct pt_regs *regs, | ||
| 92 | unsigned int i, unsigned int n, | ||
| 93 | const unsigned long *args) | ||
| 94 | { | ||
| 95 | while (n--) | ||
| 96 | microblaze_set_syscall_arg(regs, i++, *args++); | ||
| 97 | } | ||
| 98 | |||
| 99 | #endif /* __ASM_MICROBLAZE_SYSCALL_H */ | ||
