xref: /openbsd/sys/arch/alpha/include/db_machdep.h (revision 42cc9952)
1 /*	$OpenBSD: db_machdep.h,v 1.28 2021/08/30 08:11:12 jasper Exp $	*/
2 
3 /*
4  * Copyright (c) 1997 Niklas Hallqvist.  All rights reserved.
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 OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef	_MACHINE_DB_MACHDEP_H_
28 #define	_MACHINE_DB_MACHDEP_H_
29 
30 #include <uvm/uvm_param.h>
31 
32 struct opcode {
33 	enum opc_fmt { OPC_PAL, OPC_RES, OPC_MEM, OPC_OP, OPC_BR } opc_fmt;
34 	char *opc_name;
35 	int opc_print;
36 };
37 extern struct opcode opcode[];
38 
39 /* types the generic ddb module needs */
40 typedef	long db_expr_t;
41 typedef struct trapframe db_regs_t;
42 
43 extern db_regs_t	ddb_regs;
44 
45 #define	PC_REGS(regs)	((vaddr_t)(regs)->tf_regs[FRAME_PC])
46 #define	SET_PC_REGS(regs, value) (regs)->tf_regs[FRAME_PC] = (unsigned long)(value)
47 
48 /* Breakpoint related definitions */
49 #define	BKPT_INST	0x00000080	/* call_pal bpt */
50 #define	BKPT_SIZE	sizeof(int)
51 #define	BKPT_SET(inst)	BKPT_INST
52 
53 #define	IS_BREAKPOINT_TRAP(type, code) \
54     ((type) == ALPHA_KENTRY_IF && (code) == ALPHA_IF_CODE_BPT)
55 #ifdef notyet
56 #define	IS_WATCHPOINT_TRAP(type, code)	((type) == ALPHA_KENTRY_MM)
57 #else
58 #define	IS_WATCHPOINT_TRAP(type, code)	0
59 #endif
60 
61 #define	FIXUP_PC_AFTER_BREAK(regs) ((regs)->tf_regs[FRAME_PC] -= sizeof(int))
62 
63 #define SOFTWARE_SSTEP
64 #define DB_VALID_BREAKPOINT(addr) db_valid_breakpoint(addr)
65 
66 /* Hack to skip GCC "unused" warnings. */
67 #define	inst_trap_return(ins)	((ins) & 0)		/* XXX */
68 #define	inst_return(ins)	(((ins) & 0xfc000000) == 0x68000000)
69 
70 int	alpha_debug(unsigned long, unsigned long, unsigned long,
71     unsigned long, struct trapframe *);
72 vaddr_t db_branch_taken(int, vaddr_t, db_regs_t *);
73 int	db_inst_branch(int);
74 int	db_inst_call(int);
75 int	db_inst_load(int);
76 int	db_inst_return(int);
77 int	db_inst_trap_return(int);
78 int	db_inst_unconditional_flow_transfer(int);
79 u_long	db_register_value(db_regs_t *, int);
80 int	db_valid_breakpoint(vaddr_t);
81 int	ddb_trap(unsigned long, unsigned long, unsigned long,
82     unsigned long, struct trapframe *);
83 int	db_ktrap(int, int, db_regs_t *);
84 vaddr_t next_instr_address(vaddr_t, int);
85 
86 #if 1
87 /* Backwards compatibility until we switch all archs to use the db_ prefix */
88 #define branch_taken(ins, pc, fun, regs) db_branch_taken((ins), (pc), (regs))
89 #define inst_branch db_inst_branch
90 #define inst_call db_inst_call
91 #endif
92 
93 #define	DB_MACHINE_COMMANDS
94 
95 #endif	/* _MACHINE_DB_MACHDEP_H_ */
96