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