128 lines
3.6 KiB
C
128 lines
3.6 KiB
C
|
//////////////////////////////////////////////////////////////////////////////
|
||
|
//
|
||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||
|
//
|
||
|
// debug.h: runtime support for debugging
|
||
|
//
|
||
|
|
||
|
#pragma pack(4)
|
||
|
|
||
|
typedef struct _STRING {
|
||
|
UINT16 Length;
|
||
|
UINT16 MaximumLength;
|
||
|
PUINT8 Buffer;
|
||
|
} STRING, *PSTRING;
|
||
|
|
||
|
//======================================================================
|
||
|
// Selected structs and defines used by the KD protocol
|
||
|
//
|
||
|
|
||
|
//
|
||
|
// If the packet type is PACKET_TYPE_KD_DEBUG_IO, then
|
||
|
// the format of the packet data is as follows:
|
||
|
//
|
||
|
|
||
|
#define DbgKdPrintStringApi 0x00003230L
|
||
|
|
||
|
//
|
||
|
// For get string, the Null terminated prompt string
|
||
|
// immediately follows the message. The LengthOfStringRead
|
||
|
// field initially contains the maximum number of characters
|
||
|
// to read. Upon reply, this contains the number of bytes actually
|
||
|
// read. The data read immediately follows the message.
|
||
|
//
|
||
|
//
|
||
|
typedef struct _DBGKD_DEBUG_IO {
|
||
|
UINT32 ApiNumber;
|
||
|
UINT16 ProcessorLevel;
|
||
|
UINT16 Processor;
|
||
|
UINT32 LengthOfString;
|
||
|
UINT32 LengthOfStringRead;
|
||
|
} DBGKD_DEBUG_IO, *PDBGKD_DEBUG_IO;
|
||
|
|
||
|
//
|
||
|
// DbgKd APIs are for the portable kernel debugger
|
||
|
//
|
||
|
|
||
|
//
|
||
|
// KD_PACKETS are the low level data format used in KD. All packets
|
||
|
// begin with a packet leader, byte count, packet type. The sequence
|
||
|
// for accepting a packet is:
|
||
|
//
|
||
|
// - read 4 bytes to get packet leader. If read times out (10 seconds)
|
||
|
// with a short read, or if packet leader is incorrect, then retry
|
||
|
// the read.
|
||
|
//
|
||
|
// - next read 2 byte packet type. If read times out (10 seconds) with
|
||
|
// a short read, or if packet type is bad, then start again looking
|
||
|
// for a packet leader.
|
||
|
//
|
||
|
// - next read 4 byte packet Id. If read times out (10 seconds)
|
||
|
// with a short read, or if packet Id is not what we expect, then
|
||
|
// ask for resend and restart again looking for a packet leader.
|
||
|
//
|
||
|
// - next read 2 byte count. If read times out (10 seconds) with
|
||
|
// a short read, or if byte count is greater than PACKET_MAX_SIZE,
|
||
|
// then start again looking for a packet leader.
|
||
|
//
|
||
|
// - next read 4 byte packet data checksum.
|
||
|
//
|
||
|
// - The packet data immediately follows the packet. There should be
|
||
|
// ByteCount bytes following the packet header. Read the packet
|
||
|
// data, if read times out (10 seconds) then start again looking for
|
||
|
// a packet leader.
|
||
|
//
|
||
|
|
||
|
typedef struct _KD_PACKET {
|
||
|
UINT32 PacketLeader;
|
||
|
UINT16 PacketType;
|
||
|
UINT16 ByteCount;
|
||
|
UINT32 PacketId;
|
||
|
UINT32 Checksum;
|
||
|
} KD_PACKET, *PKD_PACKET;
|
||
|
|
||
|
#define PACKET_MAX_SIZE 4000
|
||
|
#define INITIAL_PACKET_ID 0x80800000 // Don't use 0
|
||
|
#define SYNC_PACKET_ID 0x00000800 // Or in with INITIAL_PACKET_ID
|
||
|
// to force a packet ID reset.
|
||
|
|
||
|
//
|
||
|
// Packet lead in sequence
|
||
|
//
|
||
|
|
||
|
#define PACKET_LEADER 0x30303030 //0x77000077
|
||
|
#define PACKET_LEADER_BYTE 0x30
|
||
|
|
||
|
#define CONTROL_PACKET_LEADER 0x69696969
|
||
|
#define CONTROL_PACKET_LEADER_BYTE 0x69
|
||
|
|
||
|
//
|
||
|
// Packet Trailing Byte
|
||
|
//
|
||
|
|
||
|
#define PACKET_TRAILING_BYTE 0xAA
|
||
|
|
||
|
//
|
||
|
// Packet Types
|
||
|
//
|
||
|
|
||
|
#define PACKET_TYPE_KD_DEBUG_IO 3
|
||
|
#define PACKET_TYPE_KD_ACKNOWLEDGE 4 // Packet-control type
|
||
|
#define PACKET_TYPE_KD_RESEND 5 // Packet-control type
|
||
|
#define PACKET_TYPE_KD_RESET 6 // Packet-control type
|
||
|
#define PACKET_TYPE_MAX 12
|
||
|
|
||
|
//
|
||
|
// Status Constants for reading data from comport
|
||
|
//
|
||
|
|
||
|
#define CP_GET_SUCCESS 0
|
||
|
#define CP_GET_NODATA 1
|
||
|
#define CP_GET_ERROR 2
|
||
|
|
||
|
#define DBGKD_64BIT_PROTOCOL_VERSION2 6
|
||
|
|
||
|
#pragma pack()
|
||
|
|
||
|
|