From patchwork Wed Mar 12 14:34:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 26130 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F1E39236AC for ; Wed, 12 Mar 2014 14:37:25 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf40062936oag.8 for ; Wed, 12 Mar 2014 07:37:25 -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=fQjagmG0WuWnHkcH+dWhGWEovzy9BaZVpeUW5XeIEKU=; b=WlqSWMgph+hinDlpNP2aaqzFJH3ly0vi6VO+OaGCkmIyW+K5m5c8JAZdtljbykO3Cx fiCWErI4XhIobovCeLy51Cln86kp30ark9zvbUqT4hZ9WVfRTs/B9gNfeeeh3tR8iWuM mvIFL0/Azkduj5QEZcMvIy2Fq5B/BzqtOgBorjQtjppm2xWH1K24IUEMnJadgwpnBE8Z VTGT8+XeJ/t0Fmw17UPHt56RSAt0Ncw3Lz5tTo77oBP3S9AfXyyKwcRTeaZvAXzuX88t /VOmCjt0QV0B5elSposurYejt7RmPGesTTXtpAANIvftIF4LoqKqCUwALpsGVUY2G3fC cURQ== X-Gm-Message-State: ALoCoQklu0qYKCwCbnGhuizZ/4FOG8V9SpCHB6+RSX4e3PK0m1amdeeFcL+isGDkRfGS5KOYn2Zv X-Received: by 10.42.110.198 with SMTP id r6mr7328792icp.33.1394635045543; Wed, 12 Mar 2014 07:37:25 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.33.203 with SMTP id j69ls2927579qgj.27.gmail; Wed, 12 Mar 2014 07:37:25 -0700 (PDT) X-Received: by 10.58.229.4 with SMTP id sm4mr33805870vec.10.1394635045200; Wed, 12 Mar 2014 07:37:25 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id tt2si7534496vdc.74.2014.03.12.07.37.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Mar 2014 07:37:25 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 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.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so10370262veb.12 for ; Wed, 12 Mar 2014 07:37:25 -0700 (PDT) X-Received: by 10.52.242.167 with SMTP id wr7mr1028998vdc.32.1394635045119; Wed, 12 Mar 2014 07:37:25 -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 i9csp293212vck; Wed, 12 Mar 2014 07:37:24 -0700 (PDT) X-Received: by 10.58.248.228 with SMTP id yp4mr506994vec.35.1394635044512; Wed, 12 Mar 2014 07:37:24 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id i7si750722vei.107.2014.03.12.07.37.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 12 Mar 2014 07:37:24 -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 1WNkFW-0001T2-JC; Wed, 12 Mar 2014 14:35:14 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WNkFV-0001SP-1P for xen-devel@lists.xenproject.org; Wed, 12 Mar 2014 14:35:13 +0000 Received: from [85.158.143.35:11174] by server-2.bemta-4.messagelabs.com id 29/FC-06539-0A070235; Wed, 12 Mar 2014 14:35:12 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-8.tower-21.messagelabs.com!1394634910!1567374!1 X-Originating-IP: [209.85.212.175] 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 19898 invoked from network); 12 Mar 2014 14:35:11 -0000 Received: from mail-wi0-f175.google.com (HELO mail-wi0-f175.google.com) (209.85.212.175) by server-8.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 12 Mar 2014 14:35:11 -0000 Received: by mail-wi0-f175.google.com with SMTP id cc10so2483867wib.2 for ; Wed, 12 Mar 2014 07:35:10 -0700 (PDT) X-Received: by 10.194.5.5 with SMTP id o5mr1446768wjo.16.1394634910696; Wed, 12 Mar 2014 07:35:10 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id r1sm16524040wia.5.2014.03.12.07.35.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Mar 2014 07:35:10 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 12 Mar 2014 14:34:50 +0000 Message-Id: <1394634891-27906-5-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1394634891-27906-1-git-send-email-julien.grall@linaro.org> References: <1394634891-27906-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 v3 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.181 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 --- 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 7d4383c..cf7c9bb 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; @@ -245,7 +246,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 *)) { @@ -652,7 +653,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..c213d18 --- /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 +static inline void early_puts(const char *s) {}; +#endif + +#endif +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */