Skip to contentSkip to conversation

OpenSBI debug console support

RFC PATCH Superseded Anup Patel 4 participants 14 messages Nov 10, 2022 – Nov 15, 2022

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Anup Patel

author
#0 lore raw

cover OpenSBI debug console support

The latest draft-v4 proposal of SBI debug console can be found here:
https://lists.riscv.org/g/tech-unixplatformspec/message/1815

This series implements SBI debug console support in OpenSBI as-per above draft proposal.

These patches can also be found in riscv_sbi_dbcn_v1 branch
at: https://github.com/avpatel/opensbi.git

Anup Patel (3):
include: Add defines for SBI debug console extension
lib: sbi: Add sbi_nputs() function
lib: sbi: Implement SBI debug console extension

 include/sbi/sbi_console.h         |  2 ++
 include/sbi/sbi_ecall_interface.h |  4 ++++
 lib/sbi/Kconfig                   |  4 ++++
 lib/sbi/objects.mk                |  1 +
 lib/sbi/sbi_console.c             | 10 ++++++++++
 lib/sbi/sbi_ecall_replace.c       | 30 ++++++++++++++++++++++++++++++
 6 files changed, 51 insertions(+)
Signature · 1 line
2.34.1
author
#1 lore raw

RFC PATCH 1/3 include: Add defines for SBI debug console extension

We add SBI debug console extension related defines/enum to the SBI ecall interface header.

---
 include/sbi/sbi_ecall_interface.h | 4 ++++
 1 file changed, 4 insertions(+)
include/sbi/sbi_ecall_interface.h +4 -0
index a3f2bf4..1dd3874 100644
@@ -29,6 +29,7 @@
 #define SBI_EXT_HSM				0x48534D
 #define SBI_EXT_SRST				0x53525354
 #define SBI_EXT_PMU				0x504D55
+#define SBI_EXT_DBCN				0x4442434E
 
 /* SBI function IDs for BASE extension*/
 #define SBI_EXT_BASE_GET_SPEC_VERSION		0x0
