| 1 | /*	$OpenBSD: db_machdep.h,v 1.21 2021/08/30 08:11:12 jasper 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 | |
| 43 | #define	SOFTWARE_SSTEP		/* Need software single step */ |
| 44 | #define	SOFTWARE_SSTEP_EMUL	/* next_instr_address() emulates 100% */ |
| 45 | vaddr_t	next_instr_address(vaddr_t, int); |
| 46 | #define	BKPT_SIZE (4) |
| 47 | #define	BKPT_SET(ins)	(BREAK_DDB) |
| 48 | #define	DB_VALID_BREAKPOINT(addr)	(((addr) & 3) == 0) |
| 49 | |
| 50 | #define	IS_BREAKPOINT_TRAP(type, code)	((type) == T_BREAK) |
| 51 | #define IS_WATCHPOINT_TRAP(type, code)	(0)	/* XXX mips3 watchpoint */ |
| 52 | |
| 53 | #define	PC_REGS(regs)	((vaddr_t)(regs)->pc) |
| 54 | #define	SET_PC_REGS(regs, value)	(regs)->pc = (register_t)(value) |
| 55 | |
| 56 | /* |
| 57 | * Test of instructions to see class. |
| 58 | */ |
| 59 | #define	inst_branch(i)		(classify_insn(i) == INSNCLASS_BRANCH) |
| 60 | #define	inst_trap_return(i)	((i) & 0) |
| 61 | #define	inst_call(i)		(classify_insn(i) == INSNCLASS_CALL) |
| 62 | #define	inst_return(i)		((i) == 0x03e00008) |
| 63 | |
| 64 | void db_machine_init(void); |
| 65 | |
| 66 | int db_enter_ddb(void); |
| 67 | void db_startcpu(int); |
| 68 | void db_stopcpu(int); |
| 69 | |
| 70 | int	dbmd_print_insn(uint32_t, vaddr_t, int (*)(const char *, ...)); |
| 71 | |
| 72 | #define DDB_STATE_NOT_RUNNING	0 |
| 73 | #define DDB_STATE_RUNNING	1 |
| 74 | #define DDB_STATE_EXITING	2 |
| 75 | |
| 76 | #endif	/* !_MIPS64_DB_MACHDEP_H_ */ |