linux-user/sparc: Clean up init_thread

Share code between sparc32 and sparc64, removing a bit of pointless
difference wrt psr/tstate.  Use sizeof(abi_ulong) for allocating
initial register window.  Use TARGET_STACK_BIAS.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210426025334.1168495-7-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
Richard Henderson 2021-04-25 19:53:15 -07:00 committed by Laurent Vivier
parent eb215f40c2
commit 089a2256ee

View File

@ -676,48 +676,25 @@ static uint32_t get_elf_hwcap2(void)
#define ELF_CLASS ELFCLASS64
#define ELF_ARCH EM_SPARCV9
#define STACK_BIAS 2047
static inline void init_thread(struct target_pt_regs *regs,
struct image_info *infop)
{
#ifndef TARGET_ABI32
regs->tstate = 0;
#endif
regs->pc = infop->entry;
regs->npc = regs->pc + 4;
regs->y = 0;
#ifdef TARGET_ABI32
regs->u_regs[14] = infop->start_stack - 16 * 4;
#else
if (personality(infop->personality) == PER_LINUX32)
regs->u_regs[14] = infop->start_stack - 16 * 4;
else
regs->u_regs[14] = infop->start_stack - 16 * 8 - STACK_BIAS;
#endif
}
#else
#define ELF_START_MMAP 0x80000000
#define ELF_HWCAP (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | HWCAP_SPARC_SWAP \
| HWCAP_SPARC_MULDIV)
#define ELF_CLASS ELFCLASS32
#define ELF_ARCH EM_SPARC
#endif /* TARGET_SPARC64 */
static inline void init_thread(struct target_pt_regs *regs,
struct image_info *infop)
{
regs->psr = 0;
/* Note that target_cpu_copy_regs does not read psr/tstate. */
regs->pc = infop->entry;
regs->npc = regs->pc + 4;
regs->y = 0;
regs->u_regs[14] = infop->start_stack - 16 * 4;
regs->u_regs[14] = (infop->start_stack - 16 * sizeof(abi_ulong)
- TARGET_STACK_BIAS);
}
#endif
#endif
#endif /* TARGET_SPARC */
#ifdef TARGET_PPC