xref: /qemu/include/semihosting/console.h (revision 8de702cb677c8381fb702cae252d6b69aa4c653b)
1a331c6d7SAlex Bennée /*
2a331c6d7SAlex Bennée  * Semihosting Console
3a331c6d7SAlex Bennée  *
4a331c6d7SAlex Bennée  * Copyright (c) 2019 Linaro Ltd
5a331c6d7SAlex Bennée  *
6a331c6d7SAlex Bennée  * SPDX-License-Identifier: GPL-2.0-or-later
7a331c6d7SAlex Bennée  */
8a331c6d7SAlex Bennée 
937677d7dSMarkus Armbruster #ifndef SEMIHOST_CONSOLE_H
1037677d7dSMarkus Armbruster #define SEMIHOST_CONSOLE_H
11a331c6d7SAlex Bennée 
12ec150c7eSMarkus Armbruster #include "cpu.h"
13ec150c7eSMarkus Armbruster 
14a331c6d7SAlex Bennée /**
1578e24848SAlex Bennée  * qemu_semihosting_console_outs:
16a331c6d7SAlex Bennée  * @env: CPUArchState
1778e24848SAlex Bennée  * @s: host address of null terminated guest string
18a331c6d7SAlex Bennée  *
1978e24848SAlex Bennée  * Send a null terminated guest string to the debug console. This may
2078e24848SAlex Bennée  * be the remote gdb session if a softmmu guest is currently being
2178e24848SAlex Bennée  * debugged.
22a331c6d7SAlex Bennée  *
23a331c6d7SAlex Bennée  * Returns: number of bytes written.
24a331c6d7SAlex Bennée  */
2578e24848SAlex Bennée int qemu_semihosting_console_outs(CPUArchState *env, target_ulong s);
2678e24848SAlex Bennée 
2778e24848SAlex Bennée /**
2878e24848SAlex Bennée  * qemu_semihosting_console_outc:
2978e24848SAlex Bennée  * @env: CPUArchState
3078e24848SAlex Bennée  * @s: host address of null terminated guest string
3178e24848SAlex Bennée  *
3278e24848SAlex Bennée  * Send single character from guest memory to the debug console. This
3378e24848SAlex Bennée  * may be the remote gdb session if a softmmu guest is currently being
3478e24848SAlex Bennée  * debugged.
3578e24848SAlex Bennée  *
3678e24848SAlex Bennée  * Returns: nothing
3778e24848SAlex Bennée  */
3878e24848SAlex Bennée void qemu_semihosting_console_outc(CPUArchState *env, target_ulong c);
39a331c6d7SAlex Bennée 
40a331c6d7SAlex Bennée /**
41*8de702cbSKeith Packard  * qemu_semihosting_console_inc:
42*8de702cbSKeith Packard  * @env: CPUArchState
43*8de702cbSKeith Packard  *
44*8de702cbSKeith Packard  * Receive single character from debug console. This may be the remote
45*8de702cbSKeith Packard  * gdb session if a softmmu guest is currently being debugged. As this
46*8de702cbSKeith Packard  * call may block if no data is available we suspend the CPU and will
47*8de702cbSKeith Packard  * re-execute the instruction when data is there. Therefore two
48*8de702cbSKeith Packard  * conditions must be met:
49*8de702cbSKeith Packard  *   - CPUState is synchronized before calling this function
50*8de702cbSKeith Packard  *   - pc is only updated once the character is successfully returned
51*8de702cbSKeith Packard  *
52*8de702cbSKeith Packard  * Returns: character read OR cpu_loop_exit!
53*8de702cbSKeith Packard  */
54*8de702cbSKeith Packard target_ulong qemu_semihosting_console_inc(CPUArchState *env);
55*8de702cbSKeith Packard 
56*8de702cbSKeith Packard /**
57a331c6d7SAlex Bennée  * qemu_semihosting_log_out:
58a331c6d7SAlex Bennée  * @s: pointer to string
59a331c6d7SAlex Bennée  * @len: length of string
60a331c6d7SAlex Bennée  *
61a331c6d7SAlex Bennée  * Send a string to the debug output. Unlike console_out these strings
62a331c6d7SAlex Bennée  * can't be sent to a remote gdb instance as they don't exist in guest
63a331c6d7SAlex Bennée  * memory.
64a331c6d7SAlex Bennée  *
65a331c6d7SAlex Bennée  * Returns: number of bytes written
66a331c6d7SAlex Bennée  */
67a331c6d7SAlex Bennée int qemu_semihosting_log_out(const char *s, int len);
68a331c6d7SAlex Bennée 
6937677d7dSMarkus Armbruster #endif /* SEMIHOST_CONSOLE_H */
70