1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Author: Hanlu Li <lihanlu@loongson.cn>
4 * Huacai Chen <chenhuacai@loongson.cn>
6 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
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,
26 return regs->regs[11];
29 static inline void syscall_rollback(struct task_struct *task,
32 regs->regs[4] = regs->orig_a0;
35 static inline long syscall_get_error(struct task_struct *task,
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,
49 static inline void syscall_set_return_value(struct task_struct *task,
53 regs->regs[4] = (long) error ? error : val;
56 static inline void syscall_get_arguments(struct task_struct *task,
60 args[0] = regs->orig_a0;
61 memcpy(&args[1], ®s->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)
74 #endif /* __ASM_LOONGARCH_SYSCALL_H */