From patchwork Thu Mar 13 15:09:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 26205 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f72.google.com (mail-pb0-f72.google.com [209.85.160.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 05893206A0 for ; Thu, 13 Mar 2014 15:11:42 +0000 (UTC) Received: by mail-pb0-f72.google.com with SMTP id jt11sf2673137pbb.11 for ; Thu, 13 Mar 2014 08:11:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=J7W0BlAZx6FLXN6jEhqZ3yH2xAjGMHQlhRq24cOFjxE=; b=lKKO6/9PU8tDQqt54pQwR+/j9AIPsf8O1S0lhOwNFdttmlC6t72/C9eMoIMsyLV1Z3 vt8JwJMYAKJDcNDXdfb25mVD0C942Nq0IFAQFfHZGKgar7Nczwi8p2Ti5NTs4kgfAgbO /qNPbPKG62AtiFntRQ9/HvoRWswOXXe7QRKf8TXFCq1rpV/Pww09jT9brR2LS+iINX7r /4T4HTizBawBAAbXaGoJRg9zDvzlODcj0tGvAiACfbP8GzpE11w5XboA0v3KnMdE9Dlc n1UGYGIslM5Zs7B+Ozo8CwBiHWSzKyzpZ9Bhma7RHeH0JME6CqngGAwA3lAOaHG1haG8 091A== X-Gm-Message-State: ALoCoQmiDdIZzBAnzNo56cch/rx4zOnPaYflvYcKyiCcsyUuQLMn5UrCfUhZDMFKUY0fzjSrOP9P X-Received: by 10.66.66.196 with SMTP id h4mr870483pat.22.1394723502188; Thu, 13 Mar 2014 08:11:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.138 with SMTP id c10ls324688qga.63.gmail; Thu, 13 Mar 2014 08:11:42 -0700 (PDT) X-Received: by 10.220.12.140 with SMTP id x12mr1852136vcx.19.1394723502064; Thu, 13 Mar 2014 08:11:42 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id ie18si407030vec.127.2014.03.13.08.11.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Mar 2014 08:11:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id cz12so1230214veb.35 for ; Thu, 13 Mar 2014 08:11:42 -0700 (PDT) X-Received: by 10.58.238.35 with SMTP id vh3mr1918034vec.16.1394723501977; Thu, 13 Mar 2014 08:11:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp374633vck; Thu, 13 Mar 2014 08:11:41 -0700 (PDT) X-Received: by 10.221.55.199 with SMTP id vz7mr534838vcb.40.1394723495579; Thu, 13 Mar 2014 08:11:35 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id rx10si526763vdc.32.2014.03.13.08.11.34 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Mar 2014 08:11:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WO7GM-0001XU-5s; Thu, 13 Mar 2014 15:09:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WO7GK-0001Vk-GZ for xen-devel@lists.xenproject.org; Thu, 13 Mar 2014 15:09:36 +0000 Received: from [85.158.137.68:17099] by server-13.bemta-3.messagelabs.com id 79/FB-18692-F2AC1235; Thu, 13 Mar 2014 15:09:35 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-12.tower-31.messagelabs.com!1394723374!448381!1 X-Originating-IP: [209.85.212.170] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6018 invoked from network); 13 Mar 2014 15:09:35 -0000 Received: from mail-wi0-f170.google.com (HELO mail-wi0-f170.google.com) (209.85.212.170) by server-12.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 13 Mar 2014 15:09:35 -0000 Received: by mail-wi0-f170.google.com with SMTP id n15so3690219wiw.5 for ; Thu, 13 Mar 2014 08:09:34 -0700 (PDT) X-Received: by 10.180.126.38 with SMTP id mv6mr2069742wib.46.1394723374666; Thu, 13 Mar 2014 08:09:34 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id d15sm6358675wjx.0.2014.03.13.08.09.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Mar 2014 08:09:33 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 13 Mar 2014 15:09:17 +0000 Message-Id: <1394723358-22845-5-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1394723358-22845-1-git-send-email-julien.grall@linaro.org> References: <1394723358-22845-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Keir Fraser , Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v4 4/5] xen/console: Add support for early printk X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: 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 Signed-off-by: Julien Grall Acked-by: Keir Fraser --- 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 #include #include +#include #include 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 #include #include /* for do_console_io */ +#include /* 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: + */