[CPORTLIB][FREELDR][KD][NTOS] Move duplicated UART settings into a common header

This commit is contained in:
Hermès Bélusca-Maïto
2026-03-16 16:18:43 +01:00
parent 73413d4ca3
commit 3012af5e30
9 changed files with 65 additions and 134 deletions
+2
View File
@@ -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);
+3 -25
View File
@@ -24,36 +24,14 @@
/* INCLUDES *******************************************************************/
#include <freeldr.h>
#include <cportlib/cportlib.h>
#if DBG
#include <cportlib/cportlib.h>
#include <cportlib/uartinfo.h>
/* 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;
+2 -6
View File
@@ -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 <cportlib/uartinfo.h>
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.
+2 -33
View File
@@ -8,44 +8,13 @@
#include "kddll.h"
#include <cportlib/cportlib.h>
#include <arc/arc.h>
#include <stdio.h>
#include <stdlib.h>
#include <ndk/halfuncs.h>
/* 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 <cportlib/cportlib.h>
#include <cportlib/uartinfo.h>
/* GLOBALS ********************************************************************/
+2 -33
View File
@@ -7,43 +7,12 @@
#include "kdgdb.h"
#include <cportlib/cportlib.h>
#include <arc/arc.h>
#include <stdlib.h>
#include <ndk/halfuncs.h>
/* 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 <cportlib/cportlib.h>
#include <cportlib/uartinfo.h>
/* GLOBALS ********************************************************************/
+3 -24
View File
@@ -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 <debug.h>
#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 <cportlib/cportlib.h>
#include <cportlib/uartinfo.h>
/* STATIC VARIABLES ***********************************************************/
-13
View File
@@ -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
+1
View File
@@ -16,6 +16,7 @@
#ifdef KDBG
#include "../kdbg/kdb.h"
#endif
#include <cportlib/uartinfo.h>
#define NDEBUG
#include <debug.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 <[email protected]>
*/
#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 */