PageRenderTime 16ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/arch/sh/include/asm/syscall_64.h

http://github.com/mirrors/linux
C Header | 75 lines | 58 code | 11 blank | 6 comment | 1 complexity | 025d8b18f11fa914e05b6778520a6ca9 MD5 | raw file
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef __ASM_SH_SYSCALL_64_H
 3#define __ASM_SH_SYSCALL_64_H
 4
 5#include <uapi/linux/audit.h>
 6#include <linux/kernel.h>
 7#include <linux/sched.h>
 8#include <asm/ptrace.h>
 9
10/* The system call number is given by the user in R9 */
11static inline long syscall_get_nr(struct task_struct *task,
12				  struct pt_regs *regs)
13{
14	return (regs->syscall_nr >= 0) ? regs->regs[9] : -1L;
15}
16
17static inline void syscall_rollback(struct task_struct *task,
18				    struct pt_regs *regs)
19{
20	/*
21	 * XXX: This needs some thought. On SH we don't
22	 * save away the original R9 value anywhere.
23	 */
24}
25
26static inline long syscall_get_error(struct task_struct *task,
27				     struct pt_regs *regs)
28{
29	return IS_ERR_VALUE(regs->regs[9]) ? regs->regs[9] : 0;
30}
31
32static inline long syscall_get_return_value(struct task_struct *task,
33					    struct pt_regs *regs)
34{
35	return regs->regs[9];
36}
37
38static inline void syscall_set_return_value(struct task_struct *task,
39					    struct pt_regs *regs,
40					    int error, long val)
41{
42	if (error)
43		regs->regs[9] = -error;
44	else
45		regs->regs[9] = val;
46}
47
48static inline void syscall_get_arguments(struct task_struct *task,
49					 struct pt_regs *regs,
50					 unsigned long *args)
51{
52	memcpy(args, &regs->regs[2], 6 * sizeof(args[0]));
53}
54
55static inline void syscall_set_arguments(struct task_struct *task,
56					 struct pt_regs *regs,
57					 const unsigned long *args)
58{
59	memcpy(&regs->regs[2], args, 6 * sizeof(args[0]));
60}
61
62static inline int syscall_get_arch(struct task_struct *task)
63{
64	int arch = AUDIT_ARCH_SH;
65
66#ifdef CONFIG_64BIT
67	arch |= __AUDIT_ARCH_64BIT;
68#endif
69#ifdef CONFIG_CPU_LITTLE_ENDIAN
70	arch |= __AUDIT_ARCH_LE;
71#endif
72
73	return arch;
74}
75#endif /* __ASM_SH_SYSCALL_64_H */