]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
1c79356b A |
29 | */ |
30 | /* | |
31 | * @OSF_COPYRIGHT@ | |
32 | */ | |
33 | /* | |
34 | * Mach Operating System | |
35 | * Copyright (c) 1991,1990 Carnegie Mellon University | |
36 | * All Rights Reserved. | |
37 | * | |
38 | * Permission to use, copy, modify and distribute this software and its | |
39 | * documentation is hereby granted, provided that both the copyright | |
40 | * notice and this permission notice appear in all copies of the | |
41 | * software, derivative works or modified versions, and any portions | |
42 | * thereof, and that both notices appear in supporting documentation. | |
43 | * | |
44 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
45 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
46 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
47 | * | |
48 | * Carnegie Mellon requests users of this software to return to | |
49 | * | |
50 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
51 | * School of Computer Science | |
52 | * Carnegie Mellon University | |
53 | * Pittsburgh PA 15213-3890 | |
54 | * | |
55 | * any improvements or extensions that they make and grant Carnegie Mellon | |
56 | * the rights to redistribute these changes. | |
57 | */ | |
58 | /* | |
59 | */ | |
60 | ||
61 | #ifndef _PPC_DB_MACHDEP_H_ | |
62 | #define _PPC_DB_MACHDEP_H_ | |
63 | ||
64 | /* | |
65 | * Machine-dependent defines for new kernel debugger. | |
66 | */ | |
67 | ||
68 | #include <kern/kern_types.h> | |
69 | #include <mach/ppc/vm_types.h> | |
70 | #include <mach/ppc/vm_param.h> | |
91447636 | 71 | #include <kern/thread.h> |
1c79356b A |
72 | #include <ppc/trap.h> |
73 | #include <ppc/proc_reg.h> | |
9bccf70c | 74 | #include <ppc/savearea.h> |
1c79356b | 75 | |
55e303ae A |
76 | typedef addr64_t db_addr_t; /* address - unsigned */ |
77 | typedef uint64_t db_expr_t; /* expression - signed??? try unsigned */ | |
1c79356b | 78 | |
9bccf70c | 79 | typedef struct savearea db_regs_t; |
1c79356b A |
80 | db_regs_t ddb_regs; /* register state */ |
81 | #define DDB_REGS (&ddb_regs) | |
82 | extern int db_active; /* ddb is active */ | |
83 | ||
9bccf70c | 84 | #define PC_REGS(regs) ((db_addr_t)(regs)->save_srr0) |
1c79356b A |
85 | |
86 | #define BKPT_INST 0x7c810808 /* breakpoint instruction */ | |
87 | #define BKPT_SIZE (4) /* size of breakpoint inst */ | |
88 | #define BKPT_SET(inst) (BKPT_INST) | |
89 | ||
9bccf70c A |
90 | #define db_clear_single_step(regs) ((regs)->save_srr1 &= ~MASK(MSR_SE)) |
91 | #define db_set_single_step(regs) ((regs)->save_srr1 |= MASK(MSR_SE)) | |
1c79356b A |
92 | |
93 | #define IS_BREAKPOINT_TRAP(type, code) (FALSE) | |
94 | #define IS_WATCHPOINT_TRAP(type, code) (FALSE) | |
95 | ||
96 | #define inst_trap_return(ins) (FALSE) | |
97 | #define inst_return(ins) (FALSE) | |
98 | #define inst_call(ins) (FALSE) | |
99 | ||
100 | int db_inst_load(unsigned long); | |
101 | int db_inst_store(unsigned long); | |
102 | ||
103 | /* access capability and access macros */ | |
104 | ||
105 | #define DB_ACCESS_LEVEL DB_ACCESS_ANY /* any space */ | |
106 | #define DB_CHECK_ACCESS(addr,size,task) \ | |
107 | db_check_access(addr,size,task) | |
108 | #define DB_PHYS_EQ(task1,addr1,task2,addr2) \ | |
109 | db_phys_eq(task1,addr1,task2,addr2) | |
110 | #define DB_VALID_KERN_ADDR(addr) \ | |
111 | ((addr) >= VM_MIN_KERNEL_ADDRESS && \ | |
55e303ae | 112 | (addr) < vm_last_addr) |
1c79356b A |
113 | #define DB_VALID_ADDRESS(addr,user) \ |
114 | ((!(user) && DB_VALID_KERN_ADDR(addr)) || \ | |
115 | ((user) && (addr) < VM_MAX_ADDRESS)) | |
116 | ||
117 | /* | |
9bccf70c | 118 | * Given pointer to savearea, determine if it represents |
1c79356b A |
119 | * a thread executing a) in user space, b) in the kernel, or c) |
120 | * in a kernel-loaded task. Return true for cases a) and c). | |
121 | */ | |
122 | #define IS_USER_TRAP(regs) \ | |
9bccf70c | 123 | (USER_MODE(regs->save_srr1)) |
1c79356b A |
124 | |
125 | extern boolean_t db_check_access( | |
126 | vm_offset_t addr, | |
127 | int size, | |
128 | task_t task); | |
129 | extern boolean_t db_phys_eq( | |
130 | task_t task1, | |
131 | vm_offset_t addr1, | |
132 | task_t task2, | |
133 | vm_offset_t addr2); | |
134 | extern db_addr_t db_disasm( | |
135 | db_addr_t loc, | |
136 | boolean_t altfmt, | |
137 | task_t task); | |
1c79356b A |
138 | extern void db_read_bytes( |
139 | vm_offset_t addr, | |
140 | int size, | |
141 | char *data, | |
142 | task_t task); | |
143 | extern void db_write_bytes( | |
144 | vm_offset_t addr, | |
145 | int size, | |
146 | char *data, | |
147 | task_t task); | |
148 | extern void db_stack_trace_cmd( | |
149 | db_expr_t addr, | |
150 | boolean_t have_addr, | |
151 | db_expr_t count, | |
152 | char *modif); | |
153 | extern void db_reboot( | |
154 | db_expr_t addr, | |
155 | boolean_t have_addr, | |
156 | db_expr_t count, | |
157 | char *modif); | |
158 | extern void db_low_trace( | |
159 | db_expr_t addr, | |
160 | int have_addr, | |
161 | db_expr_t count, | |
162 | char *modif); | |
8ad349bb A |
163 | extern void db_to_gdb( |
164 | void); | |
1c79356b A |
165 | |
166 | ||
167 | /* macros for printing OS server dependent task name */ | |
168 | ||
169 | #define DB_TASK_NAME(task) db_task_name(task) | |
170 | #define DB_TASK_NAME_TITLE "COMMAND " | |
171 | #define DB_TASK_NAME_LEN 39 | |
172 | #define DB_NULL_TASK_NAME "? " | |
173 | ||
174 | extern void db_task_name( | |
175 | task_t task); | |
176 | ||
177 | /* macro for checking if a thread has used floating-point */ | |
178 | ||
179 | #define db_act_fp_used(act) (FALSE) | |
180 | ||
181 | extern void kdb_trap( | |
182 | int type, | |
9bccf70c | 183 | struct savearea *regs); |
1c79356b | 184 | extern boolean_t db_trap_from_asm( |
9bccf70c | 185 | struct savearea *regs); |
1c79356b A |
186 | extern void kdb_on( |
187 | int cpu); | |
188 | extern void cnpollc( | |
189 | boolean_t on); | |
1c79356b A |
190 | |
191 | extern boolean_t db_phys_cmp( | |
192 | vm_offset_t, | |
193 | vm_offset_t, | |
194 | vm_size_t); | |
195 | ||
196 | #endif /* _PPC_DB_MACHDEP_H_ */ |