Shaohua Li | cfb361f | 2008-09-18 15:49:14 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Access to user system call parameters and results |
| 3 | * |
| 4 | * Copyright (C) 2008 Intel Corp. Shaohua Li <shaohua.li@intel.com> |
| 5 | * |
| 6 | * This copyrighted material is made available to anyone wishing to use, |
| 7 | * modify, copy, or redistribute it subject to the terms and conditions |
| 8 | * of the GNU General Public License v.2. |
| 9 | * |
| 10 | * See asm-generic/syscall.h for descriptions of what we must do here. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _ASM_SYSCALL_H |
| 14 | #define _ASM_SYSCALL_H 1 |
| 15 | |
Eric Paris | ce5d112 | 2014-03-11 13:50:46 -0400 | [diff] [blame] | 16 | #include <uapi/linux/audit.h> |
Shaohua Li | cfb361f | 2008-09-18 15:49:14 +0800 | [diff] [blame] | 17 | #include <linux/sched.h> |
| 18 | #include <linux/err.h> |
| 19 | |
| 20 | static inline long syscall_get_nr(struct task_struct *task, |
| 21 | struct pt_regs *regs) |
| 22 | { |
Shaohua Li | cfb361f | 2008-09-18 15:49:14 +0800 | [diff] [blame] | 23 | if ((long)regs->cr_ifs < 0) /* Not a syscall */ |
| 24 | return -1; |
Shaohua Li | 680973e | 2008-09-18 15:50:26 +0800 | [diff] [blame] | 25 | |
Shaohua Li | cfb361f | 2008-09-18 15:49:14 +0800 | [diff] [blame] | 26 | return regs->r15; |
| 27 | } |
| 28 | |
| 29 | static inline void syscall_rollback(struct task_struct *task, |
| 30 | struct pt_regs *regs) |
| 31 | { |
Shaohua Li | cfb361f | 2008-09-18 15:49:14 +0800 | [diff] [blame] | 32 | /* do nothing */ |
| 33 | } |
| 34 | |
| 35 | static inline long syscall_get_error(struct task_struct *task, |
| 36 | struct pt_regs *regs) |
| 37 | { |
Shaohua Li | cfb361f | 2008-09-18 15:49:14 +0800 | [diff] [blame] | 38 | return regs->r10 == -1 ? regs->r8:0; |
| 39 | } |
| 40 | |
| 41 | static inline long syscall_get_return_value(struct task_struct *task, |
| 42 | struct pt_regs *regs) |
| 43 | { |
Shaohua Li | cfb361f | 2008-09-18 15:49:14 +0800 | [diff] [blame] | 44 | return regs->r8; |
| 45 | } |
| 46 | |
| 47 | static inline void syscall_set_return_value(struct task_struct *task, |
| 48 | struct pt_regs *regs, |
| 49 | int error, long val) |
| 50 | { |
Shaohua Li | cfb361f | 2008-09-18 15:49:14 +0800 | [diff] [blame] | 51 | if (error) { |
| 52 | /* error < 0, but ia64 uses > 0 return value */ |
| 53 | regs->r8 = -error; |
| 54 | regs->r10 = -1; |
| 55 | } else { |
| 56 | regs->r8 = val; |
| 57 | regs->r10 = 0; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | extern void ia64_syscall_get_set_arguments(struct task_struct *task, |
| 62 | struct pt_regs *regs, unsigned int i, unsigned int n, |
| 63 | unsigned long *args, int rw); |
| 64 | static inline void syscall_get_arguments(struct task_struct *task, |
| 65 | struct pt_regs *regs, |
| 66 | unsigned int i, unsigned int n, |
| 67 | unsigned long *args) |
| 68 | { |
Shaohua Li | cfb361f | 2008-09-18 15:49:14 +0800 | [diff] [blame] | 69 | BUG_ON(i + n > 6); |
| 70 | |
| 71 | ia64_syscall_get_set_arguments(task, regs, i, n, args, 0); |
| 72 | } |
| 73 | |
| 74 | static inline void syscall_set_arguments(struct task_struct *task, |
| 75 | struct pt_regs *regs, |
| 76 | unsigned int i, unsigned int n, |
| 77 | unsigned long *args) |
| 78 | { |
Shaohua Li | cfb361f | 2008-09-18 15:49:14 +0800 | [diff] [blame] | 79 | BUG_ON(i + n > 6); |
| 80 | |
Shaohua Li | cfb361f | 2008-09-18 15:49:14 +0800 | [diff] [blame] | 81 | ia64_syscall_get_set_arguments(task, regs, i, n, args, 1); |
| 82 | } |
Eric Paris | ce5d112 | 2014-03-11 13:50:46 -0400 | [diff] [blame] | 83 | |
| 84 | static inline int syscall_get_arch(void) |
| 85 | { |
| 86 | return AUDIT_ARCH_IA64; |
| 87 | } |
Shaohua Li | cfb361f | 2008-09-18 15:49:14 +0800 | [diff] [blame] | 88 | #endif /* _ASM_SYSCALL_H */ |