syscall.h (1697B)
1/* SPDX-License-Identifier: GPL-2.0+ */ 2/* 3 * Author: Hanlu Li <lihanlu@loongson.cn> 4 * Huacai Chen <chenhuacai@loongson.cn> 5 * 6 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited 7 */ 8 9#ifndef __ASM_LOONGARCH_SYSCALL_H 10#define __ASM_LOONGARCH_SYSCALL_H 11 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> 20 21extern void *sys_call_table[]; 22 23static inline long syscall_get_nr(struct task_struct *task, 24 struct pt_regs *regs) 25{ 26 return regs->regs[11]; 27} 28 29static inline void syscall_rollback(struct task_struct *task, 30 struct pt_regs *regs) 31{ 32 regs->regs[4] = regs->orig_a0; 33} 34 35static inline long syscall_get_error(struct task_struct *task, 36 struct pt_regs *regs) 37{ 38 unsigned long error = regs->regs[4]; 39 40 return IS_ERR_VALUE(error) ? error : 0; 41} 42 43static inline long syscall_get_return_value(struct task_struct *task, 44 struct pt_regs *regs) 45{ 46 return regs->regs[4]; 47} 48 49static inline void syscall_set_return_value(struct task_struct *task, 50 struct pt_regs *regs, 51 int error, long val) 52{ 53 regs->regs[4] = (long) error ? error : val; 54} 55 56static inline void syscall_get_arguments(struct task_struct *task, 57 struct pt_regs *regs, 58 unsigned long *args) 59{ 60 args[0] = regs->orig_a0; 61 memcpy(&args[1], ®s->regs[5], 5 * sizeof(long)); 62} 63 64static inline int syscall_get_arch(struct task_struct *task) 65{ 66 return AUDIT_ARCH_LOONGARCH64; 67} 68 69static inline bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs) 70{ 71 return false; 72} 73 74#endif /* __ASM_LOONGARCH_SYSCALL_H */