From b1a31610ac2f5270016fecebb7eacd0d20d0772b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Thu, 19 Mar 2026 17:20:28 +0100 Subject: [PATCH] [FREELDR][KDCOM][KDGDB] Remove deprecated "IRQ" debugger command-line option - The "IRQ" debugger option was introduced in commit 5a6adb4f13 (r2546). It was used by the in-kernel GDB stub, to manually wire an interrupt handler `GspBreakIn()` to allow the debugger to break into the system when a command is received on the GDB serial port. Side-remark: The hooking was done via `HalGetInterruptVector()` + `IoConnectInterrupt()`, but only at phase 1 initialization when the memory manager was up, which can be "late" enough during system boot initialization. Instead of using `IoConnectInterrupt()`, one could have used explicit `KeInitializeInterrupt()` + `KeConnectInterrupt()` calls that would have worked much earlier in the boot stage. - This functionality was soon after disabled in commit c804ca06be (r2946) in the GDB stub (see `ntoskrnl/kd/gdbstub.c!KdGdbStubInit()`), never to be re-enabled again. It was removed completely in commit e160c0fb26 (r14799). - Since ReactOS was (until recently) always debugged locally using the in-kernel KDBG debugger, break-in was done with TAB-K keypress, intercepted by the keyboard driver that triggered a `DbgBreakPoint()`, thus no break-in via serial port interrupt was necessary. - Remote debugger break-in detection, which is the standard method that is used when remote-debugging using KD transport DLLs and WinDbg, was introduced in commit 12e7593f24 (r25984). As with the rest of debugger communication and as done on Windows, detection is done by polling the serial port at certain times, namely in the `KeUpdateSystemTime()` kernel procedure periodically invoked by the timer interrupt. This break-in detection was then erroneously removed in commit bf8b9467dc (r45140), and reinstated in commit 014b23b9a (r56194). - Parsing of this "IRQ" option was copy-pasted in other modules (FreeLoader, KDCOM, and KDGDB), even though it was never used. The parsing was then removed in KDBG itself in commit 95faf65ebf, but left in the other modules... until now! --- boot/freeldr/freeldr/lib/debug.c | 22 +------------------- drivers/base/kdcom/kdcom.c | 22 +------------------- drivers/base/kdgdb/kdcom.c | 22 +------------------- sdk/include/reactos/libs/cportlib/uartinfo.h | 4 ---- 4 files changed, 3 insertions(+), 67 deletions(-) diff --git a/boot/freeldr/freeldr/lib/debug.c b/boot/freeldr/freeldr/lib/debug.c index a04cadc3822..f7170ccd21f 100644 --- a/boot/freeldr/freeldr/lib/debug.c +++ b/boot/freeldr/freeldr/lib/debug.c @@ -46,7 +46,6 @@ ULONG DebugPort = RS232; #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. BOOLEAN DebugStartOfLine = TRUE; @@ -60,7 +59,7 @@ DebugInit( _In_ PCSTR DebugString) { static BOOLEAN Initialized = FALSE; - PSTR CommandLine, PortString, BaudString, IrqString; + PSTR CommandLine, PortString, BaudString; ULONG Value; CHAR DbgStringBuffer[256]; @@ -107,7 +106,6 @@ DebugInit( /* Get the port and baud rate */ PortString = strstr(CommandLine, "DEBUGPORT"); BaudString = strstr(CommandLine, "BAUDRATE"); - IrqString = strstr(CommandLine, "IRQ"); /* * Check if we got /DEBUGPORT parameters. @@ -164,24 +162,6 @@ DebugInit( } } - /* Check Serial Port Settings [IRQ] */ - if (IrqString) - { - /* Move past the actual string, to reach the rate */ - IrqString += strlen("IRQ"); - - /* Now get past any spaces */ - while (*IrqString == ' ') IrqString++; - - /* And make sure we have an IRQ */ - if (*IrqString) - { - /* Read and set it */ - Value = atol(IrqString + 1); - if (Value) PortIrq = Value; - } - } - Done: Initialized = TRUE; diff --git a/drivers/base/kdcom/kdcom.c b/drivers/base/kdcom/kdcom.c index f8a60fc35d4..d83ec56ad75 100644 --- a/drivers/base/kdcom/kdcom.c +++ b/drivers/base/kdcom/kdcom.c @@ -19,7 +19,6 @@ /* GLOBALS ********************************************************************/ CPPORT KdComPort; -ULONG KdComPortIrq = 0; // Not used at the moment. #ifdef KDDEBUG CPPORT KdDebugComPort; #endif @@ -129,7 +128,7 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) ULONG ComPortNumber = DEFAULT_DEBUG_PORT; ULONG ComPortBaudRate = DEFAULT_DEBUG_BAUD_RATE; - PCHAR CommandLine, PortString, BaudString, IrqString; + PSTR CommandLine, PortString, BaudString; ULONG Value; /* Check if we have a LoaderBlock */ @@ -144,7 +143,6 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) /* Get the port and baud rate */ PortString = strstr(CommandLine, "DEBUGPORT"); BaudString = strstr(CommandLine, "BAUDRATE"); - IrqString = strstr(CommandLine, "IRQ"); /* Check if we got the /DEBUGPORT parameter */ if (PortString) @@ -191,24 +189,6 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) if (Value) ComPortBaudRate = Value; } } - - /* Check Serial Port Settings [IRQ] */ - if (IrqString) - { - /* Move past the actual string, to reach the rate */ - IrqString += strlen("IRQ"); - - /* Now get past any spaces */ - while (*IrqString == ' ') IrqString++; - - /* And make sure we have an IRQ */ - if (*IrqString) - { - /* Read and set it */ - Value = atol(IrqString + 1); - if (Value) KdComPortIrq = Value; - } - } } #ifdef KDDEBUG diff --git a/drivers/base/kdgdb/kdcom.c b/drivers/base/kdgdb/kdcom.c index e53ec94a98a..df96d177179 100644 --- a/drivers/base/kdgdb/kdcom.c +++ b/drivers/base/kdgdb/kdcom.c @@ -17,7 +17,6 @@ /* GLOBALS ********************************************************************/ CPPORT KdComPort; -ULONG KdComPortIrq = 0; // Not used at the moment. #ifdef KDDEBUG CPPORT KdDebugComPort; #endif @@ -123,7 +122,7 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) ULONG ComPortNumber = DEFAULT_DEBUG_PORT; ULONG ComPortBaudRate = DEFAULT_DEBUG_BAUD_RATE; - PCHAR CommandLine, PortString, BaudString, IrqString; + PSTR CommandLine, PortString, BaudString; ULONG Value; /* Check if we have a LoaderBlock */ @@ -138,7 +137,6 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) /* Get the port and baud rate */ PortString = strstr(CommandLine, "DEBUGPORT"); BaudString = strstr(CommandLine, "BAUDRATE"); - IrqString = strstr(CommandLine, "IRQ"); /* Check if we got the /DEBUGPORT parameter */ if (PortString) @@ -185,24 +183,6 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) if (Value) ComPortBaudRate = Value; } } - - /* Check Serial Port Settings [IRQ] */ - if (IrqString) - { - /* Move past the actual string, to reach the rate */ - IrqString += strlen("IRQ"); - - /* Now get past any spaces */ - while (*IrqString == ' ') IrqString++; - - /* And make sure we have an IRQ */ - if (*IrqString) - { - /* Read and set it */ - Value = atol(IrqString + 1); - if (Value) KdComPortIrq = Value; - } - } } #ifdef KDDEBUG diff --git a/sdk/include/reactos/libs/cportlib/uartinfo.h b/sdk/include/reactos/libs/cportlib/uartinfo.h index c78913dad5a..99507ddf697 100644 --- a/sdk/include/reactos/libs/cportlib/uartinfo.h +++ b/sdk/include/reactos/libs/cportlib/uartinfo.h @@ -11,13 +11,9 @@ /* 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