summaryrefslogtreecommitdiffstats
path: root/arch/riscv/include/asm/semihost.h
blob: 557a34938193fc9cd581573ebb4029a463d33591 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* 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_ */