[coreboot-gerrit] New patch to review for coreboot: d6db8e5 timestamp: [NOTFORMERGE] Make timestamp library more flexible and intelligent

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Mon Feb 9 11:55:10 CET 2015


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8395

-gerrit

commit d6db8e5be1f5c6ab23298a57ef92f0a5878e2f2f
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Mon Feb 9 12:58:05 2015 +0200

    timestamp: [NOTFORMERGE] 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 at google.com>
    Reviewed-on: https://chromium-review.googlesource.com/224024
    Reviewed-by: Furquan Shaikh <furquan at chromium.org>
    Commit-Queue: Furquan Shaikh <furquan at chromium.org>
    Tested-by: Furquan Shaikh <furquan at chromium.org>
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/arch/x86/init/romstage.ld |  5 +++++
 src/include/timestamp.h       | 29 +++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/src/arch/x86/init/romstage.ld b/src/arch/x86/init/romstage.ld
index 99bcc8e..67b468f 100644
--- a/src/arch/x86/init/romstage.ld
+++ b/src/arch/x86/init/romstage.ld
@@ -55,6 +55,11 @@ SECTIONS
 	.car.data . (NOLOAD) : {
 		_car_data_start = .;
 		*(.car.global_data);
+#if IS_ENABLED(CONFIG_HAS_PRECBMEM_TIMESTAMP_REGION)
+		_timestamp = .;
+		. = . + 0x100;
+		_etimestamp = .;
+#endif
 		_car_data_end = .;
 		/* The preram cbmem console area comes last to take advantage
 		 * of a zero-sized array to hold the memconsole contents that
diff --git a/src/include/timestamp.h b/src/include/timestamp.h
index ba73135..2a9d6c0 100644
--- a/src/include/timestamp.h
+++ b/src/include/timestamp.h
@@ -61,11 +61,40 @@ enum timestamp_id {
 };
 
 #if CONFIG_COLLECT_TIMESTAMPS && (CONFIG_EARLY_CBMEM_INIT || !defined(__PRE_RAM__))
+/*
+ * 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);
+/*
+ * Sync all timestamps from timestamp_cache to cbmem area. Called by
+ * cbmem_initialize.
+ */
 void timestamp_reinit(void);
 #else
+#define timestamp_early_init(base)
 #define timestamp_init(base)
 #define timestamp_add(id, time)
 #define timestamp_add_now(id)



More information about the coreboot-gerrit mailing list