db_machdep.h revision 1.12.2.3 1 1.12.2.3 nathanw /* $NetBSD: db_machdep.h,v 1.12.2.3 2002/04/01 07:40:58 nathanw Exp $ */
2 1.12.2.2 nathanw
3 1.12.2.2 nathanw /*
4 1.12.2.2 nathanw * Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
5 1.12.2.2 nathanw * All rights reserved.
6 1.12.2.2 nathanw *
7 1.12.2.2 nathanw * Redistribution and use in source and binary forms, with or without
8 1.12.2.2 nathanw * modification, are permitted provided that the following conditions
9 1.12.2.2 nathanw * are met:
10 1.12.2.2 nathanw * 1. Redistributions of source code must retain the above copyright
11 1.12.2.2 nathanw * notice, this list of conditions and the following disclaimer.
12 1.12.2.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
13 1.12.2.2 nathanw * notice, this list of conditions and the following disclaimer in the
14 1.12.2.2 nathanw * documentation and/or other materials provided with the distribution.
15 1.12.2.2 nathanw * 3. All advertising materials mentioning features or use of this software
16 1.12.2.2 nathanw * must display the following acknowledgement:
17 1.12.2.2 nathanw * This product includes software developed by Jonathan Stone for
18 1.12.2.2 nathanw * the NetBSD Project.
19 1.12.2.2 nathanw * 4. The name of the author may not be used to endorse or promote products
20 1.12.2.2 nathanw * derived from this software without specific prior written permission.
21 1.12.2.2 nathanw *
22 1.12.2.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
23 1.12.2.2 nathanw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.12.2.2 nathanw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.12.2.2 nathanw * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
26 1.12.2.2 nathanw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.12.2.2 nathanw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.12.2.2 nathanw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.12.2.2 nathanw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.12.2.2 nathanw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.12.2.2 nathanw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.12.2.2 nathanw * SUCH DAMAGE.
33 1.12.2.2 nathanw */
34 1.12.2.2 nathanw #ifndef _MIPS_DB_MACHDEP_H_
35 1.12.2.2 nathanw #define _MIPS_DB_MACHDEP_H_
36 1.12.2.2 nathanw
37 1.12.2.2 nathanw #include <uvm/uvm_param.h> /* XXX boolean_t */
38 1.12.2.2 nathanw #include <mips/trap.h> /* T_BREAK */
39 1.12.2.2 nathanw #include <mips/reg.h> /* register state */
40 1.12.2.2 nathanw #include <mips/regnum.h> /* symbolic register indices */
41 1.12.2.2 nathanw #include <mips/proc.h> /* register state */
42 1.12.2.2 nathanw
43 1.12.2.2 nathanw
44 1.12.2.2 nathanw typedef vaddr_t db_addr_t; /* address - unsigned */
45 1.12.2.2 nathanw typedef long db_expr_t; /* expression - signed */
46 1.12.2.2 nathanw
47 1.12.2.2 nathanw typedef struct frame db_regs_t;
48 1.12.2.2 nathanw
49 1.12.2.2 nathanw extern db_regs_t ddb_regs; /* register state */
50 1.12.2.2 nathanw #define DDB_REGS (&ddb_regs)
51 1.12.2.2 nathanw
52 1.12.2.2 nathanw #define PC_REGS(regs) ((db_addr_t)(regs)->f_regs[PC])
53 1.12.2.2 nathanw
54 1.12.2.2 nathanw #define PC_ADVANCE(regs) do { \
55 1.12.2.2 nathanw if ((db_get_value((regs)->f_regs[PC], sizeof(int), FALSE) & \
56 1.12.2.2 nathanw 0xfc00003f) == 0xd) \
57 1.12.2.2 nathanw (regs)->f_regs[PC] += BKPT_SIZE; \
58 1.12.2.2 nathanw } while(0)
59 1.12.2.2 nathanw
60 1.12.2.2 nathanw /* Similar to PC_ADVANCE(), except only advance on cpu_Debugger()'s bpt */
61 1.12.2.2 nathanw #define PC_BREAK_ADVANCE(regs) do { \
62 1.12.2.2 nathanw if (db_get_value((regs)->f_regs[PC], sizeof(int), FALSE) == 0xd) \
63 1.12.2.2 nathanw (regs)->f_regs[PC] += BKPT_SIZE; \
64 1.12.2.2 nathanw } while(0)
65 1.12.2.2 nathanw
66 1.12.2.2 nathanw #define BKPT_INST 0x0001000D
67 1.12.2.2 nathanw #define BKPT_SIZE (4) /* size of breakpoint inst */
68 1.12.2.2 nathanw #define BKPT_SET(inst) (BKPT_INST)
69 1.12.2.2 nathanw
70 1.12.2.2 nathanw #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAK)
71 1.12.2.2 nathanw #define IS_WATCHPOINT_TRAP(type, code) (0) /* XXX mips3 watchpoint */
72 1.12.2.2 nathanw
73 1.12.2.2 nathanw /*
74 1.12.2.2 nathanw * Interface to disassembly (shared with mdb)
75 1.12.2.2 nathanw */
76 1.12.2.3 nathanw db_addr_t db_disasm_insn(int insn, db_addr_t loc, boolean_t altfmt);
77 1.12.2.2 nathanw
78 1.12.2.2 nathanw
79 1.12.2.2 nathanw /*
80 1.12.2.2 nathanw * Entrypoints to DDB for kernel, keyboard drivers, init hook
81 1.12.2.2 nathanw */
82 1.12.2.3 nathanw void kdb_kbd_trap(db_regs_t *);
83 1.12.2.3 nathanw void db_set_ddb_regs(int type, mips_reg_t *);
84 1.12.2.3 nathanw int kdb_trap(int type, mips_reg_t *);
85 1.12.2.2 nathanw
86 1.12.2.2 nathanw
87 1.12.2.2 nathanw /*
88 1.12.2.2 nathanw * Constants for KGDB.
89 1.12.2.2 nathanw */
90 1.12.2.2 nathanw typedef mips_reg_t kgdb_reg_t;
91 1.12.2.2 nathanw #define KGDB_NUMREGS 90
92 1.12.2.2 nathanw #define KGDB_BUFLEN 1024
93 1.12.2.2 nathanw
94 1.12.2.2 nathanw /*
95 1.12.2.2 nathanw * MIPS cpus have no hardware single-step.
96 1.12.2.2 nathanw */
97 1.12.2.2 nathanw #define SOFTWARE_SSTEP
98 1.12.2.2 nathanw
99 1.12.2.2 nathanw #define inst_trap_return(ins) ((ins)&0)
100 1.12.2.2 nathanw
101 1.12.2.3 nathanw boolean_t inst_branch(int inst);
102 1.12.2.3 nathanw boolean_t inst_call(int inst);
103 1.12.2.3 nathanw boolean_t inst_return(int inst);
104 1.12.2.3 nathanw boolean_t inst_load(int inst);
105 1.12.2.3 nathanw boolean_t inst_store(int inst);
106 1.12.2.3 nathanw boolean_t inst_unconditional_flow_transfer(int inst);
107 1.12.2.3 nathanw db_addr_t branch_taken(int inst, db_addr_t pc, db_regs_t *regs);
108 1.12.2.3 nathanw db_addr_t next_instr_address(db_addr_t pc, boolean_t bd);
109 1.12.2.2 nathanw
110 1.12.2.2 nathanw /*
111 1.12.2.2 nathanw * We have machine-dependent commands.
112 1.12.2.2 nathanw */
113 1.12.2.2 nathanw #define DB_MACHINE_COMMANDS
114 1.12.2.2 nathanw
115 1.12.2.2 nathanw #endif /* _MIPS_DB_MACHDEP_H_ */
116