From: Pankaj Bansal <pankaj.bansal@nxp.com>
To: <edk2-devel@lists.01.org>
Cc: Pankaj Bansal <pankaj.bansal@nxp.com>,
Leif Lindholm <leif.lindholm@linaro.org>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement GetElapsedTime function of TimerLib
Date: Wed, 10 Jan 2018 15:01:09 +0530 [thread overview]
Message-ID: <1515576669-14171-2-git-send-email-pankaj.bansal@nxp.com> (raw)
In-Reply-To: <1515576669-14171-1-git-send-email-pankaj.bansal@nxp.com>
This function calculates the time elaped in Naoseconds between call to
this function and BaseTime, which is passed as argument.
This is particularly useful in detecting timeout conditions.
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
index b81293c..0898339 100644
--- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
+++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c
@@ -290,3 +290,39 @@ GetTimeInNanoSecond (
return NanoSeconds;
}
+
+/**
+ Get Elapsed time in Nanoseonds w.r.t BaseTime
+
+ This function calculates the time elaped in Naoseconds between call to this
+ function and BaseTime, which is passed as argument.
+
+ @param BaseTime BaseTime in NanoSeconds.
+
+ @return The elapsed time in nanoseconds.
+
+**/
+UINT64
+EFIAPI
+GetElapsedTime (
+ IN UINT64 BaseTime
+ )
+{
+ UINT64 NanoSeconds;
+ UINT64 Ticks;
+
+ //
+ // Get current Ticks.
+ //
+ Ticks = GetPerformanceCounter();
+
+ //
+ // Convert Ticks to Nanoseconds
+ //
+ NanoSeconds = GetTimeInNanoSecond (Ticks);
+
+ //
+ // return the difference
+ //
+ return (NanoSeconds - BaseTime);
+}
--
2.7.4
next prev parent reply other threads:[~2018-01-10 9:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 9:31 [PATCH 1/2] MdePkg/TimerLib: Add a function to calculate elapsed time Pankaj Bansal
2018-01-10 9:31 ` Pankaj Bansal [this message]
2018-01-10 14:16 ` [PATCH 2/2] ArmPkg/ArmArchTimerLib: Implement GetElapsedTime function of TimerLib Laszlo Ersek
2018-01-10 16:05 ` Pankaj Bansal
2018-01-10 17:04 ` Laszlo Ersek
2018-01-11 6:28 ` Pankaj Bansal
2018-01-11 9:58 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1515576669-14171-2-git-send-email-pankaj.bansal@nxp.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox