From: Yu-Chien Peter Lin <peter.lin@sifive.com>
To: opensbi@lists.infradead.org
Cc: greentime.hu@sifive.com,
Yu-Chien Peter Lin <peter.lin@sifive.com>,
zong.li@sifive.com
Subject: [RFC PATCH 1/7] lib: utils: fdt_helper: add fdt_has_isa_extension() helper
Date: Fri, 15 Aug 2025 18:01:09 +0800 [thread overview]
Message-ID: <20250815100116.27776-2-peter.lin@sifive.com> (raw)
In-Reply-To: <20250815100116.27776-1-peter.lin@sifive.com>
Add a helper function to search for a given ISA string in
`riscv,isa-extensions` or `riscv,isa` properties within
the FDT.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com>
---
include/sbi_utils/fdt/fdt_helper.h | 2 ++
lib/utils/fdt/fdt_helper.c | 35 ++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/include/sbi_utils/fdt/fdt_helper.h b/include/sbi_utils/fdt/fdt_helper.h
index 24ad1a94..8aa216c7 100644
--- a/include/sbi_utils/fdt/fdt_helper.h
+++ b/include/sbi_utils/fdt/fdt_helper.h
@@ -56,6 +56,8 @@ int fdt_parse_timebase_frequency(const void *fdt, unsigned long *freq);
int fdt_parse_isa_extensions(const void *fdt, unsigned long *hart_exts);
+bool fdt_has_isa_extension(const void *fdt, const char *ext);
+
int fdt_parse_gaisler_uart_node(const void *fdt, int nodeoffset,
struct platform_uart_data *uart);
diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
index b0b18b1c..de72f34a 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -447,6 +447,41 @@ int fdt_parse_isa_extensions(const void *fdt, unsigned long *hart_exts)
return 0;
}
+bool fdt_has_isa_extension(const void *fdt, const char *ext)
+{
+ const struct sbi_hart_ext_data *ext_data = NULL;
+ DECLARE_BITMAP(hart_exts, SBI_HART_EXT_MAX);
+ int rc, i;
+
+ if (!fdt || !ext)
+ return false;
+
+ for (i = 0; i < SBI_HART_EXT_MAX; i++) {
+ if (!sbi_strncmp(sbi_hart_ext[i].name, ext,
+ sbi_strlen(ext))) {
+ ext_data = &sbi_hart_ext[i];
+ break;
+ }
+ }
+
+ if (!ext_data) {
+ sbi_printf("%s: extension %s not found in sbi_hart_ext[]\n",
+ __func__, ext);
+ return false;
+ }
+
+ bitmap_zero(hart_exts, SBI_HART_EXT_MAX);
+
+ rc = fdt_parse_isa_extensions(fdt, hart_exts);
+ if (rc) {
+ sbi_printf("%s: failed to parse isa extensions\n",
+ __func__);
+ return false;
+ }
+
+ return bitmap_test(hart_exts, ext_data->id);
+}
+
static int fdt_parse_uart_node_common(const void *fdt, int nodeoffset,
struct platform_uart_data *uart,
unsigned long default_freq,
--
2.48.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next prev parent reply other threads:[~2025-08-15 13:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 10:01 [RFC PATCH 0/7] Extend the reserved PMP entries Yu-Chien Peter Lin
2025-08-15 10:01 ` Yu-Chien Peter Lin [this message]
2025-08-15 10:01 ` [RFC PATCH 2/7] include: sbi: sbi_platform: add reserved_pmp_count field Yu-Chien Peter Lin
2025-08-15 10:01 ` [RFC PATCH 3/7] platform: generic: platform: introduce fw_platform_get_reserved_pmp_count() Yu-Chien Peter Lin
2025-08-15 10:01 ` [RFC PATCH 4/7] lib: sbi_init: print total and reserved PMP counts Yu-Chien Peter Lin
2025-08-15 10:01 ` [RFC PATCH 5/7] lib: sbi: riscv_asm: add reserved_pmp_alloc() to allocate a reserved PMP Yu-Chien Peter Lin
2025-08-15 10:01 ` [RFC PATCH 6/7] lib: sbi: sbi_hart: extend PMP handling to support multiple reserved entries Yu-Chien Peter Lin
2025-08-15 10:01 ` [RFC PATCH 7/7] docs: opensbi_config: add description for reserved-pmp-count Yu-Chien Peter Lin
2025-10-06 5:21 ` [RFC PATCH 0/7] Extend the reserved PMP entries 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=20250815100116.27776-2-peter.lin@sifive.com \
--to=peter.lin@sifive.com \
--cc=greentime.hu@sifive.com \
--cc=opensbi@lists.infradead.org \
--cc=zong.li@sifive.com \
/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