xref: /netbsd-src/sys/arch/m68k/include/db_machdep.h (revision 413d532bcc3f62d122e56d92e13ac64825a40baf)
1 /*	$NetBSD: db_machdep.h,v 1.31 2012/01/31 21:17:57 mlelstv Exp $	*/
2 
3 /*
4  * Mach Operating System
5  * Copyright (c) 1992 Carnegie Mellon University
6  * All Rights Reserved.
7  *
8  * Permission to use, copy, modify and distribute this software and its
9  * documentation is hereby granted, provided that both the copyright
10  * notice and this permission notice appear in all copies of the
11  * software, derivative works or modified versions, and any portions
12  * thereof, and that both notices appear in supporting documentation.
13  *
14  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17  *
18  * Carnegie Mellon requests users of this software to return to
19  *
20  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
21  *  School of Computer Science
22  *  Carnegie Mellon University
23  *  Pittsburgh PA 15213-3890
24  *
25  * any improvements or extensions that they make and grant Carnegie Mellon
26  * the rights to redistribute these changes.
27  */
28 
29 /*
30  * Machine-dependent defines for new kernel debugger.
31  */
32 #ifndef	_M68K_DB_MACHDEP_H_
33 #define	_M68K_DB_MACHDEP_H_
34 
35 #if !defined(_KERNEL) && !defined(_STANDALONE)
36 #include <stddef.h>
37 #include <stdbool.h>
38 #include <string.h>
39 #endif /* _KERNEL || _STANDALONE */
40 
41 #include <sys/types.h>
42 
43 /*
44  * XXX - Would rather not pull in vm headers, but need boolean_t,
45  * at least until boolean_t moves to <sys/types.h> or someplace.
46  */
47 #include <uvm/uvm_param.h>
48 
49 #include <machine/frame.h>
50 #include <machine/pcb.h>
51 #include <machine/psl.h>
52 #include <machine/trap.h>
53 
54 typedef	vaddr_t		db_addr_t;	/* address - unsigned */
55 #define	DDB_EXPR_FMT	"l"		/* expression is long */
56 typedef	long		db_expr_t;	/* expression - signed */
57 typedef struct trapframe db_regs_t;
58 
59 extern db_regs_t	ddb_regs;	/* register state */
60 #define DDB_REGS	(&ddb_regs)
61 
62 #define	PC_REGS(regs)	((regs)->tf_pc)
63 
64 #define	BKPT_ADDR(addr)	(addr)		/* breakpoint address */
65 #define	BKPT_INST	0x4e4f		/* breakpoint instruction */
66 #define	BKPT_SIZE	(2)		/* size of breakpoint inst */
67 #define	BKPT_SET(inst, addr)	(BKPT_INST)
68 
69 #define	FIXUP_PC_AFTER_BREAK(regs)	((regs)->tf_pc -= BKPT_SIZE)
70 
71 #define	db_clear_single_step(regs)	((regs)->tf_sr &= ~PSL_T)
72 #define	db_set_single_step(regs)	((regs)->tf_sr |=  PSL_T)
73 
74 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAKPOINT)
75 #ifdef T_WATCHPOINT
76 #define	IS_WATCHPOINT_TRAP(type, code)	((type) == T_WATCHPOINT)
77 #else
78 #define	IS_WATCHPOINT_TRAP(type, code)	0
79 #endif
80 
81 #define	M_RTS		0xffff0000
82 #define I_RTS		0x4e750000
83 #define M_JSR		0xffc00000
84 #define I_JSR		0x4e800000
85 #define M_BSR		0xff000000
86 #define I_BSR		0x61000000
87 #define	M_RTE		0xffff0000
88 #define	I_RTE		0x4e730000
89 
90 #define	inst_trap_return(ins)	(((ins)&M_RTE) == I_RTE)
91 #define	inst_return(ins)	(((ins)&M_RTS) == I_RTS)
92 #define	inst_call(ins)		(((ins)&M_JSR) == I_JSR || \
93 				 ((ins)&M_BSR) == I_BSR)
94 #define inst_load(ins)		0
95 #define inst_store(ins)		0
96 
97 /*
98  * Things needed by kgdb:
99  */
100 typedef long kgdb_reg_t;
101 #define KGDB_NUMREGS	(16+2)
102 #define KGDB_BUFLEN	512
103 
104 
105 #ifdef _KERNEL
106 
107 void	Debugger(void);		/* XXX */
108 void	kdb_kintr(db_regs_t *);
109 int 	kdb_trap(int, db_regs_t *);
110 
111 #endif /* _KERNEL */
112 
113 /*
114  * We use Elf32 symbols in DDB.
115  */
116 #define	DB_ELF_SYMBOLS
117 #define	DB_ELFSIZE	32
118 
119 #endif	/* _M68K_DB_MACHDEP_H_ */
120