Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / compat / linux / arch / i386 / linux_machdep.h
blob263e2127be43888fc4ff082652bcdff6225629b0
1 /* $NetBSD: linux_machdep.h,v 1.35 2008/10/26 17:57:49 christos Exp $ */
3 /*-
4 * Copyright (c) 1995, 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
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
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.
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.
42 struct linux_fpreg {
43 uint16_t mant[4];
44 uint16_t expo;
47 struct linux_fpxreg {
48 uint16_t mant[4];
49 uint16_t expo;
50 uint16_t pad[3];
53 struct linux_xmmreg {
54 uint32_t reg[4];
57 struct linux_fpstate {
58 uint32_t cw;
59 uint32_t sw;
60 uint32_t tag;
61 uint32_t ipoff;
62 uint32_t cssel;
63 uint32_t dataoff;
64 uint32_t datasel;
65 struct linux_fpreg st[8];
66 uint16_t status;
67 uint16_t magic;
68 uint32_t fxsr_env[6];
69 uint32_t mxcsr;
70 uint32_t reserved;
71 struct linux_fpxreg fxsr_st[8];
72 struct linux_xmmreg xmm[8];
73 uint32_t padding[56];
77 struct linux_sigcontext {
78 int sc_gs;
79 int sc_fs;
80 int sc_es;
81 int sc_ds;
82 int sc_edi;
83 int sc_esi;
84 int sc_ebp;
85 int sc_esp;
86 int sc_ebx;
87 int sc_edx;
88 int sc_ecx;
89 int sc_eax;
90 int sc_trapno;
91 int sc_err;
92 int sc_eip;
93 int sc_cs;
94 int sc_eflags;
95 int sc_esp_at_signal;
96 int sc_ss;
97 struct linux_fpstate *sc_387;
98 /* XXX check this */
99 linux_old_sigset_t sc_mask;
100 int sc_cr2;
103 struct linux_libc_fpreg {
104 unsigned short significand[4];
105 unsigned short exponent;
108 struct linux_libc_fpstate {
109 unsigned long cw;
110 unsigned long sw;
111 unsigned long tag;
112 unsigned long ipoff;
113 unsigned long cssel;
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 {
136 int sf_sig;
137 struct linux_siginfo *sf_sip;
138 struct linux_ucontext *sf_ucp;
139 struct linux_siginfo sf_si;
140 struct linux_ucontext sf_uc;
141 sig_t sf_handler;
144 struct linux_sigframe {
145 int sf_sig;
146 struct linux_sigcontext sf_sc;
147 sig_t sf_handler;
150 struct linux_user_desc {
151 unsigned int entry_number;
152 unsigned int base_addr;
153 unsigned int limit;
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 {
163 unsigned long a, b;
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
284 * handle them.
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()
290 #define LINUX_NPTL
292 #ifdef _KERNEL
293 __BEGIN_DECLS
294 void linux_syscall_intern(struct proc *);
295 const char *linux_get_uname_arch(void);
296 __END_DECLS
297 #endif /* !_KERNEL */
299 #endif /* _I386_LINUX_MACHDEP_H */