@@ -230,6 +231,9 @@ enum sbi_pmu_ctr_type {
 /* Flags defined for counter stop function */
 #define SBI_PMU_STOP_FLAG_RESET (1 << 0)
 
+/* SBI function IDs for DBCN extension */
+#define SBI_EXT_DBCN_CONSOLE_PUTS		0x0
+
 /* SBI base specification related macros */
 #define SBI_SPEC_VERSION_MAJOR_OFFSET		24
 #define SBI_SPEC_VERSION_MAJOR_MASK		0x7f
Signature · 1 line
2.34.1
#2 lore raw

RFC PATCH 1/3 include: Add defines for SBI debug console extension

Quoted 32 lines · Anup Patel

We add SBI debug console extension related defines/enum to the SBI ecall interface header.

---
 include/sbi/sbi_ecall_interface.h | 4 ++++
 1 file changed, 4 insertions(+)
include/sbi/sbi_ecall_interface.h +4 -1
index a3f2bf4..1dd3874 100644
@@ -29,6 +29,7 @@
 #define SBI_EXT_HSM                            0x48534D
 #define SBI_EXT_SRST                           0x53525354
 #define SBI_EXT_PMU                            0x504D55
+#define SBI_EXT_DBCN                           0x4442434E
 
 /* SBI function IDs for BASE extension*/
 #define SBI_EXT_BASE_GET_SPEC_VERSION          0x0
@@ -230,6 +231,9 @@ enum sbi_pmu_ctr_type {
 /* Flags defined for counter stop function */
 #define SBI_PMU_STOP_FLAG_RESET (1 << 0)
 
+/* SBI function IDs for DBCN extension */
+#define SBI_EXT_DBCN_CONSOLE_PUTS              0x0
+
 /* SBI base specification related macros */
 #define SBI_SPEC_VERSION_MAJOR_OFFSET          24
 #define SBI_SPEC_VERSION_MAJOR_MASK            0x7f
--
Quoted 2 lines

2.34.1

Signature · 2 lines
Regards,
Atish
#4 lore raw

RFC PATCH 1/3 include: Add defines for SBI debug console extension

In reply to Anup Patel

? 2022-11-10???? 22:30 +0530?Anup Patel???

Quoted 4 lines

We add SBI debug console extension related defines/enum to the SBI ecall interface header.

Look good to me

Quoted 30 lines

---
?include/sbi/sbi_ecall_interface.h | 4 ++++
?1 file changed, 4 insertions(+)

include/sbi/sbi_ecall_interface.h +0 -0
index a3f2bf4..1dd3874 100644
@@ -29,6 +29,7 @@

?#define SBI_EXT_HSM????????????????????????????0x48534D ?#define SBI_EXT_SRST???????????????????????????0x53525354 ?#define SBI_EXT_PMU????????????????????????????0x504D55 +#define SBI_EXT_DBCN???????????????????????????0x4442434E ?
?/* SBI function IDs for BASE extension*/ ?#define SBI_EXT_BASE_GET_SPEC_VERSION??????????0x0

include/sbi/sbi_ecall_interface.h +0 -0
@@ -230,6 +231,9 @@ enum sbi_pmu_ctr_type {

?/* Flags defined for counter stop function */
?#define SBI_PMU_STOP_FLAG_RESET (1 << 0)
?

include/sbi/sbi_ecall_interface.h +3 -0
+/* SBI function IDs for DBCN extension */
+#define SBI_EXT_DBCN_CONSOLE_PUTS??????????????0x0
+

?/* SBI base specification related macros */ ?#define SBI_SPEC_VERSION_MAJOR_OFFSET??????????24 ?#define SBI_SPEC_VERSION_MAJOR_MASK????????????0x7f

Signature · 1 line
2.34.1
author
#5 lore raw

RFC PATCH 2/3 lib: sbi: Add sbi_nputs() function

In reply to Anup Patel

We add new sbi_nputs() which help us print a fixed number of characters from a physical memory location.

---
 include/sbi/sbi_console.h |  2 ++
 lib/sbi/sbi_console.c     | 10 ++++++++++
 2 files changed, 12 insertions(+)
include/sbi/sbi_console.h +2 -0
index e15b55d..1bdeeb9 100644
@@ -33,6 +33,8 @@ void sbi_putc(char ch);
 
 void sbi_puts(const char *str);
 
+void sbi_nputs(const char *str, unsigned long len);
+
 void sbi_gets(char *s, int maxwidth, char endchar);
 
 int __printf(2, 3) sbi_sprintf(char *out, const char *format, ...);
lib/sbi/sbi_console.c +10 -0
index cfef2f8..a975708 100644
@@ -51,6 +51,16 @@ void sbi_puts(const char *str)
 	spin_unlock(&console_out_lock);
 }
 
+void sbi_nputs(const char *str, unsigned long len)
+{
+	unsigned long i;
+
+	spin_lock(&console_out_lock);
+	for (i = 0; i < len; i++)
+		sbi_putc(str[i]);
+	spin_unlock(&console_out_lock);
+}
+
 void sbi_gets(char *s, int maxwidth, char endchar)
 {
 	int ch;
Signature · 1 line
2.34.1
#6 lore raw

RFC PATCH 2/3 lib: sbi: Add sbi_nputs() function

Quoted 45 lines · Anup Patel

We add new sbi_nputs() which help us print a fixed number of characters from a physical memory location.

---
 include/sbi/sbi_console.h |  2 ++
 lib/sbi/sbi_console.c     | 10 ++++++++++
 2 files changed, 12 insertions(+)
include/sbi/sbi_console.h +2 -0
index e15b55d..1bdeeb9 100644
@@ -33,6 +33,8 @@ void sbi_putc(char ch);
 
 void sbi_puts(const char *str);
 
+void sbi_nputs(const char *str, unsigned long len);
+
 void sbi_gets(char *s, int maxwidth, char endchar);
 
 int __printf(2, 3) sbi_sprintf(char *out, const char *format, ...);
lib/sbi/sbi_console.c +10 -1
index cfef2f8..a975708 100644
@@ -51,6 +51,16 @@ void sbi_puts(const char *str)
        spin_unlock(&console_out_lock);
 }
 
+void sbi_nputs(const char *str, unsigned long len)
+{
+       unsigned long i;
+
+       spin_lock(&console_out_lock);
+       for (i = 0; i < len; i++)
+               sbi_putc(str[i]);
+       spin_unlock(&console_out_lock);
+}
+
 void sbi_gets(char *s, int maxwidth, char endchar)
 {
        int ch;
--
Quoted 2 lines

2.34.1

Signature · 2 lines
Regards,
Atish
#8 lore raw

RFC PATCH 2/3 lib: sbi: Add sbi_nputs() function

In reply to Anup Patel

? 2022-11-10???? 22:30 +0530?Anup Patel???

Quoted 4 lines

We add new sbi_nputs() which help us print a fixed number of characters from a physical memory location.

Look good to me.

Quoted 43 lines

---
?include/sbi/sbi_console.h |? 2 ++
?lib/sbi/sbi_console.c???? | 10 ++++++++++
?2 files changed, 12 insertions(+)

include/sbi/sbi_console.h +0 -0
index e15b55d..1bdeeb9 100644
@@ -33,6 +33,8 @@ void sbi_putc(char ch);

?
?void sbi_puts(const char *str);
?

include/sbi/sbi_console.h +2 -0
+void sbi_nputs(const char *str, unsigned long len);
+

?void sbi_gets(char *s, int maxwidth, char endchar);
?
?int __printf(2, 3) sbi_sprintf(char *out, const char *format, ...);

lib/sbi/sbi_console.c +0 -0
index cfef2f8..a975708 100644
@@ -51,6 +51,16 @@ void sbi_puts(const char *str)
 ????????spin_unlock(&console_out_lock);
 ?}

?

lib/sbi/sbi_console.c +10 -0
+void sbi_nputs(const char *str, unsigned long len)
+{
+???????unsigned long i;
+
+???????spin_lock(&console_out_lock);
+???????for (i = 0; i < len; i++)
+???????????????sbi_putc(str[i]);
+???????spin_unlock(&console_out_lock);
+}
+

?void sbi_gets(char *s, int maxwidth, char endchar) ?{
????????int ch;

Signature · 1 line
2.34.1
author
#9 lore raw

RFC PATCH 3/3 lib: sbi: Implement SBI debug console extension

In reply to Anup Patel

We implement SBI debug console extension as one of the replacement SBI extensions. This extension is only available when OpenSBI platform provides a console device to generic library.

---
 lib/sbi/Kconfig             |  4 ++++
 lib/sbi/objects.mk          |  1 +
 lib/sbi/sbi_ecall_replace.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+)
lib/sbi/Kconfig +4 -0
index df74bba..ef6728b 100644
@@ -26,6 +26,10 @@ config SBI_ECALL_PMU
 	bool "Performance Monitoring Unit extension"
 	default y
 
+config SBI_ECALL_DBCN
+	bool "Debug Console extension"
+	default y
+
 config SBI_ECALL_LEGACY
 	bool "SBI v0.1 legacy extensions"
 	default y
lib/sbi/objects.mk +1 -0
index 783c46d..7ccad52 100644
@@ -23,6 +23,7 @@ carray-sbi_ecall_exts-y += ecall_base
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_HSM) += ecall_hsm
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_SRST) += ecall_srst
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_PMU) += ecall_pmu
+carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_DBCN) += ecall_dbcn
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_LEGACY) += ecall_legacy
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_VENDOR) += ecall_vendor
 
