syscall.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 <linux/err.h>
  21. #include <linux/sched.h>
  22. static inline int
  23. syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
  24. {
  25. return regs->orig_gpr11;
  26. }
  27. static inline void
  28. syscall_rollback(struct task_struct *task, struct pt_regs *regs)
  29. {
  30. regs->gpr[11] = regs->orig_gpr11;
  31. }
  32. static inline long
  33. syscall_get_error(struct task_struct *task, struct pt_regs *regs)
  34. {
  35. return IS_ERR_VALUE(regs->gpr[11]) ? regs->gpr[11] : 0;
  36. }
  37. static inline long
  38. syscall_get_return_value(struct task_struct *task, struct pt_regs *regs)
  39. {
  40. return regs->gpr[11];
  41. }
  42. static inline void
  43. syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
  44. int error, long val)
  45. {
  46. regs->gpr[11] = (long) error ?: val;
  47. }
  48. static inline void
  49. syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
  50. unsigned int i, unsigned int n, unsigned long *args)
  51. {
  52. BUG_ON(i + n > 6);
  53. memcpy(args, &regs->gpr[3 + i], n * sizeof(args[0]));
  54. }
  55. static inline void
  56. syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
  57. unsigned int i, unsigned int n, const unsigned long *args)
  58. {
  59. BUG_ON(i + n > 6);
  60. memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0]));
  61. }
  62. #endif