162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 362306a36Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 462306a36Sopenharmony_ci * for more details. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright (C) 2001 - 2007 Tensilica Inc. 762306a36Sopenharmony_ci * Copyright (C) 2018 Cadence Design Systems Inc. 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef _ASM_SYSCALL_H 1162306a36Sopenharmony_ci#define _ASM_SYSCALL_H 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include <linux/err.h> 1462306a36Sopenharmony_ci#include <asm/ptrace.h> 1562306a36Sopenharmony_ci#include <uapi/linux/audit.h> 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cistatic inline int syscall_get_arch(struct task_struct *task) 1862306a36Sopenharmony_ci{ 1962306a36Sopenharmony_ci return AUDIT_ARCH_XTENSA; 2062306a36Sopenharmony_ci} 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_citypedef void (*syscall_t)(void); 2362306a36Sopenharmony_ciextern syscall_t sys_call_table[]; 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_cistatic inline long syscall_get_nr(struct task_struct *task, 2662306a36Sopenharmony_ci struct pt_regs *regs) 2762306a36Sopenharmony_ci{ 2862306a36Sopenharmony_ci return regs->syscall; 2962306a36Sopenharmony_ci} 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_cistatic inline void syscall_rollback(struct task_struct *task, 3262306a36Sopenharmony_ci struct pt_regs *regs) 3362306a36Sopenharmony_ci{ 3462306a36Sopenharmony_ci /* Do nothing. */ 3562306a36Sopenharmony_ci} 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_cistatic inline long syscall_get_error(struct task_struct *task, 3862306a36Sopenharmony_ci struct pt_regs *regs) 3962306a36Sopenharmony_ci{ 4062306a36Sopenharmony_ci /* 0 if syscall succeeded, otherwise -Errorcode */ 4162306a36Sopenharmony_ci return IS_ERR_VALUE(regs->areg[2]) ? regs->areg[2] : 0; 4262306a36Sopenharmony_ci} 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_cistatic inline long syscall_get_return_value(struct task_struct *task, 4562306a36Sopenharmony_ci struct pt_regs *regs) 4662306a36Sopenharmony_ci{ 4762306a36Sopenharmony_ci return regs->areg[2]; 4862306a36Sopenharmony_ci} 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_cistatic inline void syscall_set_return_value(struct task_struct *task, 5162306a36Sopenharmony_ci struct pt_regs *regs, 5262306a36Sopenharmony_ci int error, long val) 5362306a36Sopenharmony_ci{ 5462306a36Sopenharmony_ci regs->areg[2] = (long) error ? error : val; 5562306a36Sopenharmony_ci} 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci#define SYSCALL_MAX_ARGS 6 5862306a36Sopenharmony_ci#define XTENSA_SYSCALL_ARGUMENT_REGS {6, 3, 4, 5, 8, 9} 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_cistatic inline void syscall_get_arguments(struct task_struct *task, 6162306a36Sopenharmony_ci struct pt_regs *regs, 6262306a36Sopenharmony_ci unsigned long *args) 6362306a36Sopenharmony_ci{ 6462306a36Sopenharmony_ci static const unsigned int reg[] = XTENSA_SYSCALL_ARGUMENT_REGS; 6562306a36Sopenharmony_ci unsigned int i; 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci for (i = 0; i < 6; ++i) 6862306a36Sopenharmony_ci args[i] = regs->areg[reg[i]]; 6962306a36Sopenharmony_ci} 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ciasmlinkage long xtensa_rt_sigreturn(void); 7262306a36Sopenharmony_ciasmlinkage long xtensa_shmat(int, char __user *, int); 7362306a36Sopenharmony_ciasmlinkage long xtensa_fadvise64_64(int, int, 7462306a36Sopenharmony_ci unsigned long long, unsigned long long); 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#endif 77