db_machdep.h revision 137975
1129198Scognet/*
2129198Scognet * Mach Operating System
3129198Scognet * Copyright (c) 1991,1990 Carnegie Mellon University
4129198Scognet * All Rights Reserved.
5129198Scognet *
6129198Scognet * Permission to use, copy, modify and distribute this software and its
7129198Scognet * documentation is hereby granted, provided that both the copyright
8129198Scognet * notice and this permission notice appear in all copies of the
9129198Scognet * software, derivative works or modified versions, and any portions
10129198Scognet * thereof, and that both notices appear in supporting documentation.
11129198Scognet *
12129198Scognet * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13129198Scognet * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14129198Scognet * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15129198Scognet *
16129198Scognet * Carnegie Mellon requests users of this software to return to
17129198Scognet *
18129198Scognet *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19129198Scognet *  School of Computer Science
20129198Scognet *  Carnegie Mellon University
21129198Scognet *  Pittsburgh PA 15213-3890
22129198Scognet *
23129198Scognet * any improvements or extensions that they make and grant Carnegie Mellon
24129198Scognet * the rights to redistribute these changes.
25129198Scognet *
26129198Scognet *	from: FreeBSD: src/sys/i386/include/db_machdep.h,v 1.16 1999/10/04
27129198Scognet * $FreeBSD: head/sys/arm/include/db_machdep.h 137975 2004-11-21 18:11:39Z cognet $
28129198Scognet */
29129198Scognet
30129198Scognet#ifndef	_MACHINE_DB_MACHDEP_H_
31129198Scognet#define	_MACHINE_DB_MACHDEP_H_
32129198Scognet
33129198Scognet#include <machine/frame.h>
34129198Scognet#include <machine/trap.h>
35129198Scognet#include <machine/armreg.h>
36129198Scognet
37129198Scognet#define T_BREAKPOINT	(1)
38129198Scognettypedef vm_offset_t	db_addr_t;
39129198Scognettypedef int		db_expr_t;
40129198Scognet
41132059Scognet#define	PC_REGS()	((db_addr_t)kdb_thrctx->un_32.pcb32_pc)
42129198Scognet
43129198Scognet#define	BKPT_INST	(KERNEL_BREAKPOINT)
44129198Scognet#define	BKPT_SIZE	(INSN_SIZE)
45129198Scognet#define	BKPT_SET(inst)	(BKPT_INST)
46129198Scognet
47129198Scognet#define	BKPT_SKIP do {							\
48137940Scognet	kdb_frame->tf_pc += BKPT_SIZE; \
49129198Scognet} while (0)
50129198Scognet
51137975Scognet#define SOFTWARE_SSTEP	1
52129198Scognet
53129198Scognet#define	IS_BREAKPOINT_TRAP(type, code)	(type == T_BREAKPOINT)
54129198Scognet#define	IS_WATCHPOINT_TRAP(type, code)	(0)
55129198Scognet
56137940Scognet
57129198Scognet#define	inst_trap_return(ins)	(0)
58137940Scognet/* ldmxx reg, {..., pc}
59137940Scognet					    01800000  stack mode
60137940Scognet					    000f0000  register
61137940Scognet					    0000ffff  register list */
62137940Scognet/* mov pc, reg
63137940Scognet					    0000000f  register */
64137940Scognet#define	inst_return(ins)	(((ins) & 0x0e108000) == 0x08108000 || \
65137975Scognet				 ((ins) & 0x0ff0fff0) == 0x01a0f000 ||	\
66137975Scognet				 ((ins) & 0x0ffffff0) == 0x012fff10) /* bx */
67137940Scognet/* bl ...
68137940Scognet					    00ffffff  offset>>2 */
69137940Scognet#define	inst_call(ins)		(((ins) & 0x0f000000) == 0x0b000000)
70137940Scognet/* b ...
71137940Scognet					    00ffffff  offset>>2 */
72137940Scognet/* ldr pc, [pc, reg, lsl #2]
73137940Scognet					    0000000f  register */
74137940Scognet
75137975Scognet#define	inst_branch(ins)	(((ins) & 0x0f000000) == 0x0a000000 || \
76137975Scognet				 ((ins) & 0x0fdffff0) == 0x079ff100)
77137940Scognet
78129198Scognet#define	inst_load(ins)		(0)
79129198Scognet#define	inst_store(ins)		(0)
80129198Scognet
81137975Scognet#define next_instr_address(pc, bd)	((bd) ? (pc) : ((pc) + INSN_SIZE))
82137975Scognet
83129198Scognet#define	DB_SMALL_VALUE_MAX	(0x7fffffff)
84129198Scognet#define	DB_SMALL_VALUE_MIN	(-0x40001)
85129198Scognet
86137975Scognet#define	DB_ELFSIZE		32
87129198Scognet
88129198Scognetint db_validate_address(vm_offset_t);
89137975Scognet
90137975Scognetu_int branch_taken (u_int insn, u_int pc);
91137975Scognet
92129198Scognet#endif /* !_MACHINE_DB_MACHDEP_H_ */
93