db_machdep.h revision 1.32 1 1.32 nakayama /* $NetBSD: db_machdep.h,v 1.32 2011/06/20 09:25:48 nakayama Exp $ */
2 1.1 eeh
3 1.1 eeh /*
4 1.1 eeh * Mach Operating System
5 1.1 eeh * Copyright (c) 1991,1990 Carnegie Mellon University
6 1.1 eeh * All Rights Reserved.
7 1.1 eeh *
8 1.1 eeh * Permission to use, copy, modify and distribute this software and its
9 1.1 eeh * documentation is hereby granted, provided that both the copyright
10 1.1 eeh * notice and this permission notice appear in all copies of the
11 1.1 eeh * software, derivative works or modified versions, and any portions
12 1.1 eeh * thereof, and that both notices appear in supporting documentation.
13 1.1 eeh *
14 1.1 eeh * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 1.1 eeh * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16 1.1 eeh * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 1.1 eeh *
18 1.1 eeh * Carnegie Mellon requests users of this software to return to
19 1.1 eeh *
20 1.1 eeh * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
21 1.1 eeh * School of Computer Science
22 1.1 eeh * Carnegie Mellon University
23 1.1 eeh * Pittsburgh PA 15213-3890
24 1.1 eeh *
25 1.1 eeh * any improvements or extensions that they make and grant Carnegie Mellon
26 1.1 eeh * the rights to redistribute these changes.
27 1.1 eeh */
28 1.1 eeh
29 1.15 martin #ifndef _SPARC64_DB_MACHDEP_H_
30 1.15 martin #define _SPARC64_DB_MACHDEP_H_
31 1.1 eeh
32 1.1 eeh /*
33 1.1 eeh * Machine-dependent defines for new kernel debugger.
34 1.1 eeh */
35 1.1 eeh
36 1.29 mrg #include <sys/types.h>
37 1.29 mrg
38 1.11 mrg #include <uvm/uvm_extern.h>
39 1.1 eeh
40 1.32 nakayama #ifndef SUN4U
41 1.32 nakayama #define SUN4U /* see .../sparc/include/frame.h for the reason */
42 1.32 nakayama #endif
43 1.1 eeh #include <machine/frame.h>
44 1.27 rmind #include <machine/pcb.h>
45 1.1 eeh #include <machine/psl.h>
46 1.1 eeh #include <machine/trap.h>
47 1.1 eeh #include <machine/reg.h>
48 1.1 eeh
49 1.1 eeh
50 1.26 nakayama /* use 64-bit types explicitly for 32-bit kernels */
51 1.6 eeh typedef vaddr_t db_addr_t; /* address - unsigned */
52 1.31 nakayama #ifdef __arch64__
53 1.30 joerg #define DDB_EXPR_FMT "l" /* expression is int64_t (long) */
54 1.31 nakayama #else
55 1.31 nakayama #define DDB_EXPR_FMT "ll" /* expression is int64_t (long long) */
56 1.31 nakayama #endif
57 1.26 nakayama typedef int64_t db_expr_t; /* expression - signed */
58 1.1 eeh
59 1.10 eeh struct trapstate {
60 1.10 eeh int64_t tstate;
61 1.10 eeh int64_t tpc;
62 1.10 eeh int64_t tnpc;
63 1.10 eeh int64_t tt;
64 1.10 eeh };
65 1.16 petrov
66 1.1 eeh typedef struct {
67 1.20 mrg struct trapframe64 db_tf;
68 1.20 mrg struct frame64 db_fr;
69 1.20 mrg struct trapstate db_ts[5];
70 1.20 mrg int db_tl;
71 1.25 nakayama struct fpstate64 db_fpstate __aligned(BLOCK_SIZE);
72 1.1 eeh } db_regs_t;
73 1.1 eeh
74 1.20 mrg /* Current CPU register state */
75 1.24 martin #define DDB_REGS ((db_regs_t*)__UNVOLATILE(curcpu()->ci_ddb_regs))
76 1.24 martin #define DDB_TF (&DDB_REGS->db_tf)
77 1.24 martin #define DDB_FP (&DDB_REGS->db_fpstate)
78 1.20 mrg
79 1.20 mrg /* DDB commands not in db_interface.c */
80 1.23 matt void db_dump_ts(db_expr_t, bool, db_expr_t, const char *);
81 1.23 matt void db_dump_trap(db_expr_t, bool, db_expr_t, const char *);
82 1.23 matt void db_dump_fpstate(db_expr_t, bool, db_expr_t, const char *);
83 1.23 matt void db_dump_window(db_expr_t, bool, db_expr_t, const char *);
84 1.23 matt void db_dump_stack(db_expr_t, bool, db_expr_t, const char *);
85 1.1 eeh
86 1.20 mrg #define PC_REGS(regs) ((regs)->db_tf.tf_pc)
87 1.1 eeh #define PC_ADVANCE(regs) do { \
88 1.20 mrg vaddr_t n = (regs)->db_tf.tf_npc; \
89 1.20 mrg (regs)->db_tf.tf_pc = n; \
90 1.20 mrg (regs)->db_tf.tf_npc = n + 4; \
91 1.1 eeh } while(0)
92 1.1 eeh
93 1.14 scw #define BKPT_ADDR(addr) (addr) /* breakpoint address */
94 1.1 eeh #define BKPT_INST 0x91d02001 /* breakpoint instruction */
95 1.1 eeh #define BKPT_SIZE (4) /* size of breakpoint inst */
96 1.19 cherry #define BKPT_SET(inst, addr) (BKPT_INST)
97 1.1 eeh
98 1.1 eeh #define IS_BREAKPOINT_TRAP(type, code) \
99 1.1 eeh ((type) == T_BREAKPOINT || (type) == T_KGDB_EXEC)
100 1.9 eeh #define IS_WATCHPOINT_TRAP(type, code) \
101 1.9 eeh ((type) ==T_PA_WATCHPT || (type) == T_VA_WATCHPT)
102 1.9 eeh
103 1.9 eeh /*
104 1.9 eeh * Sparc cpus have no hardware single-step.
105 1.9 eeh */
106 1.9 eeh #define SOFTWARE_SSTEP
107 1.1 eeh
108 1.22 thorpej bool db_inst_trap_return(int inst);
109 1.22 thorpej bool db_inst_return(int inst);
110 1.22 thorpej bool db_inst_call(int inst);
111 1.22 thorpej bool db_inst_branch(int inst);
112 1.18 cdi int db_inst_load(int inst);
113 1.18 cdi int db_inst_store(int inst);
114 1.22 thorpej bool db_inst_unconditional_flow_transfer(int inst);
115 1.18 cdi db_addr_t db_branch_taken(int inst, db_addr_t pc, db_regs_t *regs);
116 1.9 eeh
117 1.9 eeh #define inst_trap_return(ins) db_inst_trap_return(ins)
118 1.9 eeh #define inst_return(ins) db_inst_return(ins)
119 1.9 eeh #define inst_call(ins) db_inst_call(ins)
120 1.9 eeh #define inst_branch(ins) db_inst_branch(ins)
121 1.9 eeh #define inst_load(ins) db_inst_load(ins)
122 1.9 eeh #define inst_store(ins) db_inst_store(ins)
123 1.9 eeh #define inst_unconditional_flow_transfer(ins) \
124 1.9 eeh db_inst_unconditional_flow_transfer(ins)
125 1.9 eeh #define branch_taken(ins, pc, regs) \
126 1.9 eeh db_branch_taken((ins), (pc), (regs))
127 1.9 eeh
128 1.9 eeh /* see note in db_interface.c about reversed breakpoint addrs */
129 1.9 eeh #define next_instr_address(pc, bd) \
130 1.24 martin ((bd) ? (pc) : DDB_REGS->db_tf.tf_npc)
131 1.1 eeh
132 1.1 eeh #define DB_MACHINE_COMMANDS
133 1.1 eeh
134 1.18 cdi int kdb_trap(int, struct trapframe64 *);
135 1.1 eeh
136 1.1 eeh /*
137 1.28 mrg * We use elf symbols in DDB.
138 1.1 eeh */
139 1.1 eeh #define DB_ELF_SYMBOLS
140 1.7 mrg #ifdef __arch64__
141 1.1 eeh #define DB_ELFSIZE 64
142 1.1 eeh #else
143 1.1 eeh #define DB_ELFSIZE 32
144 1.1 eeh #endif
145 1.28 mrg
146 1.1 eeh /*
147 1.1 eeh * KGDB definitions
148 1.1 eeh */
149 1.1 eeh typedef u_long kgdb_reg_t;
150 1.15 martin #define KGDB_NUMREGS 125
151 1.15 martin #define KGDB_BUFLEN 2048
152 1.1 eeh
153 1.15 martin #endif /* _SPARC64_DB_MACHDEP_H_ */
154