1139735Simp/*-
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$
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)
38294740Szbb#define T_WATCHPOINT	(2)
39129198Scognettypedef vm_offset_t	db_addr_t;
40129198Scognettypedef int		db_expr_t;
41129198Scognet
42276190Sian#define	PC_REGS()	((db_addr_t)kdb_thrctx->pcb_regs.sf_pc)
43129198Scognet
44129198Scognet#define	BKPT_INST	(KERNEL_BREAKPOINT)
45129198Scognet#define	BKPT_SIZE	(INSN_SIZE)
46129198Scognet#define	BKPT_SET(inst)	(BKPT_INST)
47129198Scognet
48129198Scognet#define	BKPT_SKIP do {							\
49137940Scognet	kdb_frame->tf_pc += BKPT_SIZE; \
50129198Scognet} while (0)
51129198Scognet
52294740Szbb#if __ARM_ARCH >= 6
53294740Szbb#define	db_clear_single_step	kdb_cpu_clear_singlestep
54294740Szbb#define	db_set_single_step	kdb_cpu_set_singlestep
55294740Szbb#define	db_pc_is_singlestep	kdb_cpu_pc_is_singlestep
56294740Szbb#else
57294740Szbb#define	SOFTWARE_SSTEP  1
58294740Szbb#endif
59129198Scognet
60129198Scognet#define	IS_BREAKPOINT_TRAP(type, code)	(type == T_BREAKPOINT)
61294740Szbb#define	IS_WATCHPOINT_TRAP(type, code)	(type == T_WATCHPOINT)
62129198Scognet
63129198Scognet#define	inst_trap_return(ins)	(0)
64137940Scognet/* ldmxx reg, {..., pc}
65137940Scognet					    01800000  stack mode
66137940Scognet					    000f0000  register
67137940Scognet					    0000ffff  register list */
68137940Scognet/* mov pc, reg
69137940Scognet					    0000000f  register */
70137940Scognet#define	inst_return(ins)	(((ins) & 0x0e108000) == 0x08108000 || \
71137975Scognet				 ((ins) & 0x0ff0fff0) == 0x01a0f000 ||	\
72137975Scognet				 ((ins) & 0x0ffffff0) == 0x012fff10) /* bx */
73137940Scognet/* bl ...
74137940Scognet					    00ffffff  offset>>2 */
75137940Scognet#define	inst_call(ins)		(((ins) & 0x0f000000) == 0x0b000000)
76137940Scognet/* b ...
77137940Scognet					    00ffffff  offset>>2 */
78137940Scognet/* ldr pc, [pc, reg, lsl #2]
79137940Scognet					    0000000f  register */
80137940Scognet
81137975Scognet#define	inst_branch(ins)	(((ins) & 0x0f000000) == 0x0a000000 || \
82181174Scognet				 ((ins) & 0x0fdffff0) == 0x079ff100 || \
83290273Szbb				 ((ins) & 0x0cd0f000) == 0x0490f000 || \
84181253Scognet				 ((ins) & 0x0ffffff0) == 0x012fff30 || /* blx */ \
85181253Scognet				 ((ins) & 0x0de0f000) == 0x0080f000)
86137940Scognet
87129198Scognet#define	inst_load(ins)		(0)
88129198Scognet#define	inst_store(ins)		(0)
89129198Scognet
90137975Scognet#define next_instr_address(pc, bd)	((bd) ? (pc) : ((pc) + INSN_SIZE))
91137975Scognet
92129198Scognet#define	DB_SMALL_VALUE_MAX	(0x7fffffff)
93129198Scognet#define	DB_SMALL_VALUE_MIN	(-0x40001)
94129198Scognet
95137975Scognet#define	DB_ELFSIZE		32
96129198Scognet
97129198Scognetint db_validate_address(vm_offset_t);
98137975Scognet
99290273Szbbu_int branch_taken (u_int insn, db_addr_t pc);
100137975Scognet
101160740Scognet#ifdef __ARMEB__
102160740Scognet#define BYTE_MSF	(1)
103160740Scognet#endif
104129198Scognet#endif /* !_MACHINE_DB_MACHDEP_H_ */
105