Aaron Durbin (adurbin@chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10883
-gerrit
commit 2e37e38948b7b6af673b42e05a11e791ee0b6f9b Author: Aaron Durbin adurbin@chromium.org Date: Sat Jul 11 12:44:10 2015 -0500
cbmem: export base_time in timestamp table
It's helpful to know the base_time (1st timestamp) in the timestamp table because it provides more information like the accumulated time before the first timestamp was recorded.
In order to maximize this information report the base time as an entry that is printed. It's called '1st timestamp'. The implementation turns all the timestamp entries into absolute time to make the logic clearer as base_time acts as a pseudo entry.
Change-Id: I1334a2d980e3bcc2968a3bd6493c68b9efcca7ae Signed-off-by: Aaron Durbin adurbin@chromium.org --- util/cbmem/cbmem.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c index 3bc0fcd..0bd35f2 100644 --- a/util/cbmem/cbmem.c +++ b/util/cbmem/cbmem.c @@ -457,7 +457,7 @@ static const struct timestamp_id_to_name { { TS_FSP_AFTER_FINALIZE, "returning from FspNotify(ReadyToBoot)" } };
-void timestamp_print_entry(uint32_t id, uint64_t stamp, uint64_t prev_stamp) +static const char *timestamp_name(uint32_t id) { int i; const char *name; @@ -470,6 +470,12 @@ void timestamp_print_entry(uint32_t id, uint64_t stamp, uint64_t prev_stamp) } }
+ return name; +} + +void timestamp_print_entry(uint32_t id, const char *name, + uint64_t stamp, uint64_t prev_stamp) +{ printf("%4d:", id); printf("%-50s", name); print_norm(arch_convert_raw_ts_entry(stamp)); @@ -486,7 +492,9 @@ static void dump_timestamps(void) { int i; struct timestamp_table *tst_p; + struct timestamp_table *abs_table; size_t size; + uint64_t prev_stamp;
if (timestamps.tag != LB_TAG_TIMESTAMPS) { fprintf(stderr, "No timestamps found in coreboot table.\n"); @@ -502,13 +510,30 @@ static void dump_timestamps(void) unmap_memory(); tst_p = map_memory_size((unsigned long)timestamps.cbmem_addr, size);
- for (i = 0; i < tst_p->num_entries; i++) { - const struct timestamp_entry *tse_p = tst_p->entries + i; - timestamp_print_entry(tse_p->entry_id, tse_p->entry_stamp, - i ? tse_p[-1].entry_stamp : 0); + abs_table = malloc(size); + if (!abs_table) { + fprintf(stderr, "Not enough memory for timestamps.\n"); + exit(1); } - + memcpy(abs_table, tst_p, size); unmap_memory(); + + /* Make all timestamps absolute. */ + for (i = 0; i < abs_table->num_entries; i++) + abs_table->entries[i].entry_stamp += abs_table->base_time; + + timestamp_print_entry(0, "1st timestamp", abs_table->base_time, 0); + + prev_stamp = abs_table->base_time; + for (i = 0; i < abs_table->num_entries; i++) { + const struct timestamp_entry *tse = &abs_table->entries[i]; + const char *name = timestamp_name(tse->entry_id); + timestamp_print_entry(tse->entry_id, name, + tse->entry_stamp, prev_stamp); + prev_stamp = tse->entry_stamp; + } + + free(abs_table); }
/* dump the cbmem console */