xref: /openbmc/qemu/bsd-user/aarch64/signal.c (revision 7dba5e10a65be276267f379f07a9643100209c0d)
1 /*
2  * ARM AArch64 specific signal definitions for bsd-user
3  *
4  * Copyright (c) 2015 Stacey D. Son <sson at FreeBSD>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library 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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18  */
19 #include "qemu/osdep.h"
20 
21 #include "qemu.h"
22 
23 /*
24  * Compare to sendsig() in sys/arm64/arm64/machdep.c
25  * Assumes that target stack frame memory is locked.
26  */
27 abi_long set_sigtramp_args(CPUARMState *regs, int sig,
28                            struct target_sigframe *frame,
29                            abi_ulong frame_addr,
30                            struct target_sigaction *ka)
31 {
32     /*
33      * Arguments to signal handler:
34      *  x0 = signal number
35      *  x1 = siginfo pointer
36      *  x2 = ucontext pointer
37      *  pc/elr = signal handler pointer
38      *  sp = sigframe struct pointer
39      *  lr = sigtramp at base of user stack
40      */
41 
42     regs->xregs[0] = sig;
43     regs->xregs[1] = frame_addr +
44         offsetof(struct target_sigframe, sf_si);
45     regs->xregs[2] = frame_addr +
46         offsetof(struct target_sigframe, sf_uc);
47 
48     regs->pc = ka->_sa_handler;
49     regs->xregs[TARGET_REG_SP] = frame_addr;
50     regs->xregs[TARGET_REG_LR] = TARGET_PS_STRINGS - TARGET_SZSIGCODE;
51 
52     return 0;
53 }
54