https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9ff9bd81c4259db3e0279…
commit 9ff9bd81c4259db3e027999dd5c05341ffaa9b4e
Author: Serge Gautherie <reactos-git_serge_171003(a)gautherie.fr>
AuthorDate: Sat Feb 3 00:19:18 2018 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Tue Aug 7 20:36:04 2018 +0200
[NTOSKRNL] Round memory size up, "debug log" part
Assumed to better match actual physical RAM size.
CORE-12321
---
ntoskrnl/ex/init.c | 5 +++--
ntoskrnl/kd/kdio.c | 9 ++++++---
ntoskrnl/kd64/kdinit.c | 3 ++-
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/ntoskrnl/ex/init.c b/ntoskrnl/ex/init.c
index 826cc3b356..1e9a9c07f8 100644
--- a/ntoskrnl/ex/init.c
+++ b/ntoskrnl/ex/init.c
@@ -1580,8 +1580,9 @@ Phase1InitializationDiscard(IN PVOID Context)
WINDOWS_NT_INFO_STRING,
&MsgEntry);
- /* Get total RAM size */
- Size = MmNumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024;
+ /* Get total RAM size, in MiB */
+ /* Round size up. Assumed to better match actual physical RAM size */
+ Size = ALIGN_UP_BY(MmNumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) / (1024 *
1024);
/* Create the string */
StringBuffer = InitBuffer->VersionBuffer;
diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c
index 53c99c43d4..38a1d3fc9a 100644
--- a/ntoskrnl/kd/kdio.c
+++ b/ntoskrnl/kd/kdio.c
@@ -93,7 +93,8 @@ KdpGetMemorySizeInMBs(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
}
}
- return NumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024;
+ /* 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 */
@@ -255,7 +256,8 @@ KdpInitDebugLog(PKD_DISPATCH_TABLE DispatchTable,
KeInitializeSpinLock(&KdpDebugLogSpinLock);
/* Display separator + ReactOS version at start of the debug log */
- MemSizeMBs = MmNumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024;
+ /* 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)
@@ -554,7 +556,8 @@ KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable,
KeInitializeSpinLock(&KdpDmesgLogSpinLock);
/* Display separator + ReactOS version at start of the debug log */
- MemSizeMBs = MmNumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024;
+ /* 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)
diff --git a/ntoskrnl/kd64/kdinit.c b/ntoskrnl/kd64/kdinit.c
index 64a7c7b519..b6a8beb9ce 100644
--- a/ntoskrnl/kd64/kdinit.c
+++ b/ntoskrnl/kd64/kdinit.c
@@ -62,7 +62,8 @@ KdpGetMemorySizeInMBs(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
}
}
- return NumberOfPhysicalPages * PAGE_SIZE / 1024 / 1024;
+ /* 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 */