[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 16/43] semihosting: Split common_semi_flen_buf per target
From: |
Richard Henderson |
Subject: |
[PATCH 16/43] semihosting: Split common_semi_flen_buf per target |
Date: |
Sat, 30 Apr 2022 06:29:05 -0700 |
We already have some larger ifdef blocks for ARM and RISCV;
split out common_semi_stack_bottom per target.
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 7fc60e223a..b2816e9f66 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
- [PATCH 15/43] semihosting: Split is_64bit_semihosting per target, (continued)
- [PATCH 15/43] semihosting: Split is_64bit_semihosting per target, Richard Henderson, 2022/04/30
- [PATCH 14/43] semihosting: Use struct gdb_stat in common_semi_flen_cb, Richard Henderson, 2022/04/30
- [PATCH 22/43] semihosting: Split out semihost_sys_read, Richard Henderson, 2022/04/30
- [PATCH 21/43] semihosting: Split out semihost_sys_close, Richard Henderson, 2022/04/30
- [PATCH 26/43] semihosting: Split out semihost_sys_isatty, Richard Henderson, 2022/04/30
- [PATCH 27/43] semihosting: Split out semihost_sys_flen, Richard Henderson, 2022/04/30
- [PATCH 30/43] semihosting: Split out semihost_sys_system, Richard Henderson, 2022/04/30
- [PATCH 31/43] semihosting: Create semihost_sys_{stat,fstat}, Richard Henderson, 2022/04/30
- [PATCH 38/43] target/m68k: Enable semihosting for non-coldfire, Richard Henderson, 2022/04/30
- [PATCH 34/43] target/m68k: Eliminate m68k_semi_is_fseek, Richard Henderson, 2022/04/30
- [PATCH 16/43] semihosting: Split common_semi_flen_buf per target,
Richard Henderson <=
- [PATCH 23/43] semihosting: Split out semihost_sys_write, Richard Henderson, 2022/04/30
- [PATCH 28/43] semihosting: Split out semihost_sys_remove, Richard Henderson, 2022/04/30
- [PATCH 29/43] semihosting: Split out semihost_sys_rename, Richard Henderson, 2022/04/30
- [PATCH 37/43] target/m68k: Do semihosting call as a normal helper, Richard Henderson, 2022/04/30
- [PATCH 32/43] semihosting: Create semihost_sys_gettimeofday, Richard Henderson, 2022/04/30
- [PATCH 08/43] semihosting: Generalize GuestFDFeatureFile, Richard Henderson, 2022/04/30
- [PATCH 18/43] semihosting: Use env more often in do_common_semihosting, Richard Henderson, 2022/04/30
- [PATCH 06/43] semihosting: Simplify softmmu_lock_user_string, Richard Henderson, 2022/04/30
- [PATCH 36/43] target/m68k: Use guestfd.h to implement syscalls., Richard Henderson, 2022/04/30
- [PATCH 40/43] target/nios2: Eliminate nios2_semi_is_lseek, Richard Henderson, 2022/04/30