master
h 36 lines 1.1 KB
Raw
1 /*
2 * ARM AArch64 sigcode 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_SIGTRAMP_H
9 #define TARGET_ARCH_SIGTRAMP_H
10
11 /* Compare to ENTRY(sigcode) in arm64/arm64/locore.S */
12 static inline abi_long setup_sigtramp(abi_ulong offset, unsigned sigf_uc,
13 unsigned sys_sigreturn)
14 {
15 int i;
16 uint32_t sys_exit = TARGET_FREEBSD_NR_exit;
17
18 uint32_t sigtramp_code[] = {
19 /* 1 */ 0x910003e0, /* mov x0, sp */
20 /* 2 */ 0x91000000 + (sigf_uc << 10), /* add x0, x0, #SIGF_UC */
21 /* 3 */ 0xd2800000 + (sys_sigreturn << 5) + 0x8, /* mov x8, #SYS_sigreturn */
22 /* 4 */ 0xd4000001, /* svc #0 */
23 /* 5 */ 0xd2800028 + (sys_exit << 5) + 0x8, /* mov x8, #SYS_exit */
24 /* 6 */ 0xd4000001, /* svc #0 */
25 /* 7 */ 0x17fffffc, /* b -4 */
26 /* 8 */ sys_sigreturn,
27 /* 9 */ sys_exit
28 };
29
30 for (i = 0; i < 9; i++) {
31 tswap32s(&sigtramp_code[i]);
32 }
33
34 return memcpy_to_target(offset, sigtramp_code, TARGET_SZSIGCODE);
35 }
36 #endif /* TARGET_ARCH_SIGTRAMP_H */