mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
lib: utils/serial: Optimize semihosting_putc implementation
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> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -160,11 +160,6 @@ static long semihosting_write(long fd, const void *memp, size_t len)
|
|||||||
|
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
static void semihosting_putc(char ch)
|
|
||||||
{
|
|
||||||
semihosting_trap(SYSWRITEC, &ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned long semihosting_puts(const char *str, unsigned long len)
|
static unsigned long semihosting_puts(const char *str, unsigned long len)
|
||||||
{
|
{
|
||||||
char ch;
|
char ch;
|
||||||
@@ -183,6 +178,11 @@ static unsigned long semihosting_puts(const char *str, unsigned long len)
|
|||||||
return (ret < 0) ? 0 : ret;
|
return (ret < 0) ? 0 : ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void semihosting_putc(char ch)
|
||||||
|
{
|
||||||
|
semihosting_puts(&ch, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static int semihosting_getc(void)
|
static int semihosting_getc(void)
|
||||||
{
|
{
|
||||||
char ch = 0;
|
char ch = 0;
|
||||||
|
Reference in New Issue
Block a user