Skip to content

Commit

Permalink
EmulatorPkg WinThunk: Use Win32 API to get Performance Frequency and …
Browse files Browse the repository at this point in the history
…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 <[email protected]>
  • Loading branch information
YangGangUEFI authored and mergify[bot] committed Nov 14, 2024
1 parent e12a8d8 commit 3299c36
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions EmulatorPkg/Win/Host/WinThunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
Module Name:
WinNtThunk.c
WinThunk.c
Abstract:
Expand All @@ -29,6 +29,8 @@ STATIC DWORD mOldStdInMode;
STATIC DWORD mOldStdOutMode;
#endif

STATIC UINT64 mPerformanceFrequency = 0;

UINTN
SecWriteStdErr (
IN UINT8 *Buffer,
Expand Down Expand Up @@ -451,16 +453,25 @@ SecQueryPerformanceFrequency (
VOID
)
{
// Hard code to nanoseconds
return 1000000000ULL;
if (mPerformanceFrequency) {
return mPerformanceFrequency;
}

QueryPerformanceFrequency ((LARGE_INTEGER *)&mPerformanceFrequency);

return mPerformanceFrequency;
}

UINT64
SecQueryPerformanceCounter (
VOID
)
{
return 0;
UINT64 PerformanceCount;

QueryPerformanceCounter ((LARGE_INTEGER *)&PerformanceCount);

return PerformanceCount;
}

VOID
Expand Down

0 comments on commit 3299c36

Please sign in to comment.