db_machdep.h revision 178172
1178172Simp/*	$OpenBSD: db_machdep.h,v 1.2 1998/09/15 10:50:12 pefo Exp $ */
2178172Simp
3178172Simp/*
4178172Simp * Copyright (c) 1998 Per Fogelstrom, Opsycon AB
5178172Simp *
6178172Simp * Redistribution and use in source and binary forms, with or without
7178172Simp * modification, are permitted provided that the following conditions
8178172Simp * are met:
9178172Simp * 1. Redistributions of source code must retain the above copyright
10178172Simp *    notice, this list of conditions and the following disclaimer.
11178172Simp * 2. Redistributions in binary form must reproduce the above copyright
12178172Simp *    notice, this list of conditions and the following disclaimer in the
13178172Simp *    documentation and/or other materials provided with the distribution.
14178172Simp * 3. All advertising materials mentioning features or use of this software
15178172Simp *    must display the following acknowledgement:
16178172Simp *	This product includes software developed under OpenBSD by
17178172Simp *	Per Fogelstrom, Opsycon AB, Sweden.
18178172Simp * 4. The name of the author may not be used to endorse or promote products
19178172Simp *    derived from this software without specific prior written permission.
20178172Simp *
21178172Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
22178172Simp * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23178172Simp * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24178172Simp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25178172Simp * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26178172Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27178172Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28178172Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29178172Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30178172Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31178172Simp * SUCH DAMAGE.
32178172Simp *
33178172Simp *	JNPR: db_machdep.h,v 1.7 2006/10/16 12:30:34 katta
34178172Simp * $FreeBSD: head/sys/mips/include/db_machdep.h 178172 2008-04-13 07:27:37Z imp $
35178172Simp */
36178172Simp
37178172Simp#ifndef	_MIPS_DB_MACHDEP_H_
38178172Simp#define	_MIPS_DB_MACHDEP_H_
39178172Simp
40178172Simp#include <machine/frame.h>
41178172Simp#include <machine/psl.h>
42178172Simp#include <machine/trap.h>
43178172Simp#include <machine/endian.h>
44178172Simp
45178172Simptypedef struct trapframe db_regs_t;
46178172Simpextern db_regs_t	ddb_regs;	/* register state */
47178172Simp
48178172Simptypedef	vm_offset_t	db_addr_t;	/* address - unsigned */
49178172Simptypedef	int		db_expr_t;	/* expression - signed */
50178172Simp
51178172Simp#if BYTE_ORDER == _BIG_ENDIAN
52178172Simp#define	BYTE_MSF	(1)
53178172Simp#endif
54178172Simp
55178172Simp#define	SOFTWARE_SSTEP		/* Need software single step */
56178172Simp#define	SOFTWARE_SSTEP_EMUL	/* next_instr_address() emulates 100% */
57178172Simpdb_addr_t	next_instr_address(db_addr_t, boolean_t);
58178172Simp#define	BKPT_SIZE			(4)
59178172Simp#define	BKPT_SET(ins)			(BREAK_DDB)
60178172Simp#define	DB_VALID_BREAKPOINT(addr)	(((addr) & 3) == 0)
61178172Simp
62178172Simp#define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAK)
63178172Simp#define	IS_WATCHPOINT_TRAP(type, code)	(0)	/* XXX mips3 watchpoint */
64178172Simp
65178172Simp#define	PC_REGS()	((db_addr_t)kdb_thrctx->pcb_regs.pc)
66178172Simp#define	BKPT_SKIP					\
67178172Simp	do {							\
68178172Simp		if((db_get_value(kdb_frame->pc, sizeof(int), FALSE) &	\
69178172Simp		    ~BREAK_VAL_MASK) == BREAK_INSTR) {			\
70178172Simp			kdb_frame->pc += BKPT_SIZE;			\
71178172Simp			kdb_thrctx->pcb_regs.pc +=  BKPT_SIZE;		\
72178172Simp		}							\
73178172Simp	} while (0);
74178172Simp
75178172Simp
76178172Simp/*
77178172Simp *  Test of instructions to see class.
78178172Simp */
79178172Simp#define	IT_CALL		0x01
80178172Simp#define	IT_BRANCH	0x02
81178172Simp#define	IT_LOAD		0x03
82178172Simp#define	IT_STORE	0x04
83178172Simp
84178172Simp#define	inst_branch(i)		(db_inst_type(i) == IT_BRANCH)
85178172Simp#define	inst_trap_return(i)	((i) & 0)
86178172Simp#define	inst_call(i)		(db_inst_type(i) == IT_CALL)
87178172Simp#define	inst_return(i)		((i) == 0x03e00008)
88178172Simp#define	inst_load(i)		(db_inst_type(i) == IT_LOAD)
89178172Simp#define	inst_store(i)		(db_inst_type(i) == IT_STORE)
90178172Simp
91178172Simp#define	DB_SMALL_VALUE_MAX	0x7fffffff
92178172Simp#define	DB_SMALL_VALUE_MIN	(-0x400001)
93178172Simp
94178172Simpint db_inst_type(int);
95178172Simpvoid db_dump_tlb(int, int);
96178172Simpdb_addr_t branch_taken(int inst, db_addr_t pc);
97178172Simpvoid stacktrace_subr(db_regs_t *, int (*)(const char *, ...));
98178172Simp
99178172Simp#endif	/* !_MIPS_DB_MACHDEP_H_ */
100