xref: /openbmc/qemu/include/semihosting/console.h (revision fb08790b)
1 /*
2  * Semihosting Console
3  *
4  * Copyright (c) 2019 Linaro Ltd
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8 
9 #ifndef SEMIHOST_CONSOLE_H
10 #define SEMIHOST_CONSOLE_H
11 
12 #include "cpu.h"
13 
14 /**
15  * qemu_semihosting_console_outs:
16  * @env: CPUArchState
17  * @s: host address of null terminated guest string
18  *
19  * Send a null terminated guest string to the debug console. This may
20  * be the remote gdb session if a softmmu guest is currently being
21  * debugged.
22  *
23  * Returns: number of bytes written.
24  */
25 int qemu_semihosting_console_outs(CPUArchState *env, target_ulong s);
26 
27 /**
28  * qemu_semihosting_console_outc:
29  * @env: CPUArchState
30  * @s: host address of null terminated guest string
31  *
32  * Send single character from guest memory to the debug console. This
33  * may be the remote gdb session if a softmmu guest is currently being
34  * debugged.
35  *
36  * Returns: nothing
37  */
38 void qemu_semihosting_console_outc(CPUArchState *env, target_ulong c);
39 
40 /**
41  * qemu_semihosting_console_read:
42  * @cs: CPUState
43  * @buf: host buffer
44  * @len: buffer size
45  *
46  * Receive at least one character from debug console.  As this call may
47  * block if no data is available we suspend the CPU and will re-execute the
48  * instruction when data is there. Therefore two conditions must be met:
49  *
50  *   - CPUState is synchronized before calling this function
51  *   - pc is only updated once the character is successfully returned
52  *
53  * Returns: number of characters read, OR cpu_loop_exit!
54  */
55 int qemu_semihosting_console_read(CPUState *cs, void *buf, int len);
56 
57 /**
58  * qemu_semihosting_log_out:
59  * @s: pointer to string
60  * @len: length of string
61  *
62  * Send a string to the debug output. Unlike console_out these strings
63  * can't be sent to a remote gdb instance as they don't exist in guest
64  * memory.
65  *
66  * Returns: number of bytes written
67  */
68 int qemu_semihosting_log_out(const char *s, int len);
69 
70 #endif /* SEMIHOST_CONSOLE_H */
71