1 /* 2 * Access to user system call parameters and results 3 * 4 * See asm-generic/syscall.h for descriptions of what we must do here. 5 */ 6 7 #ifndef _ASM_ARM_SYSCALL_H 8 #define _ASM_ARM_SYSCALL_H 9 10 #include <linux/err.h> 11 12 #include <asm/unistd.h> 13 14 #define NR_syscalls (__NR_syscalls) 15 16 extern const unsigned long sys_call_table[]; 17 18 static inline int syscall_get_nr(struct task_struct *task, 19 struct pt_regs *regs) 20 { 21 return task_thread_info(task)->syscall; 22 } 23 24 static inline void syscall_rollback(struct task_struct *task, 25 struct pt_regs *regs) 26 { 27 regs->ARM_r0 = regs->ARM_ORIG_r0; 28 } 29 30 static inline long syscall_get_error(struct task_struct *task, 31 struct pt_regs *regs) 32 { 33 unsigned long error = regs->ARM_r0; 34 return IS_ERR_VALUE(error) ? error : 0; 35 } 36 37 static inline long syscall_get_return_value(struct task_struct *task, 38 struct pt_regs *regs) 39 { 40 return regs->ARM_r0; 41 } 42 43 static inline void syscall_set_return_value(struct task_struct *task, 44 struct pt_regs *regs, 45 int error, long val) 46 { 47 regs->ARM_r0 = (long) error ? error : val; 48 } 49 50 #define SYSCALL_MAX_ARGS 7 51 52 static inline void syscall_get_arguments(struct task_struct *task, 53 struct pt_regs *regs, 54 unsigned int i, unsigned int n, 55 unsigned long *args) 56 { 57 if (i + n > SYSCALL_MAX_ARGS) { 58 unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i; 59 unsigned int n_bad = n + i - SYSCALL_MAX_ARGS; 60 pr_warning("%s called with max args %d, handling only %d\n", 61 __func__, i + n, SYSCALL_MAX_ARGS); 62 memset(args_bad, 0, n_bad * sizeof(args[0])); 63 n = SYSCALL_MAX_ARGS - i; 64 } 65 66 if (i == 0) { 67 args[0] = regs->ARM_ORIG_r0; 68 args++; 69 i++; 70 n--; 71 } 72 73 memcpy(args, ®s->ARM_r0 + i, n * sizeof(args[0])); 74 } 75 76 static inline void syscall_set_arguments(struct task_struct *task, 77 struct pt_regs *regs, 78 unsigned int i, unsigned int n, 79 const unsigned long *args) 80 { 81 if (i + n > SYSCALL_MAX_ARGS) { 82 pr_warning("%s called with max args %d, handling only %d\n", 83 __func__, i + n, SYSCALL_MAX_ARGS); 84 n = SYSCALL_MAX_ARGS - i; 85 } 86 87 if (i == 0) { 88 regs->ARM_ORIG_r0 = args[0]; 89 args++; 90 i++; 91 n--; 92 } 93 94 memcpy(®s->ARM_r0 + i, args, n * sizeof(args[0])); 95 } 96 97 #endif /* _ASM_ARM_SYSCALL_H */ 98