lib/sbi/sbi_ecall_replace.c +30 -0
index 0ea00d6..a092e2f 100644
@@ -9,6 +9,7 @@
  */
 
 #include <sbi/riscv_asm.h>
+#include <sbi/sbi_console.h>
 #include <sbi/sbi_ecall.h>
 #include <sbi/sbi_ecall_interface.h>
 #include <sbi/sbi_error.h>
@@ -202,3 +203,32 @@ struct sbi_ecall_extension ecall_srst = {
 	.probe = sbi_ecall_srst_probe,
 };
 #endif
+
+#ifdef CONFIG_SBI_ECALL_DBCN
+static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid,
+				  const struct sbi_trap_regs *regs,
+				  unsigned long *out_val,
+				  struct sbi_trap_info *out_trap)
+{
+	if (funcid == SBI_EXT_DBCN_CONSOLE_PUTS) {
+		/* TODO: sanity check on the physical address range */
+		sbi_nputs((const char *)regs->a1, regs->a0);
+		return 0;
+	}
+
+	return SBI_ENOTSUPP;
+}
+
+static int sbi_ecall_dbcn_probe(unsigned long extid, unsigned long *out_val)
+{
+	*out_val = (sbi_console_get_device()) ? 1 : 0;
+	return 0;
+}
+
+struct sbi_ecall_extension ecall_dbcn = {
+	.extid_start = SBI_EXT_DBCN,
+	.extid_end = SBI_EXT_DBCN,
+	.handle = sbi_ecall_dbcn_handler,
+	.probe = sbi_ecall_dbcn_probe,
+};
+#endif
Signature · 1 line
2.34.1
#10 lore raw

