xref: /openbsd/sys/arch/powerpc/include/db_machdep.h (revision 4cfece93)
1 /*	$OpenBSD: db_machdep.h,v 1.30 2019/03/23 05:47:23 visa Exp $*/
2 /*	$NetBSD: db_machdep.h,v 1.13 1996/04/29 20:50:08 leo Exp $	*/
3 
4 /*
5  * Mach Operating System
6  * Copyright (c) 1992 Carnegie Mellon University
7  * All Rights Reserved.
8  *
9  * Permission to use, copy, modify and distribute this software and its
10  * documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
17  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie Mellon
27  * the rights to redistribute these changes.
28  */
29 
30 /*
31  * Machine-dependent defines for new kernel debugger.
32  */
33 #ifndef	_POWERPC_DB_MACHDEP_H_
34 #define	_POWERPC_DB_MACHDEP_H_
35 
36 #include <sys/types.h>
37 #include <uvm/uvm_param.h>
38 #include <machine/trap.h>
39 
40 typedef	vaddr_t	db_addr_t;	/* address - unsigned */
41 typedef	long		db_expr_t;	/* expression - signed */
42 typedef struct trapframe db_regs_t;
43 extern	db_regs_t ddb_regs;		/* register state */
44 
45 #define	PC_REGS(regs)	((regs)->srr0)
46 #define	SET_PC_REGS(regs, value)	PC_REGS(regs) = (value)
47 
48 #define	BKPT_INST	0x7C810808	/* breakpoint instruction */
49 
50 #define	BKPT_SIZE	(4)		/* size of breakpoint inst */
51 #define	BKPT_SET(inst)	(BKPT_INST)
52 
53 #define	FIXUP_PC_AFTER_BREAK(regs)	((regs)->srr0 -= 4)
54 
55 #define SR_SINGLESTEP 0x8000
56 #define	db_clear_single_step(regs)	((regs)->srr1 &= ~SR_SINGLESTEP)
57 #define	db_set_single_step(regs)	((regs)->srr1 |=  SR_SINGLESTEP)
58 
59 #define T_BREAKPOINT	0xffff
60 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAKPOINT)
61 
62 #ifdef T_WATCHPOINT
63 #define	IS_WATCHPOINT_TRAP(type, code)	((type) == T_WATCHPOINT)
64 #else
65 #define	IS_WATCHPOINT_TRAP(type, code)	0
66 #endif
67 
68 #define	M_RTS		0xfc0007fe
69 #define I_RTS		0x4c000020
70 #define M_BC		0xfc000000
71 #define I_BC		0x40000000
72 #define M_B		0xfc000000
73 #define I_B		0x50000000
74 #define	M_RFI		0xfc0007fe
75 #define	I_RFI		0x4c000064
76 
77 #define	inst_trap_return(ins)	(((ins)&M_RFI) == I_RFI)
78 #define	inst_return(ins)	(((ins)&M_RTS) == I_RTS)
79 #define	inst_call(ins)		(((ins)&M_BC ) == I_BC  || \
80 				 ((ins)&M_B  ) == I_B )
81 
82 #ifdef _KERNEL
83 
84 int db_enter_ddb(void);
85 void db_startcpu(int);
86 void db_stopcpu(int);
87 void ppc_ipi_db(struct cpu_info *);
88 
89 void	kdb_kintr(void *);
90 void	db_save_regs(struct trapframe *frame);
91 void	ddb_trap(void);
92 db_expr_t db_dumpframe(u_int32_t pframe, int (*pr)(const char *, ...));
93 
94 #define DDB_STATE_NOT_RUNNING	0
95 #define DDB_STATE_RUNNING	1
96 #define DDB_STATE_EXITING	2
97 
98 /*
99  * We define some of our own commands
100  */
101 #define DB_MACHINE_COMMANDS
102 
103 #endif /* _KERNEL */
104 
105 #endif	/* _POWERPC_DB_MACHDEP_H_ */
106