[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 36/74] semihosting: Pass CPUState to qemu_semihosting_console_
From: |
Richard Henderson |
Subject: |
[PATCH v2 36/74] semihosting: Pass CPUState to qemu_semihosting_console_inc |
Date: |
Tue, 3 May 2022 12:48:05 -0700 |
We don't need CPUArchState, and we do want the CPUState of the
thread performing the operation -- use this instead of current_cpu.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/semihosting/console.h | 4 ++--
linux-user/semihost.c | 2 +-
semihosting/arm-compat-semi.c | 2 +-
semihosting/console.c | 12 ++++++------
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/include/semihosting/console.h b/include/semihosting/console.h
index 4f6217bf10..afc961057c 100644
--- a/include/semihosting/console.h
+++ b/include/semihosting/console.h
@@ -39,7 +39,7 @@ void qemu_semihosting_console_outc(CPUArchState *env,
target_ulong c);
/**
* qemu_semihosting_console_inc:
- * @env: CPUArchState
+ * @: CPUState
*
* Receive single character from debug console. As this call may block
* if no data is available we suspend the CPU and will re-execute the
@@ -50,7 +50,7 @@ void qemu_semihosting_console_outc(CPUArchState *env,
target_ulong c);
*
* Returns: character read OR cpu_loop_exit!
*/
-target_ulong qemu_semihosting_console_inc(CPUArchState *env);
+target_ulong qemu_semihosting_console_inc(CPUState *cs);
/**
* qemu_semihosting_log_out:
diff --git a/linux-user/semihost.c b/linux-user/semihost.c
index 17f074ac56..f14c6ae21d 100644
--- a/linux-user/semihost.c
+++ b/linux-user/semihost.c
@@ -56,7 +56,7 @@ void qemu_semihosting_console_outc(CPUArchState *env,
target_ulong addr)
* program is expecting more normal behaviour. This is slow but
* nothing using semihosting console reading is expecting to be fast.
*/
-target_ulong qemu_semihosting_console_inc(CPUArchState *env)
+target_ulong qemu_semihosting_console_inc(CPUState *cs)
{
uint8_t c;
struct termios old_tio, new_tio;
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 3ca8b6455c..c4cf33fe0e 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -418,7 +418,7 @@ void do_common_semihosting(CPUState *cs)
break;
case TARGET_SYS_READC:
- ret = qemu_semihosting_console_inc(env);
+ ret = qemu_semihosting_console_inc(cs);
common_semi_set_ret(cs, ret);
break;
diff --git a/semihosting/console.c b/semihosting/console.c
index 3dd0ac60e2..7b896fe43b 100644
--- a/semihosting/console.c
+++ b/semihosting/console.c
@@ -144,17 +144,17 @@ static void console_read(void *opaque, const uint8_t
*buf, int size)
c->sleeping_cpus = NULL;
}
-target_ulong qemu_semihosting_console_inc(CPUArchState *env)
+target_ulong qemu_semihosting_console_inc(CPUState *cs)
{
uint8_t ch;
SemihostingConsole *c = &console;
+
g_assert(qemu_mutex_iothread_locked());
- g_assert(current_cpu);
if (fifo8_is_empty(&c->fifo)) {
- c->sleeping_cpus = g_slist_prepend(c->sleeping_cpus, current_cpu);
- current_cpu->halted = 1;
- current_cpu->exception_index = EXCP_HALTED;
- cpu_loop_exit(current_cpu);
+ c->sleeping_cpus = g_slist_prepend(c->sleeping_cpus, cs);
+ cs->halted = 1;
+ cs->exception_index = EXCP_HALTED;
+ cpu_loop_exit(cs);
/* never returns */
}
ch = fifo8_pop(&c->fifo);
--
2.34.1
- [PATCH v2 25/74] semihosting: Bound length for semihost_sys_{read, write}, (continued)
- [PATCH v2 25/74] semihosting: Bound length for semihost_sys_{read, write}, Richard Henderson, 2022/05/03
- [PATCH v2 29/74] semihosting: Split out semihost_sys_remove, Richard Henderson, 2022/05/03
- [PATCH v2 30/74] semihosting: Split out semihost_sys_rename, Richard Henderson, 2022/05/03
- [PATCH v2 28/74] semihosting: Split out semihost_sys_flen, Richard Henderson, 2022/05/03
- [PATCH v2 34/74] gdbstub: Widen gdb_syscall_complete_cb return value, Richard Henderson, 2022/05/03
- [PATCH v2 32/74] semihosting: Create semihost_sys_{stat,fstat}, Richard Henderson, 2022/05/03
- [PATCH v2 33/74] semihosting: Create semihost_sys_gettimeofday, Richard Henderson, 2022/05/03
- [PATCH v2 35/74] semihosting: Fix docs comment for qemu_semihosting_console_inc, Richard Henderson, 2022/05/03
- [PATCH v2 38/74] semihosting: Cleanup chardev init, Richard Henderson, 2022/05/03
- [PATCH v2 37/74] semihosting: Expand qemu_semihosting_console_inc to read, Richard Henderson, 2022/05/03
- [PATCH v2 36/74] semihosting: Pass CPUState to qemu_semihosting_console_inc,
Richard Henderson <=
- [PATCH v2 39/74] semihosting: Create qemu_semihosting_console_write, Richard Henderson, 2022/05/03
- [PATCH v2 40/74] semihosting: Add GuestFDConsole, Richard Henderson, 2022/05/03
- [PATCH v2 41/74] semihosting: Create qemu_semihosting_guestfd_init, Richard Henderson, 2022/05/03
- [PATCH v2 42/74] semihosting: Use console_in_gf for SYS_READC, Richard Henderson, 2022/05/03
- [PATCH v2 46/74] semihosting: Remove qemu_semihosting_console_outs, Richard Henderson, 2022/05/03
- [PATCH v2 43/74] semihosting: Use console_out_gf for SYS_WRITEC, Richard Henderson, 2022/05/03
- [PATCH v2 44/74] semihosting: Remove qemu_semihosting_console_outc, Richard Henderson, 2022/05/03
- [PATCH v2 47/74] semihosting: Create semihost_sys_poll_one, Richard Henderson, 2022/05/03
- [PATCH v2 45/74] semihosting: Use console_out_gf for SYS_WRITE0, Richard Henderson, 2022/05/03
- [PATCH v2 48/74] target/m68k: Eliminate m68k_semi_is_fseek, Richard Henderson, 2022/05/03