]> xenbits.xensource.com Git - xen.git/commitdiff
xen/console: Add support for early printk
authorJulien Grall <julien.grall@linaro.org>
Thu, 13 Mar 2014 15:09:17 +0000 (15:09 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 1 Apr 2014 10:30:33 +0000 (11:30 +0100)
On ARM, a function (early_printk) was introduced to output message when the
serial port is not initialized.

This solution is fragile because the developper needs to know when the serial
port is initialized, to use either early_printk or printk. Moreover some
functions (mainly in common code), only use printk. This will result to a loss
of message sometimes.

Directly call early_printk in console code when the serial port is not yet
initialized. For this purpose use serial_steal_fn.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Keir Fraser <keir@xen.org>
xen/arch/arm/early_printk.c
xen/drivers/char/console.c
xen/include/asm-arm/early_printk.h
xen/include/xen/early_printk.h [new file with mode: 0644]

index 6b90998fe5a7cef91474867961926c1a4eacffaa..8aef1529e1bb71e9d3864ca1b792d66320c1297e 100644 (file)
@@ -13,6 +13,7 @@
 #include <xen/lib.h>
 #include <xen/stdarg.h>
 #include <xen/string.h>
+#include <xen/early_printk.h>
 #include <asm/early_printk.h>
 
 void early_putch(char c);
index 7fa9b789ced3be35bf9d23f4a60e26b7dd680e96..50b4415623509a72966839577cbefba597459295 100644 (file)
@@ -28,6 +28,7 @@
 #include <asm/debugger.h>
 #include <asm/div64.h>
 #include <xen/hypercall.h> /* for do_console_io */
+#include <xen/early_printk.h>
 
 /* console: comma-separated list of console outputs. */
 static char __initdata opt_console[30] = OPT_CONSOLE_STR;
@@ -255,7 +256,7 @@ long read_console_ring(struct xen_sysctl_readconsole *op)
 static char serial_rx_ring[SERIAL_RX_SIZE];
 static unsigned int serial_rx_cons, serial_rx_prod;
 
-static void (*serial_steal_fn)(const char *);
+static void (*serial_steal_fn)(const char *) = early_puts;
 
 int console_steal(int handle, void (*fn)(const char *))
 {
@@ -699,7 +700,10 @@ void __init console_init_preirq(void)
         else if ( !strncmp(p, "none", 4) )
             continue;
         else if ( (sh = serial_parse_handle(p)) >= 0 )
+        {
             sercon_handle = sh;
+            serial_steal_fn = NULL;
+        }
         else
         {
             char *q = strchr(p, ',');
index 5ef2ec48dc99855cc5a36265d077568fcaa2a629..f5b801e223a3f86d8d5de8071f5aca11cf73e8d0 100644 (file)
@@ -24,7 +24,6 @@
 
 #ifdef CONFIG_EARLY_PRINTK
 
-void early_puts(const char *s);
 void early_printk(const char *fmt, ...)
     __attribute__((format (printf, 1, 2)));
 void noreturn early_panic(const char *fmt, ...)
@@ -32,8 +31,6 @@ void noreturn early_panic(const char *fmt, ...)
 
 #else
 
-static inline void early_puts(const char *) {}
-
 static inline  __attribute__((format (printf, 1, 2))) void
 early_printk(const char *fmt, ...)
 {}
diff --git a/xen/include/xen/early_printk.h b/xen/include/xen/early_printk.h
new file mode 100644 (file)
index 0000000..2c3e1b3
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * printk() for use before the console is initialized
+ */
+#ifndef __XEN_EARLY_PRINTK_H__
+#define __XEN_EARLY_PRINTK_H__
+
+#ifdef CONFIG_EARLY_PRINTK
+void early_puts(const char *s);
+#else
+#define early_puts NULL
+#endif
+
+#endif
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */