https://git.reactos.org/?p=reactos.git;a=commitdiff;h=58332b076c7ae20fd32869...
commit 58332b076c7ae20fd328690dc7631b78786ba12b Author: Hervé Poussineau hpoussin@reactos.org AuthorDate: Mon Feb 15 23:20:15 2021 +0100 Commit: Hervé Poussineau hpoussin@reactos.org CommitDate: Tue Feb 16 00:12:25 2021 +0100
[NTOS:KD] Merge initialization phases 1 and 2, and fix log file debugging
Phase 2 and 3 were not done anymore since 777a2d94da285f9ab612680ebb9f5d412b74fb68.
Fix that, by merging phases 1 and 2, and by calling phase 3 later for log file debugging, when ExpInitializationPhase = 3
CORE-17470 --- ntoskrnl/kd/kdio.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c index c1b01dec20b..288977bebbc 100644 --- a/ntoskrnl/kd/kdio.c +++ b/ntoskrnl/kd/kdio.c @@ -19,6 +19,7 @@
#define KdpBufferSize (1024 * 512) static BOOLEAN KdpLoggingEnabled = FALSE; +static BOOLEAN KdpLoggingStarting = FALSE; static PCHAR KdpDebugBuffer = NULL; static volatile ULONG KdpCurrentPosition = 0; static volatile ULONG KdpFreeBytes = 0; @@ -26,6 +27,7 @@ static KSPIN_LOCK KdpDebugLogSpinLock; static KEVENT KdpLoggerThreadEvent; static HANDLE KdpLogFileHandle; ANSI_STRING KdpLogFileName = RTL_CONSTANT_STRING("\SystemRoot\debug.log"); +extern ULONG ExpInitializationPhase;
static KSPIN_LOCK KdpSerialSpinLock; ULONG SerialPortNumber = DEFAULT_DEBUG_PORT; @@ -155,6 +157,7 @@ KdpPrintToLogFile(PCHAR String, { KIRQL OldIrql; ULONG beg, end, num; + BOOLEAN DoReinit = FALSE;
if (KdpDebugBuffer == NULL) return;
@@ -184,8 +187,18 @@ KdpPrintToLogFile(PCHAR String, }
/* Release the spinlock */ + if (OldIrql == PASSIVE_LEVEL && !KdpLoggingStarting && !KdpLoggingEnabled && ExpInitializationPhase >= 2) + { + DoReinit = TRUE; + } KdpReleaseLock(&KdpDebugLogSpinLock, OldIrql);
+ if (DoReinit) + { + KdpLoggingStarting = TRUE; + KdpDebugLogInit(NULL, 3); + } + /* Signal the logger thread */ if (OldIrql <= DISPATCH_LEVEL && KdpLoggingEnabled) KeSetEvent(&KdpLoggerThreadEvent, IO_NO_INCREMENT, FALSE); @@ -224,9 +237,7 @@ KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable,
/* Initialize spinlock */ KeInitializeSpinLock(&KdpDebugLogSpinLock); - } - else if (BootPhase == 2) - { + HalDisplayString("\r\n File log debugging enabled\r\n\r\n"); } else if (BootPhase == 3) @@ -338,7 +349,7 @@ KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable, /* Register as a Provider */ InsertTailList(&KdProviders, &DispatchTable->KdProvidersList); } - else if (BootPhase == 2) + else if (BootPhase == 1) { HalDisplayString("\r\n Serial debugging enabled\r\n\r\n"); } @@ -508,9 +519,7 @@ KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable,
/* Initialize spinlock */ KeInitializeSpinLock(&KdpDmesgLogSpinLock); - } - else if (BootPhase == 2) - { + HalDisplayString("\r\n Screen debugging enabled\r\n\r\n"); } }