summaryrefslogtreecommitdiffstats
path: root/include/hw/semihosting/console.h
diff options
context:
space:
mode:
authorKeith Packard2019-11-04 21:42:30 +0100
committerAlex Bennée2020-01-09 12:41:29 +0100
commit8de702cb677c8381fb702cae252d6b69aa4c653b (patch)
treeccfa04a054ffba8c063c4c67da4fb8f6760f1531 /include/hw/semihosting/console.h
parenttarget/arm: only update pc after semihosting completes (diff)
downloadqemu-8de702cb677c8381fb702cae252d6b69aa4c653b.tar.gz
qemu-8de702cb677c8381fb702cae252d6b69aa4c653b.tar.xz
qemu-8de702cb677c8381fb702cae252d6b69aa4c653b.zip
semihosting: add qemu_semihosting_console_inc for SYS_READC
Provides a blocking call to read a character from the console using semihosting.chardev, if specified. This takes some careful command line options to use stdio successfully as the serial ports, monitor and semihost all want to use stdio. Here's a sample set of command line options which share stdio between semihost, monitor and serial ports: qemu \ -chardev stdio,mux=on,id=stdio0 \ -serial chardev:stdio0 \ -semihosting-config enable=on,chardev=stdio0 \ -mon chardev=stdio0,mode=readline This creates a chardev hooked to stdio and then connects all of the subsystems to it. A shorter mechanism would be good to hear about. Signed-off-by: Keith Packard <keithp@keithp.com> Message-Id: <20191104204230.12249-1-keithp@keithp.com> [AJB: fixed up deadlock, minor commit title reword] Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Keith Packard <keithp@keithp.com> Tested-by: Keith Packard <keithp@keithp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'include/hw/semihosting/console.h')
-rw-r--r--include/hw/semihosting/console.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/hw/semihosting/console.h b/include/hw/semihosting/console.h
index 9be9754bcd..0238f540f4 100644
--- a/include/hw/semihosting/console.h
+++ b/include/hw/semihosting/console.h
@@ -38,6 +38,22 @@ int qemu_semihosting_console_outs(CPUArchState *env, target_ulong s);
void qemu_semihosting_console_outc(CPUArchState *env, target_ulong c);
/**
+ * qemu_semihosting_console_inc:
+ * @env: CPUArchState
+ *
+ * Receive single character from debug console. This may be the remote
+ * gdb session if a softmmu guest is currently being debugged. As this
+ * call may block if no data is available we suspend the CPU and will
+ * re-execute the instruction when data is there. Therefore two
+ * conditions must be met:
+ * - CPUState is synchronized before calling this function
+ * - pc is only updated once the character is successfully returned
+ *
+ * Returns: character read OR cpu_loop_exit!
+ */
+target_ulong qemu_semihosting_console_inc(CPUArchState *env);
+
+/**
* qemu_semihosting_log_out:
* @s: pointer to string
* @len: length of string