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