Author: tkreuzer Date: Mon Jan 19 19:50:13 2009 New Revision: 38965
URL: http://svn.reactos.org/svn/reactos?rev=38965&view=rev Log: 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().
Modified: branches/ros-amd64-bringup/reactos/drivers/base/kdcom/i386/kdbg.c
Modified: branches/ros-amd64-bringup/reactos/drivers/base/kdcom/i386/kdbg.c URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/driver... ============================================================================== --- branches/ros-amd64-bringup/reactos/drivers/base/kdcom/i386/kdbg.c [iso-8859-1] (original) +++ branches/ros-amd64-bringup/reactos/drivers/base/kdcom/i386/kdbg.c [iso-8859-1] Mon Jan 19 19:50:13 2009 @@ -21,13 +21,6 @@ #include "windbgkd.h" #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 { @@ -541,13 +534,14 @@ } }
+ /****************************************************************************** * \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 @@
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 @@ } }
+ // HACK use com1 for FrLdrDbg, com2 for WinDbg + DefaultPort.ComPort = 2; + /* Get base address */ DefaultPort.BaseAddress = BaseArray[DefaultPort.ComPort];
@@ -690,6 +687,7 @@
/* Initialize the port */ KdPortInitializeEx(&DefaultPort, 0, 0); + PortInitialized = TRUE;
return STATUS_SUCCESS; } @@ -707,7 +705,6 @@ { // HACK: misuse this function to get a pointer to FrLdrDbgPrint FrLdrDbgPrint = (PVOID)LoaderBlock; - UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; }
@@ -774,8 +771,21 @@ 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 @@ 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 */