From nobody Mon Feb 9 13:40:43 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=1653980961; cv=none; d=zohomail.com; s=zohoarc; b=kcYT3z0ys8Ua1dlQGejypAoDmmgZWiQMNVCCRdfdWnD4EpqNLt1YSqKFrU/3TWTZCjv8rsThG8Eu4znirEHJWsSUnfdSElMXgtuC2rhAaJ14b9LlQXUwdPSiZwdgTopeXmjs/zfh2HIt+7m8NcKgN03c+9zxJKKkHvYIblKH6RA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653980961; 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=xR88aQIK2zwu2ATjZh/yut3alhZFE53aCziDTvElipM=; b=C20FBSTmqIEjEWdhWhe5OtRTX2fSgygCFbDIQ6HMtBsMF7HHgSMaLAskl+vavRYEQAgCTN6vkHrALSPTpy6L4Sn3++28xYAQMqzodrNc7Il53xm//vAroSoQEZQfm2iUrbyE4+PxIh1W2XrOzwM5BSGBnfYBg3EAVMIRVnepWd0= 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 1653980961665415.31535410138963; Tue, 31 May 2022 00:09:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.339129.563973 (Exim 4.92) (envelope-from ) id 1nvvzj-0001I1-UQ; Tue, 31 May 2022 07:08:47 +0000 Received: by outflank-mailman (output) from mailman id 339129.563973; Tue, 31 May 2022 07:08:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nvvzj-0001FT-MS; Tue, 31 May 2022 07:08:47 +0000 Received: by outflank-mailman (input) for mailman id 339129; Tue, 31 May 2022 06:58:25 +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 1nvvph-00080v-IZ for xen-devel@lists.xenproject.org; Tue, 31 May 2022 06:58:25 +0000 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [2a00:1450:4864:20::32b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0dfd4e5c-e0af-11ec-837f-e5687231ffcc; Tue, 31 May 2022 08:58:20 +0200 (CEST) Received: by mail-wm1-x32b.google.com with SMTP id m32-20020a05600c3b2000b0039756bb41f2so628041wms.3 for ; Mon, 30 May 2022 23:58:24 -0700 (PDT) Received: from localhost ([2a03:b0c0:1:d0::944:e002]) by smtp.gmail.com with ESMTPSA id d17-20020a05600c4c1100b0039771fbffcasm1222368wmp.21.2022.05.30.23.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 23:58:24 -0700 (PDT) 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: 0dfd4e5c-e0af-11ec-837f-e5687231ffcc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xR88aQIK2zwu2ATjZh/yut3alhZFE53aCziDTvElipM=; b=e+fpZZdxcdgtkFmrHuonJoVhU1QO5uVLzNyppJdLUwvqOkkJ6rAkwKiEBpCxpCrstc xlMf9X3nj3n4Tf0VWvsinvl5lubDK+crb6a9D6jO6e/xywv87xBEiHaPY9GhJIEXQyqp btgY+6vCp/Y63Ya3sWM2YHHCNLPnHvnY8rqpviVljWZs95rq59oyVHf/v33NCelFwCGU g2CrBJ6AAn06tocKDmIcvY49B9jfaAqTbp5zmwJnViJl5bS/QwF5nKE/mo2dwOLm69tu PMq0/Mmv15gJFaLhfypUip9xq771NCi6H+GRwZfjoxt4NV3MIC+dV/1Sx1Fp3LeflGXy KAVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xR88aQIK2zwu2ATjZh/yut3alhZFE53aCziDTvElipM=; b=tsnq2SwBKOQ1Sy+yyffY8rNHy9nM2Q1/1IQTaEbL758rs3KUHyvbxGoH1CVUe71lmF v7qtokzzY3KZDqU+KuZEfa3qJYwyRjB9Dc1owup3qmGjgdAxJdYKLYNicuE5ojAJAXRK ELuDtkHbk7/BLgcX+mfMjnp0lmpkxy1J1f370EBpcT/J/fvld1J9cp0Z2WjxNArra92v YZGX2D9icx8A1YWzoO7or6Ps4UtmUioAuZc5zKsVdJ8LZReVw85iMAjfsh1Va286my+m d3UmwMV6SYCNO8s1v37BouG63KA6ln8NsdlqLXDqSBPR+gaZ3MF3zdLdZEpI/j47p+LJ 9J+g== X-Gm-Message-State: AOAM530duEXJOJTJUE6YS9+q8TROKsgibt/ZY3HLn/pG/Ypnkl06pLXw TMU4xhPPzZyjqsAw6RiL80xRMF+2eWY= X-Google-Smtp-Source: ABdhPJzpaCVD81IDg92fh2kKoJHqIQ6L1Nbta3AzK3lRcy2F9RO3vdQOsPzyIqWeXy0SQL3SNyD5uQ== X-Received: by 2002:a05:600c:3583:b0:397:3d93:75b8 with SMTP id p3-20020a05600c358300b003973d9375b8mr21570409wmq.76.1653980304447; Mon, 30 May 2022 23:58:24 -0700 (PDT) From: Xie Xun To: xen-devel@lists.xenproject.org Cc: Xie Xun , Bob Eshleman , Alistair Francis , Connor Davis Subject: [RFC PATCH 5/6] xen/riscv: Add early_printk Date: Tue, 31 May 2022 14:57:11 +0800 Message-Id: <016c56548eee75c2b713ef90e4069690c0ae11cb.1653977696.git.xiexun162534@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1653980963514100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Xie Xun --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/early_printk.c | 48 +++++++++++++++++++++++ xen/arch/riscv/include/asm/early_printk.h | 10 +++++ 3 files changed, 59 insertions(+) create mode 100644 xen/arch/riscv/early_printk.c create mode 100644 xen/arch/riscv/include/asm/early_printk.h diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index c61349818f..f9abc8401b 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -3,6 +3,7 @@ obj-y +=3D lib/ obj-y +=3D domctl.o obj-y +=3D domain.o obj-y +=3D delay.o +obj-y +=3D early_printk.o obj-y +=3D guestcopy.o obj-y +=3D irq.o obj-y +=3D p2m.o diff --git a/xen/arch/riscv/early_printk.c b/xen/arch/riscv/early_printk.c new file mode 100644 index 0000000000..81d69add01 --- /dev/null +++ b/xen/arch/riscv/early_printk.c @@ -0,0 +1,48 @@ +/* + * RISC-V early printk using SBI + * + * Copyright (C) 2021 Bobby Eshleman + */ +#include +#include +#include +#include + +void _early_puts(const char *s, size_t nr) +{ + while ( nr-- > 0 ) + { + if (*s =3D=3D '\n') + sbi_console_putchar('\r'); + sbi_console_putchar(*s); + s++; + } +} + +static void vprintk_early(const char *prefix, const char *fmt, va_list arg= s) +{ + char buf[128]; + int sz; + + early_puts(prefix); + + sz =3D vscnprintf(buf, sizeof(buf), fmt, args); + + if ( sz < 0 ) { + early_puts("(XEN) vprintk_early error\n"); + return; + } + + if ( sz =3D=3D 0 ) + return; + + _early_puts(buf, sz); +} + +void early_printk(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + vprintk_early("(XEN) ", fmt, args); + va_end(args); +} diff --git a/xen/arch/riscv/include/asm/early_printk.h b/xen/arch/riscv/inc= lude/asm/early_printk.h new file mode 100644 index 0000000000..0d9928b333 --- /dev/null +++ b/xen/arch/riscv/include/asm/early_printk.h @@ -0,0 +1,10 @@ +#ifndef __EARLY_PRINTK_H__ +#define __EARLY_PRINTK_H__ + +#include + +#define early_puts(s) _early_puts((s), strlen((s))) +void _early_puts(const char *s, size_t nr); +void early_printk(const char *fmt, ...); + +#endif /* __EARLY_PRINTK_H__ */ --=20 2.30.2