~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/riscv/include/asm/syscall.h

Version: ~ [ linux-5.1-rc5 ] ~ [ linux-5.0.7 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.34 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.111 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.168 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.178 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.138 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.65 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2008-2009 Red Hat, Inc.  All rights reserved.
  3  * Copyright 2010 Tilera Corporation. All Rights Reserved.
  4  * Copyright 2015 Regents of the University of California, Berkeley
  5  *
  6  *   This program is free software; you can redistribute it and/or
  7  *   modify it under the terms of the GNU General Public License
  8  *   as published by the Free Software Foundation, version 2.
  9  *
 10  *   This program is distributed in the hope that it will be useful,
 11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  *   GNU General Public License for more details.
 14  *
 15  * See asm-generic/syscall.h for descriptions of what we must do here.
 16  */
 17 
 18 #ifndef _ASM_RISCV_SYSCALL_H
 19 #define _ASM_RISCV_SYSCALL_H
 20 
 21 #include <uapi/linux/audit.h>
 22 #include <linux/sched.h>
 23 #include <linux/err.h>
 24 
 25 /* The array of function pointers for syscalls. */
 26 extern void *sys_call_table[];
 27 
 28 /*
 29  * Only the low 32 bits of orig_r0 are meaningful, so we return int.
 30  * This importantly ignores the high bits on 64-bit, so comparisons
 31  * sign-extend the low 32 bits.
 32  */
 33 static inline int syscall_get_nr(struct task_struct *task,
 34                                  struct pt_regs *regs)
 35 {
 36         return regs->a7;
 37 }
 38 
 39 static inline void syscall_set_nr(struct task_struct *task,
 40                                   struct pt_regs *regs,
 41                                   int sysno)
 42 {
 43         regs->a7 = sysno;
 44 }
 45 
 46 static inline void syscall_rollback(struct task_struct *task,
 47                                     struct pt_regs *regs)
 48 {
 49         regs->a0 = regs->orig_a0;
 50 }
 51 
 52 static inline long syscall_get_error(struct task_struct *task,
 53                                      struct pt_regs *regs)
 54 {
 55         unsigned long error = regs->a0;
 56 
 57         return IS_ERR_VALUE(error) ? error : 0;
 58 }
 59 
 60 static inline long syscall_get_return_value(struct task_struct *task,
 61                                             struct pt_regs *regs)
 62 {
 63         return regs->a0;
 64 }
 65 
 66 static inline void syscall_set_return_value(struct task_struct *task,
 67                                             struct pt_regs *regs,
 68                                             int error, long val)
 69 {
 70         regs->a0 = (long) error ?: val;
 71 }
 72 
 73 static inline void syscall_get_arguments(struct task_struct *task,
 74                                          struct pt_regs *regs,
 75                                          unsigned long *args)
 76 {
 77         args[0] = regs->orig_a0;
 78         args++;
 79         memcpy(args, &regs->a1, 5 * sizeof(args[0]));
 80 }
 81 
 82 static inline void syscall_set_arguments(struct task_struct *task,
 83                                          struct pt_regs *regs,
 84                                          const unsigned long *args)
 85 {
 86         regs->orig_a0 = args[0];
 87         args++;
 88         memcpy(&regs->a1, args, 5 * sizeof(regs->a1));
 89 }
 90 
 91 static inline int syscall_get_arch(void)
 92 {
 93 #ifdef CONFIG_64BIT
 94         return AUDIT_ARCH_RISCV64;
 95 #else
 96         return AUDIT_ARCH_RISCV32;
 97 #endif
 98 }
 99 
100 #endif  /* _ASM_RISCV_SYSCALL_H */
101 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp