public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] EmulatorPkg: Implement QueryPerformanceCounter()
@ 2019-12-18  3:32 Lin, Derek (HPS SW)
  0 siblings, 0 replies; only message in thread
From: Lin, Derek (HPS SW) @ 2019-12-18  3:32 UTC (permalink / raw)
  To: derek.lin2, devel; +Cc: kitty.chen, jordan.l.justen, afish, ray.ni

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-12-18  3:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-18  3:32 [PATCH] EmulatorPkg: Implement QueryPerformanceCounter() Lin, Derek (HPS SW)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox