diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/bootstage.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/common/bootstage.c b/common/bootstage.c index a6f17ee237..a89ce6d26b 100644 --- a/common/bootstage.c +++ b/common/bootstage.c @@ -34,10 +34,11 @@ DECLARE_GLOBAL_DATA_PTR; struct bootstage_record { uint32_t time_us; + uint32_t start_us; const char *name; }; -static struct bootstage_record record[BOOTSTAGE_COUNT] = {{1, "avoid_bss"}}; +static struct bootstage_record record[BOOTSTAGE_COUNT] = {{1, 0, "avoid_bss"} }; uint32_t bootstage_mark(enum bootstage_id id, const char *name) { @@ -46,11 +47,31 @@ uint32_t bootstage_mark(enum bootstage_id id, const char *name) /* Only record the first event for each */ if (!rec->name) { rec->time_us = (uint32_t)timer_get_us(); + rec->start_us = 0; rec->name = name; } return rec->time_us; } +uint32_t bootstage_start(enum bootstage_id id, const char *name) +{ + struct bootstage_record *rec = &record[id]; + + rec->start_us = timer_get_us(); + rec->name = name; + return rec->start_us; +} + +uint32_t bootstage_accum(enum bootstage_id id) +{ + struct bootstage_record *rec = &record[id]; + uint32_t duration; + + duration = (uint32_t)timer_get_us() - rec->start_us; + rec->time_us += duration; + return duration; +} + static void print_time(unsigned long us_time) { char str[12], *s; @@ -69,8 +90,13 @@ static void print_time(unsigned long us_time) static uint32_t print_time_record(enum bootstage_id id, struct bootstage_record *rec, uint32_t prev) { - print_time(rec->time_us); - print_time(rec->time_us - prev); + if (prev == -1U) { + printf("%11s", ""); + print_time(rec->time_us); + } else { + print_time(rec->time_us); + print_time(rec->time_us - prev); + } if (rec->name) printf(" %s\n", rec->name); else @@ -187,10 +213,16 @@ void bootstage_report(void) qsort(record, ARRAY_SIZE(record), sizeof(*rec), h_compare_record); for (id = 0; id < BOOTSTAGE_COUNT; id++, rec++) { - if (rec->time_us != 0) + if (rec->time_us != 0 && !rec->start_us) prev = print_time_record(id, rec, prev); } + puts("\nAccumulated time:\n"); + for (id = 0, rec = record; id < BOOTSTAGE_COUNT; id++, rec++) { + if (rec->start_us) + prev = print_time_record(id, rec, -1); + } + add_bootstages_devicetree(working_fdt); if (flags & GD_FLG_SILENT) |