Loading...
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
/*
 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
 *
 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
 *
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Apple Public Source License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. The rights granted to you under the License
 * may not be used to create, or enable the creation or redistribution of,
 * unlawful or unlicensed copies of an Apple operating system, or to
 * circumvent, violate, or enable the circumvention or violation of, any
 * terms of an Apple operating system software license agreement.
 *
 * Please obtain a copy of the License at
 * http://www.opensource.apple.com/apsl/ and read it before using this file.
 *
 * The Original Code and all software distributed under the License are
 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 * Please see the License for the specific language governing rights and
 * limitations under the License.
 *
 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
 */

#ifndef _KDP_PROTOCOL_H_
#define _KDP_PROTOCOL_H_

/*
 * Definition of remote debugger protocol.
 */


#ifdef MACH_KERNEL_PRIVATE
#include        <mach/vm_prot.h>
#include    <mach/boolean.h>
#include        <stdint.h>
#endif

#ifdef KDP_PROXY_PACK_SUPPORT
#pragma pack(1)
#define KDP_PACKED
#else
#define KDP_PACKED __attribute__((packed))
#endif

/*
 * Retransmit parameters
 */
#if     DDEBUG_DEBUG || DEBUG_DEBUG
#define KDP_REXMIT_SECS         20      /* rexmit if no ack in 3 secs */
#else   /* DDEBUG_DEBUG || DEBUG_DEBUG */
#define KDP_REXMIT_SECS         3       /* rexmit if no ack in 3 secs */
#endif  /* DDEBUG_DEBUG || DEBUG_DEBUG */
#define KDP_REXMIT_TRIES        8       /* xmit 8 times, then give up */


/*
 * (NMI) Attention Max Wait Time
 * Remote will resume unless KDP requests is received within this
 * many seconds after an attention (nmi) packet is sent.
 */
#define KDP_MAX_ATTN_WAIT       30      /* wait max of 30 seconds */

/*
 * Well-known UDP port, debugger side.
 * FIXME: This is what the 68K guys use, but beats me how they chose it...
 */
#define KDP_REMOTE_PORT         41139   /* pick one and register it */

/*
 * UDP ports, KDB side. 5 port numbers are reserved for each port (request
 * and exception). This allows multiple KDBs to run on one host.
 */
#define UDP_HOST_COMM_BASE      41140
#define UDP_HOST_EXCEP_BASE     41145
#define NUM_UDP_HOST_PORTS      5

/*
 * Requests
 */
typedef enum {
	/* connection oriented requests */
	KDP_CONNECT, KDP_DISCONNECT,

	/* obtaining client info */
	KDP_HOSTINFO, KDP_VERSION, KDP_MAXBYTES,

	/* memory access */
	KDP_READMEM, KDP_WRITEMEM,

	/* register access */
	KDP_READREGS, KDP_WRITEREGS,

	/* executable image info */
	KDP_LOAD, KDP_IMAGEPATH,

	/* execution control */
	KDP_SUSPEND, KDP_RESUMECPUS,

	/* exception and termination notification, NOT true requests */
	KDP_EXCEPTION, KDP_TERMINATION,

	/* breakpoint control */
	KDP_BREAKPOINT_SET, KDP_BREAKPOINT_REMOVE,

	/* vm regions */
	KDP_REGIONS,

	/* reattach to a connected host */
	KDP_REATTACH,

	/* remote reboot request */
	KDP_HOSTREBOOT,

	/* memory access (64-bit wide addresses). Version 11 protocol */
	KDP_READMEM64, KDP_WRITEMEM64,

	/* breakpoint control (64-bit wide addresses). Version 11 protocol */
	KDP_BREAKPOINT64_SET, KDP_BREAKPOINT64_REMOVE,

	/* kernel version string, like "xnu-1234.5~6". Version 11 protocol */
	KDP_KERNELVERSION,

	/* physical memory access (64-bit wide addresses). Version 12 protocol */
	KDP_READPHYSMEM64, KDP_WRITEPHYSMEM64,

	/* ioport access (8-, 16-, and 32-bit) */
	KDP_READIOPORT, KDP_WRITEIOPORT,

	/* msr access (64-bit) */
	KDP_READMSR64, KDP_WRITEMSR64,

	/* get/dump panic/corefile info */
	KDP_DUMPINFO,

	/* keep this last */
	KDP_INVALID_REQUEST
} kdp_req_t;

typedef enum {
	KDP_DUMPINFO_GETINFO    = 0x00000000,
	KDP_DUMPINFO_SETINFO    = 0x00000001,
	KDP_DUMPINFO_CORE       = 0x00000102,
	KDP_DUMPINFO_PANICLOG   = 0x00000103,
	KDP_DUMPINFO_SYSTEMLOG  = 0x00000104,
	KDP_DUMPINFO_DISABLE    = 0x00000105,
	KDP_DUMPINFO_MASK       = 0x00000FFF,
	KDP_DUMPINFO_DUMP       = 0x00000100,

	KDP_DUMPINFO_REBOOT     = 0x10000000,
	KDP_DUMPINFO_NORESUME   = 0x20000000,
	KDP_DUMPINFO_RESUME     = 0x00000000, /* default behaviour */
	KDP_DUMPINFO_NOINTR     = 0x40000000, /* don't interrupt */
	KDP_DUMPINFO_INTR       = 0x00000000, /* default behaviour */
} kdp_dumpinfo_t;

/*
 * Common KDP packet header
 * NOTE: kgmacros has a non-symboled version of kdp_hdr_t so that some basic information.
 *       can be gathered from a kernel without any symbols. changes to this structure
 *       need to be reflected in kgmacros as well.
 */
typedef struct {
	kdp_req_t       request:7;      /* kdp_req_t, request type */
	unsigned        is_reply:1;     /* 0 => request, 1 => reply */
	unsigned        seq:8;          /* sequence number within session */
	unsigned        len:16;         /* length of entire pkt including hdr */
	unsigned        key;            /* session key */
} KDP_PACKED kdp_hdr_t;

/*
 * KDP errors
 */
typedef enum {
	KDPERR_NO_ERROR = 0,
	KDPERR_ALREADY_CONNECTED,
	KDPERR_BAD_NBYTES,
	KDPERR_BADFLAVOR,               /* bad flavor in w/r regs */
	KDPERR_BAD_ACCESS,              /* memory reference failure */

	KDPERR_MAX_BREAKPOINTS = 100,
	KDPERR_BREAKPOINT_NOT_FOUND = 101,
	KDPERR_BREAKPOINT_ALREADY_SET = 102
} kdp_error_t;

#if defined(__x86_64__)
#define KDPERR_ACCESS(_req, _ret)  \
	(((_req) == (uint32_t)(_ret)) ? KDPERR_NO_ERROR : KDPERR_BAD_ACCESS)
#else
#define KDPERR_ACCESS(req, cnt)  (KDPERR_NO_ERROR)
#endif /* x86_64 */


/*
 * KDP requests and reply packet formats
 */

/*
 * KDP_CONNECT
 */
typedef struct {                        /* KDP_CONNECT request */
	kdp_hdr_t       hdr;
	uint16_t        req_reply_port; /* udp port which to send replies */
	uint16_t        exc_note_port;  /* udp port which to send exc notes */
	char            greeting[0];    /* "greetings", nul-terminated */
} KDP_PACKED kdp_connect_req_t;

