master
h 37 lines 1.16 KB
Raw
1 /*
2 * arm sysarch() system call emulation
3 *
4 * Copyright (c) 2013 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 arm/arm/locore.S ENTRY_NP(sigcode) */
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 uint32_t sigtramp_code[] = {
18 /* 1 */ 0xE1A0000D, /* mov r0, sp */
19 /* 2 */ 0xE2800000 + sigf_uc, /* add r0, r0, #SIGF_UC */
20 /* 3 */ 0xE59F700C, /* ldr r7, [pc, #12] */
21 /* 4 */ 0xEF000000 + sys_sigreturn, /* swi (SYS_sigreturn) */
22 /* 5 */ 0xE59F7008, /* ldr r7, [pc, #8] */
23 /* 6 */ 0xEF000000 + sys_exit, /* swi (SYS_exit)*/
24 /* 7 */ 0xEAFFFFFA, /* b . -16 */
25 /* 8 */ sys_sigreturn,
26 /* 9 */ sys_exit
27 };
28
29 G_STATIC_ASSERT(sizeof(sigtramp_code) == TARGET_SZSIGCODE);
30
31 for (i = 0; i < 9; i++) {
32 tswap32s(&sigtramp_code[i]);
33 }
34
35 return memcpy_to_target(offset, sigtramp_code, TARGET_SZSIGCODE);
36 }
37 #endif /* TARGET_ARCH_SIGTRAMP_H */