Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / arch / loongarch / include / asm / syscall.h
blobe286dc58476e6e6c5d126866a8590a96e4b4089a
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3 * Author: Hanlu Li <lihanlu@loongson.cn>
4 * Huacai Chen <chenhuacai@loongson.cn>
6 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
7 */
9 #ifndef __ASM_LOONGARCH_SYSCALL_H
10 #define __ASM_LOONGARCH_SYSCALL_H
12 #include <linux/compiler.h>
13 #include <uapi/linux/audit.h>
14 #include <linux/elf-em.h>
15 #include <linux/kernel.h>
16 #include <linux/sched.h>
17 #include <linux/uaccess.h>
18 #include <asm/ptrace.h>
19 #include <asm/unistd.h>
21 extern void *sys_call_table[];
23 static inline long syscall_get_nr(struct task_struct *task,
24 struct pt_regs *regs)
26 return regs->regs[11];
29 static inline void syscall_rollback(struct task_struct *task,
30 struct pt_regs *regs)
32 regs->regs[4] = regs->orig_a0;
35 static inline long syscall_get_error(struct task_struct *task,
36 struct pt_regs *regs)
38 unsigned long error = regs->regs[4];
40 return IS_ERR_VALUE(error) ? error : 0;
43 static inline long syscall_get_return_value(struct task_struct *task,
44 struct pt_regs *regs)
46 return regs->regs[4];
49 static inline void syscall_set_return_value(struct task_struct *task,
50 struct pt_regs *regs,
51 int error, long val)
53 regs->regs[4] = (long) error ? error : val;
56 static inline void syscall_get_arguments(struct task_struct *task,
57 struct pt_regs *regs,
58 unsigned long *args)
60 args[0] = regs->orig_a0;
61 memcpy(&args[1], &regs->regs[5], 5 * sizeof(long));
64 static inline int syscall_get_arch(struct task_struct *task)
66 return AUDIT_ARCH_LOONGARCH64;
69 static inline bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs)
71 return false;
74 #endif /* __ASM_LOONGARCH_SYSCALL_H */