[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/60] semihosting: Split common_semi_flen_buf per target
From: |
Richard Henderson |
Subject: |
[PULL 22/60] semihosting: Split common_semi_flen_buf per target |
Date: |
Tue, 28 Jun 2022 10:23:25 +0530 |
We already have some larger ifdef blocks for ARM and RISCV;
split out common_semi_stack_bottom per target.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
semihosting/arm-compat-semi.c | 44 +++++++++++++++++------------------
1 file changed, 21 insertions(+), 23 deletions(-)
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index d2ce214078..7550dce622 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -217,6 +217,13 @@ static inline bool is_64bit_semihosting(CPUArchState *env)
{
return is_a64(env);
}
+
+static inline target_ulong common_semi_stack_bottom(CPUState *cs)
+{
+ ARMCPU *cpu = ARM_CPU(cs);
+ CPUARMState *env = &cpu->env;
+ return is_a64(env) ? env->xregs[31] : env->regs[13];
+}
#endif /* TARGET_ARM */
#ifdef TARGET_RISCV
@@ -246,6 +253,13 @@ static inline bool is_64bit_semihosting(CPUArchState *env)
{
return riscv_cpu_mxl(env) != MXL_RV32;
}
+
+static inline target_ulong common_semi_stack_bottom(CPUState *cs)
+{
+ RISCVCPU *cpu = RISCV_CPU(cs);
+ CPURISCVState *env = &cpu->env;
+ return env->gpr[xSP];
+}
#endif
/*
@@ -301,31 +315,15 @@ static void common_semi_cb(CPUState *cs, target_ulong
ret, target_ulong err)
common_semi_set_ret(cs, ret);
}
+/*
+ * Return an address in target memory of 64 bytes where the remote
+ * gdb should write its stat struct. (The format of this structure
+ * is defined by GDB's remote protocol and is not target-specific.)
+ * We put this on the guest's stack just below SP.
+ */
static target_ulong common_semi_flen_buf(CPUState *cs)
{
- target_ulong sp;
-#ifdef TARGET_ARM
- /* Return an address in target memory of 64 bytes where the remote
- * gdb should write its stat struct. (The format of this structure
- * is defined by GDB's remote protocol and is not target-specific.)
- * We put this on the guest's stack just below SP.
- */
- ARMCPU *cpu = ARM_CPU(cs);
- CPUARMState *env = &cpu->env;
-
- if (is_a64(env)) {
- sp = env->xregs[31];
- } else {
- sp = env->regs[13];
- }
-#endif
-#ifdef TARGET_RISCV
- RISCVCPU *cpu = RISCV_CPU(cs);
- CPURISCVState *env = &cpu->env;
-
- sp = env->gpr[xSP];
-#endif
-
+ target_ulong sp = common_semi_stack_bottom(cs);
return sp - 64;
}
--
2.34.1
- [PULL 09/60] semihosting: Inline set_swi_errno into common_semi_cb, (continued)
- [PULL 09/60] semihosting: Inline set_swi_errno into common_semi_cb, Richard Henderson, 2022/06/28
- [PULL 10/60] semihosting: Adjust error checking in common_semi_cb, Richard Henderson, 2022/06/28
- [PULL 11/60] semihosting: Clean up common_semi_flen_cb, Richard Henderson, 2022/06/28
- [PULL 12/60] semihosting: Clean up common_semi_open_cb, Richard Henderson, 2022/06/28
- [PULL 13/60] semihosting: Return void from do_common_semihosting, Richard Henderson, 2022/06/28
- [PULL 14/60] semihosting: Move common-semi.h to include/semihosting/, Richard Henderson, 2022/06/28
- [PULL 15/60] semihosting: Remove GDB_O_BINARY, Richard Henderson, 2022/06/28
- [PULL 16/60] include/exec: Move gdb open flags to gdbstub.h, Richard Henderson, 2022/06/28
- [PULL 17/60] include/exec: Move gdb_stat and gdb_timeval to gdbstub.h, Richard Henderson, 2022/06/28
- [PULL 19/60] gdbstub: Convert GDB error numbers to host error numbers, Richard Henderson, 2022/06/28
- [PULL 22/60] semihosting: Split common_semi_flen_buf per target,
Richard Henderson <=
- [PULL 18/60] include/exec: Define errno values in gdbstub.h, Richard Henderson, 2022/06/28
- [PULL 20/60] semihosting: Use struct gdb_stat in common_semi_flen_cb, Richard Henderson, 2022/06/28
- [PULL 24/60] semihosting: Split out common-semi-target.h, Richard Henderson, 2022/06/28
- [PULL 26/60] semihosting: Move GET_ARG/SET_ARG earlier in the file, Richard Henderson, 2022/06/28
- [PULL 25/60] semihosting: Use env more often in do_common_semihosting, Richard Henderson, 2022/06/28
- [PULL 29/60] semihosting: Split out semihost_sys_read, Richard Henderson, 2022/06/28
- [PULL 21/60] semihosting: Split is_64bit_semihosting per target, Richard Henderson, 2022/06/28
- [PULL 32/60] semihosting: Split out semihost_sys_lseek, Richard Henderson, 2022/06/28
- [PULL 33/60] semihosting: Split out semihost_sys_isatty, Richard Henderson, 2022/06/28
- [PULL 28/60] semihosting: Split out semihost_sys_close, Richard Henderson, 2022/06/28