1 /*- 2 * Copyright (c) 1994-1996 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer 10 * in this position and unchanged. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * $FreeBSD$ 29 */ 30 31 #ifndef _I386_LINUX_LINUX_H_ 32 #define _I386_LINUX_LINUX_H_ 33 34 #include <i386/linux/linux_syscall.h> 35 36 #ifdef MALLOC_DECLARE 37 MALLOC_DECLARE(M_LINUX); 38 #endif 39 40 /* 41 * Miscellaneous 42 */ 43 #define LINUX_NAME_MAX 255 44 #define LINUX_MAX_UTSNAME 65 45 46 /* Scheduling policies */ 47 #define LINUX_SCHED_OTHER 0 48 #define LINUX_SCHED_FIFO 1 49 #define LINUX_SCHED_RR 2 50 51 /* Resource limits */ 52 #define LINUX_RLIMIT_CPU 0 53 #define LINUX_RLIMIT_FSIZE 1 54 #define LINUX_RLIMIT_DATA 2 55 #define LINUX_RLIMIT_STACK 3 56 #define LINUX_RLIMIT_CORE 4 57 #define LINUX_RLIMIT_RSS 5 58 #define LINUX_RLIMIT_NPROC 6 59 #define LINUX_RLIMIT_NOFILE 7 60 #define LINUX_RLIMIT_MEMLOCK 8 61 #define LINUX_RLIMIT_AS 9 /* address space limit */ 62 63 #define LINUX_RLIM_NLIMITS 10 64 65 /* mmap options */ 66 #define LINUX_MAP_SHARED 0x0001 67 #define LINUX_MAP_PRIVATE 0x0002 68 #define LINUX_MAP_FIXED 0x0010 69 #define LINUX_MAP_ANON 0x0020 70 #define LINUX_MAP_GROWSDOWN 0x0100 71 72 typedef char * linux_caddr_t; 73 typedef long linux_clock_t; 74 typedef u_short linux_dev_t; 75 typedef u_short linux_gid_t; 76 typedef u_long linux_ino_t; 77 typedef int linux_key_t; /* XXX */ 78 typedef u_short linux_mode_t; 79 typedef u_short linux_nlink_t; 80 typedef long linux_off_t; 81 typedef int linux_pid_t; 82 typedef u_int linux_size_t; 83 typedef long linux_time_t; 84 typedef u_short linux_uid_t; 85 86 typedef struct { 87 long val[2]; 88 } linux_fsid_t; 89 90 struct linux_new_utsname { 91 char sysname[LINUX_MAX_UTSNAME]; 92 char nodename[LINUX_MAX_UTSNAME]; 93 char release[LINUX_MAX_UTSNAME]; 94 char version[LINUX_MAX_UTSNAME]; 95 char machine[LINUX_MAX_UTSNAME]; 96 char domainname[LINUX_MAX_UTSNAME]; 97 }; 98 99 /* 100 * Signalling 101 */ 102 #define LINUX_SIGHUP 1 103 #define LINUX_SIGINT 2 104 #define LINUX_SIGQUIT 3 105 #define LINUX_SIGILL 4 106 #define LINUX_SIGTRAP 5 107 #define LINUX_SIGABRT 6 108 #define LINUX_SIGIOT LINUX_SIGABRT 109 #define LINUX_SIGBUS 7 110 #define LINUX_SIGFPE 8 111 #define LINUX_SIGKILL 9 112 #define LINUX_SIGUSR1 10 113 #define LINUX_SIGSEGV 11 114 #define LINUX_SIGUSR2 12 115 #define LINUX_SIGPIPE 13 116 #define LINUX_SIGALRM 14 117 #define LINUX_SIGTERM 15 118 #define LINUX_SIGSTKFLT 16 119 #define LINUX_SIGCHLD 17 120 #define LINUX_SIGCONT 18 121 #define LINUX_SIGSTOP 19 122 #define LINUX_SIGTSTP 20 123 #define LINUX_SIGTTIN 21 124 #define LINUX_SIGTTOU 22 125 #define LINUX_SIGURG 23 126 #define LINUX_SIGXCPU 24 127 #define LINUX_SIGXFSZ 25 128 #define LINUX_SIGVTALRM 26 129 #define LINUX_SIGPROF 27 130 #define LINUX_SIGWINCH 28 131 #define LINUX_SIGIO 29 132 #define LINUX_SIGPOLL LINUX_SIGIO 133 #define LINUX_SIGPWR 30 134 #define LINUX_SIGUNUSED 31 135 136 #define LINUX_NSIG 64 137 #define LINUX_SIGTBLSZ 31 138 139 /* sigaction flags */ 140 #define LINUX_SA_NOCLDSTOP 0x00000001 141 #define LINUX_SA_NOCLDWAIT 0x00000002 142 #define LINUX_SA_SIGINFO 0x00000004 143 #define LINUX_SA_RESTORER 0x04000000 144 #define LINUX_SA_ONSTACK 0x08000000 145 #define LINUX_SA_RESTART 0x10000000 146 #define LINUX_SA_INTERRUPT 0x20000000 147 #define LINUX_SA_NOMASK 0x40000000 148 #define LINUX_SA_ONESHOT 0x80000000 149 150 /* sigprocmask actions */ 151 #define LINUX_SIG_BLOCK 0 152 #define LINUX_SIG_UNBLOCK 1 153 #define LINUX_SIG_SETMASK 2 154 155 /* sigset_t macros */ 156 #define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0 157 #define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig) 158 #define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig) 159 160 typedef void (*linux_handler_t)(int); 161 typedef u_long linux_osigset_t; 162 163 typedef struct { 164 u_int __bits[2]; 165 } linux_sigset_t; 166 167 typedef struct { 168 linux_handler_t lsa_handler; 169 linux_osigset_t lsa_mask; 170 u_long lsa_flags; 171 void (*lsa_restorer)(void); 172 } linux_osigaction_t; 173 174 typedef struct { 175 linux_handler_t lsa_handler; 176 u_long lsa_flags; 177 void (*lsa_restorer)(void); 178 linux_sigset_t lsa_mask; 179 } linux_sigaction_t; 180 181 typedef struct { 182 void *ss_sp; 183 int ss_flags; 184 linux_size_t ss_size; 185 } linux_stack_t; 186 187 /* The Linux sigcontext, pretty much a standard 386 trapframe. */ 188 struct linux_sigcontext { 189 int sc_gs; 190 int sc_fs; 191 int sc_es; 192 int sc_ds; 193 int sc_edi; 194 int sc_esi; 195 int sc_ebp; 196 int sc_esp; 197 int sc_ebx; 198 int sc_edx; 199 int sc_ecx; 200 int sc_eax; 201 int sc_trapno; 202 int sc_err; 203 int sc_eip; 204 int sc_cs; 205 int sc_eflags; 206 int sc_esp_at_signal; 207 int sc_ss; 208 int sc_387; 209 int sc_mask; 210 int sc_cr2; 211 }; 212 213 /* 214 * We make the stack look like Linux expects it when calling a signal 215 * handler, but use the BSD way of calling the handler and sigreturn(). 216 * This means that we need to pass the pointer to the handler too. 217 * It is appended to the frame to not interfere with the rest of it. 218 */ 219 struct linux_sigframe { 220 int sf_sig; 221 struct linux_sigcontext sf_sc; 222 linux_handler_t sf_handler; 223 }; 224 225 extern int bsd_to_linux_signal[]; 226 extern int linux_to_bsd_signal[]; 227 extern struct sysentvec linux_sysvec; 228 extern struct sysentvec elf_linux_sysvec; 229 230 /* 231 * Pluggable ioctl handlers 232 */ 233 struct linker_set; 234 struct linux_ioctl_args; 235 struct proc; 236 237 typedef int linux_ioctl_function_t(struct proc *, struct linux_ioctl_args *); 238 239 struct linux_ioctl_handler { 240 linux_ioctl_function_t *func; 241 int low, high; 242 }; 243 244 int linux_ioctl_register_handler(struct linux_ioctl_handler *h); 245 int linux_ioctl_register_handlers(struct linker_set *s); 246 int linux_ioctl_unregister_handler(struct linux_ioctl_handler *h); 247 int linux_ioctl_unregister_handlers(struct linker_set *s); 248 249 /* 250 * open/fcntl flags 251 */ 252 #define LINUX_O_RDONLY 00 253 #define LINUX_O_WRONLY 01 254 #define LINUX_O_RDWR 02 255 #define LINUX_O_CREAT 0100 256 #define LINUX_O_EXCL 0200 257 #define LINUX_O_NOCTTY 0400 258 #define LINUX_O_TRUNC 01000 259 #define LINUX_O_APPEND 02000 260 #define LINUX_O_NONBLOCK 04000 261 #define LINUX_O_NDELAY LINUX_O_NONBLOCK 262 #define LINUX_O_SYNC 010000 263 #define LINUX_FASYNC 020000 264 265 #define LINUX_F_DUPFD 0 266 #define LINUX_F_GETFD 1 267 #define LINUX_F_SETFD 2 268 #define LINUX_F_GETFL 3 269 #define LINUX_F_SETFL 4 270 #define LINUX_F_GETLK 5 271 #define LINUX_F_SETLK 6 272 #define LINUX_F_SETLKW 7 273 #define LINUX_F_SETOWN 8 274 #define LINUX_F_GETOWN 9 275 276 #define LINUX_F_RDLCK 0 277 #define LINUX_F_WRLCK 1 278 #define LINUX_F_UNLCK 2 279 280 /* 281 * SystemV IPC defines 282 */ 283 #define LINUX_SEMOP 1 284 #define LINUX_SEMGET 2 285 #define LINUX_SEMCTL 3 286 #define LINUX_MSGSND 11 287 #define LINUX_MSGRCV 12 288 #define LINUX_MSGGET 13 289 #define LINUX_MSGCTL 14 290 #define LINUX_SHMAT 21 291 #define LINUX_SHMDT 22 292 #define LINUX_SHMGET 23 293 #define LINUX_SHMCTL 24 294 295 #define LINUX_IPC_RMID 0 296 #define LINUX_IPC_SET 1 297 #define LINUX_IPC_STAT 2 298 #define LINUX_IPC_INFO 3 299 300 #define LINUX_SHM_LOCK 11 301 #define LINUX_SHM_UNLOCK 12 302 #define LINUX_SHM_STAT 13 303 #define LINUX_SHM_INFO 14 304 305 #define LINUX_SHM_RDONLY 0x1000 306 #define LINUX_SHM_RND 0x2000 307 #define LINUX_SHM_REMAP 0x4000 308 309 /* semctl commands */ 310 #define LINUX_GETPID 11 311 #define LINUX_GETVAL 12 312 #define LINUX_GETALL 13 313 #define LINUX_GETNCNT 14 314 #define LINUX_GETZCNT 15 315 #define LINUX_SETVAL 16 316 #define LINUX_SETALL 17 317 318 /* 319 * Socket defines 320 */ 321 #define LINUX_SOCKET 1 322 #define LINUX_BIND 2 323 #define LINUX_CONNECT 3 324 #define LINUX_LISTEN 4 325 #define LINUX_ACCEPT 5 326 #define LINUX_GETSOCKNAME 6 327 #define LINUX_GETPEERNAME 7 328 #define LINUX_SOCKETPAIR 8 329 #define LINUX_SEND 9 330 #define LINUX_RECV 10 331 #define LINUX_SENDTO 11 332 #define LINUX_RECVFROM 12 333 #define LINUX_SHUTDOWN 13 334 #define LINUX_SETSOCKOPT 14 335 #define LINUX_GETSOCKOPT 15 336 #define LINUX_SENDMSG 16 337 #define LINUX_RECVMSG 17 338 339 #define LINUX_AF_UNSPEC 0 340 #define LINUX_AF_UNIX 1 341 #define LINUX_AF_INET 2 342 #define LINUX_AF_AX25 3 343 #define LINUX_AF_IPX 4 344 #define LINUX_AF_APPLETALK 5 345 346 #define LINUX_SOL_SOCKET 1 347 #define LINUX_SOL_IP 0 348 #define LINUX_SOL_IPX 256 349 #define LINUX_SOL_AX25 257 350 #define LINUX_SOL_TCP 6 351 #define LINUX_SOL_UDP 17 352 353 #define LINUX_SO_DEBUG 1 354 #define LINUX_SO_REUSEADDR 2 355 #define LINUX_SO_TYPE 3 356 #define LINUX_SO_ERROR 4 357 #define LINUX_SO_DONTROUTE 5 358 #define LINUX_SO_BROADCAST 6 359 #define LINUX_SO_SNDBUF 7 360 #define LINUX_SO_RCVBUF 8 361 #define LINUX_SO_KEEPALIVE 9 362 #define LINUX_SO_OOBINLINE 10 363 #define LINUX_SO_NO_CHECK 11 364 #define LINUX_SO_PRIORITY 12 365 #define LINUX_SO_LINGER 13 366 367 #define LINUX_IP_TOS 1 368 #define LINUX_IP_TTL 2 369 #define LINUX_IP_HDRINCL 3 370 #define LINUX_IP_OPTIONS 4 371 372 #define LINUX_IP_MULTICAST_IF 32 373 #define LINUX_IP_MULTICAST_TTL 33 374 #define LINUX_IP_MULTICAST_LOOP 34 375 #define LINUX_IP_ADD_MEMBERSHIP 35 376 #define LINUX_IP_DROP_MEMBERSHIP 36 377 378 struct linux_sockaddr { 379 u_short sa_family; 380 char sa_data[14]; 381 }; 382 383 struct linux_ifmap { 384 u_long mem_start; 385 u_long mem_end; 386 u_short base_addr; 387 u_char irq; 388 u_char dma; 389 u_char port; 390 }; 391 392 #define LINUX_IFHWADDRLEN 6 393 #define LINUX_IFNAMSIZ 16 394 395 struct linux_ifreq { 396 union { 397 char ifrn_name[LINUX_IFNAMSIZ]; 398 } ifr_ifrn; 399 400 union { 401 struct linux_sockaddr ifru_addr; 402 struct linux_sockaddr ifru_dstaddr; 403 struct linux_sockaddr ifru_broadaddr; 404 struct linux_sockaddr ifru_netmask; 405 struct linux_sockaddr ifru_hwaddr; 406 short ifru_flags; 407 int ifru_metric; 408 int ifru_mtu; 409 struct linux_ifmap ifru_map; 410 char ifru_slave[LINUX_IFNAMSIZ]; /* Just fits the size */ 411 linux_caddr_t ifru_data; 412 } ifr_ifru; 413 }; 414 415 #define ifr_name ifr_ifrn.ifrn_name /* interface name */ 416 #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ 417 418 #endif /* !_I386_LINUX_LINUX_H_ */ 419