]> git.proxmox.com Git - mirror_qemu.git/blame - include/semihosting/console.h
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
[mirror_qemu.git] / include / semihosting / console.h
CommitLineData
a331c6d7
AB
1/*
2 * Semihosting Console
3 *
4 * Copyright (c) 2019 Linaro Ltd
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
37677d7d
MA
9#ifndef SEMIHOST_CONSOLE_H
10#define SEMIHOST_CONSOLE_H
a331c6d7 11
ec150c7e
MA
12#include "cpu.h"
13
8de702cb 14/**
e7fb6f32 15 * qemu_semihosting_console_read:
3367d452 16 * @cs: CPUState
e7fb6f32
RH
17 * @buf: host buffer
18 * @len: buffer size
8de702cb 19 *
e7fb6f32
RH
20 * Receive at least one character from debug console. As this call may
21 * block if no data is available we suspend the CPU and will re-execute the
675f702f
RH
22 * instruction when data is there. Therefore two conditions must be met:
23 *
8de702cb
KP
24 * - CPUState is synchronized before calling this function
25 * - pc is only updated once the character is successfully returned
26 *
e7fb6f32 27 * Returns: number of characters read, OR cpu_loop_exit!
8de702cb 28 */
e7fb6f32 29int qemu_semihosting_console_read(CPUState *cs, void *buf, int len);
8de702cb 30
cd66f20f
RH
31/**
32 * qemu_semihosting_console_write:
33 * @buf: host buffer
34 * @len: buffer size
35 *
36 * Write len bytes from buf to the debug console.
37 *
38 * Returns: number of bytes written -- this should only ever be short
39 * on some sort of i/o error.
40 */
41int qemu_semihosting_console_write(void *buf, int len);
42
1b9177f7
RH
43/*
44 * qemu_semihosting_console_block_until_ready:
45 * @cs: CPUState
46 *
47 * If no data is available we suspend the CPU and will re-execute the
48 * instruction when data is available.
49 */
50void qemu_semihosting_console_block_until_ready(CPUState *cs);
51
52/**
53 * qemu_semihosting_console_ready:
54 *
55 * Return true if characters are available for read; does not block.
56 */
57bool qemu_semihosting_console_ready(void);
58
37677d7d 59#endif /* SEMIHOST_CONSOLE_H */