]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/db_machdep.h
xnu-1228.3.13.tar.gz
[apple/xnu.git] / osfmk / ppc / db_machdep.h
CommitLineData
1c79356b 1/*
2d21ac55 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
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 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.
8f6c56a5 14 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
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>
91447636 69#include <kern/thread.h>
1c79356b
A
70#include <ppc/trap.h>
71#include <ppc/proc_reg.h>
9bccf70c 72#include <ppc/savearea.h>
1c79356b 73
55e303ae
A
74typedef addr64_t db_addr_t; /* address - unsigned */
75typedef uint64_t db_expr_t; /* expression - signed??? try unsigned */
1c79356b 76
9bccf70c 77typedef struct savearea db_regs_t;
1c79356b
A
78db_regs_t ddb_regs; /* register state */
79#define DDB_REGS (&ddb_regs)
80extern int db_active; /* ddb is active */
81
9bccf70c 82#define PC_REGS(regs) ((db_addr_t)(regs)->save_srr0)
1c79356b
A
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
9bccf70c
A
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))
1c79356b
A
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 && \
55e303ae 110 (addr) < vm_last_addr)
1c79356b
A
111#define DB_VALID_ADDRESS(addr,user) \
112 ((!(user) && DB_VALID_KERN_ADDR(addr)) || \
113 ((user) && (addr) < VM_MAX_ADDRESS))
114
115/*
9bccf70c 116 * Given pointer to savearea, determine if it represents
1c79356b
A
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) \
9bccf70c 121 (USER_MODE(regs->save_srr1))
1c79356b
A
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);
1c79356b
A
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);
1c79356b
A
156
157/* macros for printing OS server dependent task name */
158
159#define DB_TASK_NAME(task) db_task_name(task)
160#define DB_TASK_NAME_TITLE "COMMAND "
161#define DB_TASK_NAME_LEN 39
162#define DB_NULL_TASK_NAME "? "
163
164extern void db_task_name(
165 task_t task);
166
167/* macro for checking if a thread has used floating-point */
168
169#define db_act_fp_used(act) (FALSE)
170
171extern void kdb_trap(
172 int type,
9bccf70c 173 struct savearea *regs);
1c79356b 174extern boolean_t db_trap_from_asm(
9bccf70c 175 struct savearea *regs);
1c79356b
A
176extern void kdb_on(
177 int cpu);
178extern void cnpollc(
179 boolean_t on);
1c79356b
A
180
181extern boolean_t db_phys_cmp(
182 vm_offset_t,
183 vm_offset_t,
184 vm_size_t);
185
186#endif /* _PPC_DB_MACHDEP_H_ */