xref: /freebsd/sys/powerpc/include/db_machdep.h (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1 /*-
2  * Mach Operating System
3  * Copyright (c) 1992 Carnegie Mellon University
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify and distribute this software and its
7  * documentation is hereby granted, provided that both the copyright
8  * notice and this permission notice appear in all copies of the
9  * software, derivative works or modified versions, and any portions
10  * thereof, and that both notices appear in supporting documentation.
11  *
12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15  *
16  * Carnegie Mellon requests users of this software to return to
17  *
18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19  *  School of Computer Science
20  *  Carnegie Mellon University
21  *  Pittsburgh PA 15213-3890
22  *
23  * any improvements or extensions that they make and grant Carnegie Mellon
24  * the rights to redistribute these changes.
25  *
26  *	$OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $
27  *	$NetBSD: db_machdep.h,v 1.4.22.1 2000/08/05 11:10:43 wiz Exp $
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 <vm/vm_param.h>
37 #include <machine/elf.h>
38 
39 #define	DB_ELF_SYMBOLS
40 #define	DB_ELFSIZE	__ELF_WORD_SIZE
41 
42 typedef	vm_offset_t	db_addr_t;	/* address - unsigned */
43 typedef	intptr_t	db_expr_t;	/* expression - signed */
44 
45 #define	PC_REGS(regs)	((db_addr_t)kdb_thrctx->pcb_lr)
46 
47 #define	BKPT_INST	0x7C810808	/* breakpoint instruction */
48 
49 #define	BKPT_SIZE	(4)		/* size of breakpoint inst */
50 #define	BKPT_SET(inst)	(BKPT_INST)
51 
52 #define db_clear_single_step	kdb_cpu_clear_singlestep
53 #define db_set_single_step	kdb_cpu_set_singlestep
54 
55 #if 0
56 #define	SR_SINGLESTEP	0x400
57 #define	db_clear_single_step(regs)	((regs)->msr &= ~SR_SINGLESTEP)
58 #define	db_set_single_step(regs)	((regs)->msr |=  SR_SINGLESTEP)
59 #endif
60 
61 #define	T_BREAKPOINT	0xffff
62 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAKPOINT)
63 
64 #define T_WATCHPOINT	0xeeee
65 #ifdef T_WATCHPOINT
66 #define	IS_WATCHPOINT_TRAP(type, code)	((type) == T_WATCHPOINT)
67 #else
68 #define	IS_WATCHPOINT_TRAP(type, code)	0
69 #endif
70 
71 #define	M_RTS		0xfc0007fe
72 #define	I_RTS		0x4c000020
73 #define	M_BC		0xfc000000
74 #define	I_BC		0x40000000
75 #define	M_B		0xfc000000
76 #define	I_B		0x50000000
77 #define	M_RFI		0xfc0007fe
78 #define	I_RFI		0x4c000064
79 
80 #define	inst_trap_return(ins)	(((ins)&M_RFI) == I_RFI)
81 #define	inst_return(ins)	(((ins)&M_RTS) == I_RTS)
82 #define	inst_call(ins)		(((ins)&M_BC ) == I_BC  || \
83 				 ((ins)&M_B  ) == I_B )
84 #define	inst_load(ins)		0
85 #define	inst_store(ins)		0
86 
87 #endif	/* _POWERPC_DB_MACHDEP_H_ */
88