]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
0a7de745 | 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. | |
0a7de745 | 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. | |
0a7de745 | 17 | * |
2d21ac55 A |
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. | |
0a7de745 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b | 27 | */ |
9bccf70c | 28 | |
1c79356b | 29 | /* |
9bccf70c | 30 | * Internal definitions for kdp module |
1c79356b A |
31 | */ |
32 | ||
33 | #include <kdp/kdp.h> | |
5ba3f43e | 34 | #include <kern/machine.h> |
1c79356b | 35 | #include <kdp/kdp_protocol.h> |
b0d623f7 | 36 | #include <mach/vm_types.h> |
39037602 A |
37 | #include <mach/boolean.h> |
38 | #include <mach/mach_types.h> | |
b0d623f7 | 39 | #include <libsa/types.h> |
1c79356b A |
40 | |
41 | typedef struct { | |
0a7de745 A |
42 | void *saved_state; |
43 | thread_t kdp_thread; | |
44 | int kdp_cpu; | |
45 | uint32_t session_key; | |
46 | unsigned int conn_seq; | |
47 | unsigned short reply_port; | |
48 | unsigned short exception_port; | |
49 | boolean_t is_conn; | |
50 | boolean_t is_halted; | |
51 | unsigned char exception_seq; | |
52 | boolean_t exception_ack_needed; | |
1c79356b A |
53 | } kdp_glob_t; |
54 | ||
0a7de745 | 55 | extern kdp_glob_t kdp; |
9bccf70c | 56 | |
0a7de745 | 57 | extern volatile int kdp_flag; |
7e4a7d39 | 58 | extern int noresume_on_disconnect; |
0c530ab8 | 59 | |
39037602 A |
60 | extern char kdp_kernelversion_string[256]; |
61 | ||
9bccf70c A |
62 | #define KDP_READY 0x1 |
63 | #define KDP_ARP 0x2 | |
64 | #define KDP_BP_DIS 0x4 | |
55e303ae A |
65 | #define KDP_GETC_ENA 0x8 |
66 | #define KDP_PANIC_DUMP_ENABLED 0x10 | |
0a7de745 | 67 | #define PANIC_CORE_ON_NMI 0x20 |
55e303ae A |
68 | #define DBG_POST_CORE 0x40 |
69 | #define PANIC_LOG_DUMP 0x80 | |
b0d623f7 | 70 | #define REBOOT_POST_CORE 0x100 |
7e4a7d39 | 71 | #define SYSTEM_LOG_DUMP 0x200 |
1c79356b A |
72 | typedef boolean_t |
73 | (*kdp_dispatch_t) ( | |
0a7de745 A |
74 | kdp_pkt_t *, |
75 | int *, | |
76 | unsigned short * | |
77 | ); | |
1c79356b | 78 | |
91447636 | 79 | extern |
1c79356b A |
80 | boolean_t |
81 | kdp_packet( | |
0a7de745 A |
82 | unsigned char *, |
83 | int *, | |
84 | unsigned short * | |
85 | ); | |
1c79356b | 86 | |
91447636 | 87 | extern |
9bccf70c | 88 | boolean_t |
0a7de745 | 89 | kdp_remove_all_breakpoints(void); |
9bccf70c | 90 | |
91447636 | 91 | extern |
1c79356b A |
92 | void |
93 | kdp_exception( | |
0a7de745 A |
94 | unsigned char *, |
95 | int *, | |
96 | unsigned short *, | |
97 | unsigned int, | |
98 | unsigned int, | |
99 | unsigned int | |
100 | ); | |
1c79356b | 101 | |
91447636 | 102 | extern |
1c79356b A |
103 | boolean_t |
104 | kdp_exception_ack( | |
0a7de745 A |
105 | unsigned char *, |
106 | int | |
107 | ); | |
1c79356b | 108 | |
91447636 | 109 | extern |
1c79356b A |
110 | void |
111 | kdp_panic( | |
0a7de745 A |
112 | const char *msg |
113 | ); | |
1c79356b | 114 | |
91447636 | 115 | extern |
1c79356b | 116 | void |
b0d623f7 | 117 | kdp_machine_reboot( |
0a7de745 A |
118 | void |
119 | ); | |
1c79356b | 120 | |
91447636 | 121 | extern |
1c79356b A |
122 | void |
123 | kdp_us_spin( | |
0a7de745 A |
124 | int usec |
125 | ); | |
1c79356b | 126 | |
91447636 | 127 | extern |
1c79356b A |
128 | int |
129 | kdp_intr_disbl( | |
0a7de745 A |
130 | void |
131 | ); | |
1c79356b | 132 | |
91447636 | 133 | extern |
1c79356b A |
134 | void |
135 | kdp_intr_enbl( | |
0a7de745 A |
136 | int s |
137 | ); | |
1c79356b | 138 | |
91447636 | 139 | extern |
1c79356b A |
140 | kdp_error_t |
141 | kdp_machine_read_regs( | |
0a7de745 A |
142 | unsigned int cpu, |
143 | unsigned int flavor, | |
144 | char *data, | |
145 | int *size | |
146 | ); | |
1c79356b | 147 | |
91447636 | 148 | extern |
1c79356b A |
149 | kdp_error_t |
150 | kdp_machine_write_regs( | |
0a7de745 A |
151 | unsigned int cpu, |
152 | unsigned int flavor, | |
153 | char *data, | |
154 | int *size | |
155 | ); | |
1c79356b | 156 | |
91447636 | 157 | extern |
1c79356b A |
158 | void |
159 | kdp_machine_hostinfo( | |
0a7de745 A |
160 | kdp_hostinfo_t *hostinfo |
161 | ); | |
1c79356b | 162 | |
91447636 | 163 | extern |
1c79356b A |
164 | void |
165 | kdp_sync_cache( | |
0a7de745 A |
166 | void |
167 | ); | |
1c79356b | 168 | |
b0d623f7 A |
169 | /* Return a byte array that can be byte-copied to a memory address |
170 | * to trap into the debugger. Must be 4 bytes or less in the current | |
171 | * implementation | |
172 | */ | |
173 | #define MAX_BREAKINSN_BYTES 4 | |
174 | ||
175 | void | |
176 | kdp_machine_get_breakinsn( | |
0a7de745 A |
177 | uint8_t *bytes, |
178 | uint32_t *size | |
179 | ); | |
2d21ac55 A |
180 | |
181 | extern void | |
182 | kdp_ml_enter_debugger( | |
183 | void | |
0a7de745 | 184 | ); |
b0d623f7 A |
185 | |
186 | mach_vm_size_t | |
0a7de745 | 187 | kdp_machine_vm_read( mach_vm_address_t, caddr_t, mach_vm_size_t); |
b0d623f7 A |
188 | |
189 | mach_vm_size_t | |
0a7de745 | 190 | kdp_machine_vm_write( caddr_t, mach_vm_address_t, mach_vm_size_t); |
b0d623f7 A |
191 | |
192 | mach_vm_size_t | |
0a7de745 A |
193 | kdp_machine_phys_read(kdp_readphysmem64_req_t * rq, caddr_t /* data */, |
194 | uint16_t /* lcpu */); | |
b0d623f7 A |
195 | |
196 | mach_vm_size_t | |
0a7de745 A |
197 | kdp_machine_phys_write(kdp_writephysmem64_req_t * rq, caddr_t /* data */, |
198 | uint16_t /* lcpu */); | |
b0d623f7 A |
199 | |
200 | int | |
0a7de745 | 201 | kdp_machine_ioport_read(kdp_readioport_req_t *, caddr_t /* data */, uint16_t /* lcpu */); |
b0d623f7 A |
202 | |
203 | int | |
0a7de745 | 204 | kdp_machine_ioport_write(kdp_writeioport_req_t *, caddr_t /* data */, uint16_t /* lcpu */); |
b0d623f7 A |
205 | |
206 | int | |
0a7de745 | 207 | kdp_machine_msr64_read(kdp_readmsr64_req_t *, caddr_t /* data */, uint16_t /* lcpu */); |
b0d623f7 A |
208 | |
209 | int | |
0a7de745 | 210 | kdp_machine_msr64_write(kdp_writemsr64_req_t *, caddr_t /* data */, uint16_t /* lcpu */); |