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