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>
This commit is contained in:
parent
bf73c498d4
commit
e383b3dcc4
1 changed files with 17 additions and 10 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue