xref: /openbsd-src/sys/arch/arm/include/db_machdep.h (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /*	$OpenBSD: db_machdep.h,v 1.11 2016/04/27 11:10:48 mpi Exp $	*/
2 /*	$NetBSD: db_machdep.h,v 1.5 2001/11/22 18:00:00 thorpej Exp $	*/
3 
4 /*
5  * Copyright (c) 1996 Scott K Stevens
6  *
7  * Mach Operating System
8  * Copyright (c) 1991,1990 Carnegie Mellon University
9  * All Rights Reserved.
10  *
11  * Permission to use, copy, modify and distribute this software and its
12  * documentation is hereby granted, provided that both the copyright
13  * notice and this permission notice appear in all copies of the
14  * software, derivative works or modified versions, and any portions
15  * thereof, and that both notices appear in supporting documentation.
16  *
17  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
18  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
19  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
20  *
21  * Carnegie Mellon requests users of this software to return to
22  *
23  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
24  *  School of Computer Science
25  *  Carnegie Mellon University
26  *  Pittsburgh PA 15213-3890
27  *
28  * any improvements or extensions that they make and grant Carnegie Mellon
29  * the rights to redistribute these changes.
30  */
31 
32 #ifndef	_ARM_DB_MACHDEP_H_
33 #define	_ARM_DB_MACHDEP_H_
34 
35 /*
36  * Machine-dependent defines for new kernel debugger.
37  */
38 
39 #include <uvm/uvm_extern.h>
40 #include <arm/armreg.h>
41 #include <machine/frame.h>
42 #include <machine/trap.h>
43 
44 /* end of mangling */
45 
46 typedef	vaddr_t		db_addr_t;	/* address - unsigned */
47 typedef	long		db_expr_t;	/* expression - signed */
48 
49 typedef trapframe_t db_regs_t;
50 
51 extern db_regs_t		ddb_regs;	/* register state */
52 
53 #define	PC_REGS(regs)	((db_addr_t)(regs)->tf_pc)
54 #define	SET_PC_REGS(regs, value)	(regs)->tf_pc = (register_t)(value)
55 
56 #define	BKPT_INST	(KERNEL_BREAKPOINT)	/* breakpoint instruction */
57 #define	BKPT_SIZE	(INSN_SIZE)		/* size of breakpoint inst */
58 #define	BKPT_SET(inst)	(BKPT_INST)
59 
60 /*#define FIXUP_PC_AFTER_BREAK(regs)	((regs)->tf_pc -= BKPT_SIZE)*/
61 
62 #define T_BREAKPOINT			(1)
63 
64 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAKPOINT)
65 #define IS_WATCHPOINT_TRAP(type, code)	(0)
66 
67 #define	inst_trap_return(ins)	(0)
68 /* ldmxx reg, {..., pc}
69 					    01800000  stack mode
70 					    000f0000  register
71 					    0000ffff  register list */
72 /* mov pc, reg
73 					    0000000f  register */
74 #define	inst_return(ins)	(((ins) & 0x0e108000) == 0x08108000 || \
75 				 ((ins) & 0x0ff0fff0) == 0x01a0f000)
76 /* bl ...
77 					    00ffffff  offset>>2 */
78 #define	inst_call(ins)		(((ins) & 0x0f000000) == 0x0b000000)
79 /* b ...
80 					    00ffffff  offset>>2 */
81 /* ldr pc, [pc, reg, lsl #2]
82 					    0000000f  register */
83 #define	inst_branch(ins)	(((ins) & 0x0f000000) == 0x0a000000 || \
84 				 ((ins) & 0x0fdffff0) == 0x079ff100)
85 #define inst_unconditional_flow_transfer(ins)	\
86 	((((ins) & INSN_COND_MASK) == INSN_COND_AL) && \
87 	 (inst_branch(ins) || inst_call(ins) || inst_return(ins)))
88 
89 #define getreg_val			(0)
90 #define next_instr_address(pc, bd)	((bd) ? (pc) : ((pc) + INSN_SIZE))
91 
92 #define DB_MACHINE_COMMANDS
93 
94 #define SOFTWARE_SSTEP
95 
96 db_addr_t	db_branch_taken(u_int inst, db_addr_t pc, db_regs_t *regs);
97 int db_ktrap (int, db_regs_t *);
98 void db_machine_init (void);
99 
100 #define branch_taken(ins, pc, fun, regs) \
101 	db_branch_taken((ins), (pc), (regs))
102 
103 void db_show_frame_cmd(db_expr_t, int, db_expr_t, char *);
104 
105 #endif	/* _ARM_DB_MACHDEP_H_ */
106