From b56283a15fc266661e0df5c6f49f3c565cfe7222 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 22 Apr 2013 00:28:16 +0000 Subject: [PATCH] [KDCOM] - Code reorganization: put all the port control functions together. - Little simplifications of some functions (from CORE-7106). svn path=/trunk/; revision=58825 --- reactos/drivers/base/kddll/kdcom.c | 60 ++++++++++++++++++++------- reactos/drivers/base/kddll/kddll.c | 40 ++---------------- reactos/drivers/base/kddll/kdserial.c | 17 ++++---- 3 files changed, 55 insertions(+), 62 deletions(-) diff --git a/reactos/drivers/base/kddll/kdcom.c b/reactos/drivers/base/kddll/kdcom.c index 30743a14f6a..985dfa75e0b 100644 --- a/reactos/drivers/base/kddll/kdcom.c +++ b/reactos/drivers/base/kddll/kdcom.c @@ -41,6 +41,36 @@ ULONG KdDebugComPortIrq = 0; // Not used at the moment. /* FUNCTIONS ******************************************************************/ +NTSTATUS +NTAPI +KdD0Transition(VOID) +{ + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +KdD3Transition(VOID) +{ + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +KdSave(IN BOOLEAN SleepTransition) +{ + /* Nothing to do on COM ports */ + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +KdRestore(IN BOOLEAN SleepTransition) +{ + /* Nothing to do on COM ports */ + return STATUS_SUCCESS; +} + NTSTATUS NTAPI KdpPortInitialize(IN ULONG ComPortNumber, @@ -167,6 +197,20 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) return KdpPortInitialize(ComPortNumber, ComPortBaudRate); } +/****************************************************************************** + * \name KdDebuggerInitialize1 + * \brief Phase 1 initialization. + * \param [opt] LoaderBlock Pointer to the Loader parameter block. Can be NULL. + * \return Status + */ +NTSTATUS +NTAPI +KdDebuggerInitialize1(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) +{ + return STATUS_SUCCESS; +} + + VOID NTAPI KdpSendByte(IN UCHAR Byte) @@ -210,20 +254,4 @@ KdpPollBreakIn(VOID) return KDP_PACKET_TIMEOUT; } -NTSTATUS -NTAPI -KdSave(IN BOOLEAN SleepTransition) -{ - /* Nothing to do on COM ports */ - return STATUS_SUCCESS; -} - -NTSTATUS -NTAPI -KdRestore(IN BOOLEAN SleepTransition) -{ - /* Nothing to do on COM ports */ - return STATUS_SUCCESS; -} - /* EOF */ diff --git a/reactos/drivers/base/kddll/kddll.c b/reactos/drivers/base/kddll/kddll.c index 819696bd827..3976dea4bb9 100644 --- a/reactos/drivers/base/kddll/kddll.c +++ b/reactos/drivers/base/kddll/kddll.c @@ -31,13 +31,10 @@ KdpCalculateChecksum( IN PVOID Buffer, IN ULONG Length) { - ULONG i, Checksum = 0; - - for (i = 0; i < Length; i++) - { - Checksum += ((PUCHAR)Buffer)[i]; - } + PUCHAR ByteBuffer = Buffer; + ULONG Checksum = 0; + while (Length-- > 0) Checksum += (ULONG)*ByteBuffer++; return Checksum; } @@ -61,36 +58,6 @@ KdpSendControlPacket( /* PUBLIC FUNCTIONS ***********************************************************/ -NTSTATUS -NTAPI -KdD0Transition(VOID) -{ - return STATUS_SUCCESS; -} - -NTSTATUS -NTAPI -KdD3Transition(VOID) -{ - return STATUS_SUCCESS; -} - - -/****************************************************************************** - * \name KdDebuggerInitialize1 - * \brief Phase 1 initialization. - * \param [opt] LoaderBlock Pointer to the Loader parameter block. Can be NULL. - * \return Status - */ -NTSTATUS -NTAPI -KdDebuggerInitialize1( - IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) -{ - return STATUS_SUCCESS; -} - - /****************************************************************************** * \name KdReceivePacket * \brief Receive a packet from the KD port. @@ -339,7 +306,6 @@ KdReceivePacket( return KDP_PACKET_RECEIVED; } - VOID NTAPI KdSendPacket( diff --git a/reactos/drivers/base/kddll/kdserial.c b/reactos/drivers/base/kddll/kdserial.c index c7228e923d9..f884b554872 100644 --- a/reactos/drivers/base/kddll/kdserial.c +++ b/reactos/drivers/base/kddll/kdserial.c @@ -8,7 +8,7 @@ #include "kddll.h" - +/* FUNCTIONS ******************************************************************/ /****************************************************************************** * \name KdpSendBuffer @@ -22,11 +22,9 @@ KdpSendBuffer( IN PVOID Buffer, IN ULONG Size) { - ULONG i; - for (i = 0; i < Size; i++) - { - KdpSendByte(((PUCHAR)Buffer)[i]); - } + PUCHAR ByteBuffer = Buffer; + + while (Size-- > 0) KdpSendByte(*ByteBuffer++); } /****************************************************************************** @@ -43,15 +41,16 @@ KdpReceiveBuffer( OUT PVOID Buffer, IN ULONG Size) { - ULONG i; PUCHAR ByteBuffer = Buffer; + UCHAR Byte; KDP_STATUS Status; - for (i = 0; i < Size; i++) + while (Size-- > 0) { /* Try to get a byte from the port */ - Status = KdpReceiveByte(&ByteBuffer[i]); + Status = KdpReceiveByte(&Byte); if (Status != KDP_PACKET_RECEIVED) return Status; + *ByteBuffer++ = Byte; } return KDP_PACKET_RECEIVED; -- 2.17.1