summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagendra modadugu <ngm@google.com>2016-07-17 20:50:45 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-07-20 22:29:29 +0000
commitb4e78b309900402499b8742199fb4536570d3000 (patch)
tree9aff19957d39454db60c45933680d5924f0cf5f6
parentc4430ecac8f77a05ac4071679de1535e0da2779e (diff)
downloadchrome-ec-b4e78b309900402499b8742199fb4536570d3000.tar.gz
timer: fix clock() implementation to match TPM2 library expectations
The clock() function was introduced to provide free running clock for the TPM2 library, which expects this clock to run with a millisecond resolution. This patch fixes the bug where the function in fact was returning the clock running at a microsecond resolution. BRANCH=none BUG=chrome-os-partner:43025,chrome-os-partner:47524 BUG=chrome-os-partner:50115 TEST=with the appropriate modification of the user of this function all lockout related TCG tests pass. Change-Id: Ic02fffca610426d22e58609eb8c3693aec96ad5c Signed-off-by: nagendra modadugu <ngm@google.com> Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/361180
-rw-r--r--common/timer.c3
-rw-r--r--include/timer.h5
2 files changed, 4 insertions, 4 deletions
diff --git a/common/timer.c b/common/timer.c
index 289314e74a..b1f452f611 100644
--- a/common/timer.c
+++ b/common/timer.c
@@ -185,7 +185,8 @@ timestamp_t get_time(void)
clock_t clock(void)
{
- return (clock_t) __hw_clock_source_read();
+ /* __hw_clock_source_read() returns a microsecond resolution timer.*/
+ return (clock_t) __hw_clock_source_read() / 1000;
}
void force_time(timestamp_t ts)
diff --git a/include/timer.h b/include/timer.h
index 0e7fd7d7ea..fb7800ce2e 100644
--- a/include/timer.h
+++ b/include/timer.h
@@ -150,9 +150,8 @@ static inline unsigned time_since32(timestamp_t start)
}
/**
- * Returns a free running high resolution (ten us or better) clock.
- *
- * Used by third party libraries requiring MSDN services.
+ * Returns a free running millisecond clock counter, which matches tpm2
+ * library expectations.
*/
clock_t clock(void);