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