]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
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 | 27 | */ |
9bccf70c | 28 | |
b0d623f7 A |
29 | #ifndef _KDP_PROTOCOL_H_ |
30 | #define _KDP_PROTOCOL_H_ | |
31 | ||
9bccf70c A |
32 | /* |
33 | * Definition of remote debugger protocol. | |
1c79356b A |
34 | */ |
35 | ||
7e4a7d39 A |
36 | |
37 | #ifdef MACH_KERNEL_PRIVATE | |
1c79356b | 38 | #include <mach/vm_prot.h> |
b0d623f7 | 39 | #include <stdint.h> |
7e4a7d39 A |
40 | #endif |
41 | ||
42 | #ifdef KDP_PROXY_PACK_SUPPORT | |
43 | #pragma pack(1) | |
44 | #define KDP_PACKED | |
45 | #else | |
46 | #define KDP_PACKED __attribute__((packed)) | |
47 | #endif | |
1c79356b A |
48 | |
49 | /* | |
50 | * Retransmit parameters | |
51 | */ | |
52 | #if DDEBUG_DEBUG || DEBUG_DEBUG | |
53 | #define KDP_REXMIT_SECS 20 /* rexmit if no ack in 3 secs */ | |
54 | #else /* DDEBUG_DEBUG || DEBUG_DEBUG */ | |
55 | #define KDP_REXMIT_SECS 3 /* rexmit if no ack in 3 secs */ | |
56 | #endif /* DDEBUG_DEBUG || DEBUG_DEBUG */ | |
57 | #define KDP_REXMIT_TRIES 8 /* xmit 8 times, then give up */ | |
58 | ||
b0d623f7 | 59 | |
1c79356b A |
60 | /* |
61 | * (NMI) Attention Max Wait Time | |
62 | * Remote will resume unless KDP requests is received within this | |
63 | * many seconds after an attention (nmi) packet is sent. | |
64 | */ | |
65 | #define KDP_MAX_ATTN_WAIT 30 /* wait max of 30 seconds */ | |
66 | ||
67 | /* | |
68 | * Well-known UDP port, debugger side. | |
69 | * FIXME: This is what the 68K guys use, but beats me how they chose it... | |
70 | */ | |
71 | #define KDP_REMOTE_PORT 41139 /* pick one and register it */ | |
72 | ||
73 | /* | |
74 | * UDP ports, KDB side. 5 port numbers are reserved for each port (request | |
75 | * and exception). This allows multiple KDBs to run on one host. | |
76 | */ | |
77 | #define UDP_HOST_COMM_BASE 41140 | |
78 | #define UDP_HOST_EXCEP_BASE 41145 | |
79 | #define NUM_UDP_HOST_PORTS 5 | |
80 | ||
81 | /* | |
82 | * Requests | |
83 | */ | |
84 | typedef enum { | |
85 | /* connection oriented requests */ | |
86 | KDP_CONNECT, KDP_DISCONNECT, | |
87 | ||
88 | /* obtaining client info */ | |
9bccf70c | 89 | KDP_HOSTINFO, KDP_VERSION, KDP_MAXBYTES, |
1c79356b A |
90 | |
91 | /* memory access */ | |
92 | KDP_READMEM, KDP_WRITEMEM, | |
93 | ||
94 | /* register access */ | |
95 | KDP_READREGS, KDP_WRITEREGS, | |
96 | ||
97 | /* executable image info */ | |
98 | KDP_LOAD, KDP_IMAGEPATH, | |
99 | ||
100 | /* execution control */ | |
101 | KDP_SUSPEND, KDP_RESUMECPUS, | |
102 | ||
103 | /* exception and termination notification, NOT true requests */ | |
104 | KDP_EXCEPTION, KDP_TERMINATION, | |
105 | ||
9bccf70c A |
106 | /* breakpoint control */ |
107 | KDP_BREAKPOINT_SET, KDP_BREAKPOINT_REMOVE, | |
108 | ||
109 | /* vm regions */ | |
110 | KDP_REGIONS, | |
111 | ||
112 | /* reattach to a connected host */ | |
113 | KDP_REATTACH, | |
114 | ||
1c79356b | 115 | /* remote reboot request */ |
b0d623f7 A |
116 | KDP_HOSTREBOOT, |
117 | ||
118 | /* memory access (64-bit wide addresses). Version 11 protocol */ | |
119 | KDP_READMEM64, KDP_WRITEMEM64, | |
120 | ||
121 | /* breakpoint control (64-bit wide addresses). Version 11 protocol */ | |
122 | KDP_BREAKPOINT64_SET, KDP_BREAKPOINT64_REMOVE, | |
123 | ||
124 | /* kernel version string, like "xnu-1234.5~6". Version 11 protocol */ | |
125 | KDP_KERNELVERSION, | |
126 | ||
127 | /* physical memory access (64-bit wide addresses). Version 12 protocol */ | |
128 | KDP_READPHYSMEM64, KDP_WRITEPHYSMEM64, | |
129 | ||
130 | /* ioport access (8-, 16-, and 32-bit) */ | |
131 | KDP_READIOPORT, KDP_WRITEIOPORT, | |
132 | ||
133 | /* msr access (64-bit) */ | |
134 | KDP_READMSR64, KDP_WRITEMSR64, | |
135 | ||
7e4a7d39 A |
136 | /* get/dump panic/corefile info */ |
137 | KDP_DUMPINFO, | |
138 | ||
b0d623f7 A |
139 | /* keep this last */ |
140 | KDP_INVALID_REQUEST | |
1c79356b A |
141 | } kdp_req_t; |
142 | ||
7e4a7d39 A |
143 | typedef enum { |
144 | KDP_DUMPINFO_GETINFO = 0x00000000, | |
145 | KDP_DUMPINFO_SETINFO = 0x00000001, | |
146 | KDP_DUMPINFO_CORE = 0x00000102, | |
147 | KDP_DUMPINFO_PANICLOG = 0x00000103, | |
148 | KDP_DUMPINFO_SYSTEMLOG = 0x00000104, | |
149 | KDP_DUMPINFO_DISABLE = 0x00000105, | |
150 | KDP_DUMPINFO_MASK = 0x00000FFF, | |
151 | KDP_DUMPINFO_DUMP = 0x00000100, | |
152 | ||
153 | KDP_DUMPINFO_REBOOT = 0x10000000, | |
154 | KDP_DUMPINFO_NORESUME = 0x20000000, | |
155 | KDP_DUMPINFO_RESUME = 0x00000000, /* default behaviour */ | |
156 | KDP_DUMPINFO_NOINTR = 0x40000000, /* don't interrupt */ | |
157 | KDP_DUMPINFO_INTR = 0x00000000, /* default behaviour */ | |
158 | } kdp_dumpinfo_t; | |
159 | ||
1c79356b A |
160 | /* |
161 | * Common KDP packet header | |
7e4a7d39 A |
162 | * NOTE: kgmacros has a non-symboled version of kdp_hdr_t so that some basic information. |
163 | * can be gathered from a kernel without any symbols. changes to this structure | |
164 | * need to be reflected in kgmacros as well. | |
1c79356b A |
165 | */ |
166 | typedef struct { | |
b0d623f7 | 167 | kdp_req_t request:7; /* kdp_req_t, request type */ |
1c79356b A |
168 | unsigned is_reply:1; /* 0 => request, 1 => reply */ |
169 | unsigned seq:8; /* sequence number within session */ | |
170 | unsigned len:16; /* length of entire pkt including hdr */ | |
171 | unsigned key; /* session key */ | |
b0d623f7 | 172 | } KDP_PACKED kdp_hdr_t; |
1c79356b A |
173 | |
174 | /* | |
175 | * KDP errors | |
176 | */ | |
177 | typedef enum { | |
178 | KDPERR_NO_ERROR = 0, | |
179 | KDPERR_ALREADY_CONNECTED, | |
180 | KDPERR_BAD_NBYTES, | |
b0d623f7 | 181 | KDPERR_BADFLAVOR, /* bad flavor in w/r regs */ |
39236c6e | 182 | KDPERR_BAD_ACCESS, /* memory reference failure */ |
7e4a7d39 | 183 | |
b0d623f7 A |
184 | KDPERR_MAX_BREAKPOINTS = 100, |
185 | KDPERR_BREAKPOINT_NOT_FOUND = 101, | |
186 | KDPERR_BREAKPOINT_ALREADY_SET = 102 | |
1c79356b A |
187 | } kdp_error_t; |
188 | ||
39236c6e A |
189 | #if defined(__x86_64__) |
190 | #define KDPERR_ACCESS(_req,_ret) \ | |
191 | (((_req) == (uint32_t)(_ret)) ? KDPERR_NO_ERROR : KDPERR_BAD_ACCESS) | |
192 | #else | |
193 | #define KDPERR_ACCESS(req,cnt) (KDPERR_NO_ERROR) | |
194 | #endif /* x86_64 */ | |
195 | ||
196 | ||
1c79356b A |
197 | /* |
198 | * KDP requests and reply packet formats | |
199 | */ | |
200 | ||
201 | /* | |
202 | * KDP_CONNECT | |
203 | */ | |
204 | typedef struct { /* KDP_CONNECT request */ | |
205 | kdp_hdr_t hdr; | |
b0d623f7 A |
206 | uint16_t req_reply_port; /* udp port which to send replies */ |
207 | uint16_t exc_note_port; /* udp port which to send exc notes */ | |
208 | char greeting[0]; /* "greetings", nul-terminated */ | |
209 | } KDP_PACKED kdp_connect_req_t; | |
1c79356b A |
210 | |
211 | typedef struct { /* KDP_CONNECT reply */ | |
212 | kdp_hdr_t hdr; | |
213 | kdp_error_t error; | |
b0d623f7 | 214 | } KDP_PACKED kdp_connect_reply_t; |
1c79356b A |
215 | |
216 | /* | |
217 | * KDP_DISCONNECT | |
218 | */ | |
219 | typedef struct { /* KDP_DISCONNECT request */ | |
220 | kdp_hdr_t hdr; | |
b0d623f7 | 221 | } KDP_PACKED kdp_disconnect_req_t; |
1c79356b A |
222 | |
223 | typedef struct { /* KDP_DISCONNECT reply */ | |
224 | kdp_hdr_t hdr; | |
b0d623f7 | 225 | } KDP_PACKED kdp_disconnect_reply_t; |
1c79356b | 226 | |
9bccf70c A |
227 | /* |
228 | * KDP_REATTACH | |
229 | */ | |
230 | typedef struct { | |
231 | kdp_hdr_t hdr; | |
b0d623f7 A |
232 | uint16_t req_reply_port; /* udp port which to send replies */ |
233 | } KDP_PACKED kdp_reattach_req_t; | |
9bccf70c | 234 | |
1c79356b A |
235 | /* |
236 | * KDP_HOSTINFO | |
237 | */ | |
238 | typedef struct { /* KDP_HOSTINFO request */ | |
239 | kdp_hdr_t hdr; | |
b0d623f7 | 240 | } KDP_PACKED kdp_hostinfo_req_t; |
1c79356b A |
241 | |
242 | typedef struct { | |
b0d623f7 A |
243 | uint32_t cpus_mask; /* bit is 1 if cpu present */ |
244 | uint32_t cpu_type; | |
245 | uint32_t cpu_subtype; | |
246 | } KDP_PACKED kdp_hostinfo_t; | |
1c79356b A |
247 | |
248 | typedef struct { /* KDP_HOSTINFO reply */ | |
249 | kdp_hdr_t hdr; | |
250 | kdp_hostinfo_t hostinfo; | |
b0d623f7 | 251 | } KDP_PACKED kdp_hostinfo_reply_t; |
1c79356b | 252 | |
9bccf70c A |
253 | /* |
254 | * KDP_VERSION | |
255 | */ | |
256 | typedef struct { /* KDP_VERSION request */ | |
257 | kdp_hdr_t hdr; | |
b0d623f7 | 258 | } KDP_PACKED kdp_version_req_t; |
9bccf70c A |
259 | |
260 | #define KDP_FEATURE_BP 0x1 /* local breakpoint support */ | |
261 | ||
b0d623f7 | 262 | typedef struct { /* KDP_VERSION reply */ |
9bccf70c | 263 | kdp_hdr_t hdr; |
b0d623f7 A |
264 | uint32_t version; |
265 | uint32_t feature; | |
266 | uint32_t pad0; | |
267 | uint32_t pad1; | |
268 | } KDP_PACKED kdp_version_reply_t; | |
269 | ||
270 | #define VM_PROT_VOLATILE ((vm_prot_t) 0x08) /* not cacheable */ | |
271 | #define VM_PROT_SPARSE ((vm_prot_t) 0x10) /* sparse addr space */ | |
9bccf70c | 272 | |
1c79356b A |
273 | /* |
274 | * KDP_REGIONS | |
275 | */ | |
276 | typedef struct { /* KDP_REGIONS request */ | |
277 | kdp_hdr_t hdr; | |
b0d623f7 | 278 | } KDP_PACKED kdp_regions_req_t; |
1c79356b A |
279 | |
280 | typedef struct { | |
b0d623f7 A |
281 | uint32_t address; |
282 | uint32_t nbytes; | |
283 | uint32_t protection; /* vm_prot_t */ | |
284 | } KDP_PACKED kdp_region_t; | |
1c79356b A |
285 | |
286 | typedef struct { /* KDP_REGIONS reply */ | |
287 | kdp_hdr_t hdr; | |
b0d623f7 | 288 | uint32_t nregions; |
1c79356b | 289 | kdp_region_t regions[0]; |
b0d623f7 | 290 | } KDP_PACKED kdp_regions_reply_t; |
1c79356b A |
291 | |
292 | /* | |
293 | * KDP_MAXBYTES | |
294 | */ | |
295 | typedef struct { /* KDP_MAXBYTES request */ | |
296 | kdp_hdr_t hdr; | |
b0d623f7 | 297 | } KDP_PACKED kdp_maxbytes_req_t; |
1c79356b A |
298 | |
299 | typedef struct { /* KDP_MAXBYTES reply */ | |
300 | kdp_hdr_t hdr; | |
b0d623f7 A |
301 | uint32_t max_bytes; |
302 | } KDP_PACKED kdp_maxbytes_reply_t; | |
1c79356b A |
303 | |
304 | /* | |
305 | * KDP_READMEM | |
306 | */ | |
307 | typedef struct { /* KDP_READMEM request */ | |
308 | kdp_hdr_t hdr; | |
b0d623f7 A |
309 | uint32_t address; |
310 | uint32_t nbytes; | |
311 | } KDP_PACKED kdp_readmem_req_t; | |
1c79356b A |
312 | |
313 | typedef struct { /* KDP_READMEM reply */ | |
314 | kdp_hdr_t hdr; | |
315 | kdp_error_t error; | |
316 | char data[0]; | |
b0d623f7 A |
317 | } KDP_PACKED kdp_readmem_reply_t; |
318 | ||
319 | /* | |
320 | * KDP_READMEM64 | |
321 | */ | |
322 | typedef struct { /* KDP_READMEM64 request */ | |
323 | kdp_hdr_t hdr; | |
324 | uint64_t address; | |
325 | uint32_t nbytes; | |
326 | } KDP_PACKED kdp_readmem64_req_t; | |
327 | ||
328 | typedef struct { /* KDP_READMEM64 reply */ | |
329 | kdp_hdr_t hdr; | |
330 | kdp_error_t error; | |
331 | char data[0]; | |
332 | } KDP_PACKED kdp_readmem64_reply_t; | |
333 | ||
334 | /* | |
335 | * KDP_READPHYSMEM64 | |
336 | */ | |
337 | typedef struct { /* KDP_READPHYSMEM64 request */ | |
338 | kdp_hdr_t hdr; | |
339 | uint64_t address; | |
340 | uint32_t nbytes; | |
341 | uint16_t lcpu; | |
342 | } KDP_PACKED kdp_readphysmem64_req_t; | |
343 | ||
344 | typedef struct { /* KDP_READPHYSMEM64 reply */ | |
345 | kdp_hdr_t hdr; | |
346 | kdp_error_t error; | |
347 | char data[0]; | |
348 | } KDP_PACKED kdp_readphysmem64_reply_t; | |
1c79356b A |
349 | |
350 | /* | |
351 | * KDP_WRITEMEM | |
352 | */ | |
353 | typedef struct { /* KDP_WRITEMEM request */ | |
354 | kdp_hdr_t hdr; | |
b0d623f7 A |
355 | uint32_t address; |
356 | uint32_t nbytes; | |
1c79356b | 357 | char data[0]; |
b0d623f7 | 358 | } KDP_PACKED kdp_writemem_req_t; |
1c79356b A |
359 | |
360 | typedef struct { /* KDP_WRITEMEM reply */ | |
361 | kdp_hdr_t hdr; | |
362 | kdp_error_t error; | |
b0d623f7 A |
363 | } KDP_PACKED kdp_writemem_reply_t; |
364 | ||
365 | /* | |
366 | * KDP_WRITEMEM64 | |
367 | */ | |
368 | typedef struct { /* KDP_WRITEMEM64 request */ | |
369 | kdp_hdr_t hdr; | |
370 | uint64_t address; | |
371 | uint32_t nbytes; | |
372 | char data[0]; | |
373 | } KDP_PACKED kdp_writemem64_req_t; | |
374 | ||
375 | typedef struct { /* KDP_WRITEMEM64 reply */ | |
376 | kdp_hdr_t hdr; | |
377 | kdp_error_t error; | |
378 | } KDP_PACKED kdp_writemem64_reply_t; | |
379 | ||
380 | /* | |
381 | * KDP_WRITEPHYSMEM64 | |
382 | */ | |
383 | typedef struct { /* KDP_WRITEPHYSMEM64 request */ | |
384 | kdp_hdr_t hdr; | |
385 | uint64_t address; | |
386 | uint32_t nbytes; | |
387 | uint16_t lcpu; | |
388 | char data[0]; | |
389 | } KDP_PACKED kdp_writephysmem64_req_t; | |
390 | ||
391 | typedef struct { /* KDP_WRITEPHYSMEM64 reply */ | |
392 | kdp_hdr_t hdr; | |
393 | kdp_error_t error; | |
394 | } KDP_PACKED kdp_writephysmem64_reply_t; | |
395 | ||
396 | /* | |
397 | * KDP_WRITEIOPORT | |
398 | */ | |
399 | typedef struct { /* KDP_WRITEIOPORT request */ | |
400 | kdp_hdr_t hdr; | |
401 | uint16_t lcpu; | |
402 | uint16_t address; | |
403 | uint16_t nbytes; | |
404 | char data[0]; | |
405 | } KDP_PACKED kdp_writeioport_req_t; | |
406 | ||
407 | typedef struct { /* KDP_WRITEIOPORT reply */ | |
408 | kdp_hdr_t hdr; | |
409 | kdp_error_t error; | |
410 | } KDP_PACKED kdp_writeioport_reply_t; | |
411 | ||
412 | /* | |
413 | * KDP_READIOPORT | |
414 | */ | |
415 | typedef struct { /* KDP_READIOPORT request */ | |
416 | kdp_hdr_t hdr; | |
417 | uint16_t lcpu; | |
418 | uint16_t address; | |
419 | uint16_t nbytes; | |
420 | } KDP_PACKED kdp_readioport_req_t; | |
421 | ||
422 | typedef struct { /* KDP_READIOPORT reply */ | |
423 | kdp_hdr_t hdr; | |
424 | kdp_error_t error; | |
425 | char data[0]; | |
426 | } KDP_PACKED kdp_readioport_reply_t; | |
427 | ||
428 | ||
429 | /* | |
430 | * KDP_WRITEMSR64 | |
431 | */ | |
432 | typedef struct { /* KDP_WRITEMSR64 request */ | |
433 | kdp_hdr_t hdr; | |
434 | uint32_t address; | |
435 | uint16_t lcpu; | |
436 | char data[0]; | |
437 | } KDP_PACKED kdp_writemsr64_req_t; | |
438 | ||
439 | typedef struct { /* KDP_WRITEMSR64 reply */ | |
440 | kdp_hdr_t hdr; | |
441 | kdp_error_t error; | |
442 | } KDP_PACKED kdp_writemsr64_reply_t; | |
443 | ||
444 | /* | |
445 | * KDP_READMSR64 | |
446 | */ | |
447 | typedef struct { /* KDP_READMSR64 request */ | |
448 | kdp_hdr_t hdr; | |
449 | uint32_t address; | |
450 | uint16_t lcpu; | |
451 | } KDP_PACKED kdp_readmsr64_req_t; | |
452 | ||
453 | typedef struct { /* KDP_READMSR64 reply */ | |
454 | kdp_hdr_t hdr; | |
455 | kdp_error_t error; | |
456 | char data[0]; | |
457 | } KDP_PACKED kdp_readmsr64_reply_t; | |
458 | ||
1c79356b A |
459 | |
460 | /* | |
461 | * KDP_READREGS | |
462 | */ | |
463 | typedef struct { /* KDP_READREGS request */ | |
464 | kdp_hdr_t hdr; | |
b0d623f7 A |
465 | uint32_t cpu; |
466 | uint32_t flavor; | |
467 | } KDP_PACKED kdp_readregs_req_t; | |
1c79356b A |
468 | |
469 | typedef struct { /* KDP_READREGS reply */ | |
470 | kdp_hdr_t hdr; | |
471 | kdp_error_t error; /* could be KDPERR_BADFLAVOR */ | |
472 | char data[0]; | |
b0d623f7 | 473 | } KDP_PACKED kdp_readregs_reply_t; |
1c79356b A |
474 | |
475 | /* | |
476 | * KDP_WRITEREGS | |
477 | */ | |
478 | typedef struct { /* KDP_WRITEREGS request */ | |
479 | kdp_hdr_t hdr; | |
b0d623f7 A |
480 | uint32_t cpu; |
481 | uint32_t flavor; | |
1c79356b | 482 | char data[0]; |
b0d623f7 | 483 | } KDP_PACKED kdp_writeregs_req_t; |
1c79356b A |
484 | |
485 | typedef struct { /* KDP_WRITEREGS reply */ | |
486 | kdp_hdr_t hdr; | |
487 | kdp_error_t error; | |
b0d623f7 | 488 | } KDP_PACKED kdp_writeregs_reply_t; |
1c79356b A |
489 | |
490 | /* | |
491 | * KDP_LOAD | |
492 | */ | |
493 | typedef struct { /* KDP_LOAD request */ | |
494 | kdp_hdr_t hdr; | |
495 | char file_args[0]; | |
b0d623f7 | 496 | } KDP_PACKED kdp_load_req_t; |
1c79356b A |
497 | |
498 | typedef struct { /* KDP_LOAD reply */ | |
499 | kdp_hdr_t hdr; | |
500 | kdp_error_t error; | |
b0d623f7 | 501 | } KDP_PACKED kdp_load_reply_t; |
1c79356b A |
502 | |
503 | /* | |
504 | * KDP_IMAGEPATH | |
505 | */ | |
506 | typedef struct { /* KDP_IMAGEPATH request */ | |
507 | kdp_hdr_t hdr; | |
b0d623f7 | 508 | } KDP_PACKED kdp_imagepath_req_t; |
1c79356b A |
509 | |
510 | typedef struct { /* KDP_IMAGEPATH reply */ | |
511 | kdp_hdr_t hdr; | |
512 | char path[0]; | |
b0d623f7 | 513 | } KDP_PACKED kdp_imagepath_reply_t; |
1c79356b A |
514 | |
515 | /* | |
516 | * KDP_SUSPEND | |
517 | */ | |
518 | typedef struct { /* KDP_SUSPEND request */ | |
519 | kdp_hdr_t hdr; | |
b0d623f7 | 520 | } KDP_PACKED kdp_suspend_req_t; |
1c79356b A |
521 | |
522 | typedef struct { /* KDP_SUSPEND reply */ | |
523 | kdp_hdr_t hdr; | |
b0d623f7 | 524 | } KDP_PACKED kdp_suspend_reply_t; |
1c79356b A |
525 | |
526 | /* | |
527 | * KDP_RESUMECPUS | |
528 | */ | |
529 | typedef struct { /* KDP_RESUMECPUS request */ | |
530 | kdp_hdr_t hdr; | |
b0d623f7 A |
531 | uint32_t cpu_mask; |
532 | } KDP_PACKED kdp_resumecpus_req_t; | |
1c79356b A |
533 | |
534 | typedef struct { /* KDP_RESUMECPUS reply */ | |
535 | kdp_hdr_t hdr; | |
b0d623f7 A |
536 | } KDP_PACKED kdp_resumecpus_reply_t; |
537 | ||
538 | /* | |
539 | * KDP_BREAKPOINT_SET and KDP_BREAKPOINT_REMOVE | |
540 | */ | |
1c79356b | 541 | |
9bccf70c A |
542 | typedef struct { |
543 | kdp_hdr_t hdr; | |
b0d623f7 A |
544 | uint32_t address; |
545 | } KDP_PACKED kdp_breakpoint_req_t; | |
9bccf70c A |
546 | |
547 | typedef struct { | |
548 | kdp_hdr_t hdr; | |
549 | kdp_error_t error; | |
b0d623f7 A |
550 | } KDP_PACKED kdp_breakpoint_reply_t; |
551 | ||
552 | /* | |
553 | * KDP_BREAKPOINT64_SET and KDP_BREAKPOINT64_REMOVE | |
554 | */ | |
555 | ||
556 | typedef struct { | |
557 | kdp_hdr_t hdr; | |
558 | uint64_t address; | |
559 | } KDP_PACKED kdp_breakpoint64_req_t; | |
560 | ||
561 | typedef struct { | |
562 | kdp_hdr_t hdr; | |
563 | kdp_error_t error; | |
564 | } KDP_PACKED kdp_breakpoint64_reply_t; | |
9bccf70c | 565 | |
1c79356b A |
566 | /* |
567 | * Exception notifications | |
568 | * (Exception notifications are not requests, and in fact travel from | |
569 | * the remote debugger to the gdb agent KDB.) | |
570 | */ | |
571 | typedef struct { /* exc. info for one cpu */ | |
b0d623f7 | 572 | uint32_t cpu; |
1c79356b A |
573 | /* |
574 | * Following info is defined as | |
575 | * per <mach/exception.h> | |
576 | */ | |
b0d623f7 A |
577 | uint32_t exception; |
578 | uint32_t code; | |
579 | uint32_t subcode; | |
580 | } KDP_PACKED kdp_exc_info_t; | |
1c79356b A |
581 | |
582 | typedef struct { /* KDP_EXCEPTION notification */ | |
583 | kdp_hdr_t hdr; | |
b0d623f7 | 584 | uint32_t n_exc_info; |
1c79356b | 585 | kdp_exc_info_t exc_info[0]; |
b0d623f7 | 586 | } KDP_PACKED kdp_exception_t; |
1c79356b A |
587 | |
588 | typedef struct { /* KDP_EXCEPTION acknowledgement */ | |
589 | kdp_hdr_t hdr; | |
b0d623f7 A |
590 | } KDP_PACKED kdp_exception_ack_t; |
591 | ||
592 | /* | |
593 | * KDP_KERNELVERSION | |
594 | */ | |
595 | typedef struct { /* KDP_KERNELVERSION request */ | |
596 | kdp_hdr_t hdr; | |
597 | } KDP_PACKED kdp_kernelversion_req_t; | |
598 | ||
599 | typedef struct { /* KDP_KERNELVERSION reply */ | |
600 | kdp_hdr_t hdr; | |
601 | char version[0]; | |
602 | } KDP_PACKED kdp_kernelversion_reply_t; | |
603 | ||
1c79356b A |
604 | |
605 | /* | |
606 | * Child termination messages | |
607 | */ | |
608 | typedef enum { | |
609 | KDP_FAULT = 0, /* child took fault (internal use) */ | |
610 | KDP_EXIT, /* child exited */ | |
611 | KDP_POWEROFF, /* child power-off */ | |
612 | KDP_REBOOT, /* child reboot */ | |
613 | KDP_COMMAND_MODE /* child exit to mon command_mode */ | |
614 | } kdp_termination_code_t; | |
615 | ||
616 | typedef struct { /* KDP_TERMINATION notification */ | |
617 | kdp_hdr_t hdr; | |
b0d623f7 A |
618 | uint32_t term_code; /* kdp_termination_code_t */ |
619 | uint32_t exit_code; | |
620 | } KDP_PACKED kdp_termination_t; | |
1c79356b A |
621 | |
622 | typedef struct { | |
623 | kdp_hdr_t hdr; | |
b0d623f7 | 624 | } KDP_PACKED kdp_termination_ack_t; |
1c79356b | 625 | |
7e4a7d39 A |
626 | /* |
627 | * KDP_DUMPINFO | |
628 | */ | |
629 | typedef struct { /* KDP_DUMPINFO request */ | |
630 | kdp_hdr_t hdr; | |
631 | char name[50]; | |
632 | char destip[16]; | |
633 | char routerip[16]; | |
634 | uint32_t port; | |
635 | kdp_dumpinfo_t type; | |
636 | } KDP_PACKED kdp_dumpinfo_req_t; | |
637 | ||
638 | typedef struct { /* KDP_DUMPINFO reply */ | |
639 | kdp_hdr_t hdr; | |
640 | char name[50]; | |
641 | char destip[16]; | |
642 | char routerip[16]; | |
643 | uint32_t port; | |
644 | kdp_dumpinfo_t type; | |
645 | } KDP_PACKED kdp_dumpinfo_reply_t; | |
646 | ||
647 | ||
1c79356b A |
648 | typedef union { |
649 | kdp_hdr_t hdr; | |
650 | kdp_connect_req_t connect_req; | |
651 | kdp_connect_reply_t connect_reply; | |
652 | kdp_disconnect_req_t disconnect_req; | |
653 | kdp_disconnect_reply_t disconnect_reply; | |
654 | kdp_hostinfo_req_t hostinfo_req; | |
655 | kdp_hostinfo_reply_t hostinfo_reply; | |
9bccf70c A |
656 | kdp_version_req_t version_req; |
657 | kdp_version_reply_t version_reply; | |
1c79356b A |
658 | kdp_maxbytes_req_t maxbytes_req; |
659 | kdp_maxbytes_reply_t maxbytes_reply; | |
660 | kdp_readmem_req_t readmem_req; | |
661 | kdp_readmem_reply_t readmem_reply; | |
b0d623f7 A |
662 | kdp_readmem64_req_t readmem64_req; |
663 | kdp_readmem64_reply_t readmem64_reply; | |
664 | kdp_readphysmem64_req_t readphysmem64_req; | |
665 | kdp_readphysmem64_reply_t readphysmem64_reply; | |
1c79356b A |
666 | kdp_writemem_req_t writemem_req; |
667 | kdp_writemem_reply_t writemem_reply; | |
b0d623f7 A |
668 | kdp_writemem64_req_t writemem64_req; |
669 | kdp_writemem64_reply_t writemem64_reply; | |
670 | kdp_writephysmem64_req_t writephysmem64_req; | |
671 | kdp_writephysmem64_reply_t writephysmem64_reply; | |
1c79356b A |
672 | kdp_readregs_req_t readregs_req; |
673 | kdp_readregs_reply_t readregs_reply; | |
674 | kdp_writeregs_req_t writeregs_req; | |
675 | kdp_writeregs_reply_t writeregs_reply; | |
676 | kdp_load_req_t load_req; | |
677 | kdp_load_reply_t load_reply; | |
678 | kdp_imagepath_req_t imagepath_req; | |
679 | kdp_imagepath_reply_t imagepath_reply; | |
680 | kdp_suspend_req_t suspend_req; | |
681 | kdp_suspend_reply_t suspend_reply; | |
682 | kdp_resumecpus_req_t resumecpus_req; | |
683 | kdp_resumecpus_reply_t resumecpus_reply; | |
684 | kdp_exception_t exception; | |
685 | kdp_exception_ack_t exception_ack; | |
686 | kdp_termination_t termination; | |
687 | kdp_termination_ack_t termination_ack; | |
9bccf70c A |
688 | kdp_breakpoint_req_t breakpoint_req; |
689 | kdp_breakpoint_reply_t breakpoint_reply; | |
b0d623f7 A |
690 | kdp_breakpoint64_req_t breakpoint64_req; |
691 | kdp_breakpoint64_reply_t breakpoint64_reply; | |
9bccf70c A |
692 | kdp_reattach_req_t reattach_req; |
693 | kdp_regions_req_t regions_req; | |
694 | kdp_regions_reply_t regions_reply; | |
b0d623f7 A |
695 | kdp_kernelversion_req_t kernelversion_req; |
696 | kdp_kernelversion_reply_t kernelversion_reply; | |
697 | kdp_readioport_req_t readioport_req; | |
698 | kdp_readioport_reply_t readioport_reply; | |
699 | kdp_writeioport_req_t writeioport_req; | |
700 | kdp_writeioport_reply_t writeioport_reply; | |
701 | kdp_readmsr64_req_t readmsr64_req; | |
702 | kdp_readmsr64_reply_t readmsr64_reply; | |
703 | kdp_writemsr64_req_t writemsr64_req; | |
704 | kdp_writemsr64_reply_t writemsr64_reply; | |
7e4a7d39 A |
705 | kdp_dumpinfo_req_t dumpinfo_req; |
706 | kdp_dumpinfo_reply_t dumpinfo_reply; | |
1c79356b A |
707 | } kdp_pkt_t; |
708 | ||
709 | #define MAX_KDP_PKT_SIZE 1200 /* max packet size */ | |
710 | #define MAX_KDP_DATA_SIZE 1024 /* max r/w data per packet */ | |
b0d623f7 | 711 | |
7e4a7d39 A |
712 | /* |
713 | * Support relatively small request/responses here. | |
714 | * If kgmacros needs to make a larger request, increase | |
715 | * this buffer size | |
716 | */ | |
717 | #define KDP_MANUAL_PACKET_SIZE 128 | |
718 | struct kdp_manual_pkt { | |
719 | unsigned char data[KDP_MANUAL_PACKET_SIZE]; | |
720 | unsigned int len; | |
721 | boolean_t input; | |
722 | } KDP_PACKED; | |
723 | ||
724 | #ifdef KDP_PROXY_PACK_SUPPORT | |
725 | #pragma pack() | |
726 | #endif | |
727 | ||
b0d623f7 | 728 | #endif // _KDP_PROTOCOL_H_ |