You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/05/02 08:08:20 UTC

(nuttx) branch master updated (9eac74330a -> bd895222eb)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


    from 9eac74330a cmake:bugfix __KERNEL__ should not be defined in libc,mm.. in FLAT mode
     new b283b949b6 arch/risc-v: implement standard ecall interface for nuttsbi
     new bd895222eb arch/risc-v: implement sbi_ipi_send

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/risc-v/src/common/riscv_internal.h            |  19 ++++
 arch/risc-v/src/common/riscv_ipi.h                 |   6 +-
 arch/risc-v/src/common/supervisor/riscv_sbi.c      |  32 ++-----
 arch/risc-v/src/k230/hardware/k230_clint.h         |   2 +
 arch/risc-v/src/nuttsbi/CMakeLists.txt             |   2 +
 arch/risc-v/src/nuttsbi/Kconfig                    |   6 ++
 arch/risc-v/src/nuttsbi/Make.defs                  |   2 +-
 arch/risc-v/src/nuttsbi/sbi_internal.h             |  24 ++++-
 .../risc-v/src/nuttsbi/sbi_ipi.c                   |  35 ++++---
 arch/risc-v/src/nuttsbi/sbi_mcall.c                |  33 ++++---
 arch/risc-v/src/nuttsbi/sbi_mcall.h                | 101 +--------------------
 arch/risc-v/src/nuttsbi/sbi_mtrap.S                |   9 ++
 .../risc-v/k230/canmv230/configs/master/defconfig  |   1 +
 boards/risc-v/k230/canmv230/configs/nsbi/defconfig |   1 +
 .../risc-v/k230/canmv230/configs/remote/defconfig  |   1 +
 boards/risc-v/mpfs/icicle/configs/knsh/defconfig   |   1 +
 16 files changed, 120 insertions(+), 155 deletions(-)
 copy boards/arm/s32k1xx/s32k144evb/src/s32k1xx_uid.c => arch/risc-v/src/nuttsbi/sbi_ipi.c (81%)


(nuttx) 01/02: arch/risc-v: implement standard ecall interface for nuttsbi

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit b283b949b6024787070278badf11c1557cff1ba5
Author: Inochi Amaoto <in...@outlook.com>
AuthorDate: Sun Apr 28 18:20:50 2024 +0800

    arch/risc-v: implement standard ecall interface for nuttsbi
    
    NuttSBI have a simple ecall interface for the kernel, which make
    it hard to add new SBI call for NuttSBI. So implement standard
    ecall interface for NuttSBI and make life easier.
    
    Signed-off-by: Inochi Amaoto <in...@outlook.com>
---
 arch/risc-v/src/common/riscv_internal.h       |  13 ++++
 arch/risc-v/src/common/supervisor/riscv_sbi.c |  26 +------
 arch/risc-v/src/nuttsbi/sbi_mcall.c           |  30 +++++---
 arch/risc-v/src/nuttsbi/sbi_mcall.h           | 101 +-------------------------
 4 files changed, 37 insertions(+), 133 deletions(-)

diff --git a/arch/risc-v/src/common/riscv_internal.h b/arch/risc-v/src/common/riscv_internal.h
index 9bf3725e67..4a813f4f4d 100644
--- a/arch/risc-v/src/common/riscv_internal.h
+++ b/arch/risc-v/src/common/riscv_internal.h
@@ -168,6 +168,19 @@
 
 #endif
 
+/* SBI Extension IDs */
+
+#define SBI_EXT_HSM             0x48534D
+#define SBI_EXT_TIME            0x54494D45
+
+/* SBI function IDs for TIME extension */
+
+#define SBI_EXT_TIME_SET_TIMER  0x0
+
+/* SBI function IDs for HSM extension */
+
+#define SBI_EXT_HSM_HART_START  0x0
+
 /****************************************************************************
  * Public Types
  ****************************************************************************/
