18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* syscall.h */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef _ASM_PARISC_SYSCALL_H_
58c2ecf20Sopenharmony_ci#define _ASM_PARISC_SYSCALL_H_
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <uapi/linux/audit.h>
88c2ecf20Sopenharmony_ci#include <linux/compat.h>
98c2ecf20Sopenharmony_ci#include <linux/err.h>
108c2ecf20Sopenharmony_ci#include <asm/ptrace.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define NR_syscalls (__NR_Linux_syscalls)
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cistatic inline long syscall_get_nr(struct task_struct *tsk,
158c2ecf20Sopenharmony_ci				  struct pt_regs *regs)
168c2ecf20Sopenharmony_ci{
178c2ecf20Sopenharmony_ci	return regs->gr[20];
188c2ecf20Sopenharmony_ci}
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_cistatic inline void syscall_get_arguments(struct task_struct *tsk,
218c2ecf20Sopenharmony_ci					 struct pt_regs *regs,
228c2ecf20Sopenharmony_ci					 unsigned long *args)
238c2ecf20Sopenharmony_ci{
248c2ecf20Sopenharmony_ci	args[5] = regs->gr[21];
258c2ecf20Sopenharmony_ci	args[4] = regs->gr[22];
268c2ecf20Sopenharmony_ci	args[3] = regs->gr[23];
278c2ecf20Sopenharmony_ci	args[2] = regs->gr[24];
288c2ecf20Sopenharmony_ci	args[1] = regs->gr[25];
298c2ecf20Sopenharmony_ci	args[0] = regs->gr[26];
308c2ecf20Sopenharmony_ci}
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cistatic inline long syscall_get_error(struct task_struct *task,
338c2ecf20Sopenharmony_ci				     struct pt_regs *regs)
348c2ecf20Sopenharmony_ci{
358c2ecf20Sopenharmony_ci	unsigned long error = regs->gr[28];
368c2ecf20Sopenharmony_ci	return IS_ERR_VALUE(error) ? error : 0;
378c2ecf20Sopenharmony_ci}
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_cistatic inline long syscall_get_return_value(struct task_struct *task,
408c2ecf20Sopenharmony_ci						struct pt_regs *regs)
418c2ecf20Sopenharmony_ci{
428c2ecf20Sopenharmony_ci	return regs->gr[28];
438c2ecf20Sopenharmony_ci}
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cistatic inline void syscall_set_return_value(struct task_struct *task,
468c2ecf20Sopenharmony_ci					    struct pt_regs *regs,
478c2ecf20Sopenharmony_ci					    int error, long val)
488c2ecf20Sopenharmony_ci{
498c2ecf20Sopenharmony_ci	regs->gr[28] = error ? error : val;
508c2ecf20Sopenharmony_ci}
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistatic inline void syscall_rollback(struct task_struct *task,
538c2ecf20Sopenharmony_ci				    struct pt_regs *regs)
548c2ecf20Sopenharmony_ci{
558c2ecf20Sopenharmony_ci	/* do nothing */
568c2ecf20Sopenharmony_ci}
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_cistatic inline int syscall_get_arch(struct task_struct *task)
598c2ecf20Sopenharmony_ci{
608c2ecf20Sopenharmony_ci	int arch = AUDIT_ARCH_PARISC;
618c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
628c2ecf20Sopenharmony_ci	if (!__is_compat_task(task))
638c2ecf20Sopenharmony_ci		arch = AUDIT_ARCH_PARISC64;
648c2ecf20Sopenharmony_ci#endif
658c2ecf20Sopenharmony_ci	return arch;
668c2ecf20Sopenharmony_ci}
678c2ecf20Sopenharmony_ci#endif /*_ASM_PARISC_SYSCALL_H_*/
68