From patchwork Thu Sep 24 07:12:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 1370377 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=IVAIpCo4; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Zmy1SS6k; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BxmXt564Wz9sTN for ; Thu, 24 Sep 2020 17:15:42 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fAZ/cSiOUCISz6QtsSLAFQTlDLruQjvmpiwIJhQIycQ=; b=IVAIpCo4SEEpIlTj3ntlsddGM 7D2x3DKZfJZjFyFzem09mTQ1jnSdKI48qaEo2SXlJNI0j9cz9BfBlmKtvQsfPr3kPM42QMyWSUboy VRqkyCQ25zy/1oQJNmnPPpsD1Mn33YoQA6IvClWSb4TuBf3iYgphRjERRbp8o5Kf+mS+tWPyDCsdG qLwJAbBFR807JFZWAfJg6teHaYXK8jE+hdw42uAMv9o8Cs0CF5YYVg3C/ohlr1ONg22+o0Y2vtKqv //QU3fN93KvYP7I5mc2dhhoYm/OMQYcz7KfVr89eQ2fxIT7b1t1+Y4paPxc6lm7cMsw9vK9QHJvDi qlg7u90uA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLLTf-0003ah-7Z; Thu, 24 Sep 2020 07:15:39 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLLTZ-0003ZB-Nb for linux-um@lists.infradead.org; Thu, 24 Sep 2020 07:15:37 +0000 Received: by mail-pj1-x1042.google.com with SMTP id mn7so1120135pjb.5 for ; Thu, 24 Sep 2020 00:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dw71STGvxu+fI7O/Zk3vtwTxDzn/GLjAFDhUcWGe5Xc=; b=Zmy1SS6kl0jxxONEvBC4wfmfIJ1KuHy2r4cVTdhd5TSpg0pk/4s08WSU0NLFyQNpQt y2lIxp9PemHVppTSCraE3H6U1KBIvC01tzr3p6gvSFfFt2tC0veYPgb31cou+32kYAfY 3BFeWKUb4qhfeVPliICJFB5BrNVWCSKeiXIeG7RJnUYwfGJr3kvEajYCNuYuf/hbpTqm A9SZEuxnNoZUUHeZB18ecNm3ESGb8KUSy7f4N0/t17jMzJcxf+DQpsgdU+LKuq5R7EHx JTmHt+kPxqUF0WqrzwkrcNr3GvZOgHg7bGmLSMr3aQPlL7B6mBPg3xgrbdOFOXdxfPPJ KC6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dw71STGvxu+fI7O/Zk3vtwTxDzn/GLjAFDhUcWGe5Xc=; b=PXQ/XNKZPPNFjVdTV1z3j+jEAK1u7BER4TaiFIOUPiIRfOuJNH30UAaL5mzXn/yH+6 l11arj3jKlIyQsb3i/zub8DZnmHCuSBK9oa8BQYvNQfF/JkRtH7vQmmg83E6gkxvJmvC Gc6GCYJTozHFCjYJ8aX6S7EZkhGwTiAQiE3zMNtOClcemDoBH9eUiwJ1Dc7vT0Fkm9Rn Cjm7/z9HV8oyk2Tf8GP6EzMq9D1v2u/+j7dkRcmtAkN/DLRMyBIfwfygRRutGFcWri/R 7E3os7NxLp74lC6sE0iqKntXClF2PwxHVFfXlpe6nWiPXRuUPojA29S3qAdSLURMk821 Kb9g== X-Gm-Message-State: AOAM533xn/YZIQd/fgymglEX2Iuevoogy2DM59ssYrBn0DWkFGB0QCo0 1xjCdyYOhc/UbmzNiYzmvnw= X-Google-Smtp-Source: ABdhPJyyI9b4RjXtue10Pcn9wOYh23pY5YnZqTM4dKsIAg9ZR7hWxwRFU9TNytr+vT5qmL/RfOGtog== X-Received: by 2002:a17:90a:e44b:: with SMTP id jp11mr2724334pjb.96.1600931731555; Thu, 24 Sep 2020 00:15:31 -0700 (PDT) Received: from earth-mac.local (219x123x138x129.ap219.ftth.ucom.ne.jp. [219.123.138.129]) by smtp.gmail.com with ESMTPSA id 124sm1722152pfd.132.2020.09.24.00.15.30 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Sep 2020 00:15:30 -0700 (PDT) Received: by earth-mac.local (Postfix, from userid 501) id 8B05D2037C20AD; Thu, 24 Sep 2020 16:15:28 +0900 (JST) From: Hajime Tazaki To: linux-um@lists.infradead.org, jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com Subject: [RFC v6 13/21] um: nommu: basic console support Date: Thu, 24 Sep 2020 16:12:53 +0900 Message-Id: <379481a81c96e9a073df02dc49f976dc6e346cc4.1600922529.git.thehajime@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200924_031533_783171_503DA22F X-CRM114-Status: GOOD ( 17.25 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1042 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [thehajime[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tavi.purdila@gmail.com, linux-kernel-library@freelists.org, linux-arch@vger.kernel.org, Hajime Tazaki , retrage01@gmail.com Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This commit also disables stdio-console of UM if !CONFIG_MMU to avoid conflicts between multiple consoles. Signed-off-by: Hajime Tazaki --- arch/um/drivers/Makefile | 8 ++++- arch/um/nommu/include/uapi/asm/host_ops.h | 3 ++ arch/um/nommu/um/console.c | 42 +++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 arch/um/nommu/um/console.c diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile index ae96c83e312d..694da4aa550d 100644 --- a/arch/um/drivers/Makefile +++ b/arch/um/drivers/Makefile @@ -37,7 +37,13 @@ $(obj)/vde.o: $(obj)/vde_kern.o $(obj)/vde_user.o # When the above is fixed, don't forget to add this too! #targets += $(obj)/pcap.o -obj-y := stdio_console.o fd.o chan_kern.o chan_user.o line.o +ifdef CONFIG_MMU +obj-y := stdio_console.o +else +obj-y := +endif +obj-y += fd.o chan_kern.o chan_user.o line.o + obj-$(CONFIG_SSL) += ssl.o obj-$(CONFIG_STDERR_CONSOLE) += stderr_console.o diff --git a/arch/um/nommu/include/uapi/asm/host_ops.h b/arch/um/nommu/include/uapi/asm/host_ops.h index 6ee9489fc47e..133877c857a1 100644 --- a/arch/um/nommu/include/uapi/asm/host_ops.h +++ b/arch/um/nommu/include/uapi/asm/host_ops.h @@ -15,6 +15,7 @@ struct lkl_jmp_buf { * * These operations must be provided by a host library or by the application * itself. + * @print - optional operation that receives console messages * * @sem_alloc - allocate a host semaphore an initialize it to count * @sem_free - free a host semaphore @@ -63,6 +64,8 @@ struct lkl_jmp_buf { * */ struct lkl_host_operations { + void (*print)(const char *str, int len); + struct lkl_sem *(*sem_alloc)(int count); void (*sem_free)(struct lkl_sem *sem); void (*sem_up)(struct lkl_sem *sem); diff --git a/arch/um/nommu/um/console.c b/arch/um/nommu/um/console.c new file mode 100644 index 000000000000..e3194f7bb0dd --- /dev/null +++ b/arch/um/nommu/um/console.c @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include + +static void console_write(struct console *con, const char *str, unsigned len) +{ + if (lkl_ops->print) + lkl_ops->print(str, len); +} + +#ifdef CONFIG_LKL_EARLY_CONSOLE +static struct console lkl_boot_console = { + .name = "lkl_boot_console", + .write = console_write, + .flags = CON_PRINTBUFFER | CON_BOOT, + .index = -1, +}; + +int __init lkl_boot_console_init(void) +{ + register_console(&lkl_boot_console); + return 0; +} +early_initcall(lkl_boot_console_init); +#endif + +static struct console lkl_console = { + .name = "lkl_console", + .write = console_write, + .flags = CON_PRINTBUFFER, + .index = -1, +}; + +int __init lkl_console_init(void) +{ + register_console(&lkl_console); + return 0; +} +core_initcall(lkl_console_init); +