From nobody Mon Feb 9 10:38:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1673010910; cv=none; d=zohomail.com; s=zohoarc; b=TvqilIdhNxyZvsApEzHLKwdd9zxmswMxilJ9q9zUMwZxUBiHh512h0ljSVXmg+U1rKJPfyXyZAA0/G7NPlguQhv6uDpr8Zy8Ah47czhGAF/rasrHvfsccf3Q11fnkqOuxsqRi+SCKXDQYLdCvit5ERBHUhjonRU+0IwrSu5ZLoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673010910; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Szof3vhqcf1cuBmqVq5Q2IZcNa/4nJpd7CeH5aS/VM8=; b=h2GL4b/Z1U0KFDmP1Dnk6FIq6+p9iYy1GvkK4nB2yqodEyG8Hx2vkqCaJJszBC48gk9xE2D2RQZjKT+LyNJkqg1NEkecNPSq9dizFbG/7LzQHxjj+Fy36I0Z/Rgq0cz7ZK98X1/8KmbAMlBefpjzaJsTTb3B03i5YKbrQitFpu0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1673010910861273.94064577743745; Fri, 6 Jan 2023 05:15:10 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.472544.732825 (Exim 4.92) (envelope-from ) id 1pDmYa-00045H-CR; Fri, 06 Jan 2023 13:14:48 +0000 Received: by outflank-mailman (output) from mailman id 472544.732825; Fri, 06 Jan 2023 13:14:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pDmYa-000458-8K; Fri, 06 Jan 2023 13:14:48 +0000 Received: by outflank-mailman (input) for mailman id 472544; Fri, 06 Jan 2023 13:14:46 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pDmYY-0003zy-Jd for xen-devel@lists.xenproject.org; Fri, 06 Jan 2023 13:14:46 +0000 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [2a00:1450:4864:20::136]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 16168da3-8dc4-11ed-b8d0-410ff93cb8f0; Fri, 06 Jan 2023 14:14:44 +0100 (CET) Received: by mail-lf1-x136.google.com with SMTP id bp15so1865644lfb.13 for ; Fri, 06 Jan 2023 05:14:44 -0800 (PST) Received: from fedora.. ([195.234.76.149]) by smtp.gmail.com with ESMTPSA id f14-20020a0565123b0e00b004b7033da2d7sm150221lfv.128.2023.01.06.05.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 05:14:43 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 16168da3-8dc4-11ed-b8d0-410ff93cb8f0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Szof3vhqcf1cuBmqVq5Q2IZcNa/4nJpd7CeH5aS/VM8=; b=cQzbsV1We3uOandm0dnfdaj/H7IIIhcsfpN/Lxb7zZEiEQWUgLQ4F9PMzPlKUVHcXY jRSZco3lfG1JhL/PTtNL7XwLktSfpwQQPYNJ1d8F0CfgrXGn0EfOkFV8iO9DqQpHj6j5 60YsQ63IXJTO1yh7XAumMCtqfgb/wNJtY1saMKPfMfW913cDSM61f+kLg/zBzPlghdPq uuoErP5j9CAIfWku6Qdh1xr1Wa1dq4fIGHpkRozz7IuzyJxZGdgk779OoZINEAKJCGq6 tjhrvsqOEvkmRuxkyGpg/lQeYe0+5RkvngIsCvKtpTzVl3YD0IPli5DJGsdkopklAup8 kwPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Szof3vhqcf1cuBmqVq5Q2IZcNa/4nJpd7CeH5aS/VM8=; b=FwZCyupFCjNZq1d+nmAg73AMVK7AvMOoT3uGXLJp62W529RSlzmU6dY6PqcMPO6MpO aj57YQnlGK1jvnGO9uDLkCePYxwXa/0cKjVq0gX0edZPH/ciAm2HHST1+FDCgYvluUJw BKFVGxJxWDjCEVtGAiVvJ+/LbGyoHq0teaGg2F03I1VQhRgkQeyMRo9+tUbsPBOlOE4Y dSkF1fdRPvSyzifY3sFCHvnf79S2ZK1O1BD7100gnK3TR1mHJwtC8yRQE6NqS9sbTuds PrEy8RbbawVjuiOg5w64I90leJcfaPcmAy4RNCMISsdW0cyqFhv6ReHQjIqX0Lzl6i/E jmrA== X-Gm-Message-State: AFqh2kq462u/jLGdE86KSGpch86/sVfnVHZJbydqR4c4xIIL/p05zGD4 Tl2K2Hzv9vpWkx7m9t9KvWlRyXbUuNYmZHrf X-Google-Smtp-Source: AMrXdXvNq2lNiXoqpUOykfZiuBP8QUksdxBOvF4zWSj54AMf05ZpoqtWPB5OqFs7UVSr9Xh6n0qkVA== X-Received: by 2002:a05:6512:32cc:b0:4cb:4378:9c6 with SMTP id f12-20020a05651232cc00b004cb437809c6mr3292688lfg.23.1673010883600; Fri, 06 Jan 2023 05:14:43 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v1 4/8] xen/riscv: introduce sbi call to putchar to console Date: Fri, 6 Jan 2023 15:14:25 +0200 Message-Id: <09da5a3184242152af6af060720a007738a55d6e.1673009740.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1673010912275100013 Content-Type: text/plain; charset="utf-8" The patch introduce sbi_putchar() SBI call which is necessary to implement initial early_printk Signed-off-by: Oleksii Kurochko --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/include/asm/sbi.h | 34 ++++++++++++++++++++++++ xen/arch/riscv/sbi.c | 44 ++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 xen/arch/riscv/include/asm/sbi.h create mode 100644 xen/arch/riscv/sbi.c diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index 5a67a3f493..60db415654 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -1,5 +1,6 @@ obj-$(CONFIG_RISCV_64) +=3D riscv64/ obj-y +=3D setup.o +obj-y +=3D sbi.o =20 $(TARGET): $(TARGET)-syms $(OBJCOPY) -O binary -S $< $@ diff --git a/xen/arch/riscv/include/asm/sbi.h b/xen/arch/riscv/include/asm/= sbi.h new file mode 100644 index 0000000000..34b53f8eaf --- /dev/null +++ b/xen/arch/riscv/include/asm/sbi.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: (GPL-2.0-or-later) */ +/* + * Copyright (c) 2021 Vates SAS. + * + * Taken from xvisor, modified by Bobby Eshleman (bobby.eshleman@gmail.com= ). + * + * Taken/modified from Xvisor project with the following copyright: + * + * Copyright (c) 2019 Western Digital Corporation or its affiliates. + */ + +#ifndef __CPU_SBI_H__ +#define __CPU_SBI_H__ + +#define SBI_EXT_0_1_CONSOLE_PUTCHAR 0x1 + +struct sbiret { + long error; + long value; +}; + +struct sbiret sbi_ecall(unsigned long ext, unsigned long fid, unsigned lon= g arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5); + +/** + * Writes given character to the console device. + * + * @param ch The data to be written to the console. + */ +void sbi_console_putchar(int ch); + +#endif // __CPU_SBI_H__ diff --git a/xen/arch/riscv/sbi.c b/xen/arch/riscv/sbi.c new file mode 100644 index 0000000000..67cf5dd982 --- /dev/null +++ b/xen/arch/riscv/sbi.c @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Taken and modified from the xvisor project with the copyright Copyright= (c) + * 2019 Western Digital Corporation or its affiliates and author Anup Patel + * (anup.patel@wdc.com). + * + * Modified by Bobby Eshleman (bobby.eshleman@gmail.com). + * + * Copyright (c) 2019 Western Digital Corporation or its affiliates. + * Copyright (c) 2021 Vates SAS. + */ + +#include +#include + +struct sbiret sbi_ecall(unsigned long ext, unsigned long fid, unsigned lon= g arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5) +{ + struct sbiret ret; + register unsigned long a0 asm ("a0") =3D arg0; + register unsigned long a1 asm ("a1") =3D arg1; + register unsigned long a2 asm ("a2") =3D arg2; + register unsigned long a3 asm ("a3") =3D arg3; + register unsigned long a4 asm ("a4") =3D arg4; + register unsigned long a5 asm ("a5") =3D arg5; + register unsigned long a6 asm ("a6") =3D fid; + register unsigned long a7 asm ("a7") =3D ext; + + asm volatile ("ecall" + : "+r" (a0), "+r" (a1) + : "r" (a2), "r" (a3), "r" (a4), "r" (a5), "r" (a6), "r" (a7) + : "memory"); + ret.error =3D a0; + ret.value =3D a1; + + return ret; +} + +void sbi_console_putchar(int ch) +{ + sbi_ecall(SBI_EXT_0_1_CONSOLE_PUTCHAR, 0, ch, 0, 0, 0, 0, 0); +} --=20 2.38.1