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 /** 418de702cbSKeith Packard * qemu_semihosting_console_inc: 428de702cbSKeith Packard * @env: CPUArchState 438de702cbSKeith Packard * 44*675f702fSRichard Henderson * Receive single character from debug console. As this call may block 45*675f702fSRichard Henderson * if no data is available we suspend the CPU and will re-execute the 46*675f702fSRichard Henderson * instruction when data is there. Therefore two conditions must be met: 47*675f702fSRichard Henderson * 488de702cbSKeith Packard * - CPUState is synchronized before calling this function 498de702cbSKeith Packard * - pc is only updated once the character is successfully returned 508de702cbSKeith Packard * 518de702cbSKeith Packard * Returns: character read OR cpu_loop_exit! 528de702cbSKeith Packard */ 538de702cbSKeith Packard target_ulong qemu_semihosting_console_inc(CPUArchState *env); 548de702cbSKeith Packard 558de702cbSKeith Packard /** 56a331c6d7SAlex Bennée * qemu_semihosting_log_out: 57a331c6d7SAlex Bennée * @s: pointer to string 58a331c6d7SAlex Bennée * @len: length of string 59a331c6d7SAlex Bennée * 60a331c6d7SAlex Bennée * Send a string to the debug output. Unlike console_out these strings 61a331c6d7SAlex Bennée * can't be sent to a remote gdb instance as they don't exist in guest 62a331c6d7SAlex Bennée * memory. 63a331c6d7SAlex Bennée * 64a331c6d7SAlex Bennée * Returns: number of bytes written 65a331c6d7SAlex Bennée */ 66a331c6d7SAlex Bennée int qemu_semihosting_log_out(const char *s, int len); 67a331c6d7SAlex Bennée 6837677d7dSMarkus Armbruster #endif /* SEMIHOST_CONSOLE_H */ 69