[U-Boot] [PATCH v2 2/7] Add macros for recording init calls during UBoot execution

Andrew Murray amurray at theiet.org
Sat Sep 10 15:17:28 CEST 2011


From: Andrew Murray <amurray at mpcdata.com>

The previous patch included a compile error when the CONFIG_BOOT_TRACE macro is not
set, this is an update to that patch
---
This patch adds macros which allow for the instrumentation of UBoot boot
time. The macros can be used to call existing initialisation functions during
start up. Each macro adds printf statements before and after the initialisation
call.
---
Changes for v2:
	- Use dedicated printf with timestamp function
	- Allow DO_INITCALL_RET macro to provide return value

Signed-off-by: Andrew Murray <amurray at theiet.org>
---
 include/common.h |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/include/common.h b/include/common.h
index 1e21b7a..196c306 100644
--- a/include/common.h
+++ b/include/common.h
@@ -176,6 +176,33 @@ typedef void (interrupt_handler_t)(void *);
 
 #endif /* CONFIG_SERIAL_MULTI */
 
+#if defined(CONFIG_BOOT_TRACE)
+#define DO_INITCALL(x, ...) \
+	do { \
+		printf_boot_trace("calling  0x%pF\n", x); \
+		(x)(__VA_ARGS__); \
+		printf_boot_trace("initcall 0x%pF returned\n", x); \
+	} while (0)
+#define DO_INITCALL_RET(x, ...) \
+	({ \
+		int __ret; \
+		printf_boot_trace("calling  0x%pF\n", x); \
+		__ret = (x)(__VA_ARGS__); \
+		printf_boot_trace("initcall 0x%pF returned\n", x); \
+		__ret; \
+	})
+#define DO_INITCALL_END(x) \
+	do { \
+		printf_boot_trace("initcall 0x%pF returned\n", x); \
+	} while (0)
+#else
+#define DO_INITCALL(x, ...) \
+	({ (x)(__VA_ARGS__); })
+#define DO_INITCALL_RET(x, ...) \
+	({ (x)(__VA_ARGS__); })
+#define DO_INITCALL_END(x)
+#endif
+
 /*
  * General Purpose Utilities
  */
@@ -687,6 +714,8 @@ void	puts(const char *s);
 int	printf(const char *fmt, ...)
 		__attribute__ ((format (__printf__, 1, 2)));
 int	vprintf(const char *fmt, va_list args);
+int	printf_boot_trace(const char *fmt, ...)
+		__attribute__ ((format (__printf__, 1, 2)));
 
 /* stderr */
 #define eputc(c)		fputc(stderr, c)
-- 
1.7.4.1



More information about the U-Boot mailing list