From fb7db41cd46e96621fd97b827622668ee2c6b845 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 17 Apr 2013 16:13:44 +0000 Subject: bootstage: Allow marking a particular line of code Add a function which allows a (file, function, line number) to be marked in bootstage. Signed-off-by: Simon Glass Reviewed-by: Che-Liang Chiou --- common/bootstage.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'common/bootstage.c') diff --git a/common/bootstage.c b/common/bootstage.c index 15afa24c44..c5c69961ac 100644 --- a/common/bootstage.c +++ b/common/bootstage.c @@ -30,6 +30,8 @@ #include #include +#include +#include DECLARE_GLOBAL_DATA_PTR; @@ -117,6 +119,33 @@ ulong bootstage_mark_name(enum bootstage_id id, const char *name) return bootstage_add_record(id, name, flags, timer_get_boot_us()); } +ulong bootstage_mark_code(const char *file, const char *func, int linenum) +{ + char *str, *p; + __maybe_unused char *end; + int len = 0; + + /* First work out the length we need to allocate */ + if (linenum != -1) + len = 11; + if (func) + len += strlen(func); + if (file) + len += strlen(file); + + str = malloc(len + 1); + p = str; + end = p + len; + if (file) + p += snprintf(p, end - p, "%s,", file); + if (linenum != -1) + p += snprintf(p, end - p, "%d", linenum); + if (func) + p += snprintf(p, end - p, ": %s", func); + + return bootstage_mark_name(BOOTSTAGE_ID_ALLOC, str); +} + uint32_t bootstage_start(enum bootstage_id id, const char *name) { struct bootstage_record *rec = &record[id]; -- cgit v1.2.1