[PATCH 4/7] lib: sbi: Introduce smrnmi_handlers_init() callback for platform code

Evgeny Voevodin evvoevod at tenstorrent.com
Tue Mar 10 11:31:52 PDT 2026


From: Evgeny Voevodin <evvoevod at tenstorrent.com>

Per the definition of Smrnmi extension, location of RNMI/E vectors is
implementation defined. This commit introduces a method for platforms to
initialize location of _rnmi_handler and _rnme_handler in a custom way
before Smrnmi extension will be detected (in following commits). On
Smrnmi enabled platforms this is required to have RNMI/E handlers
installed prior to probing of any extension/feature by utilizing expected traps.

Signed-off-by: Evgeny Voevodin <evvoevod at tenstorrent.com>
---
 include/sbi/sbi_platform.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
index b67a5647..ec398200 100644
--- a/include/sbi/sbi_platform.h
+++ b/include/sbi/sbi_platform.h
@@ -150,6 +150,10 @@ struct sbi_platform_operations {
 	/** platform specific pmp disable on current HART */
 	void (*pmp_disable)(unsigned int n);
 
+	/** platform specific Smrnmi handlers init on current HART */
+	void (*smrnmi_handlers_init)(void (*rnmi_handler)(void),
+			void (*rnme_handler)(void));
+
 	/** platform specific Smrnmi exception handler.
 	 *  Returns SBI_SUCCESS on success, error code if exception cannot be
 	 *  handled. */
@@ -405,6 +409,11 @@ static inline int sbi_platform_nascent_init(const struct sbi_platform *plat)
 static inline int sbi_platform_early_init(const struct sbi_platform *plat,
 					  bool cold_boot)
 {
+	extern void _rnmi_handler(void);
+	extern void _rnme_handler(void);
+	if (plat && sbi_platform_ops(plat)->smrnmi_handlers_init)
+		sbi_platform_ops(plat)->smrnmi_handlers_init(_rnmi_handler, _rnme_handler);
+
 	if (plat && sbi_platform_ops(plat)->early_init)
 		return sbi_platform_ops(plat)->early_init(cold_boot);
 	return 0;
-- 
2.43.0




More information about the opensbi mailing list