timestamp: Make timestamp library more flexible and intelligent

Add support for:
1) Using timestamps in bootblock and verstage
2) Allowing the timestamps to be stashed into _timestamp region so that they can
be used across multiple stages
3) Performing operations over the timestamps in _timestamp region

Instead of having two separate APIs for stashing and adding timestamps, let the
timestamp library decide on its own where to save depending on timestamp cache
status. Now the sequence of operations would be something like:
timestamp_init / timestamp_early_init : Set the base time
timestamp_add / timestamp_add_now
cbmem_initialize : It internally calls timestamp_sync
timestamp_add / timestamp_add_now

BUG=chrome-os-partner:32973
BRANCH=None
TEST=Compiles successfully for ryu and samus. cbmem -t on ryu works fine.

Change-Id: Ie5ffda3112d626068bd1904afcc5a09bc4916d16
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/224024
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
Furquan Shaikh 2014-10-15 15:17:49 -07:00 committed by chrome-internal-fetch
commit 2f6b472984
7 changed files with 251 additions and 50 deletions

View file

@ -59,18 +59,45 @@ enum timestamp_id {
};
#if CONFIG_COLLECT_TIMESTAMPS
/*
* Order of usage of timestamp library is:
* Call timestamp_early_init / timestamp_init to set base time before any
* timestamp_add function is called. timestamp_early_init also ensures that the
* cache is valid in _timestamp region.
* After this, timestamp_add / timestamp_add_now can be used to record
* timestamps. Sync will be automatically taken care of by cbmem_initialize
*/
/*
* Initialize the cache to a valid state and set the base time.
* This function is used before DRAM is setup so that the timestamp cache can
* be initialized in _timestamp region.
* Both, timestamp_init and timestamp_early_init reset the cbmem state to
* timestamp table reset required. Thus, whenever a timestamp_add or
* timestamp_sync is done to add new entries into the cbmem timestamp table, it
* first resets the table to 0 entries.
*/
void timestamp_early_init(uint64_t base);
/* Initialize the base time for timestamps and mark cache as valid */
void timestamp_init(uint64_t base);
/*
* Add a new timestamp. Depending on cbmem is available or not, this timestamp
* will be stored to cbmem / timestamp cache.
*/
void timestamp_add(enum timestamp_id id, uint64_t ts_time);
/* Calls timestamp_add with current timestamp. */
void timestamp_add_now(enum timestamp_id id);
void timestamp_stash(enum timestamp_id id);
/*
* Sync all timestamps from timestamp_cache to cbmem area. Called by
* cbmem_initialize.
*/
void timestamp_sync(void);
/* Implemented by the architecture code */
uint64_t timestamp_get(void);
#else
#define timestamp_early_init(base)
#define timestamp_init(base)
#define timestamp_add(id, time)
#define timestamp_add_now(id)
#define timestamp_stash(id)
#define timestamp_sync()
#endif