diff --git a/arch/risc-v/src/common/supervisor/riscv_sbi.c b/arch/risc-v/src/common/supervisor/riscv_sbi.c
index 75f8c34fe5..dbe14fe836 100644
--- a/arch/risc-v/src/common/supervisor/riscv_sbi.c
+++ b/arch/risc-v/src/common/supervisor/riscv_sbi.c
@@ -22,19 +22,6 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* SBI Extension IDs */
-
-#define SBI_EXT_HSM             0x48534D
-#define SBI_EXT_TIME            0x54494D45
-
-/* SBI function IDs for TIME extension */
-
-#define SBI_EXT_TIME_SET_TIMER  0x0
-
-/* SBI function IDs for HSM extension */
-
-#define SBI_EXT_HSM_HART_START  0x0
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/
@@ -54,7 +41,6 @@
  * Private Functions
  ****************************************************************************/
 
-#ifndef CONFIG_NUTTSBI
 static inline uintptr_t sbi_ecall(unsigned int extid, unsigned int fid,
                                   uintptr_t parm0, uintptr_t parm1,
                                   uintptr_t parm2, uintptr_t parm3,
@@ -79,7 +65,6 @@ static inline uintptr_t sbi_ecall(unsigned int extid, unsigned int fid,
 
   return r1;
 }
-#endif /* CONFIG_NUTTSBI */
 
 /****************************************************************************
  * Public Functions
@@ -98,9 +83,6 @@ static inline uintptr_t sbi_ecall(unsigned int extid, unsigned int fid,
 
 void riscv_sbi_set_timer(uint64_t stime_value)
 {
-#ifdef CONFIG_NUTTSBI
-  sbi_mcall_set_timer(stime_value);
-#else
 #ifdef CONFIG_ARCH_RV64
   sbi_ecall(SBI_EXT_TIME, SBI_EXT_TIME_SET_TIMER, stime_value, 0, 0, 0, 0,
             0);
@@ -108,7 +90,6 @@ void riscv_sbi_set_timer(uint64_t stime_value)
   sbi_ecall(SBI_EXT_TIME, SBI_EXT_TIME_SET_TIMER, stime_value,
             stime_value >> 32, 0, 0, 0, 0);
 #endif
-#endif
 }
 
 /****************************************************************************
@@ -125,9 +106,9 @@ void riscv_sbi_set_timer(uint64_t stime_value)
 uint64_t riscv_sbi_get_time(void)
 {
 #ifdef CONFIG_NUTTSBI
-  return sbi_mcall_get_time();
-#else
-#ifdef CONFIG_ARCH_RV64
+  return sbi_ecall(SBI_EXT_FIRMWARE, SBI_EXT_FIRMWARE_GET_MTIME, 0, 0,
+                   0, 0, 0, 0);
+#elif defined(CONFIG_ARCH_RV64)
   return READ_CSR(CSR_TIME);
 #else
   uint32_t hi;
@@ -142,7 +123,6 @@ uint64_t riscv_sbi_get_time(void)
 
   return (((uint64_t) hi) << 32) | lo;
 #endif
-#endif
 }
 
 #ifndef CONFIG_NUTTSBI
diff --git a/arch/risc-v/src/nuttsbi/sbi_mcall.c b/arch/risc-v/src/nuttsbi/sbi_mcall.c
index d69fdeb752..772726769f 100644
--- a/arch/risc-v/src/nuttsbi/sbi_mcall.c
+++ b/arch/risc-v/src/nuttsbi/sbi_mcall.c
@@ -51,9 +51,25 @@ void sbi_mcall_handle(uintptr_t *regs)
 {
   /* Check the environment call number */
 
-  switch (regs[REG_A0])
+  switch (regs[REG_A7])
   {
-    case MCALL_GET_TIMER:
+    case SBI_EXT_TIME:
+      switch (regs[REG_A6])
+      {
+        case SBI_EXT_TIME_SET_TIMER:
+#ifdef CONFIG_ARCH_RV64
+          sbi_set_mtimecmp(regs[REG_A0]);
+#else
+          sbi_set_mtimecmp(regs[REG_A0] + ((uint64_t)regs[REG_A1] << 32));
+#endif
+          CLEAR_CSR(CSR_MIP, MIP_STIP);
+          SET_CSR(CSR_MIE, MIE_MTIE);
+          break;
+        default:
+          break;
+      }
+      break;
+    case SBI_EXT_FIRMWARE:
 #ifdef CONFIG_ARCH_RV64
       regs[REG_A0]    = sbi_get_mtime();
 #else
@@ -65,16 +81,6 @@ void sbi_mcall_handle(uintptr_t *regs)
 #endif
       break;
 
-    case MCALL_SET_TIMER:
-#ifdef CONFIG_ARCH_RV64
-      sbi_set_mtimecmp(regs[REG_A1]);
-#else
-      sbi_set_mtimecmp(regs[REG_A1] + ((uint64_t)regs[REG_A2] << 32));
-#endif
-      CLEAR_CSR(CSR_MIP, MIP_STIP);
-      SET_CSR(CSR_MIE, MIE_MTIE);
-      break;
-
     default:
       break;
   }
diff --git a/arch/risc-v/src/nuttsbi/sbi_mcall.h b/arch/risc-v/src/nuttsbi/sbi_mcall.h
index 95154a2eac..f641233947 100644
--- a/arch/risc-v/src/nuttsbi/sbi_mcall.h
+++ b/arch/risc-v/src/nuttsbi/sbi_mcall.h
@@ -30,105 +30,10 @@
 #include <stdint.h>
 
 /****************************************************************************
- * Public Types
+ * Pre-processor Definitions
  ****************************************************************************/
 
-enum mcall_num_e
-{
-  MCALL_INVALID,
-  MCALL_GET_TIMER,
-  MCALL_SET_TIMER,
-  MCALL_LAST
-};
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Name: mcall0
- *
- * Description:
- *   Generate an environment call to machine mode
- *
- * Input Parameters:
- *   nbr - Environment call number
- *
- ****************************************************************************/
-
-static inline uintptr_t mcall0(unsigned int nbr)
-{
-  register long r0 asm("a0") = (long)(nbr);
-
-  asm volatile
-    (
-     "ecall"
-     :: "r"(r0)
-     : "memory"
-     );
-
-  asm volatile("nop" : "=r"(r0));
-
-  return r0;
-}
-
-/****************************************************************************
- * Name: mcall1
- *
- * Description:
- *   Generate an environment call to machine mode
- *
- * Input Parameters:
- *   nbr - Environment call number
- *   parm1 - Argument for ecall
- *
- ****************************************************************************/
-
-static inline uintptr_t mcall1(unsigned int nbr, uintptr_t parm1)
-{
-  register long r0 asm("a0") = (long)(nbr);
-  register long r1 asm("a1") = (long)(parm1);
-
-  asm volatile
-    (
-     "ecall"
-     :: "r"(r0), "r"(r1)
-     : "memory"
-     );
-
-  asm volatile("nop" : "=r"(r0));
-
-  return r0;
-}
-
-/****************************************************************************
- * Name: sbi_mcall_get_time
- *
- * Description:
- *   Read the current system time (mtime)
- *
- * Returned Value:
- *   time - Value of mtime
- *
- ****************************************************************************/
-
-#define sbi_mcall_get_time() \
-  mcall0(MCALL_GET_TIMER)
-
-/****************************************************************************
- * Name: sbi_mcall_set_timer
- *
- * Description:
- *   Set new compare match value for timer. Time is in absolute time, so
- *   user must either obtain system time and calculate the offset, or keep
- *   the old compare match value in memory
- *
- * Input Parameters:
- *   stime_value - Absolute time for next compare match event
- *
- ****************************************************************************/
-
-#define sbi_mcall_set_timer(stime_value) \
-  (void)mcall1(MCALL_SET_TIMER, stime_value)
+#define SBI_EXT_FIRMWARE              0x0A000000
+#define SBI_EXT_FIRMWARE_GET_MTIME    0x0
 
 #endif /* __ARCH_RISC_V_SRC_NUTTSBI_SBI_MCALL_H */


(nuttx) 02/02: arch/risc-v: implement sbi_ipi_send

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit bd895222eb2ea9122293494c628b1e9e42227b38
Author: Inochi Amaoto <in...@outlook.com>
AuthorDate: Sun Apr 28 10:35:16 2024 +0800

    arch/risc-v: implement sbi_ipi_send
    
    And SBI ipi support.
    
    Fixup: 4f63ca1418 ("arch/risc-v: unfiy IPI access)
    Signed-off-by: Inochi Amaoto <in...@outlook.com>
---
 arch/risc-v/src/common/riscv_internal.h            |  6 +++
 arch/risc-v/src/common/riscv_ipi.h                 |  6 ++-
 arch/risc-v/src/common/supervisor/riscv_sbi.c      |  6 +++
 arch/risc-v/src/k230/hardware/k230_clint.h         |  2 +
 arch/risc-v/src/nuttsbi/CMakeLists.txt             |  2 +
 arch/risc-v/src/nuttsbi/Kconfig                    |  6 +++
 arch/risc-v/src/nuttsbi/Make.defs                  |  2 +-
 arch/risc-v/src/nuttsbi/sbi_internal.h             | 24 ++++++++++-
 .../src/{common/riscv_ipi.h => nuttsbi/sbi_ipi.c}  | 46 ++++++++++++----------
 arch/risc-v/src/nuttsbi/sbi_mcall.c                |  3 ++
 arch/risc-v/src/nuttsbi/sbi_mtrap.S                |  9 +++++
 .../risc-v/k230/canmv230/configs/master/defconfig  |  1 +
 boards/risc-v/k230/canmv230/configs/nsbi/defconfig |  1 +
 .../risc-v/k230/canmv230/configs/remote/defconfig  |  1 +
 boards/risc-v/mpfs/icicle/configs/knsh/defconfig   |  1 +
 15 files changed, 91 insertions(+), 25 deletions(-)

diff --git a/arch/risc-v/src/common/riscv_internal.h b/arch/risc-v/src/common/riscv_internal.h
index 4a813f4f4d..4365a42e60 100644
--- a/arch/risc-v/src/common/riscv_internal.h
+++ b/arch/risc-v/src/common/riscv_internal.h
@@ -171,6 +171,7 @@
 /* SBI Extension IDs */
 
 #define SBI_EXT_HSM             0x48534D
+#define SBI_EXT_IPI             0x735049
 #define SBI_EXT_TIME            0x54494D45
 
 /* SBI function IDs for TIME extension */
@@ -181,6 +182,10 @@
 
 #define SBI_EXT_HSM_HART_START  0x0
 
+/* SBI function IDs for IPI extension */
+
+#define SBI_EXT_IPI_SEND_IPI  0x0
+
 /****************************************************************************
  * Public Types
  ****************************************************************************/
@@ -325,6 +330,7 @@ static inline void riscv_set_basestack(uintptr_t base, uintptr_t size)
 /* RISC-V SBI wrappers ******************************************************/
 
 #ifdef CONFIG_ARCH_USE_S_MODE
+uintptr_t riscv_sbi_send_ipi(uint32_t hmask, uintptr_t hbase);
 void riscv_sbi_set_timer(uint64_t stime_value);
 uint64_t riscv_sbi_get_time(void);
 uintptr_t riscv_sbi_boot_secondary(uint32_t hartid, uintptr_t addr,
diff --git a/arch/risc-v/src/common/riscv_ipi.h b/arch/risc-v/src/common/riscv_ipi.h
index 425260d484..1b2b649f3b 100644
--- a/arch/risc-v/src/common/riscv_ipi.h
+++ b/arch/risc-v/src/common/riscv_ipi.h
@@ -34,10 +34,12 @@
 
 static inline void riscv_ipi_send(int cpu)
 {
-#if defined(RISCV_IPI)
+#if defined(CONFIG_ARCH_USE_S_MODE)
+  riscv_sbi_send_ipi(0x1, cpu);
+#elif defined(RISCV_IPI)
   putreg32(1, (uintptr_t)RISCV_IPI + (4 * cpu));
 #else
-  PANIC();
+#  error "No IPI support for this SoC"
 #endif
 }
 
diff --git a/arch/risc-v/src/common/supervisor/riscv_sbi.c b/arch/risc-v/src/common/supervisor/riscv_sbi.c
index dbe14fe836..da2e4c2dc0 100644
--- a/arch/risc-v/src/common/supervisor/riscv_sbi.c
+++ b/arch/risc-v/src/common/supervisor/riscv_sbi.c
@@ -125,6 +125,12 @@ uint64_t riscv_sbi_get_time(void)
 #endif
 }
 
+uintptr_t riscv_sbi_send_ipi(uint32_t hmask, uintptr_t hbase)
+{
+  return sbi_ecall(SBI_EXT_IPI, SBI_EXT_IPI_SEND_IPI,
+      hmask, hbase, 0, 0, 0, 0);
+}
+
 #ifndef CONFIG_NUTTSBI
 uintptr_t riscv_sbi_boot_secondary(uint32_t hartid, uintptr_t addr,
                                    uintptr_t a1)
diff --git a/arch/risc-v/src/k230/hardware/k230_clint.h b/arch/risc-v/src/k230/hardware/k230_clint.h
index 834984a5c2..179e893420 100644
--- a/arch/risc-v/src/k230/hardware/k230_clint.h
+++ b/arch/risc-v/src/k230/hardware/k230_clint.h
@@ -44,4 +44,6 @@
 #  define K230_TIMECMP       K230_CLINT_MTIMECMP
 #endif
 
+#define RISCV_IPI            K230_IPI
+
 #endif /* __ARCH_RISCV_SRC_K230_HARDWARE_K230_CLINT_H */
diff --git a/arch/risc-v/src/nuttsbi/CMakeLists.txt b/arch/risc-v/src/nuttsbi/CMakeLists.txt
index 2894037f11..740cf8d1d5 100644
--- a/arch/risc-v/src/nuttsbi/CMakeLists.txt
+++ b/arch/risc-v/src/nuttsbi/CMakeLists.txt
@@ -24,6 +24,8 @@ if(CONFIG_NUTTSBI)
 
   list(APPEND SRCS sbi_mtimer.c sbi_mexception.c sbi_mcall.c sbi_mscratch.c)
 
+  list(APPEND SRCS sbi_ipi.c)
+
   target_sources(arch PRIVATE ${SRCS})
 
 endif()
diff --git a/arch/risc-v/src/nuttsbi/Kconfig b/arch/risc-v/src/nuttsbi/Kconfig
index c90523088d..94ac9dd44a 100644
--- a/arch/risc-v/src/nuttsbi/Kconfig
+++ b/arch/risc-v/src/nuttsbi/Kconfig
@@ -15,6 +15,12 @@ config NUTTSBI_HART_CNT
 	int "Amount of harts in SoC"
 	default 1
 
+config NUTTSBI_IPI_BASE
+	hex "MSWI base address"
+	default 0
+	---help---
+		Sets the address of mtimecmp memory mapped register
+
 config NUTTSBI_MTIME_BASE
 	hex "MTIME base address"
 	default 0
diff --git a/arch/risc-v/src/nuttsbi/Make.defs b/arch/risc-v/src/nuttsbi/Make.defs
index b580ca11a4..7a17f583da 100644
--- a/arch/risc-v/src/nuttsbi/Make.defs
+++ b/arch/risc-v/src/nuttsbi/Make.defs
@@ -24,7 +24,7 @@ ifeq ($(CONFIG_NUTTSBI),y)
 
 SBI_ASRCS += sbi_mtrap.S sbi_vectors.S sbi_head.S
 SBI_CSRCS += sbi_mscratch.c sbi_mcall.c sbi_start.c
-SBI_CSRCS += sbi_mexception.c sbi_mtimer.c
+SBI_CSRCS += sbi_mexception.c sbi_mtimer.c sbi_ipi.c
 
 INCLUDES  += ${INCDIR_PREFIX}$(ARCH_SRCDIR)$(DELIM)nuttsbi
 
diff --git a/arch/risc-v/src/nuttsbi/sbi_internal.h b/arch/risc-v/src/nuttsbi/sbi_internal.h
index a778f4fcfe..2d4eda1107 100644
--- a/arch/risc-v/src/nuttsbi/sbi_internal.h
+++ b/arch/risc-v/src/nuttsbi/sbi_internal.h
@@ -43,7 +43,15 @@
 
 #define MMODE_IRQSTACK      (1024)
 
-/* Timer interrupt is the only one we handle, others are discarded */
+/* IPI memory mapped registers */
+
+#define IPI_IRQ             (3)
+
+/* IPI memory mapped registers */
+
+#define IPI_BASE            (CONFIG_NUTTSBI_IPI_BASE)
+
+/* Timer interrupt */
 
 #define MTIMER_IRQ          (7)
 
@@ -97,6 +105,20 @@ void sbi_mscratch_assign(uintptr_t hartid);
 
 void sbi_start(void) noreturn_function;
 
+/****************************************************************************
+ * Name: sbi_send_ipi
+ *
+ * Description:
+ *   Send an inter-processor interrupt to all the harts defined
+ *
+ * Input Parameters:
+ *   hmask - Mask fo CPU to send IPI
+ *   hbase - The firset CPU id to send
+ *
+ ****************************************************************************/
+
+void sbi_send_ipi(uintptr_t hmask, uintptr_t hbase);
+
 /****************************************************************************
  * Name: sbi_init_mtimer
  *
diff --git a/arch/risc-v/src/common/riscv_ipi.h b/arch/risc-v/src/nuttsbi/sbi_ipi.c
similarity index 68%
copy from arch/risc-v/src/common/riscv_ipi.h
copy to arch/risc-v/src/nuttsbi/sbi_ipi.c
index 425260d484..0396d2a1f2 100644
--- a/arch/risc-v/src/common/riscv_ipi.h
+++ b/arch/risc-v/src/nuttsbi/sbi_ipi.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/risc-v/src/common/riscv_ipi.h
+ * arch/risc-v/src/nuttsbi/sbi_ipi.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,35 +18,39 @@
  *
  ****************************************************************************/
 
-#ifndef __ARCH_RISCV_SRC_COMMON_RISCV_IPI_H
-#define __ARCH_RISCV_SRC_COMMON_RISCV_IPI_H
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/
 
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+#include <nuttx/irq.h>
+
+#include <arch/barriers.h>
+
+#include <stdint.h>
+
 #include "riscv_internal.h"
-#include "chip.h"
+
+#include "sbi_internal.h"
 
 /****************************************************************************
- * Public Function Prototypes
+ * Pre-processor Definitions
  ****************************************************************************/
 
-static inline void riscv_ipi_send(int cpu)
-{
-#if defined(RISCV_IPI)
-  putreg32(1, (uintptr_t)RISCV_IPI + (4 * cpu));
-#else
-  PANIC();
-#endif
-}
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
 
-static inline void riscv_ipi_clear(int cpu)
+void sbi_send_ipi(uintptr_t hmask, uintptr_t hbase)
 {
-#if defined(RISCV_IPI)
-  putreg32(0, (uintptr_t)RISCV_IPI + (4 * cpu));
-#endif
-  CLEAR_CSR(CSR_IP, IP_SIP);
-}
+  uintptr_t i;
 
-#endif /* __ARCH_RISCV_SRC_COMMON_RISCV_IPI_H */
+  for (i = hbase; hmask; i++, hmask >>= 1)
+    {
+      if (hmask & 1)
+        {
+          putreg32(1, IPI_BASE + 4 * i);
+        }
+    }
+}
diff --git a/arch/risc-v/src/nuttsbi/sbi_mcall.c b/arch/risc-v/src/nuttsbi/sbi_mcall.c
index 772726769f..02f0eeb2a9 100644
--- a/arch/risc-v/src/nuttsbi/sbi_mcall.c
+++ b/arch/risc-v/src/nuttsbi/sbi_mcall.c
@@ -53,6 +53,9 @@ void sbi_mcall_handle(uintptr_t *regs)
 
   switch (regs[REG_A7])
   {
+    case SBI_EXT_IPI:
+      sbi_send_ipi(regs[REG_A0], regs[REG_A1]);
+      break;
     case SBI_EXT_TIME:
       switch (regs[REG_A6])
       {
diff --git a/arch/risc-v/src/nuttsbi/sbi_mtrap.S b/arch/risc-v/src/nuttsbi/sbi_mtrap.S
index 731fcfbbbb..2f2925433f 100644
--- a/arch/risc-v/src/nuttsbi/sbi_mtrap.S
+++ b/arch/risc-v/src/nuttsbi/sbi_mtrap.S
@@ -70,10 +70,19 @@ machine_trap:
 
   sll        a0, a0, 1            /* Shift msbit out */
   li         a1, MTIMER_IRQ * 2   /* Machine timer irq ? (shifted left) */
+  beq        a0, a1, 2f
+  li         a1, IPI_IRQ * 2      /* Machine IPI irq ? (shifted left) */
   bne        a0, a1, 1f
 
   /* Delegate interrupt to S-mode handler */
 
+  li         a0, MIP_MSIP
+  csrc       CSR_MIE, a0
+  li         a0, MIP_SSIP
+  csrs       CSR_MIP, a0
+  j          1f
+
+2:
   li         a0, MIP_MTIP
   csrc       CSR_MIE, a0
   li         a0, MIP_STIP
diff --git a/boards/risc-v/k230/canmv230/configs/master/defconfig b/boards/risc-v/k230/canmv230/configs/master/defconfig
index 2b795059d1..9df94e26f2 100644
--- a/boards/risc-v/k230/canmv230/configs/master/defconfig
+++ b/boards/risc-v/k230/canmv230/configs/master/defconfig
@@ -78,6 +78,7 @@ CONFIG_NSH_FILE_APPS=y
 CONFIG_NSH_PROMPT_STRING=""
 CONFIG_NSH_READLINE=y
 CONFIG_NUTTSBI=y
+CONFIG_NUTTSBI_IPI_BASE=0xf04000000
 CONFIG_NUTTSBI_MTIMECMP_BASE=0xf04004000
 CONFIG_NUTTSBI_MTIME_BASE=0xf0400bff8
 CONFIG_PATH_INITIAL="/system/bin"
diff --git a/boards/risc-v/k230/canmv230/configs/nsbi/defconfig b/boards/risc-v/k230/canmv230/configs/nsbi/defconfig
index 8cf9fb8992..5e566067f3 100644
--- a/boards/risc-v/k230/canmv230/configs/nsbi/defconfig
+++ b/boards/risc-v/k230/canmv230/configs/nsbi/defconfig
@@ -71,6 +71,7 @@ CONFIG_NSH_FILEIOSIZE=512
 CONFIG_NSH_FILE_APPS=y
 CONFIG_NSH_READLINE=y
 CONFIG_NUTTSBI=y
+CONFIG_NUTTSBI_IPI_BASE=0xf04000000
 CONFIG_NUTTSBI_MTIMECMP_BASE=0xf04004000
 CONFIG_NUTTSBI_MTIME_BASE=0xf0400bff8
 CONFIG_PATH_INITIAL="/system/bin"
diff --git a/boards/risc-v/k230/canmv230/configs/remote/defconfig b/boards/risc-v/k230/canmv230/configs/remote/defconfig
index d5e46cd6d3..39aeb0ae02 100644
--- a/boards/risc-v/k230/canmv230/configs/remote/defconfig
+++ b/boards/risc-v/k230/canmv230/configs/remote/defconfig
@@ -64,6 +64,7 @@ CONFIG_NSH_FILE_APPS=y
 CONFIG_NSH_PROMPT_STRING="remote> "
 CONFIG_NSH_READLINE=y
 CONFIG_NUTTSBI=y
+CONFIG_NUTTSBI_IPI_BASE=0xf04000000
 CONFIG_NUTTSBI_MTIMECMP_BASE=0xf04004000
 CONFIG_NUTTSBI_MTIME_BASE=0xf0400bff8
 CONFIG_PATH_INITIAL="/system/bin"
diff --git a/boards/risc-v/mpfs/icicle/configs/knsh/defconfig b/boards/risc-v/mpfs/icicle/configs/knsh/defconfig
index 4ffae40eb1..0421b7398d 100644
--- a/boards/risc-v/mpfs/icicle/configs/knsh/defconfig
+++ b/boards/risc-v/mpfs/icicle/configs/knsh/defconfig
@@ -78,6 +78,7 @@ CONFIG_NSH_FILE_APPS=y
 CONFIG_NSH_LINELEN=160
 CONFIG_NSH_STRERROR=y
 CONFIG_NUTTSBI=y
+CONFIG_NUTTSBI_IPI_BASE=0x02000000
 CONFIG_NUTTSBI_MTIMECMP_BASE=0x02004000
 CONFIG_NUTTSBI_MTIME_BASE=0x0200bff8
 CONFIG_PREALLOC_TIMERS=4