syscall.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * OpenRISC Linux
  3. *
  4. * Linux architectural port borrowing liberally from similar works of
  5. * others. All original copyrights apply as per the original source
  6. * declaration.
  7. *
  8. * OpenRISC implementation:
  9. * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
  10. * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
  11. * et al.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. */
  18. #ifndef __ASM_OPENRISC_SYSCALL_H__
  19. #define __ASM_OPENRISC_SYSCALL_H__
  20. #include <uapi/linux/audit.h>
  21. #include <linux/err.h>
  22. #include <linux/sched.h>
  23. static inline int
  24. syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
  25. {
  26. return regs->orig_gpr11;
  27. }
  28. static inline void
  29. syscall_rollback(struct task_struct *task, struct pt_regs *regs)
  30. {
  31. regs->gpr[11] = regs->orig_gpr11;
  32. }
  33. static inline long
  34. syscall_get_error(struct task_struct *task, struct pt_regs *regs)
  35. {
  36. return IS_ERR_VALUE(regs->gpr[11]) ? regs->gpr[11] : 0;
  37. }
  38. static inline long
  39. syscall_get_return_value(struct task_struct *task, struct pt_regs *regs)
  40. {
  41. return regs->gpr[11];
  42. }
  43. static inline void
  44. syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
  45. int error, long val)
  46. {
  47. regs->gpr[11] = (long) error ?: val;
  48. }
  49. static inline void
  50. syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
  51. unsigned int i, unsigned int n, unsigned long *args)
  52. {
  53. BUG_ON(i + n > 6);
  54. memcpy(args, &regs->gpr[3 + i], n * sizeof(args[0]));
  55. }
  56. static inline void
  57. syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
  58. unsigned int i, unsigned int n, const unsigned long *args)
  59. {
  60. BUG_ON(i + n > 6);
  61. memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0]));
  62. }
  63. static inline int syscall_get_arch(void)
  64. {
  65. return AUDIT_ARCH_OPENRISC;
  66. }
  67. #endif