OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] lib: utils/serial: Optimize semihosting_putc implementation
@ 2023-10-18  2:42 cp0613
  2023-10-23  6:35 ` Guo Ren
  2023-11-16  6:12 ` Anup Patel
  0 siblings, 2 replies; 9+ messages in thread
From: cp0613 @ 2023-10-18  2:42 UTC (permalink / raw)
  To: opensbi

From: Chen Pei <cp0613@linux.alibaba.com>

For some debuggers that do not implement SYSWRITEC and SYSREADC
operations, we can use SYSWRITE and SYSREAD instead like the
implementation of semihosting_getc().

Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
Reviewed-by: Xiang W <wxjstz@126.com>

Changed from v1:
1. simplified by calling semihosting_puts directly.

---
 lib/utils/serial/semihosting.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/utils/serial/semihosting.c b/lib/utils/serial/semihosting.c
index ce65887..a27c69e 100644
--- a/lib/utils/serial/semihosting.c
+++ b/lib/utils/serial/semihosting.c
@@ -160,11 +160,6 @@ static long semihosting_write(long fd, const void *memp, size_t len)
 
 /* clang-format on */
 
-static void semihosting_putc(char ch)
-{
-	semihosting_trap(SYSWRITEC, &ch);
-}
-
 static unsigned long semihosting_puts(const char *str, unsigned long len)
 {
 	char ch;
@@ -183,6 +178,11 @@ static unsigned long semihosting_puts(const char *str, unsigned long len)
 	return (ret < 0) ? 0 : ret;
 }
 
+static void semihosting_putc(char ch)
+{
+	semihosting_puts(&ch, 1);
+}
+
 static int semihosting_getc(void)
 {
 	char ch = 0;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-11-17  1:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-18  2:42 [PATCH v2] lib: utils/serial: Optimize semihosting_putc implementation cp0613
2023-10-23  6:35 ` Guo Ren
2023-10-23  8:22   ` Xiang W
2023-10-23  8:35   ` Anup Patel
2023-10-23  8:57     ` Guo Ren
2023-11-16  6:12 ` Anup Patel
2023-11-16  8:45   ` Xiang W
2023-11-16 16:00     ` Anup Patel
2023-11-17  1:06       ` Xiang W

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox