1 /*
2  * host-signal.h: signal info dependent on the host architecture
3  *
4  * Copyright (c) 2022 Linaro Ltd.
5  *
6  * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
7  * See the COPYING file in the top-level directory.
8  */
9 
10 #ifndef PPC_HOST_SIGNAL_H
11 #define PPC_HOST_SIGNAL_H
12 
13 #include <asm/ptrace.h>
14 
15 /* The third argument to a SA_SIGINFO handler is ucontext_t. */
16 typedef ucontext_t host_sigcontext;
17 
18 static inline uintptr_t host_signal_pc(host_sigcontext *uc)
19 {
20     return uc->uc_mcontext.regs->nip;
21 }
22 
23 static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
24 {
25     uc->uc_mcontext.regs->nip = pc;
26 }
27 
28 static inline void *host_signal_mask(host_sigcontext *uc)
29 {
30     return &uc->uc_sigmask;
31 }
32 
33 static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
34 {
35     return uc->uc_mcontext.regs->trap != 0x400
36         && (uc->uc_mcontext.regs->dsisr & 0x02000000);
37 }
38 
39 #endif
40