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