[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 30/68] target/arm/arm-semi: Use set_swi_errno() in gdbstub callbac
From: |
Peter Maydell |
Subject: |
[PULL 30/68] target/arm/arm-semi: Use set_swi_errno() in gdbstub callback functions |
Date: |
Mon, 14 Oct 2019 17:03:26 +0100 |
When we are routing semihosting operations through the gdbstub, the
work of sorting out the return value and setting errno if necessary
is done by callback functions which are invoked by the gdbstub code.
Clean up some ifdeffery in those functions by having them call
set_swi_errno() to set the semihosting errno.
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Message-id: address@hidden
---
target/arm/arm-semi.c | 27 ++++++---------------------
1 file changed, 6 insertions(+), 21 deletions(-)
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
index 2618588076f..02cd673d47d 100644
--- a/target/arm/arm-semi.c
+++ b/target/arm/arm-semi.c
@@ -259,17 +259,11 @@ static void arm_semi_cb(CPUState *cs, target_ulong ret,
target_ulong err)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
-#ifdef CONFIG_USER_ONLY
- TaskState *ts = cs->opaque;
-#endif
target_ulong reg0 = is_a64(env) ? env->xregs[0] : env->regs[0];
if (ret == (target_ulong)-1) {
-#ifdef CONFIG_USER_ONLY
- ts->swi_errno = err;
-#else
- syscall_err = err;
-#endif
+ errno = err;
+ set_swi_errno(env, -1);
reg0 = ret;
} else {
/* Fixup syscalls that use nonstardard return conventions. */
@@ -326,11 +320,8 @@ static void arm_semi_flen_cb(CPUState *cs, target_ulong
ret, target_ulong err)
} else {
env->regs[0] = size;
}
-#ifdef CONFIG_USER_ONLY
- ((TaskState *)cs->opaque)->swi_errno = err;
-#else
- syscall_err = err;
-#endif
+ errno = err;
+ set_swi_errno(env, -1);
}
static int arm_semi_open_guestfd;
@@ -339,15 +330,9 @@ static void arm_semi_open_cb(CPUState *cs, target_ulong
ret, target_ulong err)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
-#ifdef CONFIG_USER_ONLY
- TaskState *ts = cs->opaque;
-#endif
if (ret == (target_ulong)-1) {
-#ifdef CONFIG_USER_ONLY
- ts->swi_errno = err;
-#else
- syscall_err = err;
-#endif
+ errno = err;
+ set_swi_errno(env, -1);
dealloc_guestfd(arm_semi_open_guestfd);
} else {
associate_guestfd(arm_semi_open_guestfd, ret);
--
2.20.1
- [PULL 18/68] hw/timer/exynos4210_rtc.c: Switch 1Hz ptimer to transaction-based API, (continued)
- [PULL 18/68] hw/timer/exynos4210_rtc.c: Switch 1Hz ptimer to transaction-based API, Peter Maydell, 2019/10/14
- [PULL 19/68] hw/timer/exynos4210_rtc.c: Switch main ptimer to transaction-based API, Peter Maydell, 2019/10/14
- [PULL 20/68] hw/timer/imx_epit.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 21/68] hw/timer/imx_gpt.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 22/68] hw/timer/mss-timerc: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 23/68] hw/watchdog/cmsdk-apb-watchdog.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 24/68] hw/net/lan9118.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 25/68] target/arm/arm-semi: Capture errno in softmmu version of set_swi_errno(), Peter Maydell, 2019/10/14
- [PULL 26/68] target/arm/arm-semi: Always set some kind of errno for failed calls, Peter Maydell, 2019/10/14
- [PULL 27/68] target/arm/arm-semi: Correct comment about gdb syscall races, Peter Maydell, 2019/10/14
- [PULL 30/68] target/arm/arm-semi: Use set_swi_errno() in gdbstub callback functions,
Peter Maydell <=
- [PULL 28/68] target/arm/arm-semi: Make semihosting code hand out its own file descriptors, Peter Maydell, 2019/10/14
- [PULL 29/68] target/arm/arm-semi: Restrict use of TaskState*, Peter Maydell, 2019/10/14
- [PULL 31/68] target/arm/arm-semi: Factor out implementation of SYS_CLOSE, Peter Maydell, 2019/10/14
- [PULL 32/68] target/arm/arm-semi: Factor out implementation of SYS_WRITE, Peter Maydell, 2019/10/14
- [PULL 33/68] target/arm/arm-semi: Factor out implementation of SYS_READ, Peter Maydell, 2019/10/14
- [PULL 34/68] target/arm/arm-semi: Factor out implementation of SYS_ISTTY, Peter Maydell, 2019/10/14
- [PULL 35/68] target/arm/arm-semi: Factor out implementation of SYS_SEEK, Peter Maydell, 2019/10/14
- [PULL 36/68] target/arm/arm-semi: Factor out implementation of SYS_FLEN, Peter Maydell, 2019/10/14
- [PULL 37/68] target/arm/arm-semi: Implement support for semihosting feature detection, Peter Maydell, 2019/10/14
- [PULL 38/68] target/arm/arm-semi: Implement SH_EXT_EXIT_EXTENDED extension, Peter Maydell, 2019/10/14