1 /* $NetBSD: linux_machdep.h,v 1.37 2010/07/07 01:30:34 chs 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 * 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 _I386_LINUX_MACHDEP_H 33 #define _I386_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 386 trapframe. 41 */ 42 struct linux_fpreg { 43 uint16_t mant[4]; 44 uint16_t expo; 45 }; 46 47 struct linux_fpxreg { 48 uint16_t mant[4]; 49 uint16_t expo; 50 uint16_t pad[3]; 51 }; 52 53 struct linux_xmmreg { 54 uint32_t reg[4]; 55 }; 56 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]; 74 }; 75 76 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; 101 }; 102 103 struct linux_libc_fpreg { 104 unsigned short significand[4]; 105 unsigned short exponent; 106 }; 107 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; 118 }; 119 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; 127 }; 128 129 /* 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. 134 */ 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; 142 }; 143 144 struct linux_sigframe { 145 int sf_sig; 146 struct linux_sigcontext sf_sc; 147 sig_t sf_handler; 148 }; 149 150 /* 151 * Used in ugly patch to fake device numbers. 152 */ 153 /* Major device numbers for new style ptys. */ 154 #define LINUX_PTC_MAJOR 2 155 #define LINUX_PTS_MAJOR 3 156 /* Major device numbers of VT device on both Linux and NetBSD. */ 157 #define LINUX_CONS_MAJOR 4 158 159 /* 160 * Linux ioctl calls for the keyboard. 161 */ 162 #define LINUX_KDGKBMODE 0x4b44 163 #define LINUX_KDSKBMODE 0x4b45 164 #define LINUX_KDMKTONE 0x4b30 165 #define LINUX_KDSETMODE 0x4b3a 166 #define LINUX_KDGETMODE 0x4b3b 167 #define LINUX_KDENABIO 0x4b36 168 #define LINUX_KDDISABIO 0x4b37 169 #define LINUX_KDGETLED 0x4b31 170 #define LINUX_KDSETLED 0x4b32 171 #define LINUX_KDGKBTYPE 0x4b33 172 #define LINUX_KDGKBENT 0x4b46 173 #define LINUX_KIOCSOUND 0x4b2f 174 175 /* 176 * Mode for KDSKBMODE which we don't have (we just use plain mode for this) 177 */ 178 #define LINUX_K_MEDIUMRAW 2 179 180 /* 181 * VT ioctl calls in Linux (the ones that the pcvt emulation in wscons can handle) 182 */ 183 #define LINUX_VT_OPENQRY 0x5600 184 #define LINUX_VT_GETMODE 0x5601 185 #define LINUX_VT_SETMODE 0x5602 186 #define LINUX_VT_GETSTATE 0x5603 187 #define LINUX_VT_RELDISP 0x5605 188 #define LINUX_VT_ACTIVATE 0x5606 189 #define LINUX_VT_WAITACTIVE 0x5607 190 #define LINUX_VT_DISALLOCATE 0x5608 191 192 /* 193 * This range used by VMWare (XXX) 194 */ 195 #define LINUX_VMWARE_NONE 200 196 #define LINUX_VMWARE_LAST 237 197 198 /* 199 * Range of ioctls to just pass on, so that modules (like VMWare) can 200 * handle them. 201 */ 202 #define LINUX_IOCTL_MIN_PASS LINUX_VMWARE_NONE 203 #define LINUX_IOCTL_MAX_PASS (LINUX_VMWARE_LAST+8) 204 205 #define LINUX_UNAME_ARCH linux_get_uname_arch() 206 207 #define LINUX_LWP_SETPRIVATE linux_lwp_setprivate 208 209 #ifdef _KERNEL 210 __BEGIN_DECLS 211 void linux_syscall_intern(struct proc *); 212 const char *linux_get_uname_arch(void); 213 __END_DECLS 214 #endif /* !_KERNEL */ 215 216 #endif /* _I386_LINUX_MACHDEP_H */ 217