diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2025-08-28 12:05:05 +1000 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2025-08-30 07:04:04 +1000 |
commit | c61b88fbe49e428e39eff501cddbcd53f12486cb (patch) | |
tree | f4ae79a3723b8e348f9d604549f4247da0cb89f5 /linux-user | |
parent | 0dcef5773000f4d72277c6b41200f35031bdcbb5 (diff) | |
download | qemu-c61b88fbe49e428e39eff501cddbcd53f12486cb.zip qemu-c61b88fbe49e428e39eff501cddbcd53f12486cb.tar.gz qemu-c61b88fbe49e428e39eff501cddbcd53f12486cb.tar.bz2 |
linux-user/mips: Use target_ulong for target_elf_greg_t
Make use of the fact that target_elf_gregset_t is a proper structure.
The target_ulong type matches the abi_ulong/abi_ullong
selection within mips64/target_elf.h.
Drop ELF_NREG, target_elf_greg_t, and tswapreg.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/mips/elfload.c | 48 | ||||
-rw-r--r-- | linux-user/mips/target_elf.h | 10 | ||||
-rw-r--r-- | linux-user/mips64/target_elf.h | 14 |
3 files changed, 22 insertions, 50 deletions
diff --git a/linux-user/mips/elfload.c b/linux-user/mips/elfload.c index 6e88491..e0c50f5 100644 --- a/linux-user/mips/elfload.c +++ b/linux-user/mips/elfload.c @@ -124,47 +124,19 @@ const char *get_elf_base_platform(CPUState *cs) #undef MATCH_PLATFORM_INSN -#ifdef TARGET_ABI_MIPSN32 -#define tswapreg(ptr) tswap64(ptr) -#else -#define tswapreg(ptr) tswapal(ptr) -#endif - -/* See linux kernel: arch/mips/include/asm/reg.h. */ -enum { -#ifdef TARGET_MIPS64 - TARGET_EF_R0 = 0, -#else - TARGET_EF_R0 = 6, -#endif - TARGET_EF_R26 = TARGET_EF_R0 + 26, - TARGET_EF_R27 = TARGET_EF_R0 + 27, - TARGET_EF_LO = TARGET_EF_R0 + 32, - TARGET_EF_HI = TARGET_EF_R0 + 33, - TARGET_EF_CP0_EPC = TARGET_EF_R0 + 34, - TARGET_EF_CP0_BADVADDR = TARGET_EF_R0 + 35, - TARGET_EF_CP0_STATUS = TARGET_EF_R0 + 36, - TARGET_EF_CP0_CAUSE = TARGET_EF_R0 + 37 -}; - /* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ void elf_core_copy_regs(target_elf_gregset_t *r, const CPUMIPSState *env) { - int i; - - for (i = 0; i <= TARGET_EF_R0; i++) { - r->regs[i] = 0; - } - for (i = 1; i < ARRAY_SIZE(env->active_tc.gpr); i++) { - r->regs[TARGET_EF_R0 + i] = tswapreg(env->active_tc.gpr[i]); + for (int i = 1; i < ARRAY_SIZE(env->active_tc.gpr); i++) { + r->pt.regs[i] = tswapl(env->active_tc.gpr[i]); } - r->regs[TARGET_EF_R26] = 0; - r->regs[TARGET_EF_R27] = 0; - r->regs[TARGET_EF_LO] = tswapreg(env->active_tc.LO[0]); - r->regs[TARGET_EF_HI] = tswapreg(env->active_tc.HI[0]); - r->regs[TARGET_EF_CP0_EPC] = tswapreg(env->active_tc.PC); - r->regs[TARGET_EF_CP0_BADVADDR] = tswapreg(env->CP0_BadVAddr); - r->regs[TARGET_EF_CP0_STATUS] = tswapreg(env->CP0_Status); - r->regs[TARGET_EF_CP0_CAUSE] = tswapreg(env->CP0_Cause); + r->pt.regs[26] = 0; + r->pt.regs[27] = 0; + r->pt.lo = tswapl(env->active_tc.LO[0]); + r->pt.hi = tswapl(env->active_tc.HI[0]); + r->pt.cp0_epc = tswapl(env->active_tc.PC); + r->pt.cp0_badvaddr = tswapl(env->CP0_BadVAddr); + r->pt.cp0_status = tswapl(env->CP0_Status); + r->pt.cp0_cause = tswapl(env->CP0_Cause); } diff --git a/linux-user/mips/target_elf.h b/linux-user/mips/target_elf.h index f767767..a4b7fad 100644 --- a/linux-user/mips/target_elf.h +++ b/linux-user/mips/target_elf.h @@ -8,16 +8,18 @@ #ifndef MIPS_TARGET_ELF_H #define MIPS_TARGET_ELF_H +#include "target_ptrace.h" + #define HAVE_ELF_HWCAP 1 #define HAVE_ELF_BASE_PLATFORM 1 #define HAVE_ELF_CORE_DUMP 1 -typedef abi_ulong target_elf_greg_t; - /* See linux kernel: arch/mips/include/asm/elf.h. */ -#define ELF_NREG 45 typedef struct target_elf_gregset_t { - target_elf_greg_t regs[ELF_NREG]; + union { + abi_ulong reserved[45]; + struct target_pt_regs pt; + }; } target_elf_gregset_t; #endif diff --git a/linux-user/mips64/target_elf.h b/linux-user/mips64/target_elf.h index 046a165..67bc963 100644 --- a/linux-user/mips64/target_elf.h +++ b/linux-user/mips64/target_elf.h @@ -8,20 +8,18 @@ #ifndef MIPS64_TARGET_ELF_H #define MIPS64_TARGET_ELF_H +#include "target_ptrace.h" + #define HAVE_ELF_HWCAP 1 #define HAVE_ELF_BASE_PLATFORM 1 #define HAVE_ELF_CORE_DUMP 1 -#ifdef TARGET_ABI_MIPSN32 -typedef abi_ullong target_elf_greg_t; -#else -typedef abi_ulong target_elf_greg_t; -#endif - /* See linux kernel: arch/mips/include/asm/elf.h. */ -#define ELF_NREG 45 typedef struct target_elf_gregset_t { - target_elf_greg_t regs[ELF_NREG]; + union { + target_ulong reserved[45]; + struct target_pt_regs pt; + }; } target_elf_gregset_t; #endif |