syscall.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Access to user system call parameters and results
  3. *
  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
  6. * for more details.
  7. *
  8. * See asm-generic/syscall.h for descriptions of what we must do here.
  9. *
  10. * Copyright (C) 2012 Ralf Baechle <ralf@linux-mips.org>
  11. */
  12. #ifndef __ASM_MIPS_SYSCALL_H
  13. #define __ASM_MIPS_SYSCALL_H
  14. #include <linux/kernel.h>
  15. #include <linux/sched.h>
  16. #include <linux/uaccess.h>
  17. #include <asm/ptrace.h>
  18. static inline long syscall_get_nr(struct task_struct *task,
  19. struct pt_regs *regs)
  20. {
  21. return regs->regs[2];
  22. }
  23. static inline unsigned long mips_get_syscall_arg(unsigned long *arg,
  24. struct task_struct *task, struct pt_regs *regs, unsigned int n)
  25. {
  26. unsigned long usp = regs->regs[29];
  27. switch (n) {
  28. case 0: case 1: case 2: case 3:
  29. *arg = regs->regs[4 + n];
  30. return 0;
  31. #ifdef CONFIG_32BIT
  32. case 4: case 5: case 6: case 7:
  33. return get_user(*arg, (int *)usp + 4 * n);
  34. #endif
  35. #ifdef CONFIG_64BIT
  36. case 4: case 5: case 6: case 7:
  37. #ifdef CONFIG_MIPS32_O32
  38. if (test_thread_flag(TIF_32BIT_REGS))
  39. return get_user(*arg, (int *)usp + 4 * n);
  40. else
  41. #endif
  42. *arg = regs->regs[4 + n];
  43. return 0;
  44. #endif
  45. default:
  46. BUG();
  47. }
  48. }
  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)
  53. {
  54. unsigned long arg;
  55. int ret;
  56. while (n--)
  57. ret |= mips_get_syscall_arg(&arg, task, regs, i++);
  58. /*
  59. * No way to communicate an error because this is a void function.
  60. */
  61. #if 0
  62. return ret;
  63. #endif
  64. }
  65. extern const unsigned long sys_call_table[];
  66. extern const unsigned long sys32_call_table[];
  67. extern const unsigned long sysn32_call_table[];
  68. #endif /* __ASM_MIPS_SYSCALL_H */