bootstage: Add a way to read the time from a record
Add a function which returns the time given a record ID. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -249,6 +249,20 @@ void bootstage_set_rec_count(uint count)
|
||||
data->rec_count = count;
|
||||
}
|
||||
|
||||
ulong bootstage_get_time(enum bootstage_id id)
|
||||
{
|
||||
struct bootstage_data *data = gd->bootstage;
|
||||
struct bootstage_record *rec;
|
||||
|
||||
if (!data)
|
||||
return 0;
|
||||
rec = find_id(data, id);
|
||||
if (!rec)
|
||||
return 0;
|
||||
|
||||
return rec->time_us;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record name as a printable string
|
||||
*
|
||||
|
||||
@@ -378,6 +378,14 @@ const struct bootstage_record *bootstage_get_rec(uint index);
|
||||
*/
|
||||
void bootstage_set_rec_count(uint count);
|
||||
|
||||
/*
|
||||
* bootstage_get_time() - Get the timestamp for a bootstage ID
|
||||
*
|
||||
* @id: Bootstage id to look up
|
||||
* Return: timestamp in us for that stage, or 0 if not found
|
||||
*/
|
||||
ulong bootstage_get_time(enum bootstage_id id);
|
||||
|
||||
/* Print a report about boot time */
|
||||
void bootstage_report(void);
|
||||
|
||||
@@ -478,6 +486,11 @@ static inline uint32_t bootstage_accum(enum bootstage_id id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline ulong bootstage_get_time(enum bootstage_id id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void bootstage_report(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ static int test_bootstage_mark(struct unit_test_state *uts)
|
||||
ut_asserteq_str("test_stage_mark", rec->name);
|
||||
ut_asserteq(time, rec->time_us);
|
||||
ut_asserteq(0, rec->flags);
|
||||
ut_asserteq(time, bootstage_get_time(BOOTSTAGE_ID_USER + 50));
|
||||
|
||||
/* Restore the original count */
|
||||
bootstage_set_rec_count(count);
|
||||
@@ -110,6 +111,7 @@ static int test_bootstage_accum(struct unit_test_state *uts)
|
||||
/* Check the total time accumulated */
|
||||
rec = bootstage_get_rec(index);
|
||||
ut_asserteq(rec->time_us, elapsed1 + elapsed2);
|
||||
ut_asserteq(rec->time_us, bootstage_get_time(id));
|
||||
|
||||
/* Restore the original count */
|
||||
bootstage_set_rec_count(count);
|
||||
|
||||
Reference in New Issue
Block a user