mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[KDCOM]
- Use stdlib.h header instead of declaring the atol function's prototype (caught by Jérôme). - Clarify the loop in KdpSendPacket (by Timo). NOTE: I also noticed that it was not this loop-change that fixed reconnection (see commit message of r58823), but one of the changes of revision r58822 (certainly the one in the KdpReceiveByte function) (ironically I said "Seems to fix..." since I noticed that change of behaviour when I was trying to play with the code in KdpSendPacket with modifications of r58822, but I didn't notice that in fact it happened with changes of r58822. It is only today that I constated that, during a revert of r58823 + test + a remark from Timo). svn path=/trunk/; revision=58834
This commit is contained in:
parent
dc93e99c9f
commit
1fda00d683
3 changed files with 43 additions and 23 deletions
|
@ -8,8 +8,7 @@
|
||||||
|
|
||||||
#include "kddll.h"
|
#include "kddll.h"
|
||||||
#include <cportlib/cportlib.h>
|
#include <cportlib/cportlib.h>
|
||||||
|
#include <stdlib.h>
|
||||||
long atol(const char *str);
|
|
||||||
|
|
||||||
|
|
||||||
/* Serial debug connection */
|
/* Serial debug connection */
|
||||||
|
|
|
@ -34,7 +34,10 @@ KdpCalculateChecksum(
|
||||||
PUCHAR ByteBuffer = Buffer;
|
PUCHAR ByteBuffer = Buffer;
|
||||||
ULONG Checksum = 0;
|
ULONG Checksum = 0;
|
||||||
|
|
||||||
while (Length-- > 0) Checksum += (ULONG)*ByteBuffer++;
|
while (Length-- > 0)
|
||||||
|
{
|
||||||
|
Checksum += (ULONG)*ByteBuffer++;
|
||||||
|
}
|
||||||
return Checksum;
|
return Checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,18 +338,8 @@ KdSendPacket(
|
||||||
|
|
||||||
Retries = KdContext->KdpDefaultRetries;
|
Retries = KdContext->KdpDefaultRetries;
|
||||||
|
|
||||||
do
|
for (;;)
|
||||||
{
|
{
|
||||||
if (Retries == 0)
|
|
||||||
{
|
|
||||||
/* PACKET_TYPE_KD_DEBUG_IO is allowed to instantly timeout */
|
|
||||||
if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
|
|
||||||
{
|
|
||||||
/* No response, silently fail. */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the packet id */
|
/* Set the packet id */
|
||||||
Packet.PacketId = CurrentPacketId;
|
Packet.PacketId = CurrentPacketId;
|
||||||
|
|
||||||
|
@ -357,7 +350,10 @@ KdSendPacket(
|
||||||
KdpSendBuffer(MessageHeader->Buffer, MessageHeader->Length);
|
KdpSendBuffer(MessageHeader->Buffer, MessageHeader->Length);
|
||||||
|
|
||||||
/* If we have meesage data, also send it */
|
/* If we have meesage data, also send it */
|
||||||
if (MessageData) KdpSendBuffer(MessageData->Buffer, MessageData->Length);
|
if (MessageData)
|
||||||
|
{
|
||||||
|
KdpSendBuffer(MessageData->Buffer, MessageData->Length);
|
||||||
|
}
|
||||||
|
|
||||||
/* Finalize with a trailing byte */
|
/* Finalize with a trailing byte */
|
||||||
KdpSendByte(PACKET_TRAILING_BYTE);
|
KdpSendByte(PACKET_TRAILING_BYTE);
|
||||||
|
@ -368,17 +364,37 @@ KdSendPacket(
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
KdContext);
|
KdContext);
|
||||||
if (KdStatus == KDP_PACKET_TIMEOUT)
|
|
||||||
|
/* Did we succeed? */
|
||||||
|
if (KdStatus == KDP_PACKET_RECEIVED)
|
||||||
{
|
{
|
||||||
if (Retries > 0) Retries--;
|
/* Packet received, we can quit the loop */
|
||||||
|
CurrentPacketId &= ~SYNC_PACKET_ID;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
else if (KdStatus == KDP_PACKET_TIMEOUT)
|
||||||
|
{
|
||||||
|
/* Timeout, decrement the retry count */
|
||||||
|
if (Retries > 0)
|
||||||
|
Retries--;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the retry count reaches zero, bail out
|
||||||
|
* for packet types allowed to timeout.
|
||||||
|
*/
|
||||||
|
if (Retries == 0)
|
||||||
|
{
|
||||||
|
if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// else (KdStatus == KDP_PACKET_RESEND) /* Resend the packet */
|
||||||
|
|
||||||
/* Packet timed out, send it again */
|
/* Packet timed out, send it again */
|
||||||
KDDBGPRINT("KdSendPacket got KdStatus 0x%x\n", KdStatus);
|
KDDBGPRINT("KdSendPacket got KdStatus 0x%x\n", KdStatus);
|
||||||
|
}
|
||||||
} while (KdStatus != KDP_PACKET_RECEIVED);
|
|
||||||
|
|
||||||
CurrentPacketId &= ~SYNC_PACKET_ID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -24,7 +24,10 @@ KdpSendBuffer(
|
||||||
{
|
{
|
||||||
PUCHAR ByteBuffer = Buffer;
|
PUCHAR ByteBuffer = Buffer;
|
||||||
|
|
||||||
while (Size-- > 0) KdpSendByte(*ByteBuffer++);
|
while (Size-- > 0)
|
||||||
|
{
|
||||||
|
KdpSendByte(*ByteBuffer++);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -49,7 +52,9 @@ KdpReceiveBuffer(
|
||||||
{
|
{
|
||||||
/* Try to get a byte from the port */
|
/* Try to get a byte from the port */
|
||||||
Status = KdpReceiveByte(&Byte);
|
Status = KdpReceiveByte(&Byte);
|
||||||
if (Status != KDP_PACKET_RECEIVED) return Status;
|
if (Status != KDP_PACKET_RECEIVED)
|
||||||
|
return Status;
|
||||||
|
|
||||||
*ByteBuffer++ = Byte;
|
*ByteBuffer++ = Byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue