summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-04-17 16:13:44 +0000
committerSimon Glass <sjg@chromium.org>2013-05-13 13:33:22 -0700
commitfb7db41cd46e96621fd97b827622668ee2c6b845 (patch)
treedd6701b1192af6ed1df98c91995546eab64a6d8c
parent2e65959be679a2401b0f0fc02934f6b6d48f9fd8 (diff)
downloadu-boot-imx-fb7db41cd46e96621fd97b827622668ee2c6b845.zip
u-boot-imx-fb7db41cd46e96621fd97b827622668ee2c6b845.tar.gz
u-boot-imx-fb7db41cd46e96621fd97b827622668ee2c6b845.tar.bz2
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 <sjg@chromium.org> Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
-rw-r--r--common/bootstage.c29
-rw-r--r--include/bootstage.h23
2 files changed, 52 insertions, 0 deletions
diff --git a/common/bootstage.c b/common/bootstage.c
index 15afa24..c5c6996 100644
--- a/common/bootstage.c
+++ b/common/bootstage.c
@@ -30,6 +30,8 @@
#include <common.h>
#include <libfdt.h>
+#include <malloc.h>
+#include <linux/compiler.h>
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];
diff --git a/include/bootstage.h b/include/bootstage.h
index c8235e8..0f44e71 100644
--- a/include/bootstage.h
+++ b/include/bootstage.h
@@ -267,6 +267,19 @@ ulong bootstage_error(enum bootstage_id id);
ulong bootstage_mark_name(enum bootstage_id id, const char *name);
/**
+ * Mark a time stamp in the given function and line number
+ *
+ * See BOOTSTAGE_MARKER() for a convenient macro.
+ *
+ * @param file Filename to record (NULL if none)
+ * @param func Function name to record
+ * @param linenum Line number to record
+ * @return recorded time stamp
+ */
+ulong bootstage_mark_code(const char *file, const char *func,
+ int linenum);
+
+/**
* Mark the start of a bootstage activity. The end will be marked later with
* bootstage_accum() and at that point we accumulate the time taken. Calling
* this function turns the given id into a accumulator rather than and
@@ -358,6 +371,12 @@ static inline ulong bootstage_mark_name(enum bootstage_id id, const char *name)
return 0;
}
+static inline ulong bootstage_mark_code(const char *file, const char *func,
+ int linenum)
+{
+ return 0;
+}
+
static inline uint32_t bootstage_start(enum bootstage_id id, const char *name)
{
return 0;
@@ -379,4 +398,8 @@ static inline int bootstage_unstash(void *base, int size)
}
#endif /* CONFIG_BOOTSTAGE */
+/* Helper macro for adding a bootstage to a line of code */
+#define BOOTSTAGE_MARKER() \
+ bootstage_mark_code(__FILE__, __func__, __LINE__)
+
#endif