2 * Access to user system call parameters and results
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
8 * See asm-generic/syscall.h for descriptions of what we must do here.
10 * Copyright (C) 2012 Ralf Baechle <ralf@linux-mips.org>
13 #ifndef __ASM_MIPS_SYSCALL_H
14 #define __ASM_MIPS_SYSCALL_H
16 #include <linux/compiler.h>
17 #include <uapi/linux/audit.h>
18 #include <linux/elf-em.h>
19 #include <linux/kernel.h>
20 #include <linux/sched.h>
21 #include <linux/uaccess.h>
22 #include <asm/ptrace.h>
23 #include <asm/unistd.h>
25 #ifndef __NR_syscall /* Only defined if _MIPS_SIM == _MIPS_SIM_ABI32 */
26 #define __NR_syscall 4000
29 static inline long syscall_get_nr(struct task_struct
*task
,
32 /* O32 ABI syscall() - Either 64-bit with O32 or 32-bit */
33 if ((config_enabled(CONFIG_32BIT
) ||
34 test_tsk_thread_flag(task
, TIF_32BIT_REGS
)) &&
35 (regs
->regs
[2] == __NR_syscall
))
41 static inline unsigned long mips_get_syscall_arg(unsigned long *arg
,
42 struct task_struct
*task
, struct pt_regs
*regs
, unsigned int n
)
44 unsigned long usp __maybe_unused
= regs
->regs
[29];
47 case 0: case 1: case 2: case 3:
48 *arg
= regs
->regs
[4 + n
];
53 case 4: case 5: case 6: case 7:
54 return get_user(*arg
, (int *)usp
+ n
);
58 case 4: case 5: case 6: case 7:
59 #ifdef CONFIG_MIPS32_O32
60 if (test_thread_flag(TIF_32BIT_REGS
))
61 return get_user(*arg
, (int *)usp
+ n
);
64 *arg
= regs
->regs
[4 + n
];
76 static inline long syscall_get_return_value(struct task_struct
*task
,
82 static inline void syscall_rollback(struct task_struct
*task
,
88 static inline void syscall_set_return_value(struct task_struct
*task
,
93 regs
->regs
[2] = -error
;
101 static inline void syscall_get_arguments(struct task_struct
*task
,
102 struct pt_regs
*regs
,
103 unsigned int i
, unsigned int n
,
107 /* O32 ABI syscall() - Either 64-bit with O32 or 32-bit */
108 if ((config_enabled(CONFIG_32BIT
) ||
109 test_tsk_thread_flag(task
, TIF_32BIT_REGS
)) &&
110 (regs
->regs
[2] == __NR_syscall
)) {
116 ret
|= mips_get_syscall_arg(args
++, task
, regs
, i
++);
119 * No way to communicate an error because this is a void function.
126 extern const unsigned long sys_call_table
[];
127 extern const unsigned long sys32_call_table
[];
128 extern const unsigned long sysn32_call_table
[];
130 static inline int syscall_get_arch(void)
134 if (!test_thread_flag(TIF_32BIT_REGS
)) {
135 arch
|= __AUDIT_ARCH_64BIT
;
136 /* N32 sets only TIF_32BIT_ADDR */
137 if (test_thread_flag(TIF_32BIT_ADDR
))
138 arch
|= __AUDIT_ARCH_CONVENTION_MIPS64_N32
;
141 #if defined(__LITTLE_ENDIAN)
142 arch
|= __AUDIT_ARCH_LE
;
147 #endif /* __ASM_MIPS_SYSCALL_H */