Adding support for MOXA ART SoC. Testing port of linux-2.6.32.60-moxart.
[linux-3.6.7-moxart.git] / arch / arm / include / asm / syscall.h
blobfce38a684e4493607cd0ad3c99381c56b22b7e33
1 /*
2 * Access to user system call parameters and results
4 * See asm-generic/syscall.h for descriptions of what we must do here.
5 */
7 #ifndef _ASM_ARM_SYSCALL_H
8 #define _ASM_ARM_SYSCALL_H
10 #include <linux/err.h>
11 #include <linux/sched.h>
13 extern const unsigned long sys_call_table[];
15 static inline int syscall_get_nr(struct task_struct *task,
16 struct pt_regs *regs)
18 return task_thread_info(task)->syscall;
21 static inline void syscall_rollback(struct task_struct *task,
22 struct pt_regs *regs)
24 regs->ARM_r0 = regs->ARM_ORIG_r0;
27 static inline long syscall_get_error(struct task_struct *task,
28 struct pt_regs *regs)
30 unsigned long error = regs->ARM_r0;
31 return IS_ERR_VALUE(error) ? error : 0;
34 static inline long syscall_get_return_value(struct task_struct *task,
35 struct pt_regs *regs)
37 return regs->ARM_r0;
40 static inline void syscall_set_return_value(struct task_struct *task,
41 struct pt_regs *regs,
42 int error, long val)
44 regs->ARM_r0 = (long) error ? error : val;
47 #define SYSCALL_MAX_ARGS 7
49 static inline void syscall_get_arguments(struct task_struct *task,
50 struct pt_regs *regs,
51 unsigned int i, unsigned int n,
52 unsigned long *args)
54 if (i + n > SYSCALL_MAX_ARGS) {
55 unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i;
56 unsigned int n_bad = n + i - SYSCALL_MAX_ARGS;
57 pr_warning("%s called with max args %d, handling only %d\n",
58 __func__, i + n, SYSCALL_MAX_ARGS);
59 memset(args_bad, 0, n_bad * sizeof(args[0]));
60 n = SYSCALL_MAX_ARGS - i;
63 if (i == 0) {
64 args[0] = regs->ARM_ORIG_r0;
65 args++;
66 i++;
67 n--;
70 memcpy(args, &regs->ARM_r0 + i, n * sizeof(args[0]));
73 static inline void syscall_set_arguments(struct task_struct *task,
74 struct pt_regs *regs,
75 unsigned int i, unsigned int n,
76 const unsigned long *args)
78 if (i + n > SYSCALL_MAX_ARGS) {
79 pr_warning("%s called with max args %d, handling only %d\n",
80 __func__, i + n, SYSCALL_MAX_ARGS);
81 n = SYSCALL_MAX_ARGS - i;
84 if (i == 0) {
85 regs->ARM_ORIG_r0 = args[0];
86 args++;
87 i++;
88 n--;
91 memcpy(&regs->ARM_r0 + i, args, n * sizeof(args[0]));
94 #endif /* _ASM_ARM_SYSCALL_H */