1 /* $NetBSD: db_machdep.h,v 1.23 2023/11/22 01:58:02 thorpej Exp $ */ 2 3 /* 4 * Copyright (c) 1995 Carnegie-Mellon University. 5 * All rights reserved. 6 * 7 * Author: Chris G. Demetriou 8 * 9 * Permission to use, copy, modify and distribute this software and 10 * its documentation is hereby granted, provided that both the copyright 11 * notice and this permission notice appear in all copies of the 12 * software, derivative works or modified versions, and any portions 13 * thereof, and that both notices appear in supporting documentation. 14 * 15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 18 * 19 * Carnegie Mellon requests users of this software to return to 20 * 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 22 * School of Computer Science 23 * Carnegie Mellon University 24 * Pittsburgh PA 15213-3890 25 * 26 * any improvements or extensions that they make and grant Carnegie the 27 * rights to redistribute these changes. 28 */ 29 30 #ifndef _ALPHA_DB_MACHDEP_H_ 31 #define _ALPHA_DB_MACHDEP_H_ 32 33 /* 34 * Machine-dependent defines for new kernel debugger. 35 */ 36 37 #include <sys/param.h> 38 #include <uvm/uvm_extern.h> 39 #include <machine/frame.h> 40 41 #include <ddb/db_user.h> 42 43 typedef vaddr_t db_addr_t; /* address - unsigned */ 44 #define DDB_EXPR_FMT "l" /* expression is long */ 45 typedef long db_expr_t; /* expression - signed */ 46 47 typedef struct trapframe db_regs_t; 48 extern db_regs_t *ddb_regp; /* pointer to current register state */ 49 #define DDB_REGS (ddb_regp) 50 51 #define PC_REGS(regs) ((regs)->tf_regs[FRAME_PC]) 52 53 #define BKPT_ADDR(addr) (addr) /* breakpoint address */ 54 #define BKPT_INST 0x00000080 /* breakpoint instruction */ 55 #define BKPT_SIZE (4) /* size of breakpoint inst */ 56 #define BKPT_SET(inst, addr) (BKPT_INST) 57 58 #define FIXUP_PC_AFTER_BREAK(regs) \ 59 ((regs)->tf_regs[FRAME_PC] -= BKPT_SIZE) 60 61 #define SOFTWARE_SSTEP 1 /* no hardware support */ 62 #define IS_BREAKPOINT_TRAP(type, code) ((type) == ALPHA_KENTRY_IF && \ 63 (code) == ALPHA_IF_CODE_BPT) 64 #define IS_WATCHPOINT_TRAP(type, code) 0 65 66 /* 67 * Functions needed for software single-stepping. 68 */ 69 70 bool db_inst_trap_return(int inst); 71 bool db_inst_return(int inst); 72 bool db_inst_call(int inst); 73 bool db_inst_branch(int inst); 74 bool db_inst_load(int inst); 75 bool db_inst_store(int inst); 76 bool db_inst_unconditional_flow_transfer(int inst); 77 db_addr_t db_branch_taken(int inst, db_addr_t pc, db_regs_t *regs); 78 79 #define inst_trap_return(ins) db_inst_trap_return(ins) 80 #define inst_return(ins) db_inst_return(ins) 81 #define inst_call(ins) db_inst_call(ins) 82 #define inst_branch(ins) db_inst_branch(ins) 83 #define inst_load(ins) db_inst_load(ins) 84 #define inst_store(ins) db_inst_store(ins) 85 #define inst_unconditional_flow_transfer(ins) \ 86 db_inst_unconditional_flow_transfer(ins) 87 #define branch_taken(ins, pc, regs) \ 88 db_branch_taken((ins), (pc), (regs)) 89 90 /* No delay slots on Alpha. */ 91 #define next_instr_address(v, b) ((db_addr_t) ((b) ? (v) : ((v) + 4))) 92 93 u_long db_register_value(db_regs_t *, int); 94 int ddb_trap(unsigned long, unsigned long, unsigned long, 95 unsigned long, struct trapframe *); 96 97 int alpha_debug(unsigned long, unsigned long, unsigned long, 98 unsigned long, struct trapframe *); 99 100 struct alpha_bus_space; 101 void alpha_kgdb_init(const char **, struct alpha_bus_space *); 102 103 /* 104 * We define some of our own commands. 105 */ 106 #define DB_MACHINE_COMMANDS 107 108 /* 109 * We use Elf64 symbols in DDB. 110 */ 111 #define DB_ELF_SYMBOLS 112 113 /* 114 * Stuff for KGDB. 115 */ 116 typedef long kgdb_reg_t; 117 #define KGDB_NUMREGS 66 /* from tm-alpha.h, NUM_REGS */ 118 #define KGDB_REG_V0 0 119 #define KGDB_REG_T0 1 120 #define KGDB_REG_T1 2 121 #define KGDB_REG_T2 3 122 #define KGDB_REG_T3 4 123 #define KGDB_REG_T4 5 124 #define KGDB_REG_T5 6 125 #define KGDB_REG_T6 7 126 #define KGDB_REG_T7 8 127 #define KGDB_REG_S0 9 128 #define KGDB_REG_S1 10 129 #define KGDB_REG_S2 11 130 #define KGDB_REG_S3 12 131 #define KGDB_REG_S4 13 132 #define KGDB_REG_S5 14 133 #define KGDB_REG_S6 15 /* FP */ 134 #define KGDB_REG_A0 16 135 #define KGDB_REG_A1 17 136 #define KGDB_REG_A2 18 137 #define KGDB_REG_A3 19 138 #define KGDB_REG_A4 20 139 #define KGDB_REG_A5 21 140 #define KGDB_REG_T8 22 141 #define KGDB_REG_T9 23 142 #define KGDB_REG_T10 24 143 #define KGDB_REG_T11 25 144 #define KGDB_REG_RA 26 145 #define KGDB_REG_T12 27 146 #define KGDB_REG_AT 28 147 #define KGDB_REG_GP 29 148 #define KGDB_REG_SP 30 149 #define KGDB_REG_ZERO 31 150 #define KGDB_REG_F0 32 151 #define KGDB_REG_F1 33 152 #define KGDB_REG_F2 34 153 #define KGDB_REG_F3 35 154 #define KGDB_REG_F4 36 155 #define KGDB_REG_F5 37 156 #define KGDB_REG_F6 38 157 #define KGDB_REG_F7 39 158 #define KGDB_REG_F8 40 159 #define KGDB_REG_F9 41 160 #define KGDB_REG_F10 42 161 #define KGDB_REG_F11 43 162 #define KGDB_REG_F12 44 163 #define KGDB_REG_F13 45 164 #define KGDB_REG_F14 46 165 #define KGDB_REG_F15 47 166 #define KGDB_REG_F16 48 167 #define KGDB_REG_F17 49 168 #define KGDB_REG_F18 50 169 #define KGDB_REG_F19 51 170 #define KGDB_REG_F20 52 171 #define KGDB_REG_F21 53 172 #define KGDB_REG_F22 54 173 #define KGDB_REG_F23 55 174 #define KGDB_REG_F24 56 175 #define KGDB_REG_F25 57 176 #define KGDB_REG_F26 58 177 #define KGDB_REG_F27 59 178 #define KGDB_REG_F28 60 179 #define KGDB_REG_F29 61 180 #define KGDB_REG_F30 62 181 #define KGDB_REG_F31 63 182 #define KGDB_REG_PC 64 183 #define KGDB_REG_VFP 65 184 185 /* Too much? Must be large enough for register transfer. */ 186 #define KGDB_BUFLEN 1024 187 188 /* 189 * Private alpha ddb internals. 190 */ 191 #define SYM_XentArith 0 192 #define SYM_XentIF 1 193 #define SYM_XentInt 2 194 #define SYM_XentMM 3 195 #define SYM_XentSys 4 196 #define SYM_XentUna 5 197 #define SYM_XentRestart 6 198 #define SYM_exception_return 7 199 #define SYM_alpha_kthread_backstop 8 200 #ifdef _KERNEL 201 #define SYM___eol (SYM_alpha_kthread_backstop + 1) 202 #else 203 #define SYM_dumppcb 9 204 #define SYM___eol (SYM_dumppcb + 1) 205 #endif /* _KERNEL */ 206 207 #ifdef _KERNEL 208 struct db_alpha_nlist { 209 vaddr_t n_value; 210 }; 211 212 typedef struct db_alpha_nlist db_alpha_nlist; 213 214 #define DB_ALPHA_SYM(i, x) [(i)] = { .n_value = (vaddr_t)&(x) } 215 #define DB_ALPHA_SYM_EOL [SYM___eol] = { .n_value = 0 } 216 #else 217 #include <nlist.h> 218 219 typedef struct nlist db_alpha_nlist; 220 221 #define DB_ALPHA_SYM(i, x) [(i)] = { .n_name = __STRING(x) } 222 #define DB_ALPHA_SYM_EOL [SYM___eol] = { .n_name = NULL } 223 #endif /* _KERNEL */ 224 225 bool db_alpha_sym_is_trap(db_addr_t); 226 bool db_alpha_sym_is_backstop(db_addr_t); 227 bool db_alpha_sym_is_syscall(db_addr_t); 228 const char * db_alpha_trapsym_description(db_addr_t); 229 230 unsigned long db_alpha_read_saved_reg(unsigned long *); 231 unsigned long db_alpha_tf_reg(struct trapframe *, unsigned int); 232 233 /* 234 * Extra ddb options. 235 */ 236 #define __HAVE_DB_STACK_TRACE_PRINT_RA 237 void db_stack_trace_print_ra(db_expr_t, bool, db_expr_t, bool, 238 db_expr_t, const char *, void (*)(const char *, ...)); 239 240 #endif /* _ALPHA_DB_MACHDEP_H_ */ 241