[NTOSKRNL] Print boot cycles on x64 just like on x86

This commit is contained in:
Timo Kreuzer 2022-08-27 16:09:41 +02:00
parent 225e0c89d9
commit 9658c6a220
2 changed files with 28 additions and 1 deletions

View file

@ -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 */

View file

@ -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");