xref: /openbsd/sys/arch/alpha/include/db_machdep.h (revision 91f110e0)
1 /*	$OpenBSD: db_machdep.h,v 1.23 2014/03/16 20:31:45 guenther 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 /* XXX - Need to include vm.h for boolean_t */
31 #include <uvm/uvm_extern.h>
32 
33 struct opcode {
34 	enum opc_fmt { OPC_PAL, OPC_RES, OPC_MEM, OPC_OP, OPC_BR } opc_fmt;
35 	char *opc_name;
36 	int opc_print;
37 };
38 extern struct opcode opcode[];
39 
40 /* types the generic ddb module needs */
41 typedef	vaddr_t db_addr_t;
42 typedef	long db_expr_t;
43 typedef struct trapframe db_regs_t;
44 
45 extern db_regs_t	ddb_regs;
46 #define	DDB_REGS	(&ddb_regs)
47 
48 #define	PC_REGS(regs)	((db_addr_t)(regs)->tf_regs[FRAME_PC])
49 #define	SET_PC_REGS(regs, value) (regs)->tf_regs[FRAME_PC] = (unsigned long)(value)
50 
51 /* Breakpoint related definitions */
52 #define	BKPT_INST	0x00000080	/* call_pal bpt */
53 #define	BKPT_SIZE	sizeof(int)
54 #define	BKPT_SET(inst)	BKPT_INST
55 
56 #define	IS_BREAKPOINT_TRAP(type, code) \
57     ((type) == ALPHA_KENTRY_IF && (code) == ALPHA_IF_CODE_BPT)
58 #ifdef notyet
59 #define	IS_WATCHPOINT_TRAP(type, code)	((type) == ALPHA_KENTRY_MM)
60 #else
61 #define	IS_WATCHPOINT_TRAP(type, code)	0
62 #endif
63 
64 #define	FIXUP_PC_AFTER_BREAK(regs) ((regs)->tf_regs[FRAME_PC] -= sizeof(int))
65 
66 #define SOFTWARE_SSTEP
67 #define DB_VALID_BREAKPOINT(addr) db_valid_breakpoint(addr)
68 
69 /* Hack to skip GCC "unused" warnings. */
70 #define	inst_trap_return(ins)	((ins) & 0)		/* XXX */
71 #define	inst_return(ins)	(((ins) & 0xfc000000) == 0x68000000)
72 
73 int	alpha_debug(unsigned long, unsigned long, unsigned long,
74     unsigned long, struct trapframe *);
75 db_addr_t db_branch_taken(int, db_addr_t, db_regs_t *);
76 boolean_t db_inst_branch(int);
77 boolean_t db_inst_call(int);
78 boolean_t db_inst_load(int);
79 boolean_t db_inst_return(int);
80 boolean_t db_inst_trap_return(int);
81 boolean_t db_inst_unconditional_flow_transfer(int);
82 u_long	db_register_value(db_regs_t *, int);
83 int	db_valid_breakpoint(db_addr_t);
84 int	ddb_trap(unsigned long, unsigned long, unsigned long,
85     unsigned long, struct trapframe *);
86 int	kdb_trap(int, int, db_regs_t *);
87 db_addr_t next_instr_address(db_addr_t, int);
88 
89 #if 1
90 /* Backwards compatibility until we switch all archs to use the db_ prefix */
91 #define branch_taken(ins, pc, fun, regs) db_branch_taken((ins), (pc), (regs))
92 #define inst_branch db_inst_branch
93 #define inst_call db_inst_call
94 #endif
95 
96 #define	DB_MACHINE_COMMANDS
97 
98 #endif	/* _MACHINE_DB_MACHDEP_H_ */
99