RFC PATCH 3/3 lib: sbi: Implement SBI debug console extension

Quoted 54 lines · Anup Patel

We implement SBI debug console extension as one of the replacement SBI extensions. This extension is only available when OpenSBI platform provides a console device to generic library.

---
 lib/sbi/Kconfig             |  4 ++++
 lib/sbi/objects.mk          |  1 +
 lib/sbi/sbi_ecall_replace.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+)
lib/sbi/Kconfig +4 -0
index df74bba..ef6728b 100644
@@ -26,6 +26,10 @@ config SBI_ECALL_PMU
        bool "Performance Monitoring Unit extension"
        default y
 
+config SBI_ECALL_DBCN
+       bool "Debug Console extension"
+       default y
+
 config SBI_ECALL_LEGACY
        bool "SBI v0.1 legacy extensions"
        default y
lib/sbi/objects.mk +1 -0
index 783c46d..7ccad52 100644
@@ -23,6 +23,7 @@ carray-sbi_ecall_exts-y += ecall_base
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_HSM) += ecall_hsm
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_SRST) += ecall_srst
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_PMU) += ecall_pmu
+carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_DBCN) += ecall_dbcn
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_LEGACY) += ecall_legacy
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_VENDOR) += ecall_vendor
 
lib/sbi/sbi_ecall_replace.c +1 -0
index 0ea00d6..a092e2f 100644
@@ -9,6 +9,7 @@
  */
 
 #include <sbi/riscv_asm.h>
+#include <sbi/sbi_console.h>
 #include <sbi/sbi_ecall.h>
 #include <sbi/sbi_ecall_interface.h>
 #include <sbi/sbi_error.h>
@@ -202,3 +203,32 @@ struct sbi_ecall_extension ecall_srst = {
        .probe = sbi_ecall_srst_probe,
 };

lib/sbi/sbi_ecall_replace.c struct sbi_ecall_extension ecall_srst = { · line 214

Quoted 10 lines
lib/sbi/sbi_ecall_replace.c +9 -0
 #endif
+
+#ifdef CONFIG_SBI_ECALL_DBCN
+static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid,
+                                 const struct sbi_trap_regs *regs,
+                                 unsigned long *out_val,
+                                 struct sbi_trap_info *out_trap)
+{
+       if (funcid == SBI_EXT_DBCN_CONSOLE_PUTS) {
+               /* TODO: sanity check on the physical address range */

We need PMP validation to ensure that it is not one of the M-mode reserved addresses.
What else needed to be done here ?

Quoted 21 lines
lib/sbi/sbi_ecall_replace.c +20 -1
+               sbi_nputs((const char *)regs->a1, regs->a0);
+               return 0;
+       }
+
+       return SBI_ENOTSUPP;
+}
+
+static int sbi_ecall_dbcn_probe(unsigned long extid, unsigned long *out_val)
+{
+       *out_val = (sbi_console_get_device()) ? 1 : 0;
+       return 0;
+}
+
+struct sbi_ecall_extension ecall_dbcn = {
+       .extid_start = SBI_EXT_DBCN,
+       .extid_end = SBI_EXT_DBCN,
+       .handle = sbi_ecall_dbcn_handler,
+       .probe = sbi_ecall_dbcn_probe,
+};
+#endif
--
Quoted 2 lines

2.34.1

--
Regards,
Atish

#11 lore raw

RFC PATCH 3/3 lib: sbi: Implement SBI debug console extension

? 2022-11-12???? 00:54 -0800?Atish Patra???

Quoted 61 lines · Anup Patel
Quoted 60 lines

