Skip to content

Commit 3299c36

Browse files
YangGangUEFImergify[bot]
authored andcommitted
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>
1 parent e12a8d8 commit 3299c36

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

EmulatorPkg/Win/Host/WinThunk.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
55
66
Module Name:
77
8-
WinNtThunk.c
8+
WinThunk.c
99
1010
Abstract:
1111
@@ -29,6 +29,8 @@ STATIC DWORD mOldStdInMode;
2929
STATIC DWORD mOldStdOutMode;
3030
#endif
3131

32+
STATIC UINT64 mPerformanceFrequency = 0;
33+
3234
UINTN
3335
SecWriteStdErr (
3436
IN UINT8 *Buffer,
@@ -451,16 +453,25 @@ SecQueryPerformanceFrequency (
451453
VOID
452454
)
453455
{
454-
// Hard code to nanoseconds
455-
return 1000000000ULL;
456+
if (mPerformanceFrequency) {
457+
return mPerformanceFrequency;
458+
}
459+
460+
QueryPerformanceFrequency ((LARGE_INTEGER *)&mPerformanceFrequency);
461+
462+
return mPerformanceFrequency;
456463
}
457464

458465
UINT64
459466
SecQueryPerformanceCounter (
460467
VOID
461468
)
462469
{
463-
return 0;
470+
UINT64 PerformanceCount;
471+
472+
QueryPerformanceCounter ((LARGE_INTEGER *)&PerformanceCount);
473+
474+
return PerformanceCount;
464475
}
465476

466477
VOID

0 commit comments

Comments
 (0)