Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
0004  */
0005 
0006 #ifndef _ASM_ARC_SYSCALL_H
0007 #define _ASM_ARC_SYSCALL_H  1
0008 
0009 #include <uapi/linux/audit.h>
0010 #include <linux/err.h>
0011 #include <linux/sched.h>
0012 #include <asm/unistd.h>
0013 #include <asm/ptrace.h>     /* in_syscall() */
0014 
0015 extern void *sys_call_table[];
0016 
0017 static inline long
0018 syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
0019 {
0020     if (user_mode(regs) && in_syscall(regs))
0021         return regs->r8;
0022     else
0023         return -1;
0024 }
0025 
0026 static inline void
0027 syscall_rollback(struct task_struct *task, struct pt_regs *regs)
0028 {
0029     regs->r0 = regs->orig_r0;
0030 }
0031 
0032 static inline long
0033 syscall_get_error(struct task_struct *task, struct pt_regs *regs)
0034 {
0035     /* 0 if syscall succeeded, otherwise -Errorcode */
0036     return IS_ERR_VALUE(regs->r0) ? regs->r0 : 0;
0037 }
0038 
0039 static inline long
0040 syscall_get_return_value(struct task_struct *task, struct pt_regs *regs)
0041 {
0042     return regs->r0;
0043 }
0044 
0045 static inline void
0046 syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
0047              int error, long val)
0048 {
0049     regs->r0 = (long) error ?: val;
0050 }
0051 
0052 /*
0053  * @i:      argument index [0,5]
0054  * @n:      number of arguments; n+i must be [1,6].
0055  */
0056 static inline void
0057 syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
0058               unsigned long *args)
0059 {
0060     unsigned long *inside_ptregs = &(regs->r0);
0061     unsigned int n = 6;
0062     unsigned int i = 0;
0063 
0064     while (n--) {
0065         args[i++] = (*inside_ptregs);
0066         inside_ptregs--;
0067     }
0068 }
0069 
0070 static inline int
0071 syscall_get_arch(struct task_struct *task)
0072 {
0073     return IS_ENABLED(CONFIG_ISA_ARCOMPACT)
0074         ? (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
0075             ? AUDIT_ARCH_ARCOMPACTBE : AUDIT_ARCH_ARCOMPACT)
0076         : (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
0077             ? AUDIT_ARCH_ARCV2BE : AUDIT_ARCH_ARCV2);
0078 }
0079 
0080 #endif