From: Richard Henderson <richard.henderson@linaro.org>
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>
---
linux-user/loader.h | 3 ++-
linux-user/sparc/target_elf.h | 2 ++
linux-user/elfload.c | 30 +-----------------------------
linux-user/sparc/elfload.c | 27 +++++++++++++++++++++++++++
4 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/linux-user/loader.h b/linux-user/loader.h
index 151a06f5db5..2c8414e0e53 100644
--- a/linux-user/loader.h
+++ b/linux-user/loader.h
@@ -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
diff --git a/linux-user/sparc/target_elf.h b/linux-user/sparc/target_elf.h
index 7e46748d261..b7544db0a1c 100644
--- a/linux-user/sparc/target_elf.h
+++ b/linux-user/sparc/target_elf.h
@@ -8,4 +8,6 @@
#ifndef SPARC_TARGET_ELF_H
#define SPARC_TARGET_ELF_H
+#define HAVE_ELF_HWCAP 1
+
#endif
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 149d1313c0a..16709865f78 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -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)
diff --git a/linux-user/sparc/elfload.c b/linux-user/sparc/elfload.c
index 243e6f9b66a..32ca1b05b1a 100644
--- a/linux-user/sparc/elfload.c
+++ b/linux-user/sparc/elfload.c
@@ -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;
+}
--
2.47.2