1 /* $NetBSD: linux_machdep.h,v 1.35 2008/10/26 17:57:49 christos Exp $ */
4 * Copyright (c) 1995, 2000 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
32 #ifndef _I386_LINUX_MACHDEP_H
33 #define _I386_LINUX_MACHDEP_H
35 #include <compat/linux/common/linux_types.h>
36 #include <compat/linux/common/linux_signal.h>
37 #include <compat/linux/common/linux_siginfo.h>
40 * The Linux sigcontext, pretty much a standard 386 trapframe.
57 struct linux_fpstate
{
65 struct linux_fpreg st
[8];
71 struct linux_fpxreg fxsr_st
[8];
72 struct linux_xmmreg xmm
[8];
77 struct linux_sigcontext
{
97 struct linux_fpstate
*sc_387
;
99 linux_old_sigset_t sc_mask
;
103 struct linux_libc_fpreg
{
104 unsigned short significand
[4];
105 unsigned short exponent
;
108 struct linux_libc_fpstate
{
114 unsigned long dataoff
;
115 unsigned long datasel
;
116 struct linux_libc_fpreg _st
[8];
117 unsigned long status
;
120 struct linux_ucontext
{
121 unsigned long uc_flags
;
122 struct ucontext
*uc_link
;
123 struct linux_sigaltstack uc_stack
;
124 struct linux_sigcontext uc_mcontext
;
125 linux_sigset_t uc_sigmask
;
126 struct linux_libc_fpstate uc_fpregs_mem
;
130 * We make the stack look like Linux expects it when calling a signal
131 * handler, but use the BSD way of calling the handler and sigreturn().
132 * This means that we need to pass the pointer to the handler too.
133 * It is appended to the frame to not interfere with the rest of it.
135 struct linux_rt_sigframe
{
137 struct linux_siginfo
*sf_sip
;
138 struct linux_ucontext
*sf_ucp
;
139 struct linux_siginfo sf_si
;
140 struct linux_ucontext sf_uc
;
144 struct linux_sigframe
{
146 struct linux_sigcontext sf_sc
;
150 struct linux_user_desc
{
151 unsigned int entry_number
;
152 unsigned int base_addr
;
154 unsigned int seg_32bit
:1;
155 unsigned int contents
:2;
156 unsigned int read_exec_only
:1;
157 unsigned int limit_in_pages
:1;
158 unsigned int seg_not_present
:1;
159 unsigned int useable
:1;
162 struct linux_desc_struct
{
167 #define LINUX_LOWERWORD 0x0000ffff
169 #define LINUX_GLIBC_TLS_SEL 6
172 * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h.
173 * These convert Linux user space descriptor to machine one.
175 #define LINUX_LDT_entry_a(info) \
176 ((((info)->base_addr & LINUX_LOWERWORD) << 16) | \
177 ((info)->limit & LINUX_LOWERWORD))
179 #define LINUX_ENTRY_B_READ_EXEC_ONLY 9
180 #define LINUX_ENTRY_B_CONTENTS 10
181 #define LINUX_ENTRY_B_SEG_NOT_PRESENT 15
182 #define LINUX_ENTRY_B_BASE_ADDR 16
183 #define LINUX_ENTRY_B_USEABLE 20
184 #define LINUX_ENTRY_B_SEG32BIT 22
185 #define LINUX_ENTRY_B_LIMIT 23
187 #define LINUX_LDT_entry_b(info) \
188 (((info)->base_addr & 0xff000000) | \
189 ((info)->limit & 0xf0000) | \
190 ((info)->contents << LINUX_ENTRY_B_CONTENTS) | \
191 (((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) |\
192 (((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) | \
193 (((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) |\
194 ((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) | \
195 ((info)->useable << LINUX_ENTRY_B_USEABLE) | \
196 ((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000)
198 #define LINUX_LDT_empty(info) \
199 ((info)->base_addr == 0 && \
200 (info)->limit == 0 && \
201 (info)->contents == 0 && \
202 (info)->seg_not_present == 1 && \
203 (info)->read_exec_only == 1 && \
204 (info)->seg_32bit == 0 && \
205 (info)->limit_in_pages == 0 && \
206 (info)->useable == 0)
209 * Macros for converting segments.
210 * They do the same as those in arch/i386/kernel/process.c in Linux.
212 #define LINUX_GET_BASE(desc) \
213 ((((desc)->a >> 16) & LINUX_LOWERWORD) | \
214 (((desc)->b << 16) & 0x00ff0000) | \
215 ((desc)->b & 0xff000000))
217 #define LINUX_GET_LIMIT(desc) \
218 (((desc)->a & LINUX_LOWERWORD) | \
219 ((desc)->b & 0xf0000))
221 #define LINUX_GET_32BIT(desc) \
222 (((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1)
223 #define LINUX_GET_CONTENTS(desc) \
224 (((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3)
225 #define LINUX_GET_WRITABLE(desc) \
226 (((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1)
227 #define LINUX_GET_LIMIT_PAGES(desc) \
228 (((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1)
229 #define LINUX_GET_PRESENT(desc) \
230 (((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1)
231 #define LINUX_GET_USEABLE(desc) \
232 (((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1)
235 * Used in ugly patch to fake device numbers.
237 /* Major device numbers for new style ptys. */
238 #define LINUX_PTC_MAJOR 2
239 #define LINUX_PTS_MAJOR 3
240 /* Major device numbers of VT device on both Linux and NetBSD. */
241 #define LINUX_CONS_MAJOR 4
244 * Linux ioctl calls for the keyboard.
246 #define LINUX_KDGKBMODE 0x4b44
247 #define LINUX_KDSKBMODE 0x4b45
248 #define LINUX_KDMKTONE 0x4b30
249 #define LINUX_KDSETMODE 0x4b3a
250 #define LINUX_KDGETMODE 0x4b3b
251 #define LINUX_KDENABIO 0x4b36
252 #define LINUX_KDDISABIO 0x4b37
253 #define LINUX_KDGETLED 0x4b31
254 #define LINUX_KDSETLED 0x4b32
255 #define LINUX_KDGKBTYPE 0x4b33
256 #define LINUX_KDGKBENT 0x4b46
257 #define LINUX_KIOCSOUND 0x4b2f
260 * Mode for KDSKBMODE which we don't have (we just use plain mode for this)
262 #define LINUX_K_MEDIUMRAW 2
265 * VT ioctl calls in Linux (the ones that the pcvt emulation in wscons can handle)
267 #define LINUX_VT_OPENQRY 0x5600
268 #define LINUX_VT_GETMODE 0x5601
269 #define LINUX_VT_SETMODE 0x5602
270 #define LINUX_VT_GETSTATE 0x5603
271 #define LINUX_VT_RELDISP 0x5605
272 #define LINUX_VT_ACTIVATE 0x5606
273 #define LINUX_VT_WAITACTIVE 0x5607
274 #define LINUX_VT_DISALLOCATE 0x5608
277 * This range used by VMWare (XXX)
279 #define LINUX_VMWARE_NONE 200
280 #define LINUX_VMWARE_LAST 237
283 * Range of ioctls to just pass on, so that modules (like VMWare) can
286 #define LINUX_IOCTL_MIN_PASS LINUX_VMWARE_NONE
287 #define LINUX_IOCTL_MAX_PASS (LINUX_VMWARE_LAST+8)
289 #define LINUX_UNAME_ARCH linux_get_uname_arch()
294 void linux_syscall_intern(struct proc
*);
295 const char *linux_get_uname_arch(void);
297 #endif /* !_KERNEL */
299 #endif /* _I386_LINUX_MACHDEP_H */