Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef __ASM_MICROBLAZE_SYSCALL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define __ASM_MICROBLAZE_SYSCALL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <uapi/linux/audit.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) /* The system call number is given by the user in R12 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) static inline long syscall_get_nr(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 				  struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	return regs->r12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) static inline void syscall_rollback(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 				    struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	/* TODO.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) static inline long syscall_get_error(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 				     struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	return IS_ERR_VALUE(regs->r3) ? regs->r3 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) static inline long syscall_get_return_value(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 					    struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	return regs->r3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) static inline void syscall_set_return_value(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 					    struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 					    int error, long val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		regs->r3 = -error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		regs->r3 = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) static inline microblaze_reg_t microblaze_get_syscall_arg(struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 							  unsigned int n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	switch (n) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	case 5: return regs->r10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	case 4: return regs->r9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	case 3: return regs->r8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	case 2: return regs->r7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	case 1: return regs->r6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	case 0: return regs->r5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	return ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) static inline void microblaze_set_syscall_arg(struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 					      unsigned int n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 					      unsigned long val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	switch (n) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	case 5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		regs->r10 = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	case 4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		regs->r9 = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	case 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		regs->r8 = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		regs->r7 = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		regs->r6 = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		regs->r5 = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) static inline void syscall_get_arguments(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 					 struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 					 unsigned long *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	unsigned int i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	unsigned int n = 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	while (n--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		*args++ = microblaze_get_syscall_arg(regs, i++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) static inline void syscall_set_arguments(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 					 struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 					 const unsigned long *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	unsigned int i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	unsigned int n = 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	while (n--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		microblaze_set_syscall_arg(regs, i++, *args++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) asmlinkage void do_syscall_trace_leave(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static inline int syscall_get_arch(struct task_struct *task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	return AUDIT_ARCH_MICROBLAZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #endif /* __ASM_MICROBLAZE_SYSCALL_H */