Provide a unified function to initialize the main thread.
Keep target_pt_regs isolated to this function.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
}
#endif /* USE_ELF_CORE_DUMP */
-void do_init_thread(struct target_pt_regs *regs, struct image_info *infop)
+void do_init_main_thread(CPUState *cs, struct image_info *infop)
{
- init_thread(regs, infop);
+ target_pt_regs regs = { };
+
+ init_thread(®s, infop);
+ target_cpu_copy_regs(cpu_env(cs), ®s);
}
}
int loader_exec(int fdexec, const char *filename, char **argv, char **envp,
- struct target_pt_regs *regs, struct image_info *infop,
- struct linux_binprm *bprm)
+ struct image_info *infop, struct linux_binprm *bprm)
{
int retval;
return retval;
}
- /* Success. Initialize important registers. */
- do_init_thread(regs, infop);
+ /* Success. */
return 0;
}
int (*core_dump)(int, const CPUArchState *); /* coredump routine */
};
-void do_init_thread(struct target_pt_regs *regs, struct image_info *infop);
+void do_init_main_thread(CPUState *cs, struct image_info *infop);
abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
abi_ulong stringp, int push_ptr);
int loader_exec(int fdexec, const char *filename, char **argv, char **envp,
- struct target_pt_regs *regs, struct image_info *infop,
- struct linux_binprm *);
+ struct image_info *infop, struct linux_binprm *);
uint32_t get_elf_eflags(int fd);
int load_elf_binary(struct linux_binprm *bprm, struct image_info *info);
int main(int argc, char **argv, char **envp)
{
- struct target_pt_regs regs1, *regs = ®s1;
struct image_info info1, *info = &info1;
struct linux_binprm bprm;
TaskState *ts;
trace_init_file();
qemu_plugin_load_list(&plugins, &error_fatal);
- /* Zero out regs */
- memset(regs, 0, sizeof(struct target_pt_regs));
-
/* Zero out image_info */
memset(info, 0, sizeof(struct image_info));
fd_trans_init();
- ret = loader_exec(execfd, exec_path, target_argv, target_environ, regs,
- info, &bprm);
+ ret = loader_exec(execfd, exec_path, target_argv, target_environ,
+ info, &bprm);
if (ret != 0) {
printf("Error while loading %s: %s\n", exec_path, strerror(-ret));
_exit(EXIT_FAILURE);
the real value of GUEST_BASE into account. */
tcg_prologue_init();
- target_cpu_copy_regs(env, regs);
+ do_init_main_thread(cpu, info);
if (gdbstub) {
gdbserver_start(gdbstub, &error_fatal);