| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
#ifndef __ASM_MICROBLAZE_SYSCALL_H |
| 3 |
#define __ASM_MICROBLAZE_SYSCALL_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 R12 */ |
| 11 |
static inline long syscall_get_nr(struct task_struct *task, |
| 12 |
struct pt_regs *regs) |
| 13 |
{ |
| 14 |
return regs->r12; |
| 15 |
} |
| 16 |
|
| 17 |
static inline void syscall_set_nr(struct task_struct *task, |
| 18 |
struct pt_regs *regs, |
| 19 |
int nr) |
| 20 |
{ |
| 21 |
regs->r12 = nr; |
| 22 |
} |
| 23 |
|
| 24 |
static inline void syscall_rollback(struct task_struct *task, |
| 25 |
struct pt_regs *regs) |
| 26 |
{ |
| 27 |
/* TODO. */ |
| 28 |
} |
| 29 |
|
| 30 |
static inline long syscall_get_error(struct task_struct *task, |
| 31 |
struct pt_regs *regs) |
| 32 |
{ |
| 33 |
return IS_ERR_VALUE(regs->r3) ? regs->r3 : 0; |
| 34 |
} |
| 35 |
|
| 36 |
static inline long syscall_get_return_value(struct task_struct *task, |
| 37 |
struct pt_regs *regs) |
| 38 |
{ |
| 39 |
return regs->r3; |
| 40 |
} |
| 41 |
|
| 42 |
static inline void syscall_set_return_value(struct task_struct *task, |
| 43 |
struct pt_regs *regs, |
| 44 |
int error, long val) |
| 45 |
{ |
| 46 |
if (error) |
| 47 |
regs->r3 = -error; |
| 48 |
else |
| 49 |
regs->r3 = val; |
| 50 |
} |
| 51 |
|
| 52 |
static inline microblaze_reg_t microblaze_get_syscall_arg(struct pt_regs *regs, |
| 53 |
unsigned int n) |
| 54 |
{ |
| 55 |
switch (n) { |
| 56 |
case 5: return regs->r10; |
| 57 |
case 4: return regs->r9; |
| 58 |
case 3: return regs->r8; |
| 59 |
case 2: return regs->r7; |
| 60 |
case 1: return regs->r6; |
| 61 |
case 0: return regs->r5; |
| 62 |
default: |
| 63 |
BUG(); |
| 64 |
} |
| 65 |
return ~0; |
| 66 |
} |
| 67 |
|
| 68 |
static inline void syscall_get_arguments(struct task_struct *task, |
| 69 |
struct pt_regs *regs, |
| 70 |
unsigned long *args) |
| 71 |
{ |
| 72 |
unsigned int i = 0; |
| 73 |
unsigned int n = 6; |
| 74 |
|
| 75 |
while (n--) |
| 76 |
*args++ = microblaze_get_syscall_arg(regs, i++); |
| 77 |
} |
| 78 |
|
| 79 |
asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs); |
| 80 |
asmlinkage void do_syscall_trace_leave(struct pt_regs *regs); |
| 81 |
|
| 82 |
static inline int syscall_get_arch(struct task_struct *task) |
| 83 |
{ |
| 84 |
return AUDIT_ARCH_MICROBLAZE; |
| 85 |
} |
| 86 |
#endif /* __ASM_MICROBLAZE_SYSCALL_H */ |