master
h 49 lines 1.16 KB
Raw
1 /*
2 * ARM AArch64 thread support for bsd-user.
3 *
4 * Copyright (c) 2015 Stacey D. Son
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8 #ifndef TARGET_ARCH_THREAD_H
9 #define TARGET_ARCH_THREAD_H
10
11 /* Compare to arm64/arm64/vm_machdep.c cpu_set_upcall_kse() */
12 static inline void target_thread_set_upcall(CPUARMState *regs, abi_ulong entry,
13 abi_ulong arg, abi_ulong stack_base, abi_ulong stack_size)
14 {
15 abi_ulong sp;
16
17 /*
18 * Make sure the stack is properly aligned.
19 * arm64/include/param.h (STACKLIGN() macro)
20 */
21 sp = ROUND_DOWN(stack_base + stack_size, 16);
22
23 /* sp = stack base */
24 regs->xregs[31] = sp;
25 /* pc = start function entry */
26 regs->pc = entry;
27 /* r0 = arg */
28 regs->xregs[0] = arg;
29
30
31 }
32
33 static inline void target_thread_init(struct target_pt_regs *regs,
34 struct image_info *infop)
35 {
36 abi_long stack = infop->start_stack;
37
38 /*
39 * Make sure the stack is properly aligned.
40 * arm64/include/param.h (STACKLIGN() macro)
41 */
42
43 memset(regs, 0, sizeof(*regs));
44 regs->regs[0] = infop->start_stack;
45 regs->pc = infop->entry;
46 regs->sp = ROUND_DOWN(stack, 16);
47 }
48
49 #endif /* TARGET_ARCH_THREAD_H */