qemu

FORK: QEMU emulator
git clone https://git.neptards.moe/neptards/qemu.git
Log | Files | Refs | Submodules | LICENSE

target_arch_sigtramp.h (1802B)


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