1 /* $OpenBSD: db_machdep.h,v 1.27 2019/11/07 14:44:52 mpi 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 vaddr_t db_addr_t; 41 typedef long db_expr_t; 42 typedef struct trapframe db_regs_t; 43 44 extern db_regs_t ddb_regs; 45 46 #define PC_REGS(regs) ((vaddr_t)(regs)->tf_regs[FRAME_PC]) 47 #define SET_PC_REGS(regs, value) (regs)->tf_regs[FRAME_PC] = (unsigned long)(value) 48 49 /* Breakpoint related definitions */ 50 #define BKPT_INST 0x00000080 /* call_pal bpt */ 51 #define BKPT_SIZE sizeof(int) 52 #define BKPT_SET(inst) BKPT_INST 53 54 #define IS_BREAKPOINT_TRAP(type, code) \ 55 ((type) == ALPHA_KENTRY_IF && (code) == ALPHA_IF_CODE_BPT) 56 #ifdef notyet 57 #define IS_WATCHPOINT_TRAP(type, code) ((type) == ALPHA_KENTRY_MM) 58 #else 59 #define IS_WATCHPOINT_TRAP(type, code) 0 60 #endif 61 62 #define FIXUP_PC_AFTER_BREAK(regs) ((regs)->tf_regs[FRAME_PC] -= sizeof(int)) 63 64 #define SOFTWARE_SSTEP 65 #define DB_VALID_BREAKPOINT(addr) db_valid_breakpoint(addr) 66 67 /* Hack to skip GCC "unused" warnings. */ 68 #define inst_trap_return(ins) ((ins) & 0) /* XXX */ 69 #define inst_return(ins) (((ins) & 0xfc000000) == 0x68000000) 70 71 int alpha_debug(unsigned long, unsigned long, unsigned long, 72 unsigned long, struct trapframe *); 73 vaddr_t db_branch_taken(int, vaddr_t, db_regs_t *); 74 int db_inst_branch(int); 75 int db_inst_call(int); 76 int db_inst_load(int); 77 int db_inst_return(int); 78 int db_inst_trap_return(int); 79 int db_inst_unconditional_flow_transfer(int); 80 u_long db_register_value(db_regs_t *, int); 81 int db_valid_breakpoint(vaddr_t); 82 int ddb_trap(unsigned long, unsigned long, unsigned long, 83 unsigned long, struct trapframe *); 84 int db_ktrap(int, int, db_regs_t *); 85 vaddr_t next_instr_address(vaddr_t, int); 86 87 #if 1 88 /* Backwards compatibility until we switch all archs to use the db_ prefix */ 89 #define branch_taken(ins, pc, fun, regs) db_branch_taken((ins), (pc), (regs)) 90 #define inst_branch db_inst_branch 91 #define inst_call db_inst_call 92 #endif 93 94 #define DB_MACHINE_COMMANDS 95 96 #endif /* _MACHINE_DB_MACHDEP_H_ */ 97