mirror of
https://github.com/torvalds/linux.git
synced 2026-12-03 20:06:35 +00:00
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: Bin Meng <[email protected]> Tested-by: Sergey Matyukevich <[email protected]> Acked-by: Palmer Dabbelt <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
27 lines
596 B
C
27 lines
596 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright (C) 2022 tinylab.org
|
|
* Author: Bin Meng <[email protected]>
|
|
*/
|
|
|
|
#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_ */
|