Author: hbelusca
Date: Wed Nov 28 23:23:54 2012
New Revision: 57781
URL:
http://svn.reactos.org/svn/reactos?rev=57781&view=rev
Log:
[KDDLL]
- Use cportlib for COM port facilities. Fixes COM port debugging output with Virtual PC
2007.
- Remove now unneeded header file.
CORE-4247 #comment Fixed in r57776, r57777, r57780 and r57781. #resolve
Removed:
trunk/reactos/drivers/base/kddll/kdcom.h
Modified:
trunk/reactos/drivers/base/kddll/CMakeLists.txt
trunk/reactos/drivers/base/kddll/kdcom.c
trunk/reactos/drivers/base/kddll/kddll.h
Modified: trunk/reactos/drivers/base/kddll/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kddll/CMakeLi…
==============================================================================
--- trunk/reactos/drivers/base/kddll/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/kddll/CMakeLists.txt [iso-8859-1] Wed Nov 28 23:23:54 2012
@@ -10,7 +10,9 @@
set_entrypoint(kdcom 0)
set_subsystem(kdcom native)
set_image_base(kdcom 0x00010000)
+
add_importlibs(kdcom ntoskrnl hal)
+target_link_libraries(kdcom cportlib)
add_dependencies(kdcom psdk bugcodes)
add_cd_file(TARGET kdcom DESTINATION reactos/system32 NO_CAB FOR all)
Modified: trunk/reactos/drivers/base/kddll/kdcom.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kddll/kdcom.c…
==============================================================================
--- trunk/reactos/drivers/base/kddll/kdcom.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/kddll/kdcom.c [iso-8859-1] Wed Nov 28 23:23:54 2012
@@ -7,9 +7,9 @@
*/
#include "kddll.h"
-#include "kdcom.h"
-
-/* serial debug connection */
+#include <cportlib/cportlib.h>
+
+/* Serial debug connection */
#define DEFAULT_DEBUG_PORT 2 /* COM2 */
#define DEFAULT_DEBUG_COM1_IRQ 4 /* COM1 IRQ */
#define DEFAULT_DEBUG_COM2_IRQ 3 /* COM2 IRQ */
@@ -19,91 +19,46 @@
#if defined(_M_IX86) || defined(_M_AMD64)
-const ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
+const ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
#elif defined(_M_PPC)
-const ULONG BaseArray[2] = {0, 0x800003f8};
+const ULONG BaseArray[] = {0, 0x800003F8};
#elif defined(_M_MIPS)
-const ULONG BaseArray[3] = {0, 0x80006000, 0x80007000};
+const ULONG BaseArray[] = {0, 0x80006000, 0x80007000};
#elif defined(_M_ARM)
-const ULONG BaseArray[2] = {0, 0xF1012000};
+const ULONG BaseArray[] = {0, 0xF1012000};
#else
#error Unknown architecture
#endif
/* GLOBALS ********************************************************************/
-PUCHAR ComPortBase;
-ULONG ComPortNumber = DEFAULT_DEBUG_PORT;
-ULONG ComPortBaudRate = DEFAULT_DEBUG_BAUD_RATE;
-ULONG ComPortIrq = 0;
-
-
-NTSTATUS
-NTAPI
-KdpPortInitialize()
-{
- ULONG Mode;
+CPPORT KdDebugComPort;
+ULONG KdDebugComPortIrq = 0; // Not used at the moment.
+
+
+/* FUNCTIONS ******************************************************************/
+
+NTSTATUS
+NTAPI
+KdpPortInitialize(IN ULONG ComPortNumber,
+ IN ULONG ComPortBaudRate)
+{
+ NTSTATUS Status;
KDDBGPRINT("KdpPortInitialize, Port = COM%ld\n", ComPortNumber);
- /* Enable loop mode (set Bit 4 of the MCR) */
- WRITE_PORT_UCHAR(ComPortBase + COM_MCR, MCR_LOOP);
-
- /* Clear all modem output bits */
- WRITE_PORT_UCHAR(ComPortBase + COM_MCR, MCR_LOOP);
-
- /* The upper nibble of the MSR (modem output bits) must be
- * equal to the lower nibble of the MCR (modem input bits) */
- if ((READ_PORT_UCHAR(ComPortBase + COM_MSR) & 0xF0) != 0x00)
+ Status = CpInitialize(&KdDebugComPort,
+ UlongToPtr(BaseArray[ComPortNumber]),
+ ComPortBaudRate);
+ if (!NT_SUCCESS(Status))
{
return STATUS_INVALID_PARAMETER;
}
-
- /* Set all modem output bits */
- WRITE_PORT_UCHAR(ComPortBase + COM_MCR, MCR_ALL);
-
- /* The upper nibble of the MSR (modem output bits) must be
- * equal to the lower nibble of the MCR (modem input bits) */
- if ((READ_PORT_UCHAR(ComPortBase + COM_MSR) & 0xF0) != 0xF0)
- {
- return STATUS_INVALID_PARAMETER;
- }
-
- /* Enable FIFO */
- WRITE_PORT_UCHAR(ComPortBase + COM_FCR,
- FCR_ENABLE_FIFO | FCR_CLEAR_RCVR | FCR_CLEAR_XMIT);
-
- /* Disable interrupts */
- WRITE_PORT_UCHAR(ComPortBase + COM_LCR, 0);
- WRITE_PORT_UCHAR(ComPortBase + COM_IEN, 0);
-
- /* Enable on DTR and RTS */
- WRITE_PORT_UCHAR(ComPortBase + COM_MCR, MCR_DTR | MCR_RTS);
-
- /* Set DLAB */
- WRITE_PORT_UCHAR(ComPortBase + COM_LCR, LCR_DLAB);
-
- /* Set baud rate */
- Mode = 115200 / ComPortBaudRate;
- WRITE_PORT_UCHAR(ComPortBase + COM_DLL, (UCHAR)(Mode & 0xff));
- WRITE_PORT_UCHAR(ComPortBase + COM_DLM, (UCHAR)((Mode >> 8) & 0xff));
-
- /* Reset DLAB and set 8 data bits, 1 stop bit, no parity, no break */
- WRITE_PORT_UCHAR(ComPortBase + COM_LCR, LCR_CS8 | LCR_ST1 | LCR_PNO);
-
- /* Check for 16450/16550 scratch register */
- WRITE_PORT_UCHAR(ComPortBase + COM_SCR, 0xff);
- if (READ_PORT_UCHAR(ComPortBase + COM_SCR) != 0xff)
- {
- return STATUS_INVALID_PARAMETER;
- }
- WRITE_PORT_UCHAR(ComPortBase + COM_SCR, 0x00);
- if (READ_PORT_UCHAR(ComPortBase + COM_SCR) != 0x00)
- {
- return STATUS_INVALID_PARAMETER;
- }
-
- return STATUS_SUCCESS;
+ else
+ {
+ KdComPortInUse = KdDebugComPort.Address;
+ return STATUS_SUCCESS;
+ }
}
/******************************************************************************
@@ -114,9 +69,11 @@
*/
NTSTATUS
NTAPI
-KdDebuggerInitialize0(
- IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
-{
+KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL)
+{
+ ULONG ComPortNumber = DEFAULT_DEBUG_PORT;
+ ULONG ComPortBaudRate = DEFAULT_DEBUG_BAUD_RATE;
+
PCHAR CommandLine, PortString, BaudString, IrqString;
ULONG Value;
@@ -136,7 +93,7 @@
/* Get the port and baud rate */
PortString = strstr(CommandLine, "DEBUGPORT");
BaudString = strstr(CommandLine, "BAUDRATE");
- IrqString = strstr(CommandLine, "IRQ");
+ IrqString = strstr(CommandLine, "IRQ");
/* Check if we got the /DEBUGPORT parameter */
if (PortString)
@@ -154,10 +111,10 @@
return STATUS_INVALID_PARAMETER;
}
- /* Gheck for a valid Serial Port */
+ /* Check for a valid Serial Port */
PortString += 3;
Value = atol(PortString);
- if (Value > 4)
+ if (Value >= sizeof(BaseArray) / sizeof(BaseArray[0]))
{
return STATUS_INVALID_PARAMETER;
}
@@ -198,47 +155,56 @@
{
/* Read and set it */
Value = atol(IrqString + 1);
- if (Value) ComPortIrq = Value;
- }
- }
- }
-
- /* Get base address */
- ComPortBase = UlongToPtr(BaseArray[ComPortNumber]);
- KdComPortInUse = ComPortBase;
+ if (Value) KdDebugComPortIrq = Value;
+ }
+ }
+ }
/* Initialize the port */
- return KdpPortInitialize();
+ return KdpPortInitialize(ComPortNumber, ComPortBaudRate);
}
VOID
NTAPI
KdpSendByte(IN BYTE Byte)
{
- /* Wait for the port to be ready */
- while ((READ_PORT_UCHAR(ComPortBase + COM_LSR) & LSR_TBE) == 0);
-
- /* This is needed due to subtle timing issues */
- READ_PORT_UCHAR(ComPortBase + COM_MSR);
- while ((READ_PORT_UCHAR(ComPortBase + COM_LSR) & LSR_TBE) == 0);
- READ_PORT_UCHAR(ComPortBase + COM_MSR);
-
/* Send the byte */
- WRITE_PORT_UCHAR(ComPortBase + COM_DAT, Byte);
+ CpPutByte(&KdDebugComPort, Byte);
}
KDP_STATUS
NTAPI
KdpPollByte(OUT PBYTE OutByte)
{
- READ_PORT_UCHAR(ComPortBase + COM_MSR); // Timing
-
- /* Check if data is available */
- if ((READ_PORT_UCHAR(ComPortBase + COM_LSR) & LSR_DR))
+ /* Get the byte */
+ if (CpGetByte(&KdDebugComPort, OutByte, FALSE) == CP_GET_SUCCESS)
{
/* Yes, return the byte */
- *OutByte = READ_PORT_UCHAR(ComPortBase + COM_DAT);
return KDP_PACKET_RECEIVED;
+ }
+ else
+ {
+ /* Timed out */
+ return 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 */
@@ -247,27 +213,7 @@
KDP_STATUS
NTAPI
-KdpReceiveByte(OUT PBYTE OutByte)
-{
- 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;
-}
-
-KDP_STATUS
-NTAPI
-KdpPollBreakIn()
+KdpPollBreakIn(VOID)
{
UCHAR Byte;
if (KdpPollByte(&Byte) == KDP_PACKET_RECEIVED)
@@ -282,8 +228,7 @@
NTSTATUS
NTAPI
-KdSave(
- IN BOOLEAN SleepTransition)
+KdSave(IN BOOLEAN SleepTransition)
{
/* Nothing to do on COM ports */
return STATUS_SUCCESS;
@@ -291,10 +236,10 @@
NTSTATUS
NTAPI
-KdRestore(
- IN BOOLEAN SleepTransition)
+KdRestore(IN BOOLEAN SleepTransition)
{
/* Nothing to do on COM ports */
return STATUS_SUCCESS;
}
+/* EOF */
Removed: trunk/reactos/drivers/base/kddll/kdcom.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kddll/kdcom.h…
==============================================================================
--- trunk/reactos/drivers/base/kddll/kdcom.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/kddll/kdcom.h (removed)
@@ -1,54 +1,0 @@
-/*
- * COPYRIGHT: GPL, see COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: drivers/base/kddll/kdcom.h
- * PURPOSE: COM port definitions for the kernel debugger.
- * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)ewactos.org)
- */
-
-#pragma once
-
-#define COM_DAT 0x00
-#define COM_IEN 0x01 /* interrupt enable register */
-#define COM_FCR 0x02 /* FIFO Control Register */
-#define COM_LCR 0x03 /* line control registers */
-#define COM_MCR 0x04 /* modem control reg */
-#define COM_LSR 0x05 /* line status register */
-#define COM_MSR 0x06 /* modem status register */
-#define COM_SCR 0x07 /* scratch register */
-#define COM_DLL 0x00 /* divisor latch least sig */
-#define COM_DLM 0x01 /* divisor latch most sig */
-
-#define IEN_ERDA 0x01
-#define IEN_ETHRE 0x02
-#define IEN_ERLSI 0x04
-#define IEN_EMS 0x08
-#define IEN_ALL 0x0F
-#define FCR_ENABLE_FIFO 0x01
-#define FCR_CLEAR_RCVR 0x02
-#define FCR_CLEAR_XMIT 0x04
-#define LCR_CS5 0x00
-#define LCR_CS6 0x01
-#define LCR_CS7 0x02
-#define LCR_CS8 0x03
-#define LCR_ST1 0x00
-#define LCR_ST2 0x04
-#define LCR_PNO 0x00
-#define LCR_POD 0x08
-#define LCR_PEV 0x18
-#define LCR_PMK 0x28
-#define LCR_PSP 0x38
-#define LCR_BRK 0x40
-#define LCR_DLAB 0x80
-#define MCR_DTR 0x01
-#define MCR_RTS 0x02
-#define MCR_OUT1 0x04 /* general purpose output */
-#define MCR_OUT2 0x08
-#define MCR_LOOP 0x10 /* loopback testing mode */
-#define MCR_ALL (MCR_DTR | MCR_RTS | MCR_OUT1 | MCR_OUT2 | MCR_LOOP)
-#define LSR_DR 0x01
-#define LSR_TBE 0x20
-#define MSR_CTS 0x10 /* (complemented) state of clear to send (CTS). */
-#define MSR_DSR 0x20 /* (complemented) state of data set ready (DSR). */
-#define MSR_RI 0x40 /* (complemented) state of ring indicator (RI). */
-#define MSR_DCD 0x80 /* (complemented) state of data carrier detect (DCD). */
Modified: trunk/reactos/drivers/base/kddll/kddll.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/kddll/kddll.h…
==============================================================================
--- trunk/reactos/drivers/base/kddll/kddll.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/kddll/kddll.h [iso-8859-1] Wed Nov 28 23:23:54 2012
@@ -12,14 +12,15 @@
#define NOEXTAPI
#include <ntifs.h>
-#define NDEBUG
#include <halfuncs.h>
-#include <debug.h>
#include "arc/arc.h"
#include "windbgkd.h"
#include <wdbgexts.h>
#include <ioaccess.h> /* port intrinsics */
+
+#define NDEBUG
+#include <debug.h>
long atol(const char *str);