EmulatorPkg WinThunk: Use Win32 API to get Performance Frequency and Count

Then we can use correct TimerLib in another code,
such as dpDynamicCommand(PerformanceLib).

These API are from profileapi.h header and can refer to the link:
https://learn.microsoft.com/en-us/windows/win32/api/profileapi/

Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
This commit is contained in:
Yang Gang 2024-09-19 16:12:20 +08:00 committed by mergify[bot]
parent e12a8d83fa
commit 3299c36ba1

View File

@ -5,7 +5,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
Module Name: Module Name:
WinNtThunk.c WinThunk.c
Abstract: Abstract:
@ -29,6 +29,8 @@ STATIC DWORD mOldStdInMode;
STATIC DWORD mOldStdOutMode; STATIC DWORD mOldStdOutMode;
#endif #endif
STATIC UINT64 mPerformanceFrequency = 0;
UINTN UINTN
SecWriteStdErr ( SecWriteStdErr (
IN UINT8 *Buffer, IN UINT8 *Buffer,
@ -451,8 +453,13 @@ SecQueryPerformanceFrequency (
VOID VOID
) )
{ {
// Hard code to nanoseconds if (mPerformanceFrequency) {
return 1000000000ULL; return mPerformanceFrequency;
}
QueryPerformanceFrequency ((LARGE_INTEGER *)&mPerformanceFrequency);
return mPerformanceFrequency;
} }
UINT64 UINT64
@ -460,7 +467,11 @@ SecQueryPerformanceCounter (
VOID VOID
) )
{ {
return 0; UINT64 PerformanceCount;
QueryPerformanceCounter ((LARGE_INTEGER *)&PerformanceCount);
return PerformanceCount;
} }
VOID VOID