diff options
author | Bora Guvendik <bora.guvendik@intel.com> | 2021-11-22 16:12:48 -0800 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-01-21 22:43:03 +0000 |
commit | e383b3dcc4650f81de4a20735d8a37b0720377f6 (patch) | |
tree | 627fd943585f30a3c3f3c6c03e18d08390e68fa3 /util/cbmem | |
parent | bf73c498d448678fd19354d66c03d852fcb5ec1d (diff) |
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/cbmem')
-rw-r--r-- | util/cbmem/cbmem.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c index bff863f3b8..51b4adc80c 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; |