From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756582AbcBXMXu (ORCPT ); Wed, 24 Feb 2016 07:23:50 -0500 Received: from smtp02.citrix.com ([66.165.176.63]:15641 "EHLO SMTP02.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755769AbcBXMXr (ORCPT ); Wed, 24 Feb 2016 07:23:47 -0500 X-IronPort-AV: E=Sophos;i="5.22,493,1449532800"; d="scan'208";a="340691252" From: Stefano Stabellini To: CC: , , , , , Stefano Stabellini Subject: [PATCH 1/2] hvc_xen: add earlycon support Date: Wed, 24 Feb 2016 12:23:09 +0000 Message-ID: <1456316590-20020-1-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-DLP: MIA1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce EARLYCON support in hvc_xen, useful for early debugging on arm and arm64, where xen early_printk is not available. Differently from xenboot_write_console on x86, we won't just return if !xen_pv_domain(), because arm and arm64 guests are actually xen_hvm_domain() from linux pov, and also because we want to capture all possible writes, including the ones earlier than xen_early_init(). Signed-off-by: Stefano Stabellini --- drivers/tty/hvc/hvc_xen.c | 48 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index fa816b7..34e8e9f 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -597,21 +598,11 @@ static int xen_cons_init(void) } console_initcall(xen_cons_init); -#ifdef CONFIG_EARLY_PRINTK -static void xenboot_write_console(struct console *console, const char *string, - unsigned len) +static void domU_write_early_console(const char *string, unsigned len) { unsigned int linelen, off = 0; const char *pos; - if (!xen_pv_domain()) - return; - - dom0_write_console(0, string, len); - - if (xen_initial_domain()) - return; - domU_write_console(0, "(early) ", 8); while (off < len && NULL != (pos = strchr(string+off, '\n'))) { linelen = pos-string+off; @@ -625,6 +616,21 @@ static void xenboot_write_console(struct console *console, const char *string, domU_write_console(0, string+off, len-off); } +#ifdef CONFIG_EARLY_PRINTK +static void xenboot_write_console(struct console *console, const char *string, + unsigned len) +{ + if (!xen_pv_domain()) + return; + + dom0_write_console(0, string, len); + + if (xen_initial_domain()) + return; + + domU_write_early_console(string, len); +} + struct console xenboot_console = { .name = "xenboot", .write = xenboot_write_console, @@ -664,3 +670,23 @@ void xen_raw_printk(const char *fmt, ...) xen_raw_console_write(buf); } + +static void xenboot_earlycon_write(struct console *console, + const char *string, + unsigned len) +{ + dom0_write_console(0, string, len); + + if (xen_initial_domain()) + return; + + domU_write_early_console(string, len); +} + +static int __init xenboot_earlycon_setup(struct earlycon_device *device, + const char *opt) +{ + device->con->write = xenboot_earlycon_write; + return 0; +} +EARLYCON_DECLARE(xenboot, xenboot_earlycon_setup); -- 1.7.10.4