| 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 | /** |
| 13 | * qemu_semihosting_console_read: |
| 14 | * @cs: CPUState |
| 15 | * @buf: host buffer |
| 16 | * @len: buffer size |
| 17 | * |
| 18 | * Receive at least one character from debug console. As this call may |
| 19 | * block if no data is available we suspend the CPU and will re-execute the |
| 20 | * instruction when data is there. Therefore two conditions must be met: |
| 21 | * |
| 22 | * - CPUState is synchronized before calling this function |
| 23 | * - pc is only updated once the character is successfully returned |
| 24 | * |
| 25 | * Returns: number of characters read, OR cpu_loop_exit! |
| 26 | */ |
| 27 | int qemu_semihosting_console_read(CPUState *cs, void *buf, int len); |
| 28 | |
| 29 | /** |
| 30 | * qemu_semihosting_console_write: |
| 31 | * @buf: host buffer |
| 32 | * @len: buffer size |
| 33 | * |
| 34 | * Write len bytes from buf to the debug console. |
| 35 | * |
| 36 | * Returns: number of bytes written -- this should only ever be short |
| 37 | * on some sort of i/o error. |
| 38 | */ |
| 39 | int qemu_semihosting_console_write(void *buf, int len); |
| 40 | |
| 41 | /* |
| 42 | * qemu_semihosting_console_block_until_ready: |
| 43 | * @cs: CPUState |
| 44 | * |
| 45 | * If no data is available we suspend the CPU and will re-execute the |
| 46 | * instruction when data is available. |
| 47 | */ |
| 48 | void qemu_semihosting_console_block_until_ready(CPUState *cs); |
| 49 | |
| 50 | /** |
| 51 | * qemu_semihosting_console_ready: |
| 52 | * |
| 53 | * Return true if characters are available for read; does not block. |
| 54 | */ |
| 55 | bool qemu_semihosting_console_ready(void); |
| 56 | |
| 57 | #endif /* SEMIHOST_CONSOLE_H */ |