From 58afe4cfe93be0e283e7a0fcd9a50fd52fc44169 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 29 Jul 2025 08:03:41 -1000 Subject: linux-user: Create target/elfload.c files Prepare to split the main linux-user/elfload.c. Create empty files for each target, and add the common build rule. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/sparc/elfload.c | 1 + 1 file changed, 1 insertion(+) create mode 100644 linux-user/sparc/elfload.c (limited to 'linux-user/sparc') diff --git a/linux-user/sparc/elfload.c b/linux-user/sparc/elfload.c new file mode 100644 index 0000000..73fa78e --- /dev/null +++ b/linux-user/sparc/elfload.c @@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ -- cgit v1.1 From af880af8d4624b619c9d44ff5d27440ae064f99a Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 29 Jul 2025 10:09:57 -1000 Subject: linux-user: Move get_elf_cpu_model to target/elfload.c Rename from cpu_get_model to emphasize that this is an elf-specific function. Declare the function once in loader.h. This frees up target_elf.h for other uses. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/sparc/elfload.c | 14 ++++++++++++++ linux-user/sparc/target_elf.h | 9 +-------- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'linux-user/sparc') diff --git a/linux-user/sparc/elfload.c b/linux-user/sparc/elfload.c index 73fa78e..243e6f9 100644 --- a/linux-user/sparc/elfload.c +++ b/linux-user/sparc/elfload.c @@ -1 +1,15 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "loader.h" + + +const char *get_elf_cpu_model(uint32_t eflags) +{ +#ifdef TARGET_SPARC64 + return "TI UltraSparc II"; +#else + return "Fujitsu MB86904"; +#endif +} diff --git a/linux-user/sparc/target_elf.h b/linux-user/sparc/target_elf.h index a510ceb..7e46748 100644 --- a/linux-user/sparc/target_elf.h +++ b/linux-user/sparc/target_elf.h @@ -7,12 +7,5 @@ #ifndef SPARC_TARGET_ELF_H #define SPARC_TARGET_ELF_H -static inline const char *cpu_get_model(uint32_t eflags) -{ -#ifdef TARGET_SPARC64 - return "TI UltraSparc II"; -#else - return "Fujitsu MB86904"; -#endif -} + #endif -- cgit v1.1 From e0f62c5a5b5c80d0a6b163a8113e5938b0b40d54 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sun, 27 Jul 2025 21:03:12 -1000 Subject: 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 Signed-off-by: Richard Henderson --- linux-user/sparc/elfload.c | 27 +++++++++++++++++++++++++++ linux-user/sparc/target_elf.h | 2 ++ 2 files changed, 29 insertions(+) (limited to 'linux-user/sparc') diff --git a/linux-user/sparc/elfload.c b/linux-user/sparc/elfload.c index 243e6f9..32ca1b0 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; +} diff --git a/linux-user/sparc/target_elf.h b/linux-user/sparc/target_elf.h index 7e46748..b7544db 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 -- cgit v1.1 From 7b9efb7aaef9b43b22fce7051861f59fe15ff51a Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 28 Jul 2025 12:29:11 -1000 Subject: linux-user/sparc: Create init_main_thread Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/sparc/cpu_loop.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'linux-user/sparc') diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 68f1e8e..7d30cd1 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -357,14 +357,12 @@ void cpu_loop (CPUSPARCState *env) } } -void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs) +void init_main_thread(CPUState *cs, struct image_info *info) { - int i; - env->pc = regs->pc; - env->npc = regs->npc; - env->y = regs->y; - for(i = 0; i < 8; i++) - env->gregs[i] = regs->u_regs[i]; - for(i = 0; i < 8; i++) - env->regwptr[i] = regs->u_regs[i + 8]; + CPUArchState *env = cpu_env(cs); + + env->pc = info->entry; + env->npc = env->pc + 4; + env->regwptr[WREG_SP] = (info->start_stack - 16 * sizeof(abi_ulong) + - TARGET_STACK_BIAS); } -- cgit v1.1