linux-user: Move get_elf_hwcap to sparc/elfload.c
Change the return type to abi_ulong, and pass in the cpu. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
2d0687a514
commit
e0f62c5a5b
4 changed files with 32 additions and 30 deletions
|
|
@ -565,35 +565,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,
|
|||
# define ELF_ARCH EM_SPARCV9
|
||||
#endif
|
||||
|
||||
#include "elf.h"
|
||||
|
||||
#define ELF_HWCAP get_elf_hwcap()
|
||||
|
||||
static uint32_t get_elf_hwcap(void)
|
||||
{
|
||||
/* There are not many sparc32 hwcap bits -- we have all of them. */
|
||||
uint32_t r = HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR |
|
||||
HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV;
|
||||
|
||||
#ifdef TARGET_SPARC64
|
||||
CPUSPARCState *env = cpu_env(thread_cpu);
|
||||
uint32_t features = env->def.features;
|
||||
|
||||
r |= HWCAP_SPARC_V9 | HWCAP_SPARC_V8PLUS;
|
||||
/* 32x32 multiply and divide are efficient. */
|
||||
r |= HWCAP_SPARC_MUL32 | HWCAP_SPARC_DIV32;
|
||||
/* We don't have an internal feature bit for this. */
|
||||
r |= HWCAP_SPARC_POPC;
|
||||
r |= features & CPU_FEATURE_FSMULD ? HWCAP_SPARC_FSMULD : 0;
|
||||
r |= features & CPU_FEATURE_VIS1 ? HWCAP_SPARC_VIS : 0;
|
||||
r |= features & CPU_FEATURE_VIS2 ? HWCAP_SPARC_VIS2 : 0;
|
||||
r |= features & CPU_FEATURE_FMAF ? HWCAP_SPARC_FMAF : 0;
|
||||
r |= features & CPU_FEATURE_VIS3 ? HWCAP_SPARC_VIS3 : 0;
|
||||
r |= features & CPU_FEATURE_IMA ? HWCAP_SPARC_IMA : 0;
|
||||
#endif
|
||||
|
||||
return r;
|
||||
}
|
||||
#define ELF_HWCAP get_elf_hwcap(thread_cpu)
|
||||
|
||||
static inline void init_thread(struct target_pt_regs *regs,
|
||||
struct image_info *infop)
|
||||
|
|
|
|||
|
|
@ -101,7 +101,8 @@ extern unsigned long guest_stack_size;
|
|||
/* Note that Elf32 and Elf64 use uint32_t for e_flags. */
|
||||
const char *get_elf_cpu_model(uint32_t eflags);
|
||||
|
||||
#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_ARM)
|
||||
#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_ARM) \
|
||||
|| defined(TARGET_SPARC)
|
||||
abi_ulong get_elf_hwcap(CPUState *cs);
|
||||
abi_ulong get_elf_hwcap2(CPUState *cs);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "qemu/osdep.h"
|
||||
#include "qemu.h"
|
||||
#include "loader.h"
|
||||
#include "elf.h"
|
||||
|
||||
|
||||
const char *get_elf_cpu_model(uint32_t eflags)
|
||||
|
|
@ -13,3 +14,29 @@ const char *get_elf_cpu_model(uint32_t eflags)
|
|||
return "Fujitsu MB86904";
|
||||
#endif
|
||||
}
|
||||
|
||||
abi_ulong get_elf_hwcap(CPUState *cs)
|
||||
{
|
||||
/* There are not many sparc32 hwcap bits -- we have all of them. */
|
||||
uint32_t r = HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR |
|
||||
HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV;
|
||||
|
||||
#ifdef TARGET_SPARC64
|
||||
CPUSPARCState *env = cpu_env(cs);
|
||||
uint32_t features = env->def.features;
|
||||
|
||||
r |= HWCAP_SPARC_V9 | HWCAP_SPARC_V8PLUS;
|
||||
/* 32x32 multiply and divide are efficient. */
|
||||
r |= HWCAP_SPARC_MUL32 | HWCAP_SPARC_DIV32;
|
||||
/* We don't have an internal feature bit for this. */
|
||||
r |= HWCAP_SPARC_POPC;
|
||||
r |= features & CPU_FEATURE_FSMULD ? HWCAP_SPARC_FSMULD : 0;
|
||||
r |= features & CPU_FEATURE_VIS1 ? HWCAP_SPARC_VIS : 0;
|
||||
r |= features & CPU_FEATURE_VIS2 ? HWCAP_SPARC_VIS2 : 0;
|
||||
r |= features & CPU_FEATURE_FMAF ? HWCAP_SPARC_FMAF : 0;
|
||||
r |= features & CPU_FEATURE_VIS3 ? HWCAP_SPARC_VIS3 : 0;
|
||||
r |= features & CPU_FEATURE_IMA ? HWCAP_SPARC_IMA : 0;
|
||||
#endif
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,6 @@
|
|||
#ifndef SPARC_TARGET_ELF_H
|
||||
#define SPARC_TARGET_ELF_H
|
||||
|
||||
#define HAVE_ELF_HWCAP 1
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue