semihosting: Create semihost_sys_poll_one

This will be used for implementing the xtensa select_one
system call.  Choose "poll" over "select" so that we can
reuse Glib's g_poll constants and to avoid struct timeval.

Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2022-05-02 11:15:40 -07:00
parent 2d010c2719
commit 1b9177f749
4 changed files with 106 additions and 2 deletions

View file

@ -77,10 +77,17 @@ static void console_read(void *opaque, const uint8_t *buf, int size)
c->sleeping_cpus = NULL;
}
int qemu_semihosting_console_read(CPUState *cs, void *buf, int len)
bool qemu_semihosting_console_ready(void)
{
SemihostingConsole *c = &console;
g_assert(qemu_mutex_iothread_locked());
return !fifo8_is_empty(&c->fifo);
}
void qemu_semihosting_console_block_until_ready(CPUState *cs)
{
SemihostingConsole *c = &console;
int ret = 0;
g_assert(qemu_mutex_iothread_locked());
@ -92,6 +99,14 @@ int qemu_semihosting_console_read(CPUState *cs, void *buf, int len)
cpu_loop_exit(cs);
/* never returns */
}
}
int qemu_semihosting_console_read(CPUState *cs, void *buf, int len)
{
SemihostingConsole *c = &console;
int ret = 0;
qemu_semihosting_console_block_until_ready(cs);
/* Read until buffer full or fifo exhausted. */
do {