From bf73c498d448678fd19354d66c03d852fcb5ec1d Mon Sep 17 00:00:00 2001 From: Bora Guvendik Date: Mon, 22 Nov 2021 16:03:39 -0800 Subject: timestamp: Allow timestamp_add to accept a negative number Change timestamp_add to accept negative values for events that took place before coreboot started executing. TEST=Boot to OS, check cbmem -t Signed-off-by: Bora Guvendik Change-Id: I90afc13a8e92693d86e3358f05e0a0cb7cdbca9b Reviewed-on: https://review.coreboot.org/c/coreboot/+/59554 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner Reviewed-by: Subrata Banik Reviewed-by: Tim Wawrzynczak --- src/commonlib/include/commonlib/timestamp_serialized.h | 2 +- src/include/timestamp.h | 2 +- src/lib/timestamp.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/commonlib/include/commonlib/timestamp_serialized.h b/src/commonlib/include/commonlib/timestamp_serialized.h index 3d518b77b2..5c5e56b071 100644 --- a/src/commonlib/include/commonlib/timestamp_serialized.h +++ b/src/commonlib/include/commonlib/timestamp_serialized.h @@ -7,7 +7,7 @@ struct timestamp_entry { uint32_t entry_id; - uint64_t entry_stamp; + int64_t entry_stamp; } __packed; struct timestamp_table { diff --git a/src/include/timestamp.h b/src/include/timestamp.h index 647cd13897..cbe9934069 100644 --- a/src/include/timestamp.h +++ b/src/include/timestamp.h @@ -19,7 +19,7 @@ void timestamp_init(uint64_t base); * inside REGION(timestamp) before cbmem comes online. For later stages, timestamps * added before cbmem_[recovery|initialize] calls will be lost. */ -void timestamp_add(enum timestamp_id id, uint64_t ts_time); +void timestamp_add(enum timestamp_id id, int64_t ts_time); /* Calls timestamp_add with current timestamp. */ void timestamp_add_now(enum timestamp_id id); diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c index 7347d07b16..f8e4ab840a 100644 --- a/src/lib/timestamp.c +++ b/src/lib/timestamp.c @@ -102,7 +102,7 @@ static const char *timestamp_name(enum timestamp_id id) } static void timestamp_add_table_entry(struct timestamp_table *ts_table, - enum timestamp_id id, uint64_t ts_time) + enum timestamp_id id, int64_t ts_time) { struct timestamp_entry *tse; @@ -117,7 +117,7 @@ static void timestamp_add_table_entry(struct timestamp_table *ts_table, printk(BIOS_ERR, "ERROR: Timestamp table full\n"); } -void timestamp_add(enum timestamp_id id, uint64_t ts_time) +void timestamp_add(enum timestamp_id id, int64_t ts_time) { struct timestamp_table *ts_table; @@ -135,7 +135,7 @@ void timestamp_add(enum timestamp_id id, uint64_t ts_time) timestamp_add_table_entry(ts_table, id, ts_time); if (CONFIG(TIMESTAMPS_ON_CONSOLE)) - printk(BIOS_INFO, "Timestamp - %s: %llu\n", timestamp_name(id), ts_time); + printk(BIOS_INFO, "Timestamp - %s: %lld\n", timestamp_name(id), ts_time); } void timestamp_add_now(enum timestamp_id id) -- cgit v1.2.3