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