xref: /openbmc/qemu/linux-user/sparc/elfload.c (revision ca18b336e12c8433177a3cd639c5bf757952adaa)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include "qemu/osdep.h"
4 #include "qemu.h"
5 #include "loader.h"
6 #include "elf.h"
7 
8 
9 const char *get_elf_cpu_model(uint32_t eflags)
10 {
11 #ifdef TARGET_SPARC64
12     return "TI UltraSparc II";
13 #else
14     return "Fujitsu MB86904";
15 #endif
16 }
17 
18 abi_ulong get_elf_hwcap(CPUState *cs)
19 {
20     /* There are not many sparc32 hwcap bits -- we have all of them. */
21     uint32_t r = HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR |
22                  HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV;
23 
24 #ifdef TARGET_SPARC64
25     CPUSPARCState *env = cpu_env(cs);
26     uint32_t features = env->def.features;
27 
28     r |= HWCAP_SPARC_V9 | HWCAP_SPARC_V8PLUS;
29     /* 32x32 multiply and divide are efficient. */
30     r |= HWCAP_SPARC_MUL32 | HWCAP_SPARC_DIV32;
31     /* We don't have an internal feature bit for this. */
32     r |= HWCAP_SPARC_POPC;
33     r |= features & CPU_FEATURE_FSMULD ? HWCAP_SPARC_FSMULD : 0;
34     r |= features & CPU_FEATURE_VIS1 ? HWCAP_SPARC_VIS : 0;
35     r |= features & CPU_FEATURE_VIS2 ? HWCAP_SPARC_VIS2 : 0;
36     r |= features & CPU_FEATURE_FMAF ? HWCAP_SPARC_FMAF : 0;
37     r |= features & CPU_FEATURE_VIS3 ? HWCAP_SPARC_VIS3 : 0;
38     r |= features & CPU_FEATURE_IMA ? HWCAP_SPARC_IMA : 0;
39 #endif
40 
41     return r;
42 }
43