summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorBora Guvendik <bora.guvendik@intel.com>2021-11-22 16:12:48 -0800
committerFelix Held <felix-coreboot@felixheld.de>2022-01-21 22:43:03 +0000
commite383b3dcc4650f81de4a20735d8a37b0720377f6 (patch)
tree627fd943585f30a3c3f3c6c03e18d08390e68fa3 /util
parentbf73c498d448678fd19354d66c03d852fcb5ec1d (diff)
downloadcoreboot-e383b3dcc4650f81de4a20735d8a37b0720377f6.tar.gz
coreboot-e383b3dcc4650f81de4a20735d8a37b0720377f6.tar.bz2
coreboot-e383b3dcc4650f81de4a20735d8a37b0720377f6.zip
util/cbmem: Rebase to handle negative timestamps
Rebase all of the timestamps to the lowest (potentially negative) value in the list when displaying them. Also drop the extra `timestamp_print_*_entry` calls for time 0 and instead inserted a "dummy" timestamp entry of time 0 into the table. TEST=Boot to OS after adding negative timestamps, cbmem -t Signed-off-by: Bora Guvendik <bora.guvendik@intel.com> Change-Id: I7eb519c360e066d48dde205401e4ccd3b0b3d8a5 Reviewed-on: https://review.coreboot.org/c/coreboot/+/59555 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Subrata Banik <subratabanik@google.com>
Diffstat (limited to 'util')
-rw-r--r--util/cbmem/cbmem.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c
index bff863f3b867..51b4adc80cd7 100644
--- a/util/cbmem/cbmem.c
+++ b/util/cbmem/cbmem.c
@@ -621,23 +621,30 @@ static void dump_timestamps(int mach_readable)
if (!tst_p)
die("Unable to map full timestamp table\n");
- /* Report the base time within the table. */
- prev_stamp = 0;
- if (mach_readable)
- timestamp_print_parseable_entry(0, tst_p->base_time,
- prev_stamp);
- else
- timestamp_print_entry(0, tst_p->base_time, prev_stamp);
- prev_stamp = tst_p->base_time;
-
- sorted_tst_p = malloc(size);
+ sorted_tst_p = malloc(size + sizeof(struct timestamp_entry));
if (!sorted_tst_p)
die("Failed to allocate memory");
aligned_memcpy(sorted_tst_p, tst_p, size);
+ /*
+ * Insert a timestamp to represent the base time (start of coreboot),
+ * in case we have to rebase for negative timestamps below.
+ */
+ sorted_tst_p->entries[tst_p->num_entries].entry_id = 0;
+ sorted_tst_p->entries[tst_p->num_entries].entry_stamp = 0;
+ sorted_tst_p->num_entries += 1;
+
qsort(&sorted_tst_p->entries[0], sorted_tst_p->num_entries,
sizeof(struct timestamp_entry), compare_timestamp_entries);
+ /*
+ * If there are negative timestamp entries, rebase all of the
+ * timestamps to the lowest one in the list.
+ */
+ if (sorted_tst_p->entries[0].entry_stamp < 0)
+ sorted_tst_p->base_time = -sorted_tst_p->entries[0].entry_stamp;
+ prev_stamp = 0;
+
total_time = 0;
for (uint32_t i = 0; i < sorted_tst_p->num_entries; i++) {
uint64_t stamp;