xref: /openbsd/sys/arch/mips64/include/db_machdep.h (revision 09467b48)
1 /*	$OpenBSD: db_machdep.h,v 1.20 2019/11/07 14:44:53 mpi Exp $ */
2 
3 /*
4  * Copyright (c) 1998-2003 Opsycon AB (www.opsycon.se)
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  */
28 
29 #ifndef	_MIPS64_DB_MACHDEP_H_
30 #define	_MIPS64_DB_MACHDEP_H_
31 
32 #include <machine/frame.h>
33 #include <machine/trap.h>
34 #include <uvm/uvm_param.h>
35 
36 #define DB_MACHINE_COMMANDS	/* We have machine specific commands */
37 
38 typedef struct trapframe db_regs_t;
39 extern db_regs_t	ddb_regs;
40 
41 typedef	long		db_expr_t;
42 typedef vaddr_t		db_addr_t;
43 
44 #define	SOFTWARE_SSTEP		/* Need software single step */
45 #define	SOFTWARE_SSTEP_EMUL	/* next_instr_address() emulates 100% */
46 vaddr_t	next_instr_address(vaddr_t, int);
47 #define	BKPT_SIZE   (4)
48 #define	BKPT_SET(ins)	(BREAK_DDB)
49 #define	DB_VALID_BREAKPOINT(addr)	(((addr) & 3) == 0)
50 
51 #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAK)
52 #define IS_WATCHPOINT_TRAP(type, code)	(0)	/* XXX mips3 watchpoint */
53 
54 #define	PC_REGS(regs)	((vaddr_t)(regs)->pc)
55 #define	SET_PC_REGS(regs, value)	(regs)->pc = (register_t)(value)
56 
57 /*
58  *  Test of instructions to see class.
59  */
60 #define	inst_branch(i)		(classify_insn(i) == INSNCLASS_BRANCH)
61 #define	inst_trap_return(i)	((i) & 0)
62 #define	inst_call(i)		(classify_insn(i) == INSNCLASS_CALL)
63 #define	inst_return(i)		((i) == 0x03e00008)
64 
65 void db_machine_init(void);
66 
67 int db_enter_ddb(void);
68 void db_startcpu(int);
69 void db_stopcpu(int);
70 
71 int	dbmd_print_insn(uint32_t, vaddr_t, int (*)(const char *, ...));
72 
73 #define DDB_STATE_NOT_RUNNING	0
74 #define DDB_STATE_RUNNING	1
75 #define DDB_STATE_EXITING	2
76 
77 #endif	/* !_MIPS64_DB_MACHDEP_H_ */
78