1 /* $NetBSD: db_machdep.h,v 1.1 1999/09/13 10:31:17 itojun Exp $ */ 2 3 /* 4 * Mach Operating System 5 * Copyright (c) 1991,1990 Carnegie Mellon University 6 * All Rights Reserved. 7 * 8 * Permission to use, copy, modify and distribute this software and its 9 * documentation is hereby granted, provided that both the copyright 10 * notice and this permission notice appear in all copies of the 11 * software, derivative works or modified versions, and any portions 12 * thereof, and that both notices appear in supporting documentation. 13 * 14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 17 * 18 * Carnegie Mellon requests users of this software to return to 19 * 20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 21 * School of Computer Science 22 * Carnegie Mellon University 23 * Pittsburgh PA 15213-3890 24 * 25 * any improvements or extensions that they make and grant Carnegie Mellon 26 * the rights to redistribute these changes. 27 */ 28 29 #ifndef _SH3_DB_MACHDEP_H_ 30 #define _SH3_DB_MACHDEP_H_ 31 32 /* 33 * Machine-dependent defines for new kernel debugger. 34 */ 35 36 #include <sys/param.h> 37 #include <vm/vm.h> 38 #include <machine/trap.h> 39 40 typedef vm_offset_t db_addr_t; /* address - unsigned */ 41 #if 1 42 typedef long db_expr_t; /* expression - signed */ 43 #else 44 typedef short db_expr_t; /* expression - signed */ 45 #endif 46 47 typedef struct trapframe db_regs_t; 48 db_regs_t ddb_regs; /* register state */ 49 #define DDB_REGS (&ddb_regs) 50 51 #define PC_REGS(regs) ((db_addr_t)(regs)->tf_spc) 52 53 #define BKPT_INST 0xc3c3 /* breakpoint instruction */ 54 #define BKPT_SIZE (2) /* size of breakpoint inst */ 55 #define BKPT_SET(inst) (BKPT_INST) 56 57 #define FIXUP_PC_AFTER_BREAK(regs) ((regs)->tf_spc -= BKPT_SIZE) 58 59 #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_USERBREAK) 60 #define IS_WATCHPOINT_TRAP(type, code) (0) /* XXX (msaitoh) */ 61 62 #define I_CALL 0xe8 63 #define I_CALLI 0xff 64 #define I_RET 0xc3 65 #define I_IRET 0xcf 66 67 #define inst_trap_return(ins) (((ins)&0xff) == I_IRET) 68 #define inst_return(ins) (((ins)&0xff) == I_RET) 69 #define inst_call(ins) (((ins)&0xff) == I_CALL || \ 70 (((ins)&0xff) == I_CALLI && \ 71 ((ins)&0x3800) == 0x1000)) 72 #define inst_load(ins) 0 73 #define inst_store(ins) 0 74 75 /* access capability and access macros */ 76 77 #define DB_ACCESS_LEVEL 2 /* access any space */ 78 #define DB_CHECK_ACCESS(addr, size, task) \ 79 db_check_access(addr, size, task) 80 #define DB_PHYS_EQ(task1, addr1, task2, addr2) \ 81 db_phys_eq(task1, addr1, task2, addr2) 82 #define DB_VALID_KERN_ADDR(addr) \ 83 ((addr) >= VM_MIN_KERNEL_ADDRESS && \ 84 (addr) < VM_MAX_KERNEL_ADDRESS) 85 #define DB_VALID_ADDRESS(addr, user) \ 86 ((!(user) && DB_VALID_KERN_ADDR(addr)) || \ 87 ((user) && (addr) < VM_MAX_ADDRESS)) 88 89 #if 0 90 boolean_t db_check_access __P((vm_offset_t, int, task_t)); 91 boolean_t db_phys_eq __P((task_t, vm_offset_t, task_t, vm_offset_t)); 92 #endif 93 94 /* macros for printing OS server dependent task name */ 95 96 #define DB_TASK_NAME(task) db_task_name(task) 97 #define DB_TASK_NAME_TITLE "COMMAND " 98 #define DB_TASK_NAME_LEN 23 99 #define DB_NULL_TASK_NAME "? " 100 101 /* 102 * Constants for KGDB. 103 */ 104 typedef long kgdb_reg_t; 105 #define KGDB_NUMREGS 14 106 #define KGDB_BUFLEN 512 107 108 #if 0 109 void db_task_name(/* task_t */); 110 #endif 111 112 /* macro for checking if a thread has used floating-point */ 113 114 #define db_thread_fp_used(thread) ((thread)->pcb->ims.ifps != 0) 115 #define next_instr_address(v, b) ((db_addr_t) ((b) ? (v + 4) : ((v) + 2))) 116 117 int kdb_trap __P((int, int, db_regs_t *)); 118 119 /* 120 * We use ELF symbols in DDB. 121 * 122 */ 123 #define DB_ELF_SYMBOLS 124 #define DB_ELFSIZE 32 125 126 /* 127 * SH cpus have no hardware single-step. 128 */ 129 #define SOFTWARE_SSTEP 130 131 /* XXX following three functions is not implemented yet. (msaitoh) */ 132 boolean_t inst_branch __P((int inst)); 133 db_addr_t branch_taken __P((int inst, db_addr_t pc, db_regs_t *regs)); 134 boolean_t inst_unconditional_flow_transfer __P((int inst)); 135 136 #endif /* _SH3_DB_MACHDEP_H_ */ 137