1*7dba5e10SStacey Son /* 2*7dba5e10SStacey Son * ARM AArch64 sigcode for bsd-user 3*7dba5e10SStacey Son * 4*7dba5e10SStacey Son * Copyright (c) 2015 Stacey D. Son <sson at FreeBSD> 5*7dba5e10SStacey Son * 6*7dba5e10SStacey Son * This library is free software; you can redistribute it and/or 7*7dba5e10SStacey Son * modify it under the terms of the GNU Lesser General Public 8*7dba5e10SStacey Son * License as published by the Free Software Foundation; either 9*7dba5e10SStacey Son * version 2 of the License, or (at your option) any later version. 10*7dba5e10SStacey Son * 11*7dba5e10SStacey Son * This library is distributed in the hope that it will be useful, 12*7dba5e10SStacey Son * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*7dba5e10SStacey Son * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14*7dba5e10SStacey Son * Lesser General Public License for more details. 15*7dba5e10SStacey Son * 16*7dba5e10SStacey Son * You should have received a copy of the GNU Lesser General Public 17*7dba5e10SStacey Son * License along with this library; if not, see <http://www.gnu.org/licenses/>. 18*7dba5e10SStacey Son */ 19*7dba5e10SStacey Son 20*7dba5e10SStacey Son #ifndef TARGET_ARCH_SIGTRAMP_H 21*7dba5e10SStacey Son #define TARGET_ARCH_SIGTRAMP_H 22*7dba5e10SStacey Son 23*7dba5e10SStacey Son /* Compare to ENTRY(sigcode) in arm64/arm64/locore.S */ 24*7dba5e10SStacey Son static inline abi_long setup_sigtramp(abi_ulong offset, unsigned sigf_uc, 25*7dba5e10SStacey Son unsigned sys_sigreturn) 26*7dba5e10SStacey Son { 27*7dba5e10SStacey Son int i; 28*7dba5e10SStacey Son uint32_t sys_exit = TARGET_FREEBSD_NR_exit; 29*7dba5e10SStacey Son 30*7dba5e10SStacey Son uint32_t sigtramp_code[] = { 31*7dba5e10SStacey Son /* 1 */ 0x910003e0, /* mov x0, sp */ 32*7dba5e10SStacey Son /* 2 */ 0x91000000 + (sigf_uc << 10), /* add x0, x0, #SIGF_UC */ 33*7dba5e10SStacey Son /* 3 */ 0xd2800000 + (sys_sigreturn << 5) + 0x8, /* mov x8, #SYS_sigreturn */ 34*7dba5e10SStacey Son /* 4 */ 0xd4000001, /* svc #0 */ 35*7dba5e10SStacey Son /* 5 */ 0xd2800028 + (sys_exit << 5) + 0x8, /* mov x8, #SYS_exit */ 36*7dba5e10SStacey Son /* 6 */ 0xd4000001, /* svc #0 */ 37*7dba5e10SStacey Son /* 7 */ 0x17fffffc, /* b -4 */ 38*7dba5e10SStacey Son /* 8 */ sys_sigreturn, 39*7dba5e10SStacey Son /* 9 */ sys_exit 40*7dba5e10SStacey Son }; 41*7dba5e10SStacey Son 42*7dba5e10SStacey Son for (i = 0; i < 9; i++) { 43*7dba5e10SStacey Son tswap32s(&sigtramp_code[i]); 44*7dba5e10SStacey Son } 45*7dba5e10SStacey Son 46*7dba5e10SStacey Son return memcpy_to_target(offset, sigtramp_code, TARGET_SZSIGCODE); 47*7dba5e10SStacey Son } 48*7dba5e10SStacey Son #endif /* TARGET_ARCH_SIGTRAMP_H */ 49