From f280114f0e4f0dd1bc772b1a690872ebd02ee368 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Wed, 30 Mar 2022 20:47:56 +1000 Subject: [PATCH] console: semihost_console: use semihost API Update the semihost_console implementation to use the semihost API instead of manually constructing the supervisor calls. Signed-off-by: Jordan Yates --- drivers/console/semihost_console.c | 44 ++++-------------------------- 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/drivers/console/semihost_console.c b/drivers/console/semihost_console.c index 8d5b4fabdfc..afe43b2345f 100644 --- a/drivers/console/semihost_console.c +++ b/drivers/console/semihost_console.c @@ -3,50 +3,16 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include -#include -#include +#include +#include +#include +#include extern void __stdout_hook_install(int (*fn)(int)); -#define SYS_WRITEC 0x03 - int arch_printk_char_out(int _c) { - char c = _c; - -#if defined(CONFIG_CPU_CORTEX_M) - - register unsigned long r0 __asm__("r0") = SYS_WRITEC; - register void *r1 __asm__("r1") = &c; - - __asm__ __volatile__ ("bkpt 0xab" : : "r" (r0), "r" (r1) : "memory"); - -#elif defined(CONFIG_ARM64) - - register unsigned long x0 __asm__("x0") = SYS_WRITEC; - register void *x1 __asm__("x1") = &c; - - __asm__ volatile ("hlt 0xf000" : : "r" (x0), "r" (x1) : "memory"); - -#elif defined(CONFIG_RISCV) - - register unsigned long a0 __asm__("a0") = SYS_WRITEC; - register void *a1 __asm__("a1") = &c; - - __asm__ volatile ( - ".option push\n\t" - ".option norvc\n\t" - "slli zero, zero, 0x1f\n\t" - "ebreak\n\t" - "srai zero, zero, 0x7\n\t" - ".option pop" - : : "r" (a0), "r" (a1) : "memory"); - -#else -#error "unsupported CPU type" -#endif - + semihost_poll_out((char)_c); return 0; }