#include <mach/vm_prot.h>
#if DDEBUG_DEBUG || DEBUG_DEBUG
#define KDP_REXMIT_SECS 20
#else
#define KDP_REXMIT_SECS 3
#endif
#define KDP_REXMIT_TRIES 8
#define KDP_MAX_ATTN_WAIT 30
#define KDP_REMOTE_PORT 41139
#define UDP_HOST_COMM_BASE 41140
#define UDP_HOST_EXCEP_BASE 41145
#define NUM_UDP_HOST_PORTS 5
typedef enum {
KDP_CONNECT, KDP_DISCONNECT,
KDP_HOSTINFO, KDP_VERSION, KDP_MAXBYTES,
KDP_READMEM, KDP_WRITEMEM,
KDP_READREGS, KDP_WRITEREGS,
KDP_LOAD, KDP_IMAGEPATH,
KDP_SUSPEND, KDP_RESUMECPUS,
KDP_EXCEPTION, KDP_TERMINATION,
KDP_BREAKPOINT_SET, KDP_BREAKPOINT_REMOVE,
KDP_REGIONS,
KDP_REATTACH,
KDP_HOSTREBOOT
} kdp_req_t;
typedef struct {
kdp_req_t request:7;
unsigned is_reply:1;
unsigned seq:8;
unsigned len:16;
unsigned key;
} kdp_hdr_t;
typedef enum {
KDPERR_NO_ERROR = 0,
KDPERR_ALREADY_CONNECTED,
KDPERR_BAD_NBYTES,
KDPERR_BADFLAVOR
} kdp_error_t;
typedef struct {
kdp_hdr_t hdr;
unsigned short req_reply_port;
unsigned short exc_note_port;
char greeting[0];
} kdp_connect_req_t;
typedef struct {
kdp_hdr_t hdr;
kdp_error_t error;
} kdp_connect_reply_t;
typedef struct {
kdp_hdr_t hdr;
} kdp_disconnect_req_t;
typedef struct {
kdp_hdr_t hdr;
} kdp_disconnect_reply_t;
typedef struct {
kdp_hdr_t hdr;
unsigned short req_reply_port;
} kdp_reattach_req_t;
typedef struct {
kdp_hdr_t hdr;
} kdp_hostinfo_req_t;
typedef struct {
unsigned cpus_mask;
int cpu_type;
int cpu_subtype;
} kdp_hostinfo_t;
typedef struct {
kdp_hdr_t hdr;
kdp_hostinfo_t hostinfo;
} kdp_hostinfo_reply_t;
typedef struct {
kdp_hdr_t hdr;
} kdp_version_req_t;
#define KDP_FEATURE_BP 0x1
typedef struct {
kdp_hdr_t hdr;
unsigned version;
unsigned feature;
unsigned pad0;
unsigned pad1;
} kdp_version_reply_t;
typedef struct {
kdp_hdr_t hdr;
} kdp_regions_req_t;
#define VM_PROT_VOLATILE ((vm_prot_t) 0x08)
#define VM_PROT_SPARSE ((vm_prot_t) 0x10)
typedef struct {
void *address;
unsigned nbytes;
vm_prot_t protection;
} kdp_region_t;
typedef struct {
kdp_hdr_t hdr;
unsigned nregions;
kdp_region_t regions[0];
} kdp_regions_reply_t;
typedef struct {
kdp_hdr_t hdr;
} kdp_maxbytes_req_t;
typedef struct {
kdp_hdr_t hdr;
unsigned max_bytes;
} kdp_maxbytes_reply_t;
typedef struct {
kdp_hdr_t hdr;
void *address;
unsigned nbytes;
} kdp_readmem_req_t;
typedef struct {
kdp_hdr_t hdr;
kdp_error_t error;
char data[0];
} kdp_readmem_reply_t;
typedef struct {
kdp_hdr_t hdr;
void *address;
unsigned nbytes;
char data[0];
} kdp_writemem_req_t;
typedef struct {
kdp_hdr_t hdr;
kdp_error_t error;
} kdp_writemem_reply_t;
typedef struct {
kdp_hdr_t hdr;
unsigned cpu;
unsigned flavor;
} kdp_readregs_req_t;
typedef struct {
kdp_hdr_t hdr;
kdp_error_t error;
char data[0];
} kdp_readregs_reply_t;
typedef struct {
kdp_hdr_t hdr;
unsigned cpu;
unsigned flavor;
char data[0];
} kdp_writeregs_req_t;
typedef struct {
kdp_hdr_t hdr;
kdp_error_t error;
} kdp_writeregs_reply_t;
typedef struct {
kdp_hdr_t hdr;
char file_args[0];
} kdp_load_req_t;
typedef struct {
kdp_hdr_t hdr;
kdp_error_t error;
} kdp_load_reply_t;
typedef struct {
kdp_hdr_t hdr;
} kdp_imagepath_req_t;
typedef struct {
kdp_hdr_t hdr;
char path[0];
} kdp_imagepath_reply_t;
typedef struct {
kdp_hdr_t hdr;
} kdp_suspend_req_t;
typedef struct {
kdp_hdr_t hdr;
} kdp_suspend_reply_t;
typedef struct {
kdp_hdr_t hdr;
unsigned cpu_mask;
} kdp_resumecpus_req_t;
typedef struct {
kdp_hdr_t hdr;
} kdp_resumecpus_reply_t;
typedef struct {
kdp_hdr_t hdr;
unsigned long address;
} kdp_breakpoint_req_t;
typedef struct {
kdp_hdr_t hdr;
kdp_error_t error;
} kdp_breakpoint_reply_t;
typedef struct {
unsigned cpu;
unsigned exception;
unsigned code;
unsigned subcode;
} kdp_exc_info_t;
typedef struct {
kdp_hdr_t hdr;
unsigned n_exc_info;
kdp_exc_info_t exc_info[0];
} kdp_exception_t;
typedef struct {
kdp_hdr_t hdr;
} kdp_exception_ack_t;
typedef enum {
KDP_FAULT = 0,
KDP_EXIT,
KDP_POWEROFF,
KDP_REBOOT,
KDP_COMMAND_MODE
} kdp_termination_code_t;
typedef struct {
kdp_hdr_t hdr;
kdp_termination_code_t term_code;
unsigned exit_code;
} kdp_termination_t;
typedef struct {
kdp_hdr_t hdr;
} kdp_termination_ack_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_writemem_req_t writemem_req;
kdp_writemem_reply_t writemem_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_reattach_req_t reattach_req;
kdp_regions_req_t regions_req;
kdp_regions_reply_t regions_reply;
} kdp_pkt_t;
#define MAX_KDP_PKT_SIZE 1200
#define MAX_KDP_DATA_SIZE 1024