Refactor hw timer code to accommodate execution tracing.
This CL separates the HW timestamp acquisition into an inline
function and provides interface to set the base time (to be
retrieved from coreboot table).
BUG=chromium-os:20733
TEST=manual
. build the new firmaware image
. bring up a stumpy with the new image to ChromeOS
. examine crossystem reported timer values.
Observe that the values start with zero and increase
monotonously.
Change-Id: I4ede0a55112e061e9d3790f01c8ca41a8539364b
Signed-off-by: Vadim Bendebury <[email protected]>
Reviewed-on: http://gerrit.chromium.org/gerrit/8215
Reviewed-by: Stefan Reinauer <[email protected]>
diff --git a/board/chromebook-x86/vbexport/utility.c b/board/chromebook-x86/vbexport/utility.c
index c45d2ff..6d178ff 100644
--- a/board/chromebook-x86/vbexport/utility.c
+++ b/board/chromebook-x86/vbexport/utility.c
@@ -17,14 +17,16 @@
uint64_t VbExGetTimer(void)
{
- uint32_t high, low;
uint64_t time_now;
- __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high));
-
- time_now = ((uint64_t)high << 32) | (uint64_t)low;
+ time_now = rdtsc();
if (!base_value)
base_value = time_now;
return time_now - base_value;
}
+
+void set_base_timer_value(uint64_t new_base)
+{
+ base_value = new_base;
+}