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