diff --git a/boot/freeldr/freeldr/include/comm.h b/boot/freeldr/freeldr/include/comm.h index 12fcf52d000..d3ffb40f9e5 100644 --- a/boot/freeldr/freeldr/include/comm.h +++ b/boot/freeldr/freeldr/include/comm.h @@ -21,8 +21,10 @@ #pragma once +#if DBG BOOLEAN Rs232PortInitialize(ULONG ComPort, ULONG BaudRate); BOOLEAN Rs232PortGetByte(PUCHAR ByteReceived); // BOOLEAN Rs232PortPollByte(PUCHAR ByteReceived); VOID Rs232PortPutByte(UCHAR ByteToSend); +#endif BOOLEAN Rs232PortInUse(PUCHAR Base); diff --git a/boot/freeldr/freeldr/lib/comm/rs232.c b/boot/freeldr/freeldr/lib/comm/rs232.c index 61309fcd39b..0d2bc404a8e 100644 --- a/boot/freeldr/freeldr/lib/comm/rs232.c +++ b/boot/freeldr/freeldr/lib/comm/rs232.c @@ -24,36 +24,14 @@ /* INCLUDES *******************************************************************/ #include -#include #if DBG +#include +#include + /* STATIC VARIABLES ***********************************************************/ -#if defined(SARCH_PC98) -#define DEFAULT_BAUD_RATE 9600 -#else -#define DEFAULT_BAUD_RATE 19200 -#endif - -#if defined(_M_IX86) || defined(_M_AMD64) -#if defined(SARCH_PC98) -static const ULONG BaseArray[] = {0, 0x30, 0x238}; -#else -static const ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; -#endif -#elif defined(_M_PPC) -static const ULONG BaseArray[] = {0, 0x800003F8}; -#elif defined(_M_MIPS) -static const ULONG BaseArray[] = {0, 0x80006000, 0x80007000}; -#elif defined(_M_ARM) -static const ULONG BaseArray[] = {0, 0xF1012000}; -#else -#error Unknown architecture -#endif - -#define MAX_COM_PORTS (sizeof(BaseArray) / sizeof(BaseArray[0]) - 1) - /* The COM port must only be initialized once! */ static ULONG Rs232ComPort = 0; static CPPORT Rs232ComPortInfo; diff --git a/boot/freeldr/freeldr/lib/debug.c b/boot/freeldr/freeldr/lib/debug.c index efb059e2740..9f4dac422e4 100644 --- a/boot/freeldr/freeldr/lib/debug.c +++ b/boot/freeldr/freeldr/lib/debug.c @@ -43,12 +43,8 @@ static UCHAR DbgChannels[DBG_CHANNELS_COUNT]; ULONG DebugPort = RS232; /* Serial debug connection */ -#if defined(SARCH_PC98) -ULONG BaudRate = 9600; -#else -ULONG BaudRate = 115200; -#endif - +#include +ULONG BaudRate = DEFAULT_DEBUG_BAUD_RATE; ULONG ComPort = 0; // The COM port initializer chooses the first available port starting from COM4 down to COM1. ULONG PortIrq = 0; // Not used at the moment. diff --git a/drivers/base/kdcom/kdcom.c b/drivers/base/kdcom/kdcom.c index c4cfa39e177..f8a60fc35d4 100644 --- a/drivers/base/kdcom/kdcom.c +++ b/drivers/base/kdcom/kdcom.c @@ -8,44 +8,13 @@ #include "kddll.h" -#include #include #include #include #include -/* Serial debug connection */ -#if defined(SARCH_PC98) -#define DEFAULT_DEBUG_PORT 2 /* COM2 */ -#define DEFAULT_DEBUG_COM1_IRQ 4 -#define DEFAULT_DEBUG_COM2_IRQ 5 -#define DEFAULT_DEBUG_BAUD_RATE 9600 -#define DEFAULT_BAUD_RATE 9600 -#else -#define DEFAULT_DEBUG_PORT 2 /* COM2 */ -#define DEFAULT_DEBUG_COM1_IRQ 4 -#define DEFAULT_DEBUG_COM2_IRQ 3 -#define DEFAULT_DEBUG_BAUD_RATE 115200 -#define DEFAULT_BAUD_RATE 19200 -#endif - -#if defined(_M_IX86) || defined(_M_AMD64) -#if defined(SARCH_PC98) -const ULONG BaseArray[] = {0, 0x30, 0x238}; -#else -const ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; -#endif -#elif defined(_M_PPC) -const ULONG BaseArray[] = {0, 0x800003F8}; -#elif defined(_M_MIPS) -const ULONG BaseArray[] = {0, 0x80006000, 0x80007000}; -#elif defined(_M_ARM) -const ULONG BaseArray[] = {0, 0xF1012000}; -#else -#error Unknown architecture -#endif - -#define MAX_COM_PORTS (sizeof(BaseArray) / sizeof(BaseArray[0]) - 1) +#include +#include /* GLOBALS ********************************************************************/ diff --git a/drivers/base/kdgdb/kdcom.c b/drivers/base/kdgdb/kdcom.c index 18710247680..e53ec94a98a 100644 --- a/drivers/base/kdgdb/kdcom.c +++ b/drivers/base/kdgdb/kdcom.c @@ -7,43 +7,12 @@ #include "kdgdb.h" -#include #include #include #include -/* Serial debug connection */ -#if defined(SARCH_PC98) -#define DEFAULT_DEBUG_PORT 2 /* COM2 */ -#define DEFAULT_DEBUG_COM1_IRQ 4 -#define DEFAULT_DEBUG_COM2_IRQ 5 -#define DEFAULT_DEBUG_BAUD_RATE 9600 -#define DEFAULT_BAUD_RATE 9600 -#else -#define DEFAULT_DEBUG_PORT 2 /* COM2 */ -#define DEFAULT_DEBUG_COM1_IRQ 4 -#define DEFAULT_DEBUG_COM2_IRQ 3 -#define DEFAULT_DEBUG_BAUD_RATE 115200 -#define DEFAULT_BAUD_RATE 19200 -#endif - -#if defined(_M_IX86) || defined(_M_AMD64) -#if defined(SARCH_PC98) -const ULONG BaseArray[] = {0, 0x30, 0x238}; -#else -const ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; -#endif -#elif defined(_M_PPC) -const ULONG BaseArray[] = {0, 0x800003F8}; -#elif defined(_M_MIPS) -const ULONG BaseArray[] = {0, 0x80006000, 0x80007000}; -#elif defined(_M_ARM) -const ULONG BaseArray[] = {0, 0xF1012000}; -#else -#error Unknown architecture -#endif - -#define MAX_COM_PORTS (sizeof(BaseArray) / sizeof(BaseArray[0]) - 1) +#include +#include /* GLOBALS ********************************************************************/ diff --git a/ntoskrnl/kd/i386/kdserial.c b/ntoskrnl/kd/i386/kdserial.c index db5f75b54bc..0414054057a 100644 --- a/ntoskrnl/kd/i386/kdserial.c +++ b/ntoskrnl/kd/i386/kdserial.c @@ -4,7 +4,7 @@ * FILE: ntoskrnl/kd/i386/kdbg.c * PURPOSE: Serial i/o functions for the kernel debugger. * PROGRAMMER: Alex Ionescu - * Hervé Poussineau + * Hervé Poussineau */ /* INCLUDES *****************************************************************/ @@ -13,29 +13,8 @@ #define NDEBUG #include -#if defined(SARCH_PC98) -#define DEFAULT_BAUD_RATE 9600 -#else -#define DEFAULT_BAUD_RATE 19200 -#endif - -#if defined(_M_IX86) || defined(_M_AMD64) -#if defined(SARCH_PC98) -const ULONG BaseArray[] = {0, 0x30, 0x238}; -#else -const ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; -#endif -#elif defined(_M_PPC) -const ULONG BaseArray[] = {0, 0x800003F8}; -#elif defined(_M_MIPS) -const ULONG BaseArray[] = {0, 0x80006000, 0x80007000}; -#elif defined(_M_ARM) -const ULONG BaseArray[] = {0, 0xF1012000}; -#else -#error Unknown architecture -#endif - -#define MAX_COM_PORTS (sizeof(BaseArray) / sizeof(BaseArray[0]) - 1) +//#include +#include /* STATIC VARIABLES ***********************************************************/ diff --git a/ntoskrnl/kd/kd.h b/ntoskrnl/kd/kd.h index 0ac26af9398..53d277db909 100644 --- a/ntoskrnl/kd/kd.h +++ b/ntoskrnl/kd/kd.h @@ -76,19 +76,6 @@ KdpDebugLogInit( /* KD GLOBALS ****************************************************************/ -/* Serial debug connection */ -#if defined(SARCH_PC98) -#define DEFAULT_DEBUG_PORT 2 /* COM2 */ -#define DEFAULT_DEBUG_COM1_IRQ 4 /* COM1 IRQ */ -#define DEFAULT_DEBUG_COM2_IRQ 5 /* COM2 IRQ */ -#define DEFAULT_DEBUG_BAUD_RATE 9600 /* 9600 Baud */ -#else -#define DEFAULT_DEBUG_PORT 2 /* COM2 */ -#define DEFAULT_DEBUG_COM1_IRQ 4 /* COM1 IRQ */ -#define DEFAULT_DEBUG_COM2_IRQ 3 /* COM2 IRQ */ -#define DEFAULT_DEBUG_BAUD_RATE 115200 /* 115200 Baud */ -#endif - /* KD Native Modes */ // #define KdScreen 0 // #define KdSerial 1 diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c index 8c90e8da25c..73f2a68d73a 100644 --- a/ntoskrnl/kd/kdio.c +++ b/ntoskrnl/kd/kdio.c @@ -16,6 +16,7 @@ #ifdef KDBG #include "../kdbg/kdb.h" #endif +#include #define NDEBUG #include diff --git a/sdk/include/reactos/libs/cportlib/uartinfo.h b/sdk/include/reactos/libs/cportlib/uartinfo.h new file mode 100644 index 00000000000..c78913dad5a --- /dev/null +++ b/sdk/include/reactos/libs/cportlib/uartinfo.h @@ -0,0 +1,50 @@ +/* + * PROJECT: ReactOS ComPort Library + * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) + * or MIT (https://spdx.org/licenses/MIT) + * PURPOSE: Default UART Settings + * COPYRIGHT: Copyright 2022-2026 Hermès Bélusca-Maïto + */ + +#pragma once + +/* Serial debug connection */ +#if defined(SARCH_PC98) +#define DEFAULT_DEBUG_PORT 2 /* COM2 */ +#define DEFAULT_DEBUG_COM1_IRQ 4 +#define DEFAULT_DEBUG_COM2_IRQ 5 +#define DEFAULT_DEBUG_BAUD_RATE 9600 +#else +#define DEFAULT_DEBUG_PORT 2 /* COM2 */ +#define DEFAULT_DEBUG_COM1_IRQ 4 +#define DEFAULT_DEBUG_COM2_IRQ 3 +#define DEFAULT_DEBUG_BAUD_RATE 115200 +#endif + +/* Serial connection */ +#if defined(SARCH_PC98) +#define DEFAULT_BAUD_RATE 9600 +#else +#define DEFAULT_BAUD_RATE 19200 +#endif + +#if defined(_M_IX86) || defined(_M_AMD64) +#if defined(SARCH_PC98) +static const ULONG BaseArray[] = {0, 0x30, 0x238}; +#else +static const ULONG BaseArray[] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; +#endif +#elif defined(_M_PPC) +static const ULONG BaseArray[] = {0, 0x800003F8}; +#elif defined(_M_MIPS) +static const ULONG BaseArray[] = {0, 0x80006000, 0x80007000}; +#elif defined(_M_ARM) +static const ULONG BaseArray[] = {0, 0xF1012000}; +// #define QEMUUART ((ULONG)0x09000000) +#else +#error Unknown architecture +#endif + +#define MAX_COM_PORTS (sizeof(BaseArray) / sizeof(BaseArray[0]) - 1) + +/* EOF */