diff options
author | Anup Patel <anup.patel@wdc.com> | 2021-04-21 18:03:50 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2021-04-28 16:58:23 +0530 |
commit | 068ca086af2312d56efe51a724d78d84e1339ab4 (patch) | |
tree | 0e90c1a9e7a03254ff5dcb33507c5c9a06f9de3e /lib/utils/sys | |
parent | a3689db92a0e83ef25c52887aa686e4527e35a22 (diff) |
lib: sbi: Simplify console platform operations
Instead of having console_putc() and console_getc() callbacks in
platform operations, it will be much simpler for console driver to
directly register these operations as device to the sbi_console
implementation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Xiang W <wxjstz@126.com>
Diffstat (limited to 'lib/utils/sys')
-rw-r--r-- | lib/utils/sys/htif.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/utils/sys/htif.c b/lib/utils/sys/htif.c index fd70fb9..2fd38a7 100644 --- a/lib/utils/sys/htif.c +++ b/lib/utils/sys/htif.c @@ -6,6 +6,7 @@ */ #include <sbi/riscv_locks.h> +#include <sbi/sbi_console.h> #include <sbi_utils/sys/htif.h> #define HTIF_DATA_BITS 48 @@ -98,7 +99,7 @@ static void do_tohost_fromhost(uint64_t dev, uint64_t cmd, uint64_t data) spin_unlock(&htif_lock); } -void htif_putc(char ch) +static void htif_putc(char ch) { /* HTIF devices are not supported on RV32, so do a proxy write call */ volatile uint64_t magic_mem[8]; @@ -109,7 +110,7 @@ void htif_putc(char ch) do_tohost_fromhost(HTIF_DEV_SYSTEM, 0, (uint64_t)(uintptr_t)magic_mem); } #else -void htif_putc(char ch) +static void htif_putc(char ch) { spin_lock(&htif_lock); __set_tohost(HTIF_DEV_CONSOLE, HTIF_CONSOLE_CMD_PUTC, ch); @@ -117,7 +118,7 @@ void htif_putc(char ch) } #endif -int htif_getc(void) +static int htif_getc(void) { int ch; @@ -140,6 +141,19 @@ int htif_getc(void) return ch - 1; } +static struct sbi_console_device htif_console = { + .name = "htif", + .console_putc = htif_putc, + .console_getc = htif_getc +}; + +int htif_serial_init(void) +{ + sbi_console_set_device(&htif_console); + + return 0; +} + int htif_system_reset_check(u32 type, u32 reason) { return 1; |