From: Julien Grall <julien.grall@linaro.org>
To: xen-devel@lists.xenproject.org
Cc: stefano.stabellini@citrix.com, Keir Fraser <keir@xen.org>,
Julien Grall <julien.grall@linaro.org>,
tim@xen.org, ian.campbell@citrix.com
Subject: [PATCH v4 4/5] xen/console: Add support for early printk
Date: Thu, 13 Mar 2014 15:09:17 +0000 [thread overview]
Message-ID: <1394723358-22845-5-git-send-email-julien.grall@linaro.org> (raw)
In-Reply-To: <1394723358-22845-1-git-send-email-julien.grall@linaro.org>
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.
Cc: Keir Fraser <keir@xen.org>
Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
Changes in v4:
- Define early_puts as NULL when CONFIG_EARLY_PRINTK is not enabled
Changes in v2:
- Create xen/early_printk.h
---
xen/arch/arm/early_printk.c | 1 +
xen/drivers/char/console.c | 6 +++++-
xen/include/asm-arm/early_printk.h | 3 ---
xen/include/xen/early_printk.h | 21 +++++++++++++++++++++
4 files changed, 27 insertions(+), 4 deletions(-)
create mode 100644 xen/include/xen/early_printk.h
diff --git a/xen/arch/arm/early_printk.c b/xen/arch/arm/early_printk.c
index 6b90998..8aef152 100644
--- a/xen/arch/arm/early_printk.c
+++ b/xen/arch/arm/early_printk.c
@@ -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);
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 7fa9b78..50b4415 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -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, ',');
diff --git a/xen/include/asm-arm/early_printk.h b/xen/include/asm-arm/early_printk.h
index 5ef2ec4..f5b801e 100644
--- a/xen/include/asm-arm/early_printk.h
+++ b/xen/include/asm-arm/early_printk.h
@@ -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
index 0000000..2c3e1b3
--- /dev/null
+++ b/xen/include/xen/early_printk.h
@@ -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:
+ */
--
1.7.10.4
next prev parent reply other threads:[~2014-03-13 15:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-13 15:09 [PATCH v4 0/5] xen/arm: Merge early_printk function in console code Julien Grall
2014-03-13 15:09 ` [PATCH v4 1/5] xen/arm: earlyprintk: move early_flush in early_puts Julien Grall
2014-03-13 15:09 ` [PATCH v4 2/5] xen/arm: earlyprintk: export early_puts Julien Grall
2014-03-13 15:09 ` [PATCH v4 3/5] xen/arm: Rename EARLY_PRINTK compile option to CONFIG_EARLY_PRINTK Julien Grall
2014-03-13 15:09 ` Julien Grall [this message]
2014-03-28 15:29 ` [PATCH v4 4/5] xen/console: Add support for early printk Keir Fraser
2014-03-13 15:09 ` [PATCH v4 5/5] xen/arm: Replace early_{printk, panic} call to {printk, panic} call Julien Grall
2014-04-01 10:54 ` [PATCH v4 0/5] xen/arm: Merge early_printk function in console code Ian Campbell
2014-04-01 11:07 ` Julien Grall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1394723358-22845-5-git-send-email-julien.grall@linaro.org \
--to=julien.grall@linaro.org \
--cc=ian.campbell@citrix.com \
--cc=keir@xen.org \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).