We implement SBI debug console extension as one of the replacement SBI extensions. This extension is only available when OpenSBI platform provides a console device to generic library.

---

?lib/sbi/Kconfig???????????? |? 4 ++++
?lib/sbi/objects.mk????????? |? 1 +
?lib/sbi/sbi_ecall_replace.c | 30 ++++++++++++++++++++++++++++++

?3 files changed, 35 insertions(+)

lib/sbi/Kconfig +0 -0
index df74bba..ef6728b 100644
@@ -26,6 +26,10 @@ config SBI_ECALL_PMU

??????? bool "Performance Monitoring Unit extension" ??????? default y

lib/sbi/Kconfig +4 -0
+config SBI_ECALL_DBCN
+?????? bool "Debug Console extension"
+?????? default y
+

?config SBI_ECALL_LEGACY
??????? bool "SBI v0.1 legacy extensions"
??????? default y

lib/sbi/objects.mk +0 -0
index 783c46d..7ccad52 100644
@@ -23,6 +23,7 @@ carray-sbi_ecall_exts-y += ecall_base

?carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_HSM) += ecall_hsm ?carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_SRST) += ecall_srst ?carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_PMU) += ecall_pmu +carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_DBCN) += ecall_dbcn ?carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_LEGACY) += ecall_legacy ?carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_VENDOR) += ecall_vendor

lib/sbi/sbi_ecall_replace.c +0 -0
index 0ea00d6..a092e2f 100644
@@ -9,6 +9,7 @@

? */

?#include <sbi/riscv_asm.h>
+#include <sbi/sbi_console.h>
?#include <sbi/sbi_ecall.h>
?#include <sbi/sbi_ecall_interface.h>
?#include <sbi/sbi_error.h>

lib/sbi/sbi_ecall_replace.c +0 -0
@@ -202,3 +203,32 @@ struct sbi_ecall_extension ecall_srst = {
 ??????? .probe = sbi_ecall_srst_probe,
 ?};

?#endif

lib/sbi/sbi_ecall_replace.c +5 -0
+
+#ifdef CONFIG_SBI_ECALL_DBCN
+static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid,
+???????????????????????????????? const struct sbi_trap_regs *regs,
+???????????????????????????????? unsigned long *out_val,
Quoted 8 lines
Quoted 4 lines

+???????????????????????????????? struct sbi_trap_info *out_trap) +{
+?????? if (funcid == SBI_EXT_DBCN_CONSOLE_PUTS) { +?????????????? /* TODO: sanity check on the physical address range */

We need PMP validation to ensure that it is not one of the M-mode reserved addresses.
What else needed to be done here ?

We also need to confirm that this memory is not mmio.

We can imitate sbi_domain_check_addr to create sbi_domain_check_range for range checking.

Regards,
Xiang W

Quoted 30 lines
Quoted 22 lines

+?????????????? sbi_nputs((const char *)regs->a1, regs->a0); +?????????????? return 0;
+?????? }

lib/sbi/sbi_ecall_replace.c +17 -1
+
+?????? return SBI_ENOTSUPP;
+}
+
+static int sbi_ecall_dbcn_probe(unsigned long extid, unsigned long *out_val)
+{
+?????? *out_val = (sbi_console_get_device()) ? 1 : 0;
+?????? return 0;
+}
+
+struct sbi_ecall_extension ecall_dbcn = {
+?????? .extid_start = SBI_EXT_DBCN,
+?????? .extid_end = SBI_EXT_DBCN,
+?????? .handle = sbi_ecall_dbcn_handler,
+?????? .probe = sbi_ecall_dbcn_probe,
+};
+#endif
--
Quoted 2 lines

2.34.1

--
Regards,
Atish

author
#12 lore raw

RFC PATCH 3/3 lib: sbi: Implement SBI debug console extension

In reply to Atish Patra
Quoted 62 lines · Atish Patra
Quoted 60 lines · Anup Patel

We implement SBI debug console extension as one of the replacement SBI extensions. This extension is only available when OpenSBI platform provides a console device to generic library.

---
 lib/sbi/Kconfig             |  4 ++++
 lib/sbi/objects.mk          |  1 +
 lib/sbi/sbi_ecall_replace.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+)
