Commit db5489f4 authored by Bin Meng's avatar Bin Meng Committed by Greg Kroah-Hartman

riscv: Implement semihost.h for earlycon semihost driver

Per RISC-V semihosting spec [1], implement semihost.h for the existing
Arm semihosting earlycon driver to work on RISC-V.

Link: https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc [1]
Signed-off-by: default avatarBin Meng <bmeng@tinylab.org>
Tested-by: default avatarSergey Matyukevich <sergey.matyukevich@syntacore.com>
Acked-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
Link: https://lore.kernel.org/r/20221209150437.795918-3-bmeng@tinylab.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 88907175
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2022 tinylab.org
* Author: Bin Meng <bmeng@tinylab.org>
*/
#ifndef _RISCV_SEMIHOST_H_
#define _RISCV_SEMIHOST_H_
struct uart_port;
static inline void smh_putc(struct uart_port *port, unsigned char c)
{
asm volatile("addi a1, %0, 0\n"
"addi a0, zero, 3\n"
".balign 16\n"
".option push\n"
".option norvc\n"
"slli zero, zero, 0x1f\n"
"ebreak\n"
"srai zero, zero, 0x7\n"
".option pop\n"
: : "r" (&c) : "a0", "a1", "memory");
}
#endif /* _RISCV_SEMIHOST_H_ */
......@@ -75,7 +75,7 @@ config SERIAL_AMBA_PL011_CONSOLE
config SERIAL_EARLYCON_ARM_SEMIHOST
bool "Early console using ARM semihosting"
depends on ARM64 || ARM
depends on ARM64 || ARM || RISCV
select SERIAL_CORE
select SERIAL_CORE_CONSOLE
select SERIAL_EARLYCON
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment