[Skiboot] [PATCH] mambo: add mprintf()

Oliver O'Halloran oohall at gmail.com
Fri Jan 6 00:03:23 AEDT 2017


mprintf() is printf(), but it goes straight to the mambo console. This
allows it to be independent of Skiboot's actual console infrastructure
so it can be used for debugging the console drivers and for debugging
code that runs before the console is setup.

Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 include/console.h         |  2 ++
 platforms/mambo/console.c | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/include/console.h b/include/console.h
index b726251fc5f2..708b696bf03e 100644
--- a/include/console.h
+++ b/include/console.h
@@ -100,4 +100,6 @@ extern struct opal_con_ops uart_opal_con;
 extern struct opal_con_ops fsp_opal_con;
 extern struct opal_con_ops dummy_opal_con;
 
+void mprintf(const char *fmt, ...);
+
 #endif /* __CONSOLE_H */
diff --git a/platforms/mambo/console.c b/platforms/mambo/console.c
index c7d7ab030c30..d02cde93590b 100644
--- a/platforms/mambo/console.c
+++ b/platforms/mambo/console.c
@@ -66,3 +66,22 @@ void enable_mambo_console(void)
 	prlog(PR_NOTICE, "Enabling Mambo console\n");
 	set_console(&mambo_con_driver);
 }
+
+/*
+ * mambo console based printf(), this is useful for debugging the console
+ * since mambo_console_write() can be safely called from anywhere.
+ *
+ * This is a debug hack and you shouldn't use it in real code.
+ */
+void mprintf(const char *fmt, ...)
+{
+	char buf[320];
+	va_list args;
+	int i;
+
+	va_start(args, fmt);
+	i = vsnprintf(buf, sizeof(buf), fmt, args);
+	va_end(args);
+
+	mambo_console_write(buf, i);
+}
-- 
2.7.4



More information about the Skiboot mailing list