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_read: 29 * @cs: CPUState 30 * @buf: host buffer 31 * @len: buffer size 32 * 33 * Receive at least one character from debug console. As this call may 34 * block if no data is available we suspend the CPU and will re-execute the 35 * instruction when data is there. Therefore two conditions must be met: 36 * 37 * - CPUState is synchronized before calling this function 38 * - pc is only updated once the character is successfully returned 39 * 40 * Returns: number of characters read, OR cpu_loop_exit! 41 */ 42 int qemu_semihosting_console_read(CPUState *cs, void *buf, int len); 43 44 /** 45 * qemu_semihosting_console_write: 46 * @buf: host buffer 47 * @len: buffer size 48 * 49 * Write len bytes from buf to the debug console. 50 * 51 * Returns: number of bytes written -- this should only ever be short 52 * on some sort of i/o error. 53 */ 54 int qemu_semihosting_console_write(void *buf, int len); 55 56 /** 57 * qemu_semihosting_log_out: 58 * @s: pointer to string 59 * @len: length of string 60 * 61 * Send a string to the debug output. Unlike console_out these strings 62 * can't be sent to a remote gdb instance as they don't exist in guest 63 * memory. 64 * 65 * Returns: number of bytes written 66 */ 67 int qemu_semihosting_log_out(const char *s, int len); 68 69 #endif /* SEMIHOST_CONSOLE_H */ 70