X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/b0d623f7f2ae71ed96e60569f61f9a9a27016e80..3903760236c30e3b5ace7a4eefac3a269d68957c:/osfmk/kdp/kdp_protocol.h diff --git a/osfmk/kdp/kdp_protocol.h b/osfmk/kdp/kdp_protocol.h index 723382ca5..8cc612288 100644 --- a/osfmk/kdp/kdp_protocol.h +++ b/osfmk/kdp/kdp_protocol.h @@ -33,8 +33,19 @@ * Definition of remote debugger protocol. */ + +#ifdef MACH_KERNEL_PRIVATE #include +#include #include +#endif + +#ifdef KDP_PROXY_PACK_SUPPORT +#pragma pack(1) +#define KDP_PACKED +#else +#define KDP_PACKED __attribute__((packed)) +#endif /* * Retransmit parameters @@ -46,7 +57,6 @@ #endif /* DDEBUG_DEBUG || DEBUG_DEBUG */ #define KDP_REXMIT_TRIES 8 /* xmit 8 times, then give up */ -#define KDP_PACKED __attribute__((packed)) /* * (NMI) Attention Max Wait Time @@ -124,12 +134,35 @@ typedef enum { /* 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 */ @@ -147,12 +180,21 @@ typedef enum { 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 */ @@ -582,6 +624,28 @@ 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; @@ -639,9 +703,27 @@ typedef union { 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_