|
1 | 1 | /*
|
| 2 | + * Access to user system call parameters and results |
| 3 | + * |
2 | 4 | * This file is subject to the terms and conditions of the GNU General Public
|
3 | 5 | * License. See the file "COPYING" in the main directory of this archive
|
4 | 6 | * for more details.
|
5 | 7 | *
|
| 8 | + * See asm-generic/syscall.h for descriptions of what we must do here. |
| 9 | + * |
6 | 10 | * Copyright (C) 2012 Ralf Baechle <[email protected]>
|
7 | 11 | */
|
8 | 12 |
|
9 | 13 | #ifndef __ASM_MIPS_SYSCALL_H
|
10 | 14 | #define __ASM_MIPS_SYSCALL_H
|
11 | 15 |
|
| 16 | +#include <linux/kernel.h> |
| 17 | +#include <linux/sched.h> |
| 18 | +#include <linux/uaccess.h> |
| 19 | +#include <asm/ptrace.h> |
| 20 | + |
| 21 | +static inline long syscall_get_nr(struct task_struct *task, |
| 22 | + struct pt_regs *regs) |
| 23 | +{ |
| 24 | + return regs->regs[2]; |
| 25 | +} |
| 26 | + |
| 27 | +static inline unsigned long mips_get_syscall_arg(unsigned long *arg, |
| 28 | + struct task_struct *task, struct pt_regs *regs, unsigned int n) |
| 29 | +{ |
| 30 | + unsigned long usp = regs->regs[29]; |
| 31 | + |
| 32 | + switch (n) { |
| 33 | + case 0: case 1: case 2: case 3: |
| 34 | + *arg = regs->regs[4 + n]; |
| 35 | + |
| 36 | + return 0; |
| 37 | + |
| 38 | +#ifdef CONFIG_32BIT |
| 39 | + case 4: case 5: case 6: case 7: |
| 40 | + return get_user(*arg, (int *)usp + 4 * n); |
| 41 | +#endif |
| 42 | + |
| 43 | +#ifdef CONFIG_64BIT |
| 44 | + case 4: case 5: case 6: case 7: |
| 45 | +#ifdef CONFIG_MIPS32_O32 |
| 46 | + if (test_thread_flag(TIF_32BIT_REGS)) |
| 47 | + return get_user(*arg, (int *)usp + 4 * n); |
| 48 | + else |
| 49 | +#endif |
| 50 | + *arg = regs->regs[4 + n]; |
| 51 | + |
| 52 | + return 0; |
| 53 | +#endif |
| 54 | + |
| 55 | + default: |
| 56 | + BUG(); |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +static inline void syscall_get_arguments(struct task_struct *task, |
| 61 | + struct pt_regs *regs, |
| 62 | + unsigned int i, unsigned int n, |
| 63 | + unsigned long *args) |
| 64 | +{ |
| 65 | + unsigned long arg; |
| 66 | + int ret; |
| 67 | + |
| 68 | + while (n--) |
| 69 | + ret |= mips_get_syscall_arg(&arg, task, regs, i++); |
| 70 | + |
| 71 | + /* |
| 72 | + * No way to communicate an error because this is a void function. |
| 73 | + */ |
| 74 | +#if 0 |
| 75 | + return ret; |
| 76 | +#endif |
| 77 | +} |
| 78 | + |
12 | 79 | extern const unsigned long sys_call_table[];
|
13 | 80 | extern const unsigned long sys32_call_table[];
|
14 | 81 | extern const unsigned long sysn32_call_table[];
|
|
0 commit comments