From: Clément Léger <cleger@rivosinc.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v3 4/4] lib: sbi: implement SBI FWFT extension
Date: Wed, 19 Jun 2024 11:42:42 +0200 [thread overview]
Message-ID: <20240619094244.603628-5-cleger@rivosinc.com> (raw)
In-Reply-To: <20240619094244.603628-1-cleger@rivosinc.com>
The SBI FWFT extension defines a set of function that can be called to
control the configuration of some platform features (misaligned
trap delegation, etc). This patch implements sbi_fwft_set() and
sbi_fwft_get() as defined in the specification [1].
Link: https://lists.riscv.org/g/tech-prs/message/924 [1]
Signed-off-by: Cl?ment L?ger <cleger@rivosinc.com>
---
lib/sbi/Kconfig | 4 ++++
lib/sbi/objects.mk | 3 +++
lib/sbi/sbi_ecall_fwft.c | 49 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 56 insertions(+)
create mode 100644 lib/sbi/sbi_ecall_fwft.c
diff --git a/lib/sbi/Kconfig b/lib/sbi/Kconfig
index cc8e031..6cf54ce 100644
--- a/lib/sbi/Kconfig
+++ b/lib/sbi/Kconfig
@@ -38,6 +38,10 @@ config SBI_ECALL_CPPC
bool "CPPC extension"
default y
+config SBI_ECALL_FWFT
+ bool "Firmware Feature extension"
+ default y
+
config SBI_ECALL_LEGACY
bool "SBI v0.1 legacy extensions"
default y
diff --git a/lib/sbi/objects.mk b/lib/sbi/objects.mk
index 221e72c..211abad 100644
--- a/lib/sbi/objects.mk
+++ b/lib/sbi/objects.mk
@@ -46,6 +46,9 @@ libsbi-objs-$(CONFIG_SBI_ECALL_DBCN) += sbi_ecall_dbcn.o
carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_CPPC) += ecall_cppc
libsbi-objs-$(CONFIG_SBI_ECALL_CPPC) += sbi_ecall_cppc.o
+carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_FWFT) += ecall_fwft
+libsbi-objs-$(CONFIG_SBI_ECALL_FWFT) += sbi_ecall_fwft.o
+
carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_LEGACY) += ecall_legacy
libsbi-objs-$(CONFIG_SBI_ECALL_LEGACY) += sbi_ecall_legacy.o
diff --git a/lib/sbi/sbi_ecall_fwft.c b/lib/sbi/sbi_ecall_fwft.c
new file mode 100644
index 0000000..267cbab
--- /dev/null
+++ b/lib/sbi/sbi_ecall_fwft.c
@@ -0,0 +1,49 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Rivos Inc.
+ *
+ * Authors:
+ * Cl?ment L?ger <cleger@rivosinc.com>
+ */
+
+#include <sbi/sbi_ecall.h>
+#include <sbi/sbi_ecall_interface.h>
+#include <sbi/sbi_error.h>
+#include <sbi/sbi_fwft.h>
+#include <sbi/sbi_trap.h>
+
+static int sbi_ecall_fwft_handler(unsigned long extid, unsigned long funcid,
+ struct sbi_trap_regs *regs,
+ struct sbi_ecall_return *out)
+{
+ int ret = 0;
+
+ switch (funcid) {
+ case SBI_EXT_FWFT_SET:
+ ret = sbi_fwft_set(regs->a0, regs->a1, regs->a2);
+ break;
+ case SBI_EXT_FWFT_GET:
+ ret = sbi_fwft_get(regs->a0, &out->value);
+ break;
+ default:
+ ret = SBI_ENOTSUPP;
+ break;
+ }
+
+ return ret;
+}
+
+struct sbi_ecall_extension ecall_fwft;
+
+static int sbi_ecall_fwft_register_extensions(void)
+{
+ return sbi_ecall_register_extension(&ecall_fwft);
+}
+
+struct sbi_ecall_extension ecall_fwft = {
+ .extid_start = SBI_EXT_FWFT,
+ .extid_end = SBI_EXT_FWFT,
+ .register_extensions = sbi_ecall_fwft_register_extensions,
+ .handle = sbi_ecall_fwft_handler,
+};
--
2.45.2
next prev parent reply other threads:[~2024-06-19 9:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 9:42 [PATCH v3 0/4] Add SBI FWFT extension support Clément Léger
2024-06-19 9:42 ` [PATCH v3 1/4] lib: sbi: add support for firmware features extension Clément Léger
2024-06-19 12:47 ` Anup Patel
2024-06-19 9:42 ` [PATCH v3 2/4] lib: sbi: fwft: add support for SBI_FWFT_MISALIGNED_EXC_DELEG Clément Léger
2024-06-19 12:48 ` Anup Patel
2024-06-21 13:50 ` Andrew Jones
2024-06-24 8:28 ` Clément Léger
2024-06-19 9:42 ` [PATCH v3 3/4] lib: sbi: fwft: add support for SBI_FWFT_PTE_AD_HW_UPDATING Clément Léger
2024-06-19 12:48 ` Anup Patel
2024-06-19 9:42 ` Clément Léger [this message]
2024-06-19 12:49 ` [PATCH v3 4/4] lib: sbi: implement SBI FWFT extension Anup Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240619094244.603628-5-cleger@rivosinc.com \
--to=cleger@rivosinc.com \
--cc=opensbi@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox