Use KeStallExecutionProcessor, once its ready (after KdDebuggerInitialize1 was called) for the receive timeout. Repeat 100 times with 1 ms wait. This seems to work quite well, but might be tuned for better values.

svn path=/trunk/; revision=52482
This commit is contained in:
Timo Kreuzer 2011-06-27 16:51:00 +00:00
parent 2f7cf157d8
commit 0f06493485
3 changed files with 22 additions and 8 deletions

View file

@ -10,7 +10,7 @@
#include "kdcom.h"
/* Define wait timeout value. */
#define REPEAT_COUNT (1000 * 1000)
#define REPEAT_COUNT 100
/* serial debug connection */
#define DEFAULT_DEBUG_PORT 2 /* COM2 */
@ -258,6 +258,20 @@ KdpReceiveByte(OUT PBYTE OutByte)
/* We successfully got a byte */
return KDP_PACKET_RECEIVED;
}
/* Check if phase 1 is complete */
if (KdpPhase1Complete)
{
/* Use hal to wait 1ms */
KeStallExecutionProcessor(1000);
}
else
{
volatile unsigned long i;
/* Do some busy waiting */
for (i = 0; i < 1000; i++);
}
}
/* Timed out */

View file

@ -14,6 +14,7 @@
PFNDBGPRNT KdpDbgPrint = NULL;
ULONG CurrentPacketId = INITIAL_PACKET_ID | SYNC_PACKET_ID;
ULONG RemotePacketId = 0;
BOOLEAN KdpPhase1Complete = FALSE;
/* PRIVATE FUNCTIONS **********************************************************/
@ -88,11 +89,9 @@ NTAPI
KdDebuggerInitialize1(
IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
{
// HACK: misuse this function to get a pointer to FrLdrDbgPrint
KdpDbgPrint = (PVOID)LoaderBlock;
KDDBGPRINT("KdDebuggerInitialize1\n");
KdpPhase1Complete = TRUE;
return STATUS_NOT_IMPLEMENTED;
return STATUS_SUCCESS;
}
@ -198,7 +197,7 @@ KdReceivePacket(
switch (Packet.PacketType)
{
case PACKET_TYPE_KD_ACKNOWLEDGE:
/* Are we waiting for an ACK packet? */
/* Are we waiting for an ACK packet? */
if (PacketType == PACKET_TYPE_KD_ACKNOWLEDGE &&
Packet.PacketId == (CurrentPacketId & ~SYNC_PACKET_ID))
{
@ -276,7 +275,7 @@ KdReceivePacket(
if (MessageData)
{
/* Set the length of the message data */
MessageData->Length = *DataLength;
MessageData->Length = (USHORT)*DataLength;
/* Do we have data? */
if (MessageData->Length)
@ -359,7 +358,7 @@ KdSendPacket(
/* Initialize a KD_PACKET */
Packet.PacketLeader = PACKET_LEADER;
Packet.PacketType = PacketType;
Packet.PacketType = (USHORT)PacketType;
Packet.ByteCount = MessageHeader->Length;
Packet.Checksum = KdpCalculateChecksum(MessageHeader->Buffer,
MessageHeader->Length);

View file

@ -25,6 +25,7 @@ typedef UCHAR BYTE, *PBYTE;
typedef ULONG (*PFNDBGPRNT)(const char *Format, ...);
extern PFNDBGPRNT KdpDbgPrint;
extern BOOLEAN KdpPhase1Complete;
typedef enum
{