lib/sbi/Kconfig +4 -0
index df74bba..ef6728b 100644
@@ -26,6 +26,10 @@ config SBI_ECALL_PMU
        bool "Performance Monitoring Unit extension"
        default y
 
+config SBI_ECALL_DBCN
+       bool "Debug Console extension"
+       default y
+
 config SBI_ECALL_LEGACY
        bool "SBI v0.1 legacy extensions"
        default y
lib/sbi/objects.mk +1 -0
index 783c46d..7ccad52 100644
@@ -23,6 +23,7 @@ carray-sbi_ecall_exts-y += ecall_base
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_HSM) += ecall_hsm
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_SRST) += ecall_srst
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_PMU) += ecall_pmu
+carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_DBCN) += ecall_dbcn
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_LEGACY) += ecall_legacy
 carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_VENDOR) += ecall_vendor
 
lib/sbi/sbi_ecall_replace.c +6 -0
index 0ea00d6..a092e2f 100644
@@ -9,6 +9,7 @@
  */
 
 #include <sbi/riscv_asm.h>
+#include <sbi/sbi_console.h>
 #include <sbi/sbi_ecall.h>
 #include <sbi/sbi_ecall_interface.h>
 #include <sbi/sbi_error.h>
@@ -202,3 +203,32 @@ struct sbi_ecall_extension ecall_srst = {
        .probe = sbi_ecall_srst_probe,
 };
 #endif
+
+#ifdef CONFIG_SBI_ECALL_DBCN
+static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid,
+                                 const struct sbi_trap_regs *regs,
+                                 unsigned long *out_val,
Quoted 8 lines

lib/sbi/sbi_ecall_replace.c struct sbi_ecall_extension ecall_srst = { · line 214

Quoted 4 lines
lib/sbi/sbi_ecall_replace.c +4 -0
+                                 struct sbi_trap_info *out_trap)
+{
+       if (funcid == SBI_EXT_DBCN_CONSOLE_PUTS) {
+               /* TODO: sanity check on the physical address range */

We need PMP validation to ensure that it is not one of the M-mode reserved addresses.
What else needed to be done here ?

Yes, I need to add required checks here.

Regards,
Anup

Quoted 29 lines
Quoted 22 lines
lib/sbi/sbi_ecall_replace.c +20 -1
+               sbi_nputs((const char *)regs->a1, regs->a0);
+               return 0;
+       }
+
+       return SBI_ENOTSUPP;
+}
+
+static int sbi_ecall_dbcn_probe(unsigned long extid, unsigned long *out_val)
+{
+       *out_val = (sbi_console_get_device()) ? 1 : 0;
+       return 0;
+}
+
+struct sbi_ecall_extension ecall_dbcn = {
+       .extid_start = SBI_EXT_DBCN,
+       .extid_end = SBI_EXT_DBCN,
+       .handle = sbi_ecall_dbcn_handler,
+       .probe = sbi_ecall_dbcn_probe,
+};
+#endif
--
Quoted 2 lines

2.34.1

--
Regards,
Atish

#13 lore raw

cover OpenSBI debug console support

In reply to Anup Patel
Quoted 4 lines · Anup Patel

The latest draft-v4 proposal of SBI debug console can be found here:
https://lists.riscv.org/g/tech-unixplatformspec/message/1815

Can you send it as a patch to the tec-prs mailing list in the adoc format as well ?

Quoted 22 lines

This series implements SBI debug console support in OpenSBI as-per above draft proposal.

These patches can also be found in riscv_sbi_dbcn_v1 branch
at: https://github.com/avpatel/opensbi.git

Anup Patel (3):
include: Add defines for SBI debug console extension
lib: sbi: Add sbi_nputs() function
lib: sbi: Implement SBI debug console extension

 include/sbi/sbi_console.h         |  2 ++
 include/sbi/sbi_ecall_interface.h |  4 ++++
 lib/sbi/Kconfig                   |  4 ++++
 lib/sbi/objects.mk                |  1 +
 lib/sbi/sbi_console.c             | 10 ++++++++++
 lib/sbi/sbi_ecall_replace.c       | 30 ++++++++++++++++++++++++++++++
 6 files changed, 51 insertions(+)

--
2.34.1

Signature · 2 lines
Regards,
Atish