diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2015-07-30 14:36:32 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-08-14 21:04:32 +0000 |
commit | 73a8098d79d84292ff56674f843f73753520fcbd (patch) | |
tree | 0c068529910d7de373a858b49ea9ad02ea898e9b | |
parent | 26984c7de4ac14347e8395e6e111677a707807f2 (diff) | |
download | chrome-ec-73a8098d79d84292ff56674f843f73753520fcbd.tar.gz |
export MSDN clock() function
TPM implementation requires a free running clock with granularity
better than a 10 us. clock_t definition comes from the toolchain
includes.
BRANCH=none
BUG=chrome-os-partner:43025
TEST=none yet
Change-Id: Id3de5fd055aa598afe15657011b88d2c6be4cdfb
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/289953
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | common/timer.c | 5 | ||||
-rw-r--r-- | include/timer.h | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/common/timer.c b/common/timer.c index 8538635218..4fa2e6b93b 100644 --- a/common/timer.c +++ b/common/timer.c @@ -184,6 +184,11 @@ timestamp_t get_time(void) return ts; } +clock_t clock(void) +{ + return (clock_t) __hw_clock_source_read(); +} + void force_time(timestamp_t ts) { clksrc_high = ts.le.hi; diff --git a/include/timer.h b/include/timer.h index ddeb79a318..2c439e959e 100644 --- a/include/timer.h +++ b/include/timer.h @@ -8,6 +8,8 @@ #ifndef __CROS_EC_TIMER_H #define __CROS_EC_TIMER_H +#include <sys/types.h> + #include "common.h" #include "task_id.h" @@ -146,4 +148,11 @@ static inline unsigned time_since32(timestamp_t start) return get_time().le.lo - start.le.lo; } +/** + * Returns a free running high resolution (ten us or better) clock. + * + * Used by third party libraries requiring MSDN services. + */ +clock_t clock(void); + #endif /* __CROS_EC_TIMER_H */ |