[PATCH 05/10] lib: sbi: domain: add domain lookup by name
Raymond Mao
raymondmaoca at gmail.com
Thu May 14 15:57:51 PDT 2026
From: Raymond Mao <raymond.mao at riscstar.com>
Provide a helper to resolve a domain by its DT node name, used by
sysirq DT parsing.
Signed-off-by: Raymond Mao <raymond.mao at riscstar.com>
---
include/sbi/sbi_domain.h | 3 +++
lib/sbi/sbi_domain.c | 15 +++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h
index 7e288cd8..b7267da8 100644
--- a/include/sbi/sbi_domain.h
+++ b/include/sbi/sbi_domain.h
@@ -232,6 +232,9 @@ struct sbi_domain *sbi_hartindex_to_domain(u32 hartindex);
/** Update HART local pointer to point to specified domain */
void sbi_update_hartindex_to_domain(u32 hartindex, struct sbi_domain *dom);
+/** Find domain by DT node name (domain name) */
+struct sbi_domain *sbi_domain_find_by_name(const char *name);
+
/** Get pointer to sbi_domain for current HART */
#define sbi_domain_thishart_ptr() \
sbi_hartindex_to_domain(current_hartindex())
diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
index 2a846eea..c33f2b3c 100644
--- a/lib/sbi/sbi_domain.c
+++ b/lib/sbi/sbi_domain.c
@@ -60,6 +60,21 @@ void sbi_update_hartindex_to_domain(u32 hartindex, struct sbi_domain *dom)
sbi_scratch_write_type(scratch, void *, domain_hart_ptr_offset, dom);
}
+struct sbi_domain *sbi_domain_find_by_name(const char *name)
+{
+ struct sbi_domain *dom;
+
+ if (!name)
+ return NULL;
+
+ sbi_domain_for_each(dom) {
+ if (!sbi_strncmp(dom->name, name, sizeof(dom->name)))
+ return dom;
+ }
+
+ return NULL;
+}
+
bool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartindex)
{
bool ret;
--
2.25.1
More information about the opensbi
mailing list