1 /*        $NetBSD: linux_machdep.h,v 1.12 2011/11/21 22:00:42 njoly Exp $       */
2 
3 /*-
4  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Eric Haszlakiewicz.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _ALPHA_LINUX_MACHDEP_H
33 #define _ALPHA_LINUX_MACHDEP_H
34 
35 #include <compat/linux/common/linux_types.h>
36 #include <compat/linux/common/linux_signal.h>
37 #include <compat/linux/common/linux_siginfo.h>
38 
39 /*
40  * The Linux sigcontext, pretty much a standard alpha trapframe.
41  */
42 struct linux_sigcontext {
43           long                sc_onstack;
44           long                sc_mask;
45           long                sc_pc;
46           long                sc_ps;
47           long                sc_regs[32];
48           long                sc_ownedfp;
49           long                sc_fpregs[32];
50           unsigned long       sc_fpcr;
51           unsigned long       sc_fp_control;
52           unsigned long       sc_reserved1, sc_reserved2;
53           unsigned long       sc_ssize;
54           char *              sc_sbase;
55           unsigned long       sc_traparg_a0;
56           unsigned long       sc_traparg_a1;
57           unsigned long       sc_traparg_a2;
58           unsigned long       sc_fp_trap_pc;
59           unsigned long       sc_fp_trigger_sum;
60           unsigned long       sc_fp_trigger_inst;
61 };
62 
63 struct linux_ucontext {
64           u_long                        uc_flags;
65           struct linux_ucontext         *uc_link;
66           linux_old_sigset_t  uc_osf_sigmask;
67           linux_stack_t                 uc_stack;
68           struct linux_sigcontext       uc_mcontext;
69           linux_sigset_t                uc_sigmask;
70 };
71 
72 /*
73  * We make the stack look like Linux expects it when calling a signal
74  * handler, but use the BSD way of calling the handler and sigreturn().
75  */
76 
77 #define LINUX_INSN_MOV_R30_R16          0x47fe0410
78 #define LINUX_INSN_LDI_R0     0x201f0000
79 #define LINUX_INSN_CALLSYS    0x00000083
80 
81 struct linux_sigframe {
82           struct              linux_sigcontext sf_sc;
83           unsigned long       extramask[LINUX__NSIG_WORDS-1];
84           unsigned int        retcode[3];
85 };
86 
87 struct linux_rt_sigframe {
88           struct linux_siginfo          info;
89           struct linux_ucontext         uc;
90           unsigned int                  retcode[3];
91 };
92 
93 #ifdef _KERNEL
94 __BEGIN_DECLS
95 void setup_linux_rt_sigframe(struct trapframe *, const ksiginfo_t *,
96     const sigset_t *);
97 void setup_linux_sigframe(struct trapframe *, const ksiginfo_t *,
98     const sigset_t *);
99 int linux_restore_sigcontext(struct lwp *, struct linux_sigcontext,
100     sigset_t *);
101 void linux_syscall_intern(struct proc *);
102 __END_DECLS
103 #endif /* !_KERNEL */
104 
105 #endif /* _ALPHA_LINUX_MACHDEP_H */
106