https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9b43a3a067965830ea217…
commit 9b43a3a067965830ea21757d1950439e5d8d4eaa
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Sat Mar 7 17:32:49 2020 +0100
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Mon Nov 16 08:55:02 2020 +0100
[NTOS:KD] Move implementation of banner display from each debug output type to common
code
---
ntoskrnl/kd/kdinit.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++
ntoskrnl/kd/kdio.c | 81 ----------------------------------------------------
2 files changed, 72 insertions(+), 81 deletions(-)
diff --git a/ntoskrnl/kd/kdinit.c b/ntoskrnl/kd/kdinit.c
index a2ed88ca6ee..d50f9fd0558 100644
--- a/ntoskrnl/kd/kdinit.c
+++ b/ntoskrnl/kd/kdinit.c
@@ -8,6 +8,7 @@
*/
#include <ntoskrnl.h>
+#include <reactos/buildno.h>
#define NDEBUG
#include <debug.h>
@@ -39,6 +40,71 @@ extern ANSI_STRING KdpLogFileName;
/* PRIVATE FUNCTIONS *********************************************************/
+/*
+ * Get the total size of the memory before
+ * Mm is initialized, by counting the number
+ * of physical pages. Useful for debug logging.
+ *
+ * Strongly inspired by:
+ * mm\ARM3\mminit.c : MiScanMemoryDescriptors(...)
+ *
+ * See also: kd\kdio.c
+ */
+static CODE_SEG("INIT")
+SIZE_T
+KdpGetMemorySizeInMBs(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+ PLIST_ENTRY ListEntry;
+ PMEMORY_ALLOCATION_DESCRIPTOR Descriptor;
+ SIZE_T NumberOfPhysicalPages = 0;
+
+ /* Loop the memory descriptors */
+ for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Flink;
+ ListEntry != &LoaderBlock->MemoryDescriptorListHead;
+ ListEntry = ListEntry->Flink)
+ {
+ /* Get the descriptor */
+ Descriptor = CONTAINING_RECORD(ListEntry,
+ MEMORY_ALLOCATION_DESCRIPTOR,
+ ListEntry);
+
+ /* Check if this is invisible memory */
+ if ((Descriptor->MemoryType == LoaderFirmwarePermanent) ||
+ (Descriptor->MemoryType == LoaderSpecialMemory) ||
+ (Descriptor->MemoryType == LoaderHALCachedMemory) ||
+ (Descriptor->MemoryType == LoaderBBTMemory))
+ {
+ /* Skip this descriptor */
+ continue;
+ }
+
+ /* Check if this is bad memory */
+ if (Descriptor->MemoryType != LoaderBad)
+ {
+ /* Count this in the total of pages */
+ NumberOfPhysicalPages += Descriptor->PageCount;
+ }
+ }
+
+ /* Round size up. Assumed to better match actual physical RAM size */
+ return ALIGN_UP_BY(NumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) / (1024 * 1024);
+}
+
+/* See also: kd\kdio.c */
+static CODE_SEG("INIT")
+VOID
+KdpPrintBanner(IN SIZE_T MemSizeMBs)
+{
+ DPRINT1("-----------------------------------------------------\n");
+ DPRINT1("ReactOS " KERNEL_VERSION_STR " (Build "
KERNEL_VERSION_BUILD_STR ") (Commit " KERNEL_VERSION_COMMIT_HASH
")\n");
+ DPRINT1("%u System Processor [%u MB Memory]\n", KeNumberProcessors,
MemSizeMBs);
+
+ if (KeLoaderBlock)
+ {
+ DPRINT1("Command Line: %s\n", KeLoaderBlock->LoadOptions);
+ DPRINT1("ARC Paths: %s %s %s %s\n",
KeLoaderBlock->ArcBootDeviceName, KeLoaderBlock->NtHalPathName,
KeLoaderBlock->ArcHalDeviceName, KeLoaderBlock->NtBootPathName);
+ }
+}
BOOLEAN
NTAPI
KdRegisterDebuggerDataBlock(IN ULONG Tag,
@@ -84,6 +150,7 @@ KdInitSystem(IN ULONG BootPhase,
PLDR_DATA_TABLE_ENTRY LdrEntry;
ULONG i;
PCHAR CommandLine;
+ SIZE_T MemSizeMBs;
/* Check if this is Phase 1 */
if (BootPhase)
@@ -234,6 +301,11 @@ KdInitSystem(IN ULONG BootPhase,
/* Let user-mode know that it's enabled as well */
SharedUserData->KdDebuggerEnabled = TRUE;
+
+ /* Display separator + ReactOS version at start of the debug log */
+ MemSizeMBs = KdpGetMemorySizeInMBs(KeLoaderBlock);
+ KdpPrintBanner(MemSizeMBs);
+
}
else
{
diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c
index 0e72108ec2c..21d98615fe6 100644
--- a/ntoskrnl/kd/kdio.c
+++ b/ntoskrnl/kd/kdio.c
@@ -46,70 +46,6 @@ volatile ULONG KdbDmesgTotalWritten = 0;
volatile BOOLEAN KdbpIsInDmesgMode = FALSE;
static KSPIN_LOCK KdpDmesgLogSpinLock;
-/* UTILITY FUNCTIONS *********************************************************/
-
-/*
- * Get the total size of the memory before
- * Mm is initialized, by counting the number
- * of physical pages. Useful for debug logging.
- *
- * Strongly inspired by:
- * mm\ARM3\mminit.c : MiScanMemoryDescriptors(...)
- *
- * See also: kd64\kdinit.c
- */
-static CODE_SEG("INIT")
-SIZE_T
-KdpGetMemorySizeInMBs(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
-{
- PLIST_ENTRY ListEntry;
- PMEMORY_ALLOCATION_DESCRIPTOR Descriptor;
- SIZE_T NumberOfPhysicalPages = 0;
-
- /* Loop the memory descriptors */
- for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Flink;
- ListEntry != &LoaderBlock->MemoryDescriptorListHead;
- ListEntry = ListEntry->Flink)
- {
- /* Get the descriptor */
- Descriptor = CONTAINING_RECORD(ListEntry,
- MEMORY_ALLOCATION_DESCRIPTOR,
- ListEntry);
-
- /* Check if this is invisible memory */
- if ((Descriptor->MemoryType == LoaderFirmwarePermanent) ||
- (Descriptor->MemoryType == LoaderSpecialMemory) ||
- (Descriptor->MemoryType == LoaderHALCachedMemory) ||
- (Descriptor->MemoryType == LoaderBBTMemory))
- {
- /* Skip this descriptor */
- continue;
- }
-
- /* Check if this is bad memory */
- if (Descriptor->MemoryType != LoaderBad)
- {
- /* Count this in the total of pages */
- NumberOfPhysicalPages += Descriptor->PageCount;
- }
- }
-
- /* Round size up. Assumed to better match actual physical RAM size */
- return ALIGN_UP_BY(NumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) / (1024 * 1024);
-}
-
-/* See also: kd64\kdinit.c */
-static CODE_SEG("INIT")
-VOID
-KdpPrintBanner(IN SIZE_T MemSizeMBs)
-{
- DPRINT1("-----------------------------------------------------\n");
- DPRINT1("ReactOS " KERNEL_VERSION_STR " (Build "
KERNEL_VERSION_BUILD_STR ") (Commit " KERNEL_VERSION_COMMIT_HASH
")\n");
- DPRINT1("%u System Processor [%u MB Memory]\n", KeNumberProcessors,
MemSizeMBs);
- DPRINT1("Command Line: %s\n", KeLoaderBlock->LoadOptions);
- DPRINT1("ARC Paths: %s %s %s %s\n", KeLoaderBlock->ArcBootDeviceName,
KeLoaderBlock->NtHalPathName, KeLoaderBlock->ArcHalDeviceName,
KeLoaderBlock->NtBootPathName);
-}
-
/* LOCKING FUNCTIONS *********************************************************/
KIRQL
@@ -254,7 +190,6 @@ KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable,
IO_STATUS_BLOCK Iosb;
HANDLE ThreadHandle;
KPRIORITY Priority;
- SIZE_T MemSizeMBs;
if (!KdpDebugMode.File) return;
@@ -277,11 +212,6 @@ KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable,
/* Initialize spinlock */
KeInitializeSpinLock(&KdpDebugLogSpinLock);
-
- /* Display separator + ReactOS version at start of the debug log */
- /* Round size up. Assumed to better match actual physical RAM size */
- MemSizeMBs = ALIGN_UP_BY(MmNumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) /
(1024 * 1024);
- KdpPrintBanner(MemSizeMBs);
}
else if (BootPhase == 2)
{
@@ -374,7 +304,6 @@ NTAPI
KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable,
ULONG BootPhase)
{
- SIZE_T MemSizeMBs;
if (!KdpDebugMode.Serial) return;
if (BootPhase == 0)
@@ -396,10 +325,6 @@ KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable,
/* Register as a Provider */
InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
-
- /* Display separator + ReactOS version at start of the debug log */
- MemSizeMBs = KdpGetMemorySizeInMBs(KeLoaderBlock);
- KdpPrintBanner(MemSizeMBs);
}
else if (BootPhase == 2)
{
@@ -545,7 +470,6 @@ NTAPI
KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable,
ULONG BootPhase)
{
- SIZE_T MemSizeMBs;
if (!KdpDebugMode.Screen) return;
if (BootPhase == 0)
@@ -572,11 +496,6 @@ KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable,
/* Initialize spinlock */
KeInitializeSpinLock(&KdpDmesgLogSpinLock);
-
- /* Display separator + ReactOS version at start of the debug log */
- /* Round size up. Assumed to better match actual physical RAM size */
- MemSizeMBs = ALIGN_UP_BY(MmNumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) /
(1024 * 1024);
- KdpPrintBanner(MemSizeMBs);
}
else if (BootPhase == 2)
{