From 8aa27c3f4e91f741d3aca2eb97c50abdfb771b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 21 Apr 2013 23:23:30 +0000 Subject: [PATCH] [KDCOM] - Directly use CpGetByte and Co. functions from the CPortLib since they are working ok. - Remove unusued variables. svn path=/trunk/; revision=58822 --- reactos/drivers/base/kddll/kdcom.c | 45 ++++++++------------------- reactos/drivers/base/kddll/kddll.c | 7 +---- reactos/drivers/base/kddll/kddll.h | 2 -- reactos/drivers/base/kddll/kdserial.c | 8 ++--- 4 files changed, 16 insertions(+), 46 deletions(-) diff --git a/reactos/drivers/base/kddll/kdcom.c b/reactos/drivers/base/kddll/kdcom.c index ea017d8b0f1..3a87ab10be7 100644 --- a/reactos/drivers/base/kddll/kdcom.c +++ b/reactos/drivers/base/kddll/kdcom.c @@ -176,52 +176,33 @@ KDP_STATUS NTAPI KdpPollByte(OUT PBYTE OutByte) { - /* Get the byte */ - if (CpGetByte(&KdDebugComPort, OutByte, FALSE) == CP_GET_SUCCESS) - { - /* Yes, return the byte */ - return KDP_PACKET_RECEIVED; - } - else - { - /* Timed out */ - return KDP_PACKET_TIMEOUT; - } + /* Poll the byte */ + return (CpGetByte(&KdDebugComPort, OutByte, FALSE) == CP_GET_SUCCESS + ? KDP_PACKET_RECEIVED + : KDP_PACKET_TIMEOUT); } KDP_STATUS NTAPI KdpReceiveByte(OUT PBYTE OutByte) { - // TODO: Use CpGetByte(&KdDebugComPort, OutByte, TRUE); - - ULONG Repeats = KdpStallScaleFactor * 100; - - while (Repeats--) - { - /* Check if data is available */ - if (KdpPollByte(OutByte) == KDP_PACKET_RECEIVED) - { - /* We successfully got a byte */ - return KDP_PACKET_RECEIVED; - } - } - - /* Timed out */ - return KDP_PACKET_TIMEOUT; + /* Get the byte */ + return (CpGetByte(&KdDebugComPort, OutByte, TRUE) == CP_GET_SUCCESS + ? KDP_PACKET_RECEIVED + : KDP_PACKET_TIMEOUT); } KDP_STATUS NTAPI KdpPollBreakIn(VOID) { + KDP_STATUS KdStatus; UCHAR Byte; - if (KdpPollByte(&Byte) == KDP_PACKET_RECEIVED) + + KdStatus = KdpPollByte(&Byte); + if ((KdStatus == KDP_PACKET_RECEIVED) && (Byte == BREAKIN_PACKET_BYTE)) { - if (Byte == BREAKIN_PACKET_BYTE) - { - return KDP_PACKET_RECEIVED; - } + return KDP_PACKET_RECEIVED; } return KDP_PACKET_TIMEOUT; } diff --git a/reactos/drivers/base/kddll/kddll.c b/reactos/drivers/base/kddll/kddll.c index 027306daf85..a5b92473035 100644 --- a/reactos/drivers/base/kddll/kddll.c +++ b/reactos/drivers/base/kddll/kddll.c @@ -12,9 +12,7 @@ PFNDBGPRNT KdpDbgPrint = NULL; ULONG CurrentPacketId = INITIAL_PACKET_ID | SYNC_PACKET_ID; -ULONG RemotePacketId = 0; -BOOLEAN KdpPhase1Complete = FALSE; -ULONG KdpStallScaleFactor = 10000; +ULONG RemotePacketId = INITIAL_PACKET_ID; /* PRIVATE FUNCTIONS **********************************************************/ @@ -89,9 +87,6 @@ NTAPI KdDebuggerInitialize1( IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) { - KdpStallScaleFactor = KeGetPcr()->StallScaleFactor * 100; - KdpPhase1Complete = TRUE; - return STATUS_SUCCESS; } diff --git a/reactos/drivers/base/kddll/kddll.h b/reactos/drivers/base/kddll/kddll.h index 6e461fe0500..6d7e6e4a758 100644 --- a/reactos/drivers/base/kddll/kddll.h +++ b/reactos/drivers/base/kddll/kddll.h @@ -28,8 +28,6 @@ typedef UCHAR BYTE, *PBYTE; typedef ULONG (*PFNDBGPRNT)(const char *Format, ...); extern PFNDBGPRNT KdpDbgPrint; -extern BOOLEAN KdpPhase1Complete; -extern ULONG KdpStallScaleFactor; typedef enum { diff --git a/reactos/drivers/base/kddll/kdserial.c b/reactos/drivers/base/kddll/kdserial.c index f3149a4efa3..b41904bc06a 100644 --- a/reactos/drivers/base/kddll/kdserial.c +++ b/reactos/drivers/base/kddll/kdserial.c @@ -22,7 +22,7 @@ KdpSendBuffer( IN PVOID Buffer, IN ULONG Size) { - INT i; + ULONG i; for (i = 0; i < Size; i++) { KdpSendByte(((PUCHAR)Buffer)[i]); @@ -51,11 +51,7 @@ KdpReceiveBuffer( { /* Try to get a byte from the port */ Status = KdpReceiveByte(&ByteBuffer[i]); - - if (Status != KDP_PACKET_RECEIVED) - { - return Status; - } + if (Status != KDP_PACKET_RECEIVED) return Status; } return KDP_PACKET_RECEIVED;