summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYang Gang <yanggang@byosoft.com.cn>2024-09-19 16:12:20 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-11-14 02:15:43 +0000
commit3299c36ba181b1e7d23987f94cad688e2ea67223 (patch)
tree2de9a3efdc3d20186a2db3b4f8fa49f86d8ecf80
parente12a8d83faf7cf79b3dc7585950dd639df333342 (diff)
downloadedk2-3299c36ba181b1e7d23987f94cad688e2ea67223.tar.gz
edk2-3299c36ba181b1e7d23987f94cad688e2ea67223.tar.bz2
edk2-3299c36ba181b1e7d23987f94cad688e2ea67223.zip
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>
-rw-r--r--EmulatorPkg/Win/Host/WinThunk.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/EmulatorPkg/Win/Host/WinThunk.c b/EmulatorPkg/Win/Host/WinThunk.c
index 0abe4727e0..e1b158c2da 100644
--- a/EmulatorPkg/Win/Host/WinThunk.c
+++ b/EmulatorPkg/Win/Host/WinThunk.c
@@ -5,7 +5,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
Module Name:
- WinNtThunk.c
+ WinThunk.c
Abstract:
@@ -29,6 +29,8 @@ STATIC DWORD mOldStdInMode;
STATIC DWORD mOldStdOutMode;
#endif
+STATIC UINT64 mPerformanceFrequency = 0;
+
UINTN
SecWriteStdErr (
IN UINT8 *Buffer,
@@ -451,8 +453,13 @@ SecQueryPerformanceFrequency (
VOID
)
{
- // Hard code to nanoseconds
- return 1000000000ULL;
+ if (mPerformanceFrequency) {
+ return mPerformanceFrequency;
+ }
+
+ QueryPerformanceFrequency ((LARGE_INTEGER *)&mPerformanceFrequency);
+
+ return mPerformanceFrequency;
}
UINT64
@@ -460,7 +467,11 @@ SecQueryPerformanceCounter (
VOID
)
{
- return 0;
+ UINT64 PerformanceCount;
+
+ QueryPerformanceCounter ((LARGE_INTEGER *)&PerformanceCount);
+
+ return PerformanceCount;
}
VOID