ARM: 7574/1: kernel/process.c: include idmap.h instead of redeclaring setup_mm_for_re...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / include / asm / syscall.h
CommitLineData
bf2c9f98
WF
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>
8ef102c6 11#include <linux/sched.h>
bf2c9f98 12
1f66e06f
WF
13#include <asm/unistd.h>
14
15#define NR_syscalls (__NR_syscalls)
16
bf2c9f98
WF
17extern const unsigned long sys_call_table[];
18
19static inline int syscall_get_nr(struct task_struct *task,
20 struct pt_regs *regs)
21{
22 return task_thread_info(task)->syscall;
23}
24
25static inline void syscall_rollback(struct task_struct *task,
26 struct pt_regs *regs)
27{
28 regs->ARM_r0 = regs->ARM_ORIG_r0;
29}
30
31static inline long syscall_get_error(struct task_struct *task,
32 struct pt_regs *regs)
33{
34 unsigned long error = regs->ARM_r0;
35 return IS_ERR_VALUE(error) ? error : 0;
36}
37
38static inline long syscall_get_return_value(struct task_struct *task,
39 struct pt_regs *regs)
40{
41 return regs->ARM_r0;
42}
43
44static inline void syscall_set_return_value(struct task_struct *task,
45 struct pt_regs *regs,
46 int error, long val)
47{
48 regs->ARM_r0 = (long) error ? error : val;
49}
50
51#define SYSCALL_MAX_ARGS 7
52
53static inline void syscall_get_arguments(struct task_struct *task,
54 struct pt_regs *regs,
55 unsigned int i, unsigned int n,
56 unsigned long *args)
57{
58 if (i + n > SYSCALL_MAX_ARGS) {
59 unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i;
60 unsigned int n_bad = n + i - SYSCALL_MAX_ARGS;
61 pr_warning("%s called with max args %d, handling only %d\n",
62 __func__, i + n, SYSCALL_MAX_ARGS);
63 memset(args_bad, 0, n_bad * sizeof(args[0]));
64 n = SYSCALL_MAX_ARGS - i;
65 }
66
67 if (i == 0) {
68 args[0] = regs->ARM_ORIG_r0;
69 args++;
70 i++;
71 n--;
72 }
73
74 memcpy(args, &regs->ARM_r0 + i, n * sizeof(args[0]));
75}
76
77static inline void syscall_set_arguments(struct task_struct *task,
78 struct pt_regs *regs,
79 unsigned int i, unsigned int n,
80 const unsigned long *args)
81{
82 if (i + n > SYSCALL_MAX_ARGS) {
83 pr_warning("%s called with max args %d, handling only %d\n",
84 __func__, i + n, SYSCALL_MAX_ARGS);
85 n = SYSCALL_MAX_ARGS - i;
86 }
87
88 if (i == 0) {
89 regs->ARM_ORIG_r0 = args[0];
90 args++;
91 i++;
92 n--;
93 }
94
95 memcpy(&regs->ARM_r0 + i, args, n * sizeof(args[0]));
96}
97
98#endif /* _ASM_ARM_SYSCALL_H */