1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2d5b37092SMichal Simek #ifndef __ASM_MICROBLAZE_SYSCALL_H
3d5b37092SMichal Simek #define __ASM_MICROBLAZE_SYSCALL_H
4d5b37092SMichal Simek
5ce5d1128SEric Paris #include <uapi/linux/audit.h>
6d5b37092SMichal Simek #include <linux/kernel.h>
7d5b37092SMichal Simek #include <linux/sched.h>
8d5b37092SMichal Simek #include <asm/ptrace.h>
9d5b37092SMichal Simek
10d5b37092SMichal Simek /* The system call number is given by the user in R12 */
syscall_get_nr(struct task_struct * task,struct pt_regs * regs)11d5b37092SMichal Simek static inline long syscall_get_nr(struct task_struct *task,
12d5b37092SMichal Simek struct pt_regs *regs)
13d5b37092SMichal Simek {
14d5b37092SMichal Simek return regs->r12;
15d5b37092SMichal Simek }
16d5b37092SMichal Simek
syscall_rollback(struct task_struct * task,struct pt_regs * regs)17d5b37092SMichal Simek static inline void syscall_rollback(struct task_struct *task,
18d5b37092SMichal Simek struct pt_regs *regs)
19d5b37092SMichal Simek {
20d5b37092SMichal Simek /* TODO. */
21d5b37092SMichal Simek }
22d5b37092SMichal Simek
syscall_get_error(struct task_struct * task,struct pt_regs * regs)23d5b37092SMichal Simek static inline long syscall_get_error(struct task_struct *task,
24d5b37092SMichal Simek struct pt_regs *regs)
25d5b37092SMichal Simek {
26d5b37092SMichal Simek return IS_ERR_VALUE(regs->r3) ? regs->r3 : 0;
27d5b37092SMichal Simek }
28d5b37092SMichal Simek
syscall_get_return_value(struct task_struct * task,struct pt_regs * regs)29d5b37092SMichal Simek static inline long syscall_get_return_value(struct task_struct *task,
30d5b37092SMichal Simek struct pt_regs *regs)
31d5b37092SMichal Simek {
32d5b37092SMichal Simek return regs->r3;
33d5b37092SMichal Simek }
34d5b37092SMichal Simek
syscall_set_return_value(struct task_struct * task,struct pt_regs * regs,int error,long val)35d5b37092SMichal Simek static inline void syscall_set_return_value(struct task_struct *task,
36d5b37092SMichal Simek struct pt_regs *regs,
37d5b37092SMichal Simek int error, long val)
38d5b37092SMichal Simek {
39d5b37092SMichal Simek if (error)
40d5b37092SMichal Simek regs->r3 = -error;
41d5b37092SMichal Simek else
42d5b37092SMichal Simek regs->r3 = val;
43d5b37092SMichal Simek }
44d5b37092SMichal Simek
microblaze_get_syscall_arg(struct pt_regs * regs,unsigned int n)45d5b37092SMichal Simek static inline microblaze_reg_t microblaze_get_syscall_arg(struct pt_regs *regs,
46d5b37092SMichal Simek unsigned int n)
47d5b37092SMichal Simek {
48d5b37092SMichal Simek switch (n) {
49d5b37092SMichal Simek case 5: return regs->r10;
50d5b37092SMichal Simek case 4: return regs->r9;
51d5b37092SMichal Simek case 3: return regs->r8;
52d5b37092SMichal Simek case 2: return regs->r7;
53d5b37092SMichal Simek case 1: return regs->r6;
54d5b37092SMichal Simek case 0: return regs->r5;
55d5b37092SMichal Simek default:
56d5b37092SMichal Simek BUG();
57d5b37092SMichal Simek }
58d5b37092SMichal Simek return ~0;
59d5b37092SMichal Simek }
60d5b37092SMichal Simek
syscall_get_arguments(struct task_struct * task,struct pt_regs * regs,unsigned long * args)61d5b37092SMichal Simek static inline void syscall_get_arguments(struct task_struct *task,
62d5b37092SMichal Simek struct pt_regs *regs,
63d5b37092SMichal Simek unsigned long *args)
64d5b37092SMichal Simek {
65*b35f549dSSteven Rostedt (Red Hat) unsigned int i = 0;
66*b35f549dSSteven Rostedt (Red Hat) unsigned int n = 6;
67*b35f549dSSteven Rostedt (Red Hat)
68d5b37092SMichal Simek while (n--)
69d5b37092SMichal Simek *args++ = microblaze_get_syscall_arg(regs, i++);
70d5b37092SMichal Simek }
71d5b37092SMichal Simek
728543e6c9SMichal Simek asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs);
73c1df53b3SMichal Simek asmlinkage void do_syscall_trace_leave(struct pt_regs *regs);
74c1df53b3SMichal Simek
syscall_get_arch(struct task_struct * task)7516add411SDmitry V. Levin static inline int syscall_get_arch(struct task_struct *task)
76ce5d1128SEric Paris {
77ce5d1128SEric Paris return AUDIT_ARCH_MICROBLAZE;
78ce5d1128SEric Paris }
79d5b37092SMichal Simek #endif /* __ASM_MICROBLAZE_SYSCALL_H */
80