1*781be866SWarner Losh /* 2*781be866SWarner Losh * arm signal functions 3*781be866SWarner Losh * 4*781be866SWarner Losh * Copyright (c) 2013 Stacey D. Son 5*781be866SWarner Losh * 6*781be866SWarner Losh * This program is free software; you can redistribute it and/or modify 7*781be866SWarner Losh * it under the terms of the GNU General Public License as published by 8*781be866SWarner Losh * the Free Software Foundation; either version 2 of the License, or 9*781be866SWarner Losh * (at your option) any later version. 10*781be866SWarner Losh * 11*781be866SWarner Losh * This program is distributed in the hope that it will be useful, 12*781be866SWarner Losh * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*781be866SWarner Losh * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*781be866SWarner Losh * GNU General Public License for more details. 15*781be866SWarner Losh * 16*781be866SWarner Losh * You should have received a copy of the GNU General Public License 17*781be866SWarner Losh * along with this program; if not, see <http://www.gnu.org/licenses/>. 18*781be866SWarner Losh */ 19*781be866SWarner Losh 20*781be866SWarner Losh #include "qemu.h" 21*781be866SWarner Losh 22*781be866SWarner Losh /* 23*781be866SWarner Losh * Compare to arm/arm/machdep.c sendsig() 24*781be866SWarner Losh * Assumes that target stack frame memory is locked. 25*781be866SWarner Losh */ 26*781be866SWarner Losh abi_long set_sigtramp_args(CPUARMState *env, int sig, 27*781be866SWarner Losh struct target_sigframe *frame, 28*781be866SWarner Losh abi_ulong frame_addr, 29*781be866SWarner Losh struct target_sigaction *ka) 30*781be866SWarner Losh { 31*781be866SWarner Losh /* 32*781be866SWarner Losh * Arguments to signal handler: 33*781be866SWarner Losh * r0 = signal number 34*781be866SWarner Losh * r1 = siginfo pointer 35*781be866SWarner Losh * r2 = ucontext pointer 36*781be866SWarner Losh * r5 = ucontext pointer 37*781be866SWarner Losh * pc = signal handler pointer 38*781be866SWarner Losh * sp = sigframe struct pointer 39*781be866SWarner Losh * lr = sigtramp at base of user stack 40*781be866SWarner Losh */ 41*781be866SWarner Losh 42*781be866SWarner Losh env->regs[0] = sig; 43*781be866SWarner Losh env->regs[1] = frame_addr + 44*781be866SWarner Losh offsetof(struct target_sigframe, sf_si); 45*781be866SWarner Losh env->regs[2] = frame_addr + 46*781be866SWarner Losh offsetof(struct target_sigframe, sf_uc); 47*781be866SWarner Losh 48*781be866SWarner Losh /* the trampoline uses r5 as the uc address */ 49*781be866SWarner Losh env->regs[5] = frame_addr + 50*781be866SWarner Losh offsetof(struct target_sigframe, sf_uc); 51*781be866SWarner Losh env->regs[TARGET_REG_PC] = ka->_sa_handler & ~1; 52*781be866SWarner Losh env->regs[TARGET_REG_SP] = frame_addr; 53*781be866SWarner Losh env->regs[TARGET_REG_LR] = TARGET_PS_STRINGS - TARGET_SZSIGCODE; 54*781be866SWarner Losh /* 55*781be866SWarner Losh * Low bit indicates whether or not we're entering thumb mode. 56*781be866SWarner Losh */ 57*781be866SWarner Losh cpsr_write(env, (ka->_sa_handler & 1) * CPSR_T, CPSR_T, CPSRWriteByInstr); 58*781be866SWarner Losh 59*781be866SWarner Losh return 0; 60*781be866SWarner Losh } 61