xref: /OK3568_Linux_fs/kernel/arch/nds32/include/asm/ptrace.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun // Copyright (C) 2005-2017 Andes Technology Corporation
3*4882a593Smuzhiyun 
4*4882a593Smuzhiyun #ifndef __ASM_NDS32_PTRACE_H
5*4882a593Smuzhiyun #define __ASM_NDS32_PTRACE_H
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #include <uapi/asm/ptrace.h>
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun /*
10*4882a593Smuzhiyun  * If pt_regs.syscallno == NO_SYSCALL, then the thread is not executing
11*4882a593Smuzhiyun  * a syscall -- i.e., its most recent entry into the kernel from
12*4882a593Smuzhiyun  * userspace was not via syscall, or otherwise a tracer cancelled the
13*4882a593Smuzhiyun  * syscall.
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * This must have the value -1, for ABI compatibility with ptrace etc.
16*4882a593Smuzhiyun  */
17*4882a593Smuzhiyun #define NO_SYSCALL (-1)
18*4882a593Smuzhiyun #ifndef __ASSEMBLY__
19*4882a593Smuzhiyun #include <linux/types.h>
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun struct pt_regs {
22*4882a593Smuzhiyun 	union {
23*4882a593Smuzhiyun 		struct user_pt_regs user_regs;
24*4882a593Smuzhiyun 		struct {
25*4882a593Smuzhiyun 			long uregs[26];
26*4882a593Smuzhiyun 			long fp;
27*4882a593Smuzhiyun 			long gp;
28*4882a593Smuzhiyun 			long lp;
29*4882a593Smuzhiyun 			long sp;
30*4882a593Smuzhiyun 			long ipc;
31*4882a593Smuzhiyun #if defined(CONFIG_HWZOL)
32*4882a593Smuzhiyun 			long lb;
33*4882a593Smuzhiyun 			long le;
34*4882a593Smuzhiyun 			long lc;
35*4882a593Smuzhiyun #else
36*4882a593Smuzhiyun 			long dummy[3];
37*4882a593Smuzhiyun #endif
38*4882a593Smuzhiyun 			long syscallno;
39*4882a593Smuzhiyun 		};
40*4882a593Smuzhiyun 	};
41*4882a593Smuzhiyun 	long orig_r0;
42*4882a593Smuzhiyun 	long ir0;
43*4882a593Smuzhiyun 	long ipsw;
44*4882a593Smuzhiyun 	long pipsw;
45*4882a593Smuzhiyun 	long pipc;
46*4882a593Smuzhiyun 	long pp0;
47*4882a593Smuzhiyun 	long pp1;
48*4882a593Smuzhiyun 	long fucop_ctl;
49*4882a593Smuzhiyun 	long osp;
50*4882a593Smuzhiyun };
51*4882a593Smuzhiyun 
in_syscall(struct pt_regs const * regs)52*4882a593Smuzhiyun static inline bool in_syscall(struct pt_regs const *regs)
53*4882a593Smuzhiyun {
54*4882a593Smuzhiyun 	return regs->syscallno != NO_SYSCALL;
55*4882a593Smuzhiyun }
56*4882a593Smuzhiyun 
forget_syscall(struct pt_regs * regs)57*4882a593Smuzhiyun static inline void forget_syscall(struct pt_regs *regs)
58*4882a593Smuzhiyun {
59*4882a593Smuzhiyun 	regs->syscallno = NO_SYSCALL;
60*4882a593Smuzhiyun }
regs_return_value(struct pt_regs * regs)61*4882a593Smuzhiyun static inline unsigned long regs_return_value(struct pt_regs *regs)
62*4882a593Smuzhiyun {
63*4882a593Smuzhiyun 	return regs->uregs[0];
64*4882a593Smuzhiyun }
65*4882a593Smuzhiyun extern void show_regs(struct pt_regs *);
66*4882a593Smuzhiyun /* Avoid circular header include via sched.h */
67*4882a593Smuzhiyun struct task_struct;
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun #define arch_has_single_step()		(1)
70*4882a593Smuzhiyun #define user_mode(regs)			(((regs)->ipsw & PSW_mskPOM) == 0)
71*4882a593Smuzhiyun #define interrupts_enabled(regs)	(!!((regs)->ipsw & PSW_mskGIE))
72*4882a593Smuzhiyun #define user_stack_pointer(regs)	((regs)->sp)
73*4882a593Smuzhiyun #define instruction_pointer(regs)	((regs)->ipc)
74*4882a593Smuzhiyun #define profile_pc(regs) 		instruction_pointer(regs)
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun #endif /* __ASSEMBLY__ */
77*4882a593Smuzhiyun #endif
78