From patchwork Tue Oct 6 09:44:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 1377326 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=mi63Z7LL; 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=ZlholVl/; 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 4C5CJn0jYXz9sS8 for ; Tue, 6 Oct 2020 20:46:01 +1100 (AEDT) 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=mi63Z7LLvk2YcLVJqsviCHjge QBayjhfSzNC3T+t/+zUmiZYfXGB3l/37Iev3Phq6KwKLVtjAejWqI0LS2/2w4c7FKZD4ZJpKHWb/3 zwdNhxFds7ZQrZ2ivu9KFBWnK1UPULzKVvTYS3DeFox401TNYkrPrmgxfdpqUZrND0gddYol2Nmoo YyJie+EyGmO8gNG2W0zIvh0DAtwta+lc1Ul3VaAnCh7ZPAbesiP3+q8kY1304qx9rVcnqn3y12yua r+xsVD5s18U8fMFXWB7xVhy70WC4kEdtgbU/5HV/LJHk0OpgHY97OPxKyZFxzyRfplISy2tVSEhRZ 6Bj5EX9sQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPjXh-00005W-Oq; Tue, 06 Oct 2020 09:45:57 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPjXe-0008VS-Fx for linux-um@lists.infradead.org; Tue, 06 Oct 2020 09:45:56 +0000 Received: by mail-pg1-x542.google.com with SMTP id x16so7705336pgj.3 for ; Tue, 06 Oct 2020 02:45:54 -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=ZlholVl/dFZV1wJbuj+c1Edq1swxwn3sjURNYfImVwLS+jPaY96fWkhSangajbCy0/ bFEXWpO0ekB+jE1eGmqdlGE38V1U9qagvPtM1JjfmeRuy2Am+p1ANll6avpFZXZroy+1 UtbQhHIHheTgcT/7Pt6lflqckAAkyQbUfQXyBKExAWazXHCa+XF/630fM9Cpnj1QaqaE e8W7Sor2Gc09XP968raF3VnJnQK0b43Ox4HY11uG1QPJ0wP+j2sb3L3l4bO4tLYGedMW fWSBFC3P572H43g8VY48TJf2rZsPFXpOAkUVtRD+YcnXwAtxVSH7XbvOYL7x6hpnVixz DFzQ== 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=FNE5LZ+jU4bNH9j0J3euWhoymDqGAzvAb5xEPzMEfxh0ynFWsFViwsHre5GGMrx3pw /BjvRhejHKWDrwDA2ekWNkOcezP8tDVyiou6p7GcpArSHMMHt7HFqA9oMthWtN0984HQ /YL2HkKeKTdXq5L229D8wNjc2084RtY5tkDY6eNZr7oczEWwaHv+qNis3kc0kE09nO1p E8RmCabh5q/iUP3ucbMS4zZ5XDzwb/tHES4EF9x6Sd31uUzKIjzlSJZxUo7iiodlwwCT zvVVtySYOd600H0FOH0j9wJ9b2BAzjDoM9VCvO9VXmoDD7kz2/GiXuEhseFTf7JVeEyZ VoZQ== X-Gm-Message-State: AOAM533AXHWRZZPTMYO17J2aZ8xadVXvUeaYo1e3CimfOVuoKFsYSlW+ gNmF9lgjjA4N4SlWMarVEuY= X-Google-Smtp-Source: ABdhPJwVglZOcLYRka5KE8m8A0q01wp6rqFE8JjGc/rKwzzSz0J0QSIAiCaqsDb6zAfuLdueOpCF7Q== X-Received: by 2002:a63:2547:: with SMTP id l68mr3233160pgl.241.1601977552525; Tue, 06 Oct 2020 02:45:52 -0700 (PDT) Received: from earth-mac.local (219x123x138x129.ap219.ftth.ucom.ne.jp. [219.123.138.129]) by smtp.gmail.com with ESMTPSA id x5sm2988461pfp.113.2020.10.06.02.45.51 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Oct 2020 02:45:51 -0700 (PDT) Received: by earth-mac.local (Postfix, from userid 501) id 3FF9220390F4FA; Tue, 6 Oct 2020 18:45:49 +0900 (JST) From: Hajime Tazaki To: linux-um@lists.infradead.org, jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com Subject: [RFC v7 13/21] um: nommu: basic console support Date: Tue, 6 Oct 2020 18:44:22 +0900 Message-Id: <50557e259c25a5fea82e687665ab611ea54f599f.1601960644.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-20201006_054554_550179_ED302965 X-CRM114-Status: GOOD ( 17.67 ) 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:542 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [thehajime[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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); +