| 1 | /*	$NetBSD: ptrace.h,v 1.19 2021/03/06 08:08:19 rin Exp $	*/ |
| 2 | |
| 3 | #ifndef _POWERPC_PTRACE_H |
| 4 | #define	_POWERPC_PTRACE_H |
| 5 | |
| 6 | #define	PT_STEP		(PT_FIRSTMACH + 0) |
| 7 | #define	PT_GETREGS	(PT_FIRSTMACH + 1) |
| 8 | #define	PT_SETREGS	(PT_FIRSTMACH + 2) |
| 9 | #define	PT_GETFPREGS	(PT_FIRSTMACH + 3) |
| 10 | #define	PT_SETFPREGS	(PT_FIRSTMACH + 4) |
| 11 | #define	PT_GETVECREGS	(PT_FIRSTMACH + 5) |
| 12 | #define	PT_SETVECREGS	(PT_FIRSTMACH + 6) |
| 13 | #define	PT_SETSTEP	(PT_FIRSTMACH + 7) |
| 14 | #define	PT_CLEARSTEP	(PT_FIRSTMACH + 8) |
| 15 | |
| 16 | #define	PT_MACHDEP_STRINGS				\ |
| 17 | 	"PT_STEP",					\ |
| 18 | 	"PT_GETREGS",		"PT_SETREGS",		\ |
| 19 | 	"PT_GETFPREGS",		"PT_SETFPREGS",		\ |
| 20 | 	"PT_GETVECREGS",	"PT_SETVECREGS",	\ |
| 21 | 	"PT_SETSTEP",		"PT_CLEARSTEP", |
| 22 | |
| 23 | #include <machine/reg.h> |
| 24 | #define PTRACE_REG_PC(r)	(r)->pc |
| 25 | #define PTRACE_REG_FP(r)	(r)->fixreg[31] |
| 26 | #define PTRACE_REG_SET_PC(r, v)	(r)->pc = (v) |
| 27 | #define PTRACE_REG_SP(r)	(r)->fixreg[1] |
| 28 | #define PTRACE_REG_INTRV(r)	(r)->fixreg[3] |
| 29 | |
| 30 | #ifdef _KERNEL |
| 31 | #ifdef _KERNEL_OPT |
| 32 | #include "opt_altivec.h" |
| 33 | #endif |
| 34 | |
| 35 | #if defined(ALTIVEC) || defined(PPC_HAVE_SPE) |
| 36 | |
| 37 | /* We have machine-dependent process tracing requests. */ |
| 38 | #define __HAVE_PTRACE_MACHDEP |
| 39 | |
| 40 | #define	PTRACE_MACHDEP_REQUEST_CASES \ |
| 41 | 	case PT_GETVECREGS: \ |
| 42 | 	case PT_SETVECREGS: |
| 43 | |
| 44 | int ptrace_machdep_dorequest(struct lwp *, struct lwp **, int, void *, int); |
| 45 | int process_machdep_dovecregs(struct lwp *, struct lwp *, struct uio *); |
| 46 | int process_machdep_validvecregs(struct proc *); |
| 47 | |
| 48 | /* We have machine-dependent procfs nodes. */ |
| 49 | #define __HAVE_PROCFS_MACHDEP |
| 50 | |
| 51 | #define	PROCFS_MACHDEP_NODE_TYPES \ |
| 52 | 	Pmachdep_vecregs,		/* AltiVec register set */ |
| 53 | |
| 54 | #define	PROCFS_MACHDEP_NODETYPE_CASES \ |
| 55 | 	case Pmachdep_vecregs: |
| 56 | |
| 57 | #define	PROCFS_MACHDEP_PROTECT_CASES \ |
| 58 | 	case Pmachdep_vecregs: |
| 59 | |
| 60 | #define	PROCFS_MACHDEP_NODETYPE_DEFNS \ |
| 61 | 	{ DT_REG, N("vecregs"), Pmachdep_vecregs, \ |
| 62 | 	 procfs_machdep_validvecregs }, |
| 63 | |
| 64 | /* Functions used by procfs. */ |
| 65 | struct mount; |
| 66 | struct pfsnode; |
| 67 | int procfs_machdep_dovecregs(struct lwp *, struct lwp *, |
| 68 | 	struct pfsnode *, struct uio *); |
| 69 | int procfs_machdep_validvecregs(struct lwp *, struct mount *); |
| 70 | |
| 71 | #endif /* ALTIVEC || PPC_HAVE_SPE */ |
| 72 | |
| 73 | #if defined(PPC_BOOKE) || defined(PPC_IBM4XX) |
| 74 | int ppc_sstep(struct lwp *, int); |
| 75 | #endif /* PPC_BOOKE || PPC_IBM4XX */ |
| 76 | #endif /* _KERNEL */ |
| 77 | |
| 78 | #define PTRACE_ILLEGAL_ASM	__asm __volatile (".long 0" : : : "memory") |
| 79 | |
| 80 | #define PTRACE_BREAKPOINT	((const uint8_t[]) { 0x7f, 0xe0, 0x00, 0x08 }) |
| 81 | #define PTRACE_BREAKPOINT_ASM	__asm __volatile("trap") |
| 82 | #define PTRACE_BREAKPOINT_SIZE	4 |
| 83 | |
| 84 | #endif /* _POWERPC_PTRACE_H */ |