https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9658c6a2207bc52d5cdca…
commit 9658c6a2207bc52d5cdcab3a6a9ef3145bd6ec1b
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sat Aug 27 16:09:41 2022 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Thu Nov 24 21:17:58 2022 +0200
[NTOSKRNL] Print boot cycles on x64 just like on x86
---
ntoskrnl/include/internal/amd64/ke.h | 24 +++++++++++++++++++++++-
ntoskrnl/ke/amd64/kiinit.c | 5 +++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/ntoskrnl/include/internal/amd64/ke.h b/ntoskrnl/include/internal/amd64/ke.h
index 97fa0f997b8..318b119d513 100644
--- a/ntoskrnl/include/internal/amd64/ke.h
+++ b/ntoskrnl/include/internal/amd64/ke.h
@@ -1,6 +1,10 @@
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_AMD64_KE_H
#define __NTOSKRNL_INCLUDE_INTERNAL_AMD64_KE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define X86_EFLAGS_TF 0x00000100 /* Trap flag */
#define X86_EFLAGS_IF 0x00000200 /* Interrupt Enable flag */
#define X86_EFLAGS_IOPL 0x00003000 /* I/O Privilege Level bits */
@@ -363,7 +367,21 @@ KiUserTrap(IN PKTRAP_FRAME TrapFrame)
return !!(TrapFrame->SegCs & MODE_MASK);
}
-#define Ki386PerfEnd()
+//
+// PERF Code
+//
+FORCEINLINE
+VOID
+Ki386PerfEnd(VOID)
+{
+ extern ULONGLONG BootCyclesEnd, BootCycles;
+ BootCyclesEnd = __rdtsc();
+ DbgPrint("Boot took %I64u cycles!\n", BootCyclesEnd - BootCycles);
+ DbgPrint("Interrupts: %u System Calls: %u Context Switches: %u\n",
+ KeGetCurrentPrcb()->InterruptCount,
+ KeGetCurrentPrcb()->KeSystemCalls,
+ KeGetContextSwitches(KeGetCurrentPrcb()));
+}
struct _KPCR;
@@ -455,6 +473,10 @@ KiSetTrapContext(
_In_ PCONTEXT Context,
_In_ KPROCESSOR_MODE RequestorMode);
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_AMD64_KE_H */
/* EOF */
diff --git a/ntoskrnl/ke/amd64/kiinit.c b/ntoskrnl/ke/amd64/kiinit.c
index 310810475ea..65819290f46 100644
--- a/ntoskrnl/ke/amd64/kiinit.c
+++ b/ntoskrnl/ke/amd64/kiinit.c
@@ -34,6 +34,8 @@ UCHAR DECLSPEC_ALIGN(16) KiDoubleFaultStackData[KERNEL_STACK_SIZE] =
{0};
ULONG_PTR P0BootStack = (ULONG_PTR)&P0BootStackData[KERNEL_STACK_SIZE];
ULONG_PTR KiDoubleFaultStack =
(ULONG_PTR)&KiDoubleFaultStackData[KERNEL_STACK_SIZE];
+ULONGLONG BootCycles, BootCyclesEnd;
+
void KiInitializeSegments();
void KiSystemCallEntry64();
void KiSystemCallEntry32();
@@ -382,6 +384,9 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
ULONG64 InitialStack;
PKIPCR Pcr;
+ /* Boot cycles timestamp */
+ BootCycles = __rdtsc();
+
/* HACK */
FrLdrDbgPrint = LoaderBlock->u.I386.CommonDataArea;
//FrLdrDbgPrint("Hello from KiSystemStartup!!!\n");