@@ -39,6 +39,9 @@
#define SBI_EXT_FWFT 0x46574654
#define SBI_EXT_MPXY 0x4D505859
+/* SBI extension ID for Yield. */
+#define SBI_EXT_YIELD 0x0800594c
+
/* SBI function IDs for BASE extension*/
#define SBI_EXT_BASE_GET_SPEC_VERSION 0x0
#define SBI_EXT_BASE_GET_IMP_ID 0x1
@@ -122,6 +125,9 @@
#define SBI_EXT_DBTR_TRIGGER_ENABLE 0x6
#define SBI_EXT_DBTR_TRIGGER_DISABLE 0x7
+/* SBI function IDs for the Yield extension. */
+#define SBI_EXT_YIELD_YIELD 0x0
+
/* SBI function IDs for FW feature extension */
#define SBI_EXT_FWFT_SET 0x0
#define SBI_EXT_FWFT_GET 0x1
@@ -76,6 +76,15 @@ config SBI_ECALL_LEGACY
bool "SBI v0.1 legacy extensions"
default y
+config SBI_ECALL_YIELD
+ bool "Yield extension"
+ default y
+ help
+ Enable the Yield ECALL extension.
+ Yield completes the calling domain and hart's claimed SYSIRQs.
+ A delivery backend may request a context return once work is drained.
+ Interrupt claiming still uses RPMI SYSTEM_IRQ through SBI MPXY.
+
config SBI_ECALL_VENDOR
bool "Platform-defined vendor extensions"
default y
@@ -64,6 +64,9 @@ libsbi-objs-$(CONFIG_SBI_ECALL_SSE) += sbi_ecall_sse.o
carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_MPXY) += ecall_mpxy
libsbi-objs-$(CONFIG_SBI_ECALL_MPXY) += sbi_ecall_mpxy.o
+carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_YIELD) += ecall_yield
+libsbi-objs-$(CONFIG_SBI_ECALL_YIELD) += sbi_ecall_yield.o
+
libsbi-objs-y += sbi_bitmap.o
libsbi-objs-y += sbi_bitops.o
libsbi-objs-y += sbi_console.o
new file mode 100644
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/*
+ * Copyright (c) 2026 RISCstar Solutions Corporation.
+ *
+ * Author: Raymond Mao <raymond.mao@riscstar.com>
+ */
+
+#include <sbi/sbi_ecall.h>
+#include <sbi/sbi_ecall_interface.h>
+#include <sbi/sbi_error.h>
+#include <sbi_utils/sysirq/rpmi_sysirq.h>
+
+static int sbi_ecall_yield_handler(unsigned long extid, unsigned long funcid,
+ struct sbi_trap_regs *regs,
+ struct sbi_ecall_return *out)
+{
+ u32 completed = 0;
+ int rc;
+
+ if (funcid != SBI_EXT_YIELD_YIELD)
+ return SBI_ENOTSUPP;
+ rc = rpmi_sysirq_complete_thishart(&completed);
+ out->value = completed;
+ return rc;
+}
+
+struct sbi_ecall_extension ecall_yield;
+
+static int sbi_ecall_yield_register_extensions(void)
+{
+ if (!rpmi_sysirq_available())
+ return SBI_OK;
+ return sbi_ecall_register_extension(&ecall_yield);
+}
+
+struct sbi_ecall_extension ecall_yield = {
+ .name = "yield",
+ .extid_start = SBI_EXT_YIELD,
+ .extid_end = SBI_EXT_YIELD,
+ .register_extensions = sbi_ecall_yield_register_extensions,
+ .handle = sbi_ecall_yield_handler,
+};