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