xref: /qemu/bsd-user/arm/target_arch_sigtramp.h (revision eacb50b8d92452251d890f6bfb4ac8eb22acb8d2)
1*eacb50b8SWarner Losh /*
2*eacb50b8SWarner Losh  *  arm sysarch() system call emulation
3*eacb50b8SWarner Losh  *
4*eacb50b8SWarner Losh  *  Copyright (c) 2013 Stacey D. Son
5*eacb50b8SWarner Losh  *
6*eacb50b8SWarner Losh  *  This program is free software; you can redistribute it and/or modify
7*eacb50b8SWarner Losh  *  it under the terms of the GNU General Public License as published by
8*eacb50b8SWarner Losh  *  the Free Software Foundation; either version 2 of the License, or
9*eacb50b8SWarner Losh  *  (at your option) any later version.
10*eacb50b8SWarner Losh  *
11*eacb50b8SWarner Losh  *  This program is distributed in the hope that it will be useful,
12*eacb50b8SWarner Losh  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13*eacb50b8SWarner Losh  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*eacb50b8SWarner Losh  *  GNU General Public License for more details.
15*eacb50b8SWarner Losh  *
16*eacb50b8SWarner Losh  *  You should have received a copy of the GNU General Public License
17*eacb50b8SWarner Losh  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
18*eacb50b8SWarner Losh  */
19*eacb50b8SWarner Losh 
20*eacb50b8SWarner Losh #ifndef _TARGET_ARCH_SIGTRAMP_H_
21*eacb50b8SWarner Losh #define _TARGET_ARCH_SIGTRAMP_H_
22*eacb50b8SWarner Losh 
23*eacb50b8SWarner Losh /* Compare to arm/arm/locore.S ENTRY_NP(sigcode) */
24*eacb50b8SWarner Losh static inline abi_long setup_sigtramp(abi_ulong offset, unsigned sigf_uc,
25*eacb50b8SWarner Losh         unsigned sys_sigreturn)
26*eacb50b8SWarner Losh {
27*eacb50b8SWarner Losh     int i;
28*eacb50b8SWarner Losh     uint32_t sys_exit = TARGET_FREEBSD_NR_exit;
29*eacb50b8SWarner Losh     uint32_t sigtramp_code[] = {
30*eacb50b8SWarner Losh     /* 1 */ 0xE1A0000D,                  /* mov r0, sp */
31*eacb50b8SWarner Losh     /* 2 */ 0xE2800000 + sigf_uc,        /* add r0, r0, #SIGF_UC */
32*eacb50b8SWarner Losh     /* 3 */ 0xE59F700C,                  /* ldr r7, [pc, #12] */
33*eacb50b8SWarner Losh     /* 4 */ 0xEF000000 + sys_sigreturn,  /* swi (SYS_sigreturn) */
34*eacb50b8SWarner Losh     /* 5 */ 0xE59F7008,                  /* ldr r7, [pc, #8] */
35*eacb50b8SWarner Losh     /* 6 */ 0xEF000000 + sys_exit,       /* swi (SYS_exit)*/
36*eacb50b8SWarner Losh     /* 7 */ 0xEAFFFFFA,                  /* b . -16 */
37*eacb50b8SWarner Losh     /* 8 */ sys_sigreturn,
38*eacb50b8SWarner Losh     /* 9 */ sys_exit
39*eacb50b8SWarner Losh     };
40*eacb50b8SWarner Losh 
41*eacb50b8SWarner Losh     G_STATIC_ASSERT(sizeof(sigtramp_code) == TARGET_SZSIGCODE);
42*eacb50b8SWarner Losh 
43*eacb50b8SWarner Losh     for (i = 0; i < 9; i++) {
44*eacb50b8SWarner Losh         tswap32s(&sigtramp_code[i]);
45*eacb50b8SWarner Losh     }
46*eacb50b8SWarner Losh 
47*eacb50b8SWarner Losh     return memcpy_to_target(offset, sigtramp_code, TARGET_SZSIGCODE);
48*eacb50b8SWarner Losh }
49*eacb50b8SWarner Losh #endif /* _TARGET_ARCH_SIGTRAMP_H_ */
50