[PATCH 6/7] platform: tenstorrent: ascalon: Introduce Smrnmi handlers init callback

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


From: Evgeny Voevodin <evvoevod at tenstorrent.com>

This provides a generic method for Ascalon-based platforms to set up RNMI/E
handlers. NMIVEC and NMEVEC MMR CSRs should be written by each hart
accessing its own offset within the MMR region. Platform code will
provide a base address of MMR region and the rest will be handled by
introduced generic tt_ascalon_smrnmi_handlers_init() function.

Signed-off-by: Evgeny Voevodin <evvoevod at tenstorrent.com>
---
 platform/generic/include/tenstorrent/ascalon.h | 10 ++++++++++
 platform/generic/tenstorrent/ascalon.c         | 11 +++++++++++
 2 files changed, 21 insertions(+)

diff --git a/platform/generic/include/tenstorrent/ascalon.h b/platform/generic/include/tenstorrent/ascalon.h
index 5d7b7635..91def5fc 100644
--- a/platform/generic/include/tenstorrent/ascalon.h
+++ b/platform/generic/include/tenstorrent/ascalon.h
@@ -9,4 +9,14 @@
 void tt_ascalon_discover_pmas_from_boot_hart(void);
 void tt_ascalon_verify_pmas_nonboot_hart(void);
 
+#define ASCALON_MMR_NMIVEC			0x20
+#define ASCALON_MMR_NMEVEC			0x28
+#define ASCALON_MMR_HART_STRIDE		0x10000
+#define ASCALON_MMR(MMR_BASE, MMR_REG, HARTID) \
+	(MMR_BASE + (HARTID) * ASCALON_MMR_HART_STRIDE + MMR_REG)
+
+
+void tt_ascalon_smrnmi_handlers_init(void (*rnmi_handler)(void),
+			void (*rnme_handler)(void), unsigned long mmr_base);
+
 #endif
diff --git a/platform/generic/tenstorrent/ascalon.c b/platform/generic/tenstorrent/ascalon.c
index 485144cd..889923e5 100644
--- a/platform/generic/tenstorrent/ascalon.c
+++ b/platform/generic/tenstorrent/ascalon.c
@@ -4,6 +4,7 @@
  */
 
 #include <sbi/riscv_asm.h>
+#include <sbi/riscv_io.h>
 #include <sbi/sbi_console.h>
 #include <sbi/sbi_csr_detect.h>
 
@@ -51,3 +52,13 @@ void tt_ascalon_verify_pmas_nonboot_hart(void)
 		}
 	}
 }
+void tt_ascalon_smrnmi_handlers_init(void (*rnmi_handler)(void),
+		void (*rnme_handler)(void), unsigned long mmr_base)
+{
+	unsigned long hartid = current_hartid();
+
+	writeq((unsigned long)rnmi_handler,
+			(void*)ASCALON_MMR(mmr_base, ASCALON_MMR_NMIVEC, hartid));
+	writeq((unsigned long)rnme_handler,
+			(void*)ASCALON_MMR(mmr_base, ASCALON_MMR_NMEVEC, hartid));
+}
-- 
2.43.0




More information about the opensbi mailing list