summaryrefslogtreecommitdiff
path: root/src/lib/timestamp.c
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2016-02-09 16:09:15 -0800
committerJulius Werner <jwerner@chromium.org>2016-02-12 21:54:52 +0100
commit8c09377deab1b5a5120889bb6c689ad460381c29 (patch)
tree6633f840aa3f0a76c841847b8e527a652d557e49 /src/lib/timestamp.c
parent4b13c7c61e9a54f893f8e16f57b1666ad4bafdbc (diff)
downloadcoreboot-8c09377deab1b5a5120889bb6c689ad460381c29.tar.xz
timestamp: Remove HAS_PRECBMEM_TIMESTAMP_REGION Kconfig
This patch generalizes the approach previously used for ARM32 TTB_SUBTABLES to "auto-detect" whether a certain region was defined in memlayout.ld. This allows us to get rid of the explicit Kconfig for the TIMESTAMP region, reducing configuration redundancy and avoiding confusion when setting up future boards. (Removing armv4/bootblock_simple.c because it references this Kconfig and it is a dead file that I just forgot to remove in CL:12076.) BRANCH=None BUG=None TEST=Booted Oak and confirmed that all pre-RAM timestamps are still there. Built Nyan and Falco. Change-Id: I557a4b263018511d17baa4177963130a97ea310a Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/13652 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/lib/timestamp.c')
-rw-r--r--src/lib/timestamp.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c
index 2850fb7509..ae84c4f673 100644
--- a/src/lib/timestamp.c
+++ b/src/lib/timestamp.c
@@ -38,8 +38,10 @@ struct __attribute__((__packed__)) timestamp_cache {
struct timestamp_entry entries[MAX_BSS_TIMESTAMP_CACHE];
};
-#if (IS_ENABLED(CONFIG_HAS_PRECBMEM_TIMESTAMP_REGION) && defined(__PRE_RAM__))
-#define USE_TIMESTAMP_REGION 1
+DECLARE_OPTIONAL_REGION(timestamp);
+
+#if defined(__PRE_RAM__)
+#define USE_TIMESTAMP_REGION (_timestamp_size > 0)
#else
#define USE_TIMESTAMP_REGION 0
#endif
@@ -254,21 +256,30 @@ static void timestamp_sync_cache_to_cbmem(int is_recovery)
/*
* There's no need to worry about the base_time fields being out of
- * sync because the following configurations are used/supported:
+ * sync because only the following configurations are used/supported:
+ *
+ * 1. Timestamps get initialized before ramstage, which implies
+ * CONFIG_EARLY_CBMEM_INIT and CBMEM initialization in romstage.
+ * This requires the board to define a TIMESTAMP() region in its
+ * memlayout.ld (default on x86). The base_time from timestamp_init()
+ * (usually called from bootblock.c on most non-x86 boards) persists
+ * in that region until it gets synced to CBMEM in romstage.
+ * In ramstage, the BSS cache's base_time will be 0 until the second
+ * sync, which will adjust the timestamps in there to the correct
+ * base_time (from CBMEM) with the timestamp_add_table_entry() below.
*
- * 1. CONFIG_HAS_PRECBMEM_TIMESTAMP_REGION is enabled. This
- * implies CONFIG_EARLY_CBMEM_INIT so once cbmem comes
- * online we sync the timestamps to the cbmem storage while
- * running in romstage. In ramstage the cbmem area is
- * recovered and utilized.
+ * 2. Timestamps only get initialized in ramstage *and*
+ * CONFIG_LATE_CBMEM_INIT is set. main() will call timestamp_init()
+ * very early (before any timestamps get logged) to set a base_time
+ * in the BSS cache, which will later get synced over to CBMEM.
*
- * 2. CONFIG_LATE_CBMEM_INIT (!CONFIG_EARLY_CBMEM_INIT) is
- * being used. That means the only cache that exists is
- * in ramstage. Once cbmem comes online in ramstage those
- * values are sync'd over.
+ * If you try to initialize timestamps before ramstage but don't define
+ * a TIMESTAMP region, all operations will fail (safely), and coreboot
+ * will behave as if timestamps only get initialized in ramstage.
*
- * Any other combinations will result in inconsistent base_time
- * values including bizarre timestamp values.
+ * If CONFIG_EARLY_CBMEM_INIT is set but timestamps only get
+ * initialized in ramstage, the base_time from timestamp_init() will
+ * get ignored and all timestamps will be 0-based.
*/
for (i = 0; i < ts_cache_table->num_entries; i++) {
struct timestamp_entry *tse = &ts_cache_table->entries[i];