2 * Access to user system call parameters and results
4 * Copyright IBM Corp. 2008
5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License (version 2 only)
9 * as published by the Free Software Foundation.
12 #ifndef _ASM_SYSCALL_H
13 #define _ASM_SYSCALL_H 1
15 #include <linux/sched.h>
16 #include <asm/ptrace.h>
18 static inline long syscall_get_nr(struct task_struct *task,
21 return regs->svcnr ? regs->svcnr : -1;
24 static inline void syscall_rollback(struct task_struct *task,
27 regs->gprs[2] = regs->orig_gpr2;
30 static inline long syscall_get_error(struct task_struct *task,
33 return (regs->gprs[2] >= -4096UL) ? -regs->gprs[2] : 0;
36 static inline long syscall_get_return_value(struct task_struct *task,
42 static inline void syscall_set_return_value(struct task_struct *task,
46 regs->gprs[2] = error ? -error : val;
49 static inline void syscall_get_arguments(struct task_struct *task,
51 unsigned int i, unsigned int n,
54 unsigned long mask = -1UL;
58 if (test_tsk_thread_flag(task, TIF_31BIT))
62 args[--n] = regs->args[0] & mask;
65 args[n] = regs->gprs[2 + i + n] & mask;
67 args[0] = regs->orig_gpr2 & mask;
70 static inline void syscall_set_arguments(struct task_struct *task,
72 unsigned int i, unsigned int n,
73 const unsigned long *args)
77 regs->args[0] = args[--n];
80 regs->gprs[2 + i + n] = args[n];
82 regs->orig_gpr2 = args[0];
85 #endif /* _ASM_SYSCALL_H */