- Directly use CpGetByte and Co. functions from the CPortLib since they are working ok.
- Remove unusued variables.

svn path=/trunk/; revision=58822
This commit is contained in:
Hermès Bélusca-Maïto 2013-04-21 23:23:30 +00:00
parent bc461d6fa9
commit 8aa27c3f4e
4 changed files with 16 additions and 46 deletions

View file

@ -176,52 +176,33 @@ KDP_STATUS
NTAPI NTAPI
KdpPollByte(OUT PBYTE OutByte) KdpPollByte(OUT PBYTE OutByte)
{ {
/* Get the byte */ /* Poll the byte */
if (CpGetByte(&KdDebugComPort, OutByte, FALSE) == CP_GET_SUCCESS) return (CpGetByte(&KdDebugComPort, OutByte, FALSE) == CP_GET_SUCCESS
{ ? KDP_PACKET_RECEIVED
/* Yes, return the byte */ : KDP_PACKET_TIMEOUT);
return KDP_PACKET_RECEIVED;
}
else
{
/* Timed out */
return KDP_PACKET_TIMEOUT;
}
} }
KDP_STATUS KDP_STATUS
NTAPI NTAPI
KdpReceiveByte(OUT PBYTE OutByte) KdpReceiveByte(OUT PBYTE OutByte)
{ {
// TODO: Use CpGetByte(&KdDebugComPort, OutByte, TRUE); /* Get the byte */
return (CpGetByte(&KdDebugComPort, OutByte, TRUE) == CP_GET_SUCCESS
ULONG Repeats = KdpStallScaleFactor * 100; ? KDP_PACKET_RECEIVED
: KDP_PACKET_TIMEOUT);
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;
} }
KDP_STATUS KDP_STATUS
NTAPI NTAPI
KdpPollBreakIn(VOID) KdpPollBreakIn(VOID)
{ {
KDP_STATUS KdStatus;
UCHAR Byte; 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; return KDP_PACKET_TIMEOUT;
} }

View file

@ -12,9 +12,7 @@
PFNDBGPRNT KdpDbgPrint = NULL; PFNDBGPRNT KdpDbgPrint = NULL;
ULONG CurrentPacketId = INITIAL_PACKET_ID | SYNC_PACKET_ID; ULONG CurrentPacketId = INITIAL_PACKET_ID | SYNC_PACKET_ID;
ULONG RemotePacketId = 0; ULONG RemotePacketId = INITIAL_PACKET_ID;
BOOLEAN KdpPhase1Complete = FALSE;
ULONG KdpStallScaleFactor = 10000;
/* PRIVATE FUNCTIONS **********************************************************/ /* PRIVATE FUNCTIONS **********************************************************/
@ -89,9 +87,6 @@ NTAPI
KdDebuggerInitialize1( KdDebuggerInitialize1(
IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
{ {
KdpStallScaleFactor = KeGetPcr()->StallScaleFactor * 100;
KdpPhase1Complete = TRUE;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

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

View file

@ -22,7 +22,7 @@ KdpSendBuffer(
IN PVOID Buffer, IN PVOID Buffer,
IN ULONG Size) IN ULONG Size)
{ {
INT i; ULONG i;
for (i = 0; i < Size; i++) for (i = 0; i < Size; i++)
{ {
KdpSendByte(((PUCHAR)Buffer)[i]); KdpSendByte(((PUCHAR)Buffer)[i]);
@ -51,11 +51,7 @@ KdpReceiveBuffer(
{ {
/* Try to get a byte from the port */ /* Try to get a byte from the port */
Status = KdpReceiveByte(&ByteBuffer[i]); Status = KdpReceiveByte(&ByteBuffer[i]);
if (Status != KDP_PACKET_RECEIVED) return Status;
if (Status != KDP_PACKET_RECEIVED)
{
return Status;
}
} }
return KDP_PACKET_RECEIVED; return KDP_PACKET_RECEIVED;