aboutsummaryrefslogtreecommitdiff
path: root/semihosting/console.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-05-01 16:59:06 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-06-28 04:35:52 +0530
commitfb08790b35174a98301ecbac4d5234d0cbfebea0 (patch)
tree7c817d8d4bd0cef02987c9d21c9e7f2a5b6cc914 /semihosting/console.c
parente7fb6f320548c1b0c25d291466a0249ee80d91b6 (diff)
downloadqemu-fb08790b35174a98301ecbac4d5234d0cbfebea0.zip
qemu-fb08790b35174a98301ecbac4d5234d0cbfebea0.tar.gz
qemu-fb08790b35174a98301ecbac4d5234d0cbfebea0.tar.bz2
semihosting: Cleanup chardev init
Rename qemu_semihosting_connect_chardevs to qemu_semihosting_chardev_init; pass the result directly to qemu_semihosting_console_init. Store the chardev in SemihostingConsole instead of SemihostingConfig, which lets us drop semihosting_get_chardev. Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'semihosting/console.c')
-rw-r--r--semihosting/console.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/semihosting/console.c b/semihosting/console.c
index e5ac3f2..1d16a29 100644
--- a/semihosting/console.c
+++ b/semihosting/console.c
@@ -27,11 +27,21 @@
#include "qapi/error.h"
#include "qemu/fifo8.h"
+/* Access to this structure is protected by the BQL */
+typedef struct SemihostingConsole {
+ CharBackend backend;
+ Chardev *chr;
+ GSList *sleeping_cpus;
+ bool got;
+ Fifo8 fifo;
+} SemihostingConsole;
+
+static SemihostingConsole console;
+
int qemu_semihosting_log_out(const char *s, int len)
{
- Chardev *chardev = semihosting_get_chardev();
- if (chardev) {
- return qemu_chr_write_all(chardev, (uint8_t *) s, len);
+ if (console.chr) {
+ return qemu_chr_write_all(console.chr, (uint8_t *) s, len);
} else {
return write(STDERR_FILENO, s, len);
}
@@ -106,16 +116,6 @@ void qemu_semihosting_console_outc(CPUArchState *env, target_ulong addr)
#define FIFO_SIZE 1024
-/* Access to this structure is protected by the BQL */
-typedef struct SemihostingConsole {
- CharBackend backend;
- GSList *sleeping_cpus;
- bool got;
- Fifo8 fifo;
-} SemihostingConsole;
-
-static SemihostingConsole console;
-
static int console_can_read(void *opaque)
{
SemihostingConsole *c = opaque;
@@ -169,10 +169,9 @@ int qemu_semihosting_console_read(CPUState *cs, void *buf, int len)
return ret;
}
-void qemu_semihosting_console_init(void)
+void qemu_semihosting_console_init(Chardev *chr)
{
- Chardev *chr = semihosting_get_chardev();
-
+ console.chr = chr;
if (chr) {
fifo8_create(&console.fifo, FIFO_SIZE);
qemu_chr_fe_init(&console.backend, chr, &error_abort);