kdcom: add a debug hack to use com2 for WinDbg, while com1 stays for FrLdrDbgPrint. Also mark the Port as initialized in KdDebuggerInitialize0. Remove the KD_RECV_CODE enum, use the KDSTATUS enum that already exist. Implement PACKET_TYPE_KD_POLL_BREAKIN case for KdReceivePacket as described in http://www.nynaeve.net/?p=169 Now we return from KdPollBreakIn().

svn path=/branches/ros-amd64-bringup/; revision=38965
This commit is contained in:
Timo Kreuzer
2009-01-20 01:50:13 +00:00
parent 9313950dd3
commit 2aa87f6dc5

View File

@@ -22,13 +22,6 @@
#include <kddll.h>
#include <ioaccess.h> /* port intrinsics */
typedef enum _KD_RECV_CODE
{
KD_RECV_CODE_OK = 0,
KD_RECV_CODE_TIMEOUT = 1,
KD_RECV_CODE_FAILED = 2
} KD_RECV_CODE, * PKD_RECV_CODE;
typedef struct _KD_PORT_INFORMATION
{
ULONG ComPort;
@@ -541,13 +534,14 @@ KdpSendBuffer(
}
}
/******************************************************************************
* \name KdpReceiveBuffer
* \brief Recieves data from the KD port and fills a buffer.
* \param Buffer Pointer to a buffer that receives the data.
* \param Size Size of data to receive in bytes.
* \return KD_RECV_CODE_OK if successful.
* KD_RECV_CODE_TIMEOUT if the receice timed out (10 seconds).
* \return KdPacketReceived if successful.
* KdPacketTimedOut if the receice timed out (10 seconds).
* \todo Handle timeout.
*/
KDSTATUS
@@ -571,12 +565,12 @@ KdpReceiveBuffer(
if (TimeOut)
{
return KD_RECV_CODE_TIMEOUT;
return KdPacketTimedOut;
}
FrLdrDbgPrint("Received byte: %x\n", ByteBuffer[i]);
}
return KD_RECV_CODE_OK;
return KdPacketReceived;
}
/* NEW PUBLIC FUNCTIONS ******************************************************/
@@ -679,6 +673,9 @@ KdDebuggerInitialize0(
}
}
// HACK use com1 for FrLdrDbg, com2 for WinDbg
DefaultPort.ComPort = 2;
/* Get base address */
DefaultPort.BaseAddress = BaseArray[DefaultPort.ComPort];
@@ -690,6 +687,7 @@ KdDebuggerInitialize0(
/* Initialize the port */
KdPortInitializeEx(&DefaultPort, 0, 0);
PortInitialized = TRUE;
return STATUS_SUCCESS;
}
@@ -707,7 +705,6 @@ KdDebuggerInitialize1(
{
// HACK: misuse this function to get a pointer to FrLdrDbgPrint
FrLdrDbgPrint = (PVOID)LoaderBlock;
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
@@ -774,8 +771,21 @@ KdSendPacket(
return;
}
/*
* @unimplemented
/******************************************************************************
* \name KdReceivePacket
* \brief Receive a packet from the KD port.
* \param [in] PacketType Describes the type of the packet to receive.
* This can be one of the PACKET_TYPE_ constants.
* \param [out] MessageHeader Pointer to a STRING structure for the header.
* \param [out] MessageData Pointer to a STRING structure for the data.
* \return KdPacketReceived if successful, KdPacketTimedOut if the receive
* timed out, KdPacketNeedsResend to signal that the last packet needs
* to be sent again.
* \note If PacketType is PACKET_TYPE_KD_POLL_BREAKIN, the function doesn't
* wait for any data, but returns KdPacketTimedOut instantly if no breakin
* packet byte is received.
* \sa http://www.nynaeve.net/?p=169
*/
KDSTATUS
NTAPI
@@ -786,8 +796,24 @@ KdReceivePacket(
OUT PULONG DataLength,
IN OUT PKD_CONTEXT Context)
{
// UNIMPLEMENTED;
return 0;
UCHAR BreakIn = 0;
/* Special handling for breakin packet */
if(PacketType == PACKET_TYPE_KD_POLL_BREAKIN)
{
if (KdPortGetByteEx(&DefaultPort, &BreakIn))
{
if (BreakIn == BREAKIN_PACKET_BYTE)
{
return KdPacketReceived;
}
}
return KdPacketTimedOut;
}
// FIXME: handle other cases
return KdPacketReceived;
}
/* EOF */