xref: /freebsd/sys/powerpc/include/db_machdep.h (revision ae83180158c4c937f170e31eff311b18c0286a93)
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  * $FreeBSD$
29  */
30 
31 /*
32  * Machine-dependent defines for new kernel debugger.
33  */
34 #ifndef _POWERPC_DB_MACHDEP_H_
35 #define	_POWERPC_DB_MACHDEP_H_
36 
37 #define	PPC_MPC6XX
38 
39 #include <vm/vm_param.h>
40 
41 #define	DB_ELF_SYMBOLS
42 #define	DB_ELFSIZE	32
43 
44 typedef	vm_offset_t	db_addr_t;	/* address - unsigned */
45 typedef	long		db_expr_t;	/* expression - signed */
46 struct powerpc_saved_state {
47 	u_int32_t	r[32];		/* data registers */
48 	u_int32_t	iar;
49 	u_int32_t	msr;
50 	u_int32_t	lr;
51 	u_int32_t	ctr;
52 	u_int32_t	cr;
53 	u_int32_t	xer;
54 	u_int32_t	dear;
55 	u_int32_t	esr;
56 	u_int32_t	pid;
57 };
58 typedef struct powerpc_saved_state db_regs_t;
59 extern db_regs_t	ddb_regs;	/* register state */
60 #define	DDB_REGS	(&ddb_regs)
61 
62 #define	PC_REGS(regs)	((db_addr_t)(regs)->iar)
63 
64 #define	BKPT_INST	0x7C810808	/* breakpoint instruction */
65 
66 #define	BKPT_SIZE	(4)		/* size of breakpoint inst */
67 #define	BKPT_SET(inst)	(BKPT_INST)
68 
69 #define	FIXUP_PC_AFTER_BREAK	(DDB_REGS)->iar -= 4;
70 
71 #define	SR_SINGLESTEP	0x400
72 #define	db_clear_single_step(regs)	((regs)->msr &= ~SR_SINGLESTEP)
73 #define	db_set_single_step(regs)	((regs)->msr |=  SR_SINGLESTEP)
74 
75 #define	T_BREAKPOINT	0xffff
76 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAKPOINT)
77 
78 #define T_WATCHPOINT	0xeeee
79 #ifdef T_WATCHPOINT
80 #define	IS_WATCHPOINT_TRAP(type, code)	((type) == T_WATCHPOINT)
81 #else
82 #define	IS_WATCHPOINT_TRAP(type, code)	0
83 #endif
84 
85 #define	M_RTS		0xfc0007fe
86 #define	I_RTS		0x4c000020
87 #define	M_BC		0xfc000000
88 #define	I_BC		0x40000000
89 #define	M_B		0xfc000000
90 #define	I_B		0x50000000
91 #define	M_RFI		0xfc0007fe
92 #define	I_RFI		0x4c000064
93 
94 #define	inst_trap_return(ins)	(((ins)&M_RFI) == I_RFI)
95 #define	inst_return(ins)	(((ins)&M_RTS) == I_RTS)
96 #define	inst_call(ins)		(((ins)&M_BC ) == I_BC  || \
97 				 ((ins)&M_B  ) == I_B )
98 #define	inst_load(ins)		0
99 #define	inst_store(ins)		0
100 
101 #define	DB_SMALL_VALUE_MAX	(0x7fffffff)
102 #define	DB_SMALL_VALUE_MIN	(-0x40001)
103 
104 #ifdef _KERNEL
105 
106 void	kdb_kintr(void *);
107 int	kdb_trap(int, void *);
108 
109 #endif /* _KERNEL */
110 
111 #endif	/* _POWERPC_DB_MACHDEP_H_ */
112