From patchwork Mon Feb 24 14:52: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: 25201 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A6C3A2066C for ; Mon, 24 Feb 2014 14:54:17 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id at1sf22679113iec.5 for ; Mon, 24 Feb 2014 06:54:17 -0800 (PST) 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=2nkMGnvML6LucKmLeLnbjeyTkQx8JmnqcBNnanNCfl0=; b=BzcuvHeE4gj4rGLgd10+VXYKLaiXOATwj4Hd/XLDCdwqxXOAtrefH1Uoao0dXHB/AR wlmLA8CHX79M5b4mx3K6PNgZTmn1gFSp4BUF8RNqzxKLgqQpGi5Op5WDEA4M6qr2q+iv jAtgpKd/qkHRIoqTwP5Yt+136Dsz5ggLZPdIJqnG+yYxHh1Sy5uQtquNM27RuxyHDIF9 rO6Z8Ago6WzjS1gMSPrk1xqm86uyzg8ZCHVsLHcIJXWS1rspbD6NCygJdw3SoYL0szhw grTgjLrt1TsLsVW06/u+wsxZxB8922U12dA9Oftat7wKZ/bXAwaJIVYMMpJuvp+U5B5F 5GPQ== X-Gm-Message-State: ALoCoQl0S2Y4QVS1FoXw1NpCOkOb49Q1mOL3ooWkSECv8VOJdPouP+9E9Vtrm23Nkbb7JtwQAhKw X-Received: by 10.182.66.73 with SMTP id d9mr9145863obt.8.1393253657084; Mon, 24 Feb 2014 06:54:17 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.129 with SMTP id g1ls2026965qge.69.gmail; Mon, 24 Feb 2014 06:54:16 -0800 (PST) X-Received: by 10.220.188.70 with SMTP id cz6mr181537vcb.59.1393253656961; Mon, 24 Feb 2014 06:54:16 -0800 (PST) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id a5si5900178vez.6.2014.02.24.06.54.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Feb 2014 06:54:16 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id id10so5953773vcb.27 for ; Mon, 24 Feb 2014 06:54:16 -0800 (PST) X-Received: by 10.52.230.105 with SMTP id sx9mr10927047vdc.10.1393253656860; Mon, 24 Feb 2014 06:54:16 -0800 (PST) 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.174.196 with SMTP id u4csp66772vcz; Mon, 24 Feb 2014 06:54:16 -0800 (PST) X-Received: by 10.221.2.138 with SMTP id nu10mr572424vcb.52.1393253655186; Mon, 24 Feb 2014 06:54:15 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id ks3si5899164vec.13.2014.02.24.06.54.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 24 Feb 2014 06:54:15 -0800 (PST) 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 1WHwuC-0006CI-HJ; Mon, 24 Feb 2014 14:53:16 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WHwuA-0006Ak-QX for xen-devel@lists.xenproject.org; Mon, 24 Feb 2014 14:53:15 +0000 Received: from [85.158.139.211:49219] by server-3.bemta-5.messagelabs.com id 52/61-13671-ADC5B035; Mon, 24 Feb 2014 14:53:14 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-13.tower-206.messagelabs.com!1393253592!5884970!1 X-Originating-IP: [74.125.83.43] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.9.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10365 invoked from network); 24 Feb 2014 14:53:12 -0000 Received: from mail-ee0-f43.google.com (HELO mail-ee0-f43.google.com) (74.125.83.43) by server-13.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 24 Feb 2014 14:53:12 -0000 Received: by mail-ee0-f43.google.com with SMTP id e51so3048710eek.16 for ; Mon, 24 Feb 2014 06:53:12 -0800 (PST) X-Received: by 10.14.194.193 with SMTP id m41mr25170875een.76.1393253592430; Mon, 24 Feb 2014 06:53:12 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id x6sm64689130eew.20.2014.02.24.06.53.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Feb 2014 06:53:11 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 24 Feb 2014 14:52:50 +0000 Message-Id: <1393253572-7157-5-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1393253572-7157-1-git-send-email-julien.grall@linaro.org> References: <1393253572-7157-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 v2 4/6] 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.220.182 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 affe424..8f5a94f 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 532c426..cdf23f1 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 dd190c9..2e8c18a 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 early_panic(const char *fmt, ...) __attribute__((noreturn)) @@ -32,8 +31,6 @@ void early_panic(const char *fmt, ...) __attribute__((noreturn)) #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: + */