syscall.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2008-2009 Red Hat, Inc. All rights reserved.
  4. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  5. * Copyright 2015 Regents of the University of California, Berkeley
  6. *
  7. * See asm-generic/syscall.h for descriptions of what we must do here.
  8. */
  9. #ifndef _ASM_RISCV_SYSCALL_H
  10. #define _ASM_RISCV_SYSCALL_H
  11. #include <uapi/linux/audit.h>
  12. #include <linux/sched.h>
  13. #include <linux/err.h>
  14. /* The array of function pointers for syscalls. */
  15. extern void * const sys_call_table[];
  16. extern void * const compat_sys_call_table[];
  17. /*
  18. * Only the low 32 bits of orig_r0 are meaningful, so we return int.
  19. * This importantly ignores the high bits on 64-bit, so comparisons
  20. * sign-extend the low 32 bits.
  21. */
  22. static inline int syscall_get_nr(struct task_struct *task,
  23. struct pt_regs *regs)
  24. {
  25. return regs->a7;
  26. }
  27. static inline void syscall_rollback(struct task_struct *task,
  28. struct pt_regs *regs)
  29. {
  30. regs->a0 = regs->orig_a0;
  31. }
  32. static inline long syscall_get_error(struct task_struct *task,
  33. struct pt_regs *regs)
  34. {
  35. unsigned long error = regs->a0;
  36. return IS_ERR_VALUE(error) ? error : 0;
  37. }
  38. static inline long syscall_get_return_value(struct task_struct *task,
  39. struct pt_regs *regs)
  40. {
  41. return regs->a0;
  42. }
  43. static inline void syscall_set_return_value(struct task_struct *task,
  44. struct pt_regs *regs,
  45. int error, long val)
  46. {
  47. regs->a0 = (long) error ?: val;
  48. }
  49. static inline void syscall_get_arguments(struct task_struct *task,
  50. struct pt_regs *regs,
  51. unsigned long *args)
  52. {
  53. args[0] = regs->orig_a0;
  54. args++;
  55. memcpy(args, &regs->a1, 5 * sizeof(args[0]));
  56. }
  57. static inline int syscall_get_arch(struct task_struct *task)
  58. {
  59. #ifdef CONFIG_64BIT
  60. return AUDIT_ARCH_RISCV64;
  61. #else
  62. return AUDIT_ARCH_RISCV32;
  63. #endif
  64. }
  65. asmlinkage long sys_riscv_flush_icache(uintptr_t, uintptr_t, uintptr_t);
  66. #endif /* _ASM_RISCV_SYSCALL_H */