From: Stacey Son <s...@freebsd.org> Initializes thread's register state
Signed-off-by: Stacey Son <s...@freebsd.org> Signed-off-by: Ajeet Singh <itac...@freebsd.org> Co-authored-by: Jessica Clarke <jrt...@jrtc27.com> --- bsd-user/aarch64/target_arch_thread.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bsd-user/aarch64/target_arch_thread.h b/bsd-user/aarch64/target_arch_thread.h index d2f2dea7ce..bfc9050cb1 100644 --- a/bsd-user/aarch64/target_arch_thread.h +++ b/bsd-user/aarch64/target_arch_thread.h @@ -42,4 +42,20 @@ static inline void target_thread_set_upcall(CPUARMState *regs, abi_ulong entry, pstate_write(regs, PSTATE_MODE_EL0t); } +static inline void target_thread_init(struct target_pt_regs *regs, + struct image_info *infop) +{ + abi_long stack = infop->start_stack; + + /* + * Make sure the stack is properly aligned. + * arm64/include/param.h (STACKLIGN() macro) + */ + + memset(regs, 0, sizeof(*regs)); + regs->regs[0] = infop->start_stack; + regs->pc = infop->entry; + regs->sp = stack & ~(16 - 1); +} + #endif /* TARGET_ARCH_THREAD_H */ -- 2.34.1