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