linux_machdep.h revision 1.30 1 /* $NetBSD: linux_machdep.h,v 1.30 2007/05/10 21:30:15 christos Exp $ */
2
3 /*-
4 * Copyright (c) 1995, 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden.
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 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef _I386_LINUX_MACHDEP_H
40 #define _I386_LINUX_MACHDEP_H
41
42 #include <compat/linux/common/linux_types.h>
43 #include <compat/linux/common/linux_signal.h>
44 #include <compat/linux/common/linux_siginfo.h>
45
46 /*
47 * The Linux sigcontext, pretty much a standard 386 trapframe.
48 */
49 struct linux_fpreg {
50 uint16_t mant[4];
51 uint16_t expo;
52 };
53
54 struct linux_fpxreg {
55 uint16_t mant[4];
56 uint16_t expo;
57 uint16_t pad[3];
58 };
59
60 struct linux_xmmreg {
61 uint32_t reg[4];
62 };
63
64 struct linux_fpstate {
65 uint32_t cw;
66 uint32_t sw;
67 uint32_t tag;
68 uint32_t ipoff;
69 uint32_t cssel;
70 uint32_t dataoff;
71 uint32_t datasel;
72 struct linux_fpreg st[8];
73 uint16_t status;
74 uint16_t magic;
75 uint32_t fxsr_env[6];
76 uint32_t mxcsr;
77 uint32_t reserved;
78 struct linux_fpxreg fxsr_st[8];
79 struct linux_xmmreg xmm[8];
80 uint32_t padding[56];
81 };
82
83
84 struct linux_sigcontext {
85 int sc_gs;
86 int sc_fs;
87 int sc_es;
88 int sc_ds;
89 int sc_edi;
90 int sc_esi;
91 int sc_ebp;
92 int sc_esp;
93 int sc_ebx;
94 int sc_edx;
95 int sc_ecx;
96 int sc_eax;
97 int sc_trapno;
98 int sc_err;
99 int sc_eip;
100 int sc_cs;
101 int sc_eflags;
102 int sc_esp_at_signal;
103 int sc_ss;
104 struct linux_fpstate *sc_387;
105 /* XXX check this */
106 linux_old_sigset_t sc_mask;
107 int sc_cr2;
108 };
109
110 struct linux_libc_fpreg {
111 unsigned short significand[4];
112 unsigned short exponent;
113 };
114
115 struct linux_libc_fpstate {
116 unsigned long cw;
117 unsigned long sw;
118 unsigned long tag;
119 unsigned long ipoff;
120 unsigned long cssel;
121 unsigned long dataoff;
122 unsigned long datasel;
123 struct linux_libc_fpreg _st[8];
124 unsigned long status;
125 };
126
127 struct linux_ucontext {
128 unsigned long uc_flags;
129 struct ucontext *uc_link;
130 struct linux_sigaltstack uc_stack;
131 struct linux_sigcontext uc_mcontext;
132 linux_sigset_t uc_sigmask;
133 struct linux_libc_fpstate uc_fpregs_mem;
134 };
135
136 /*
137 * We make the stack look like Linux expects it when calling a signal
138 * handler, but use the BSD way of calling the handler and sigreturn().
139 * This means that we need to pass the pointer to the handler too.
140 * It is appended to the frame to not interfere with the rest of it.
141 */
142 struct linux_rt_sigframe {
143 int sf_sig;
144 struct linux_siginfo *sf_sip;
145 struct linux_ucontext *sf_ucp;
146 struct linux_siginfo sf_si;
147 struct linux_ucontext sf_uc;
148 sig_t sf_handler;
149 };
150
151 struct linux_sigframe {
152 int sf_sig;
153 struct linux_sigcontext sf_sc;
154 sig_t sf_handler;
155 };
156
157 /*
158 * Used in ugly patch to fake device numbers.
159 */
160 /* Major device numbers for new style ptys. */
161 #define LINUX_PTC_MAJOR 2
162 #define LINUX_PTS_MAJOR 3
163 /* Major device numbers of VT device on both Linux and NetBSD. */
164 #define LINUX_CONS_MAJOR 4
165
166 /*
167 * Linux ioctl calls for the keyboard.
168 */
169 #define LINUX_KDGKBMODE 0x4b44
170 #define LINUX_KDSKBMODE 0x4b45
171 #define LINUX_KDMKTONE 0x4b30
172 #define LINUX_KDSETMODE 0x4b3a
173 #define LINUX_KDGETMODE 0x4b3b
174 #define LINUX_KDENABIO 0x4b36
175 #define LINUX_KDDISABIO 0x4b37
176 #define LINUX_KDGETLED 0x4b31
177 #define LINUX_KDSETLED 0x4b32
178 #define LINUX_KDGKBTYPE 0x4b33
179 #define LINUX_KDGKBENT 0x4b46
180 #define LINUX_KIOCSOUND 0x4b2f
181
182 /*
183 * Mode for KDSKBMODE which we don't have (we just use plain mode for this)
184 */
185 #define LINUX_K_MEDIUMRAW 2
186
187 /*
188 * VT ioctl calls in Linux (the ones that the pcvt emulation in wscons can handle)
189 */
190 #define LINUX_VT_OPENQRY 0x5600
191 #define LINUX_VT_GETMODE 0x5601
192 #define LINUX_VT_SETMODE 0x5602
193 #define LINUX_VT_GETSTATE 0x5603
194 #define LINUX_VT_RELDISP 0x5605
195 #define LINUX_VT_ACTIVATE 0x5606
196 #define LINUX_VT_WAITACTIVE 0x5607
197 #define LINUX_VT_DISALLOCATE 0x5608
198
199 /*
200 * This range used by VMWare (XXX)
201 */
202 #define LINUX_VMWARE_NONE 200
203 #define LINUX_VMWARE_LAST 237
204
205 /*
206 * Range of ioctls to just pass on, so that LKMs (like VMWare) can
207 * handle them.
208 */
209 #define LINUX_IOCTL_MIN_PASS LINUX_VMWARE_NONE
210 #define LINUX_IOCTL_MAX_PASS (LINUX_VMWARE_LAST+8)
211
212 #define LINUX_UNAME_ARCH linux_get_uname_arch()
213
214 #ifdef _KERNEL
215 __BEGIN_DECLS
216 void linux_syscall_intern(struct proc *);
217 const char *linux_get_uname_arch(void);
218 __END_DECLS
219 #endif /* !_KERNEL */
220
221 #endif /* _I386_LINUX_MACHDEP_H */
222