syscall.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (C) 2008-2009 Red Hat, Inc. All rights reserved.
  3. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation, version 2.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  12. * NON INFRINGEMENT. See the GNU General Public License for
  13. * more details.
  14. *
  15. * See asm-generic/syscall.h for descriptions of what we must do here.
  16. */
  17. #ifndef _ASM_TILE_SYSCALL_H
  18. #define _ASM_TILE_SYSCALL_H
  19. #include <linux/sched.h>
  20. #include <linux/err.h>
  21. #include <arch/abi.h>
  22. /*
  23. * Only the low 32 bits of orig_r0 are meaningful, so we return int.
  24. * This importantly ignores the high bits on 64-bit, so comparisons
  25. * sign-extend the low 32 bits.
  26. */
  27. static inline int syscall_get_nr(struct task_struct *t, struct pt_regs *regs)
  28. {
  29. return regs->regs[TREG_SYSCALL_NR];
  30. }
  31. static inline void syscall_rollback(struct task_struct *task,
  32. struct pt_regs *regs)
  33. {
  34. regs->regs[0] = regs->orig_r0;
  35. }
  36. static inline long syscall_get_error(struct task_struct *task,
  37. struct pt_regs *regs)
  38. {
  39. unsigned long error = regs->regs[0];
  40. return IS_ERR_VALUE(error) ? error : 0;
  41. }
  42. static inline long syscall_get_return_value(struct task_struct *task,
  43. struct pt_regs *regs)
  44. {
  45. return regs->regs[0];
  46. }
  47. static inline void syscall_set_return_value(struct task_struct *task,
  48. struct pt_regs *regs,
  49. int error, long val)
  50. {
  51. regs->regs[0] = (long) error ?: val;
  52. }
  53. static inline void syscall_get_arguments(struct task_struct *task,
  54. struct pt_regs *regs,
  55. unsigned int i, unsigned int n,
  56. unsigned long *args)
  57. {
  58. BUG_ON(i + n > 6);
  59. memcpy(args, &regs[i], n * sizeof(args[0]));
  60. }
  61. static inline void syscall_set_arguments(struct task_struct *task,
  62. struct pt_regs *regs,
  63. unsigned int i, unsigned int n,
  64. const unsigned long *args)
  65. {
  66. BUG_ON(i + n > 6);
  67. memcpy(&regs[i], args, n * sizeof(args[0]));
  68. }
  69. #endif /* _ASM_TILE_SYSCALL_H */