typedef struct {                        /* KDP_CONNECT reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
} KDP_PACKED kdp_connect_reply_t;

/*
 * KDP_DISCONNECT
 */
typedef struct {                        /* KDP_DISCONNECT request */
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_disconnect_req_t;

typedef struct {                        /* KDP_DISCONNECT reply */
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_disconnect_reply_t;

/*
 * KDP_REATTACH
 */
typedef struct {
	kdp_hdr_t hdr;
	uint16_t req_reply_port; /* udp port which to send replies */
} KDP_PACKED kdp_reattach_req_t;

/*
 * KDP_HOSTINFO
 */
typedef struct {                        /* KDP_HOSTINFO request */
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_hostinfo_req_t;

typedef struct {
	uint32_t                cpus_mask;      /* bit is 1 if cpu present */
	uint32_t                cpu_type;
	uint32_t                cpu_subtype;
} KDP_PACKED kdp_hostinfo_t;

typedef struct {                        /* KDP_HOSTINFO reply */
	kdp_hdr_t       hdr;
	kdp_hostinfo_t  hostinfo;
} KDP_PACKED kdp_hostinfo_reply_t;

/*
 * KDP_VERSION
 */
typedef struct {                        /* KDP_VERSION request */
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_version_req_t;

#define KDP_FEATURE_BP  0x1     /* local breakpoint support */

typedef struct {                        /* KDP_VERSION reply */
	kdp_hdr_t       hdr;
	uint32_t        version;
	uint32_t        feature;
	uint32_t        pad0;
	uint32_t        pad1;
} KDP_PACKED kdp_version_reply_t;

#define VM_PROT_VOLATILE        ((vm_prot_t) 0x08)      /* not cacheable */
#define VM_PROT_SPARSE          ((vm_prot_t) 0x10)      /* sparse addr space */

/*
 * KDP_REGIONS
 */
typedef struct {                        /* KDP_REGIONS request */
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_regions_req_t;

typedef struct {
	uint32_t        address;
	uint32_t        nbytes;
	uint32_t        protection;     /* vm_prot_t */
} KDP_PACKED kdp_region_t;

typedef struct {                        /* KDP_REGIONS reply */
	kdp_hdr_t       hdr;
	uint32_t        nregions;
	kdp_region_t    regions[0];
} KDP_PACKED kdp_regions_reply_t;

/*
 * KDP_MAXBYTES
 */
typedef struct {                        /* KDP_MAXBYTES request */
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_maxbytes_req_t;

typedef struct {                        /* KDP_MAXBYTES reply */
	kdp_hdr_t       hdr;
	uint32_t        max_bytes;
} KDP_PACKED kdp_maxbytes_reply_t;

/*
 * KDP_READMEM
 */
typedef struct {                        /* KDP_READMEM request */
	kdp_hdr_t       hdr;
	uint32_t        address;
	uint32_t        nbytes;
} KDP_PACKED kdp_readmem_req_t;

typedef struct {                        /* KDP_READMEM reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
	char            data[0];
} KDP_PACKED kdp_readmem_reply_t;

/*
 * KDP_READMEM64
 */
typedef struct {                        /* KDP_READMEM64 request */
	kdp_hdr_t       hdr;
	uint64_t        address;
	uint32_t        nbytes;
} KDP_PACKED kdp_readmem64_req_t;

typedef struct {                        /* KDP_READMEM64 reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
	char            data[0];
} KDP_PACKED kdp_readmem64_reply_t;

/*
 * KDP_READPHYSMEM64
 */
typedef struct {                        /* KDP_READPHYSMEM64 request */
	kdp_hdr_t       hdr;
	uint64_t        address;
	uint32_t        nbytes;
	uint16_t        lcpu;
} KDP_PACKED kdp_readphysmem64_req_t;

typedef struct {                        /* KDP_READPHYSMEM64 reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
	char            data[0];
} KDP_PACKED kdp_readphysmem64_reply_t;

/*
 * KDP_WRITEMEM
 */
typedef struct {                        /* KDP_WRITEMEM request */
	kdp_hdr_t       hdr;
	uint32_t        address;
	uint32_t        nbytes;
	char            data[0];
} KDP_PACKED kdp_writemem_req_t;

typedef struct {                        /* KDP_WRITEMEM reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
} KDP_PACKED kdp_writemem_reply_t;

/*
 * KDP_WRITEMEM64
 */
typedef struct {                        /* KDP_WRITEMEM64 request */
	kdp_hdr_t       hdr;
	uint64_t        address;
	uint32_t        nbytes;
	char            data[0];
} KDP_PACKED kdp_writemem64_req_t;

typedef struct {                        /* KDP_WRITEMEM64 reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
} KDP_PACKED kdp_writemem64_reply_t;

/*
 * KDP_WRITEPHYSMEM64
 */
typedef struct {                        /* KDP_WRITEPHYSMEM64 request */
	kdp_hdr_t       hdr;
	uint64_t        address;
	uint32_t        nbytes;
	uint16_t        lcpu;
	char            data[0];
} KDP_PACKED kdp_writephysmem64_req_t;

typedef struct {                        /* KDP_WRITEPHYSMEM64 reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
} KDP_PACKED kdp_writephysmem64_reply_t;

/*
 * KDP_WRITEIOPORT
 */
typedef struct {                        /* KDP_WRITEIOPORT request */
	kdp_hdr_t       hdr;
	uint16_t        lcpu;
	uint16_t        address;
	uint16_t        nbytes;
	char            data[0];
} KDP_PACKED kdp_writeioport_req_t;

typedef struct {                        /* KDP_WRITEIOPORT reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
} KDP_PACKED kdp_writeioport_reply_t;

/*
 * KDP_READIOPORT
 */
typedef struct {                        /* KDP_READIOPORT request */
	kdp_hdr_t       hdr;
	uint16_t        lcpu;
	uint16_t        address;
	uint16_t        nbytes;
} KDP_PACKED kdp_readioport_req_t;

typedef struct {                        /* KDP_READIOPORT reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
	char            data[0];
} KDP_PACKED kdp_readioport_reply_t;


/*
 * KDP_WRITEMSR64
 */
typedef struct {                        /* KDP_WRITEMSR64 request */
	kdp_hdr_t       hdr;
	uint32_t        address;
	uint16_t        lcpu;
	char            data[0];
} KDP_PACKED kdp_writemsr64_req_t;

typedef struct {                        /* KDP_WRITEMSR64 reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
} KDP_PACKED kdp_writemsr64_reply_t;

/*
 * KDP_READMSR64
 */
typedef struct {                        /* KDP_READMSR64 request */
	kdp_hdr_t       hdr;
	uint32_t        address;
	uint16_t        lcpu;
} KDP_PACKED kdp_readmsr64_req_t;

typedef struct {                        /* KDP_READMSR64 reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
	char            data[0];
} KDP_PACKED kdp_readmsr64_reply_t;


/*
 * KDP_READREGS
 */
typedef struct {                        /* KDP_READREGS request */
	kdp_hdr_t       hdr;
	uint32_t        cpu;
	uint32_t        flavor;
} KDP_PACKED kdp_readregs_req_t;

typedef struct {                        /* KDP_READREGS reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;          /* could be KDPERR_BADFLAVOR */
	char            data[0];
} KDP_PACKED kdp_readregs_reply_t;

/*
 * KDP_WRITEREGS
 */
typedef struct {                        /* KDP_WRITEREGS request */
	kdp_hdr_t       hdr;
	uint32_t        cpu;
	uint32_t        flavor;
	char            data[0];
} KDP_PACKED kdp_writeregs_req_t;

typedef struct {                        /* KDP_WRITEREGS reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
} KDP_PACKED kdp_writeregs_reply_t;

/*
 * KDP_LOAD
 */
typedef struct {                        /* KDP_LOAD request */
	kdp_hdr_t       hdr;
	char            file_args[0];
} KDP_PACKED kdp_load_req_t;

typedef struct {                        /* KDP_LOAD reply */
	kdp_hdr_t       hdr;
	kdp_error_t     error;
} KDP_PACKED kdp_load_reply_t;

/*
 * KDP_IMAGEPATH
 */
typedef struct {                        /* KDP_IMAGEPATH request */
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_imagepath_req_t;

typedef struct {                        /* KDP_IMAGEPATH reply */
	kdp_hdr_t       hdr;
	char            path[0];
} KDP_PACKED kdp_imagepath_reply_t;

/*
 * KDP_SUSPEND
 */
typedef struct {                        /* KDP_SUSPEND request */
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_suspend_req_t;

typedef struct {                        /* KDP_SUSPEND reply */
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_suspend_reply_t;

/*
 * KDP_RESUMECPUS
 */
typedef struct {                        /* KDP_RESUMECPUS request */
	kdp_hdr_t       hdr;
	uint32_t        cpu_mask;
} KDP_PACKED kdp_resumecpus_req_t;

typedef struct {                        /* KDP_RESUMECPUS reply */
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_resumecpus_reply_t;

/*
 * KDP_BREAKPOINT_SET and KDP_BREAKPOINT_REMOVE
 */

typedef struct {
	kdp_hdr_t hdr;
	uint32_t      address;
} KDP_PACKED kdp_breakpoint_req_t;

typedef struct {
	kdp_hdr_t hdr;
	kdp_error_t error;
} KDP_PACKED kdp_breakpoint_reply_t;

/*
 * KDP_BREAKPOINT64_SET and KDP_BREAKPOINT64_REMOVE
 */

typedef struct {
	kdp_hdr_t hdr;
	uint64_t        address;
} KDP_PACKED kdp_breakpoint64_req_t;

typedef struct {
	kdp_hdr_t hdr;
	kdp_error_t error;
} KDP_PACKED kdp_breakpoint64_reply_t;

/*
 * Exception notifications
 * (Exception notifications are not requests, and in fact travel from
 * the remote debugger to the gdb agent KDB.)
 */
typedef struct {                        /* exc. info for one cpu */
	uint32_t        cpu;
	/*
	 * Following info is defined as
	 * per <mach/exception.h>
	 */
	uint32_t        exception;
	uint32_t        code;
	uint32_t        subcode;
} KDP_PACKED kdp_exc_info_t;

typedef struct {                        /* KDP_EXCEPTION notification */
	kdp_hdr_t       hdr;
	uint32_t        n_exc_info;
	kdp_exc_info_t  exc_info[0];
} KDP_PACKED kdp_exception_t;

typedef struct {                        /* KDP_EXCEPTION acknowledgement */
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_exception_ack_t;

/*
 * KDP_KERNELVERSION
 */
typedef struct {                        /* KDP_KERNELVERSION request */
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_kernelversion_req_t;

typedef struct {                        /* KDP_KERNELVERSION reply */
	kdp_hdr_t       hdr;
	char            version[0];
} KDP_PACKED kdp_kernelversion_reply_t;


/*
 * Child termination messages
 */
typedef enum {
	KDP_FAULT = 0,          /* child took fault (internal use) */
	KDP_EXIT,               /* child exited */
	KDP_POWEROFF,           /* child power-off */
	KDP_REBOOT,             /* child reboot */
	KDP_COMMAND_MODE        /* child exit to mon command_mode */
} kdp_termination_code_t;

typedef struct {                        /* KDP_TERMINATION notification */
	kdp_hdr_t               hdr;
	uint32_t                term_code;      /* kdp_termination_code_t */
	uint32_t                exit_code;
} KDP_PACKED kdp_termination_t;

typedef struct {
	kdp_hdr_t       hdr;
} KDP_PACKED kdp_termination_ack_t;

/*
 * KDP_DUMPINFO
 */
typedef struct {                        /* KDP_DUMPINFO request */
	kdp_hdr_t       hdr;
	char            name[50];
	char            destip[16];
	char            routerip[16];
	uint32_t        port;
	kdp_dumpinfo_t  type;
} KDP_PACKED kdp_dumpinfo_req_t;

typedef struct {                        /* KDP_DUMPINFO reply */
	kdp_hdr_t       hdr;
	char            name[50];
	char            destip[16];
	char            routerip[16];
	uint32_t        port;
	kdp_dumpinfo_t  type;
} KDP_PACKED kdp_dumpinfo_reply_t;


typedef union {
	kdp_hdr_t               hdr;
	kdp_connect_req_t       connect_req;
	kdp_connect_reply_t     connect_reply;
	kdp_disconnect_req_t    disconnect_req;
	kdp_disconnect_reply_t  disconnect_reply;
	kdp_hostinfo_req_t      hostinfo_req;
	kdp_hostinfo_reply_t    hostinfo_reply;
	kdp_version_req_t       version_req;
	kdp_version_reply_t     version_reply;
	kdp_maxbytes_req_t      maxbytes_req;
	kdp_maxbytes_reply_t    maxbytes_reply;
	kdp_readmem_req_t       readmem_req;
	kdp_readmem_reply_t     readmem_reply;
	kdp_readmem64_req_t     readmem64_req;
	kdp_readmem64_reply_t   readmem64_reply;
	kdp_readphysmem64_req_t readphysmem64_req;
	kdp_readphysmem64_reply_t       readphysmem64_reply;
	kdp_writemem_req_t      writemem_req;
	kdp_writemem_reply_t    writemem_reply;
	kdp_writemem64_req_t    writemem64_req;
	kdp_writemem64_reply_t  writemem64_reply;
	kdp_writephysmem64_req_t        writephysmem64_req;
	kdp_writephysmem64_reply_t      writephysmem64_reply;
	kdp_readregs_req_t      readregs_req;
	kdp_readregs_reply_t    readregs_reply;
	kdp_writeregs_req_t     writeregs_req;
	kdp_writeregs_reply_t   writeregs_reply;
	kdp_load_req_t          load_req;
	kdp_load_reply_t        load_reply;
	kdp_imagepath_req_t     imagepath_req;
	kdp_imagepath_reply_t   imagepath_reply;
	kdp_suspend_req_t       suspend_req;
	kdp_suspend_reply_t     suspend_reply;
	kdp_resumecpus_req_t    resumecpus_req;
	kdp_resumecpus_reply_t  resumecpus_reply;
	kdp_exception_t         exception;
	kdp_exception_ack_t     exception_ack;
	kdp_termination_t       termination;
	kdp_termination_ack_t   termination_ack;
	kdp_breakpoint_req_t    breakpoint_req;
	kdp_breakpoint_reply_t  breakpoint_reply;
	kdp_breakpoint64_req_t  breakpoint64_req;
	kdp_breakpoint64_reply_t        breakpoint64_reply;
	kdp_reattach_req_t      reattach_req;
	kdp_regions_req_t       regions_req;
	kdp_regions_reply_t     regions_reply;
	kdp_kernelversion_req_t kernelversion_req;
	kdp_kernelversion_reply_t       kernelversion_reply;
	kdp_readioport_req_t    readioport_req;
	kdp_readioport_reply_t  readioport_reply;
	kdp_writeioport_req_t   writeioport_req;
	kdp_writeioport_reply_t writeioport_reply;
	kdp_readmsr64_req_t     readmsr64_req;
	kdp_readmsr64_reply_t   readmsr64_reply;
	kdp_writemsr64_req_t    writemsr64_req;
	kdp_writemsr64_reply_t  writemsr64_reply;
	kdp_dumpinfo_req_t      dumpinfo_req;
	kdp_dumpinfo_reply_t    dumpinfo_reply;
} kdp_pkt_t;

#define MAX_KDP_PKT_SIZE        1200    /* max packet size */
#define MAX_KDP_DATA_SIZE       1024    /* max r/w data per packet */

/*
 * Support relatively small request/responses here.
 * If kgmacros needs to make a larger request, increase
 * this buffer size
 */
#define KDP_MANUAL_PACKET_SIZE 128
struct kdp_manual_pkt {
	unsigned char       data[KDP_MANUAL_PACKET_SIZE];
	unsigned int        len;
	boolean_t           input;
} KDP_PACKED;

#ifdef KDP_PROXY_PACK_SUPPORT
#pragma pack()
#endif

#endif // _KDP_PROTOCOL_H_