[edk2-devel] [PATCH] EmulatorPkg: Implement QueryPerformanceCounter()

Lin, Derek (HPS SW) posted 1 patch 4 years, 3 months ago
Failed in applying to current master (apply log)
EmulatorPkg/Unix/Host/EmuThunk.c | 6 ++++--
EmulatorPkg/Win/Host/WinThunk.c  | 7 ++++++-
2 files changed, 10 insertions(+), 3 deletions(-)
[edk2-devel] [PATCH] EmulatorPkg: Implement QueryPerformanceCounter()
Posted by Lin, Derek (HPS SW) 4 years, 3 months ago
Implement QueryPerformanceCounter() for Emulator on both Unix and Windows.

Signed-off-by: Derek Lin <derek.lin2@hpe.com>
Signed-off-by: Kitty Chen <kitty.chen@hpe.com>
---
 EmulatorPkg/Unix/Host/EmuThunk.c | 6 ++++--
 EmulatorPkg/Win/Host/WinThunk.c  | 7 ++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/EmulatorPkg/Unix/Host/EmuThunk.c b/EmulatorPkg/Unix/Host/EmuThunk.c
index 1e9dc99187..4fd7b3d093 100644
--- a/EmulatorPkg/Unix/Host/EmuThunk.c
+++ b/EmulatorPkg/Unix/Host/EmuThunk.c
@@ -274,8 +274,10 @@ QueryPerformanceCounter (
 
   return (Start * sTimebaseInfo.numer) / sTimebaseInfo.denom;
 #else
-  // Need to figure out what to do for Linux?
-  return 0;
+  int status;
+  struct timespec time;
+  status = clock_gettime(CLOCK_REALTIME, &time);
+  return time.tv_nsec;
 #endif
 }
 
diff --git a/EmulatorPkg/Win/Host/WinThunk.c b/EmulatorPkg/Win/Host/WinThunk.c
index a77be2a64b..a1f8870e27 100644
--- a/EmulatorPkg/Win/Host/WinThunk.c
+++ b/EmulatorPkg/Win/Host/WinThunk.c
@@ -447,7 +447,12 @@ SecQueryPerformanceCounter (
   VOID
   )
 {
-  return 0;
+  UINT64 PerformanceCount;
+
+  PerformanceCount = 0;
+  QueryPerformanceCounter ((LARGE_INTEGER *) &PerformanceCount);
+
+  return PerformanceCount;
 }
 
 
-- 
2.20.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52324): https://edk2.groups.io/g/devel/message/52324
Mute This Topic: https://groups.io/mt/68782312/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-