syscall.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. /* The array of function pointers for syscalls. */
  23. extern void *sys_call_table[];
  24. #ifdef CONFIG_COMPAT
  25. extern void *compat_sys_call_table[];
  26. #endif
  27. /*
  28. * Only the low 32 bits of orig_r0 are meaningful, so we return int.
  29. * This importantly ignores the high bits on 64-bit, so comparisons
  30. * sign-extend the low 32 bits.
  31. */
  32. static inline int syscall_get_nr(struct task_struct *t, struct pt_regs *regs)
  33. {
  34. return regs->regs[TREG_SYSCALL_NR];
  35. }
  36. static inline void syscall_rollback(struct task_struct *task,
  37. struct pt_regs *regs)
  38. {
  39. regs->regs[0] = regs->orig_r0;
  40. }
  41. static inline long syscall_get_error(struct task_struct *task,
  42. struct pt_regs *regs)
  43. {
  44. unsigned long error = regs->regs[0];
  45. return IS_ERR_VALUE(error) ? error : 0;
  46. }
  47. static inline long syscall_get_return_value(struct task_struct *task,
  48. struct pt_regs *regs)
  49. {
  50. return regs->regs[0];
  51. }
  52. static inline void syscall_set_return_value(struct task_struct *task,
  53. struct pt_regs *regs,
  54. int error, long val)
  55. {
  56. regs->regs[0] = (long) error ?: val;
  57. }
  58. static inline void syscall_get_arguments(struct task_struct *task,
  59. struct pt_regs *regs,
  60. unsigned int i, unsigned int n,
  61. unsigned long *args)
  62. {
  63. BUG_ON(i + n > 6);
  64. memcpy(args, &regs[i], n * sizeof(args[0]));
  65. }
  66. static inline void syscall_set_arguments(struct task_struct *task,
  67. struct pt_regs *regs,
  68. unsigned int i, unsigned int n,
  69. const unsigned long *args)
  70. {
  71. BUG_ON(i + n > 6);
  72. memcpy(&regs[i], args, n * sizeof(args[0]));
  73. }
  74. #endif /* _ASM_TILE_SYSCALL_H */