1c21dee17SSøren Schmidt /*- 20a26f931SEd Maste * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 383ef78beSPedro F. Giffuni * 49a14aa01SUlrich Spörlein * Copyright (c) 1994-1996 Søren Schmidt 5c21dee17SSøren Schmidt * All rights reserved. 6c21dee17SSøren Schmidt * 7c21dee17SSøren Schmidt * Redistribution and use in source and binary forms, with or without 8c21dee17SSøren Schmidt * modification, are permitted provided that the following conditions 9c21dee17SSøren Schmidt * are met: 10c21dee17SSøren Schmidt * 1. Redistributions of source code must retain the above copyright 110a26f931SEd Maste * notice, this list of conditions and the following disclaimer. 12c21dee17SSøren Schmidt * 2. Redistributions in binary form must reproduce the above copyright 13c21dee17SSøren Schmidt * notice, this list of conditions and the following disclaimer in the 14c21dee17SSøren Schmidt * documentation and/or other materials provided with the distribution. 15c21dee17SSøren Schmidt * 160a26f931SEd Maste * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 170a26f931SEd Maste * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 180a26f931SEd Maste * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 190a26f931SEd Maste * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 200a26f931SEd Maste * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 210a26f931SEd Maste * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 220a26f931SEd Maste * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 230a26f931SEd Maste * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 240a26f931SEd Maste * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 250a26f931SEd Maste * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 260a26f931SEd Maste * SUCH DAMAGE. 27c3aac50fSPeter Wemm * $FreeBSD$ 28c21dee17SSøren Schmidt */ 29c21dee17SSøren Schmidt 30a4e3bad7SJung-uk Kim #ifndef _I386_LINUX_H_ 31a4e3bad7SJung-uk Kim #define _I386_LINUX_H_ 3262c3734cSBruce Evans 33562894f0SBrooks Davis #include <sys/abi_compat.h> 3479363394SAndrew Gallatin 354ab7403bSDmitry Chagin #include <compat/linux/linux.h> 36ebea8660SMarcel Moolenaar #include <i386/linux/linux_syscall.h> 37c21dee17SSøren Schmidt 38931e2a1aSEd Maste #define LINUX_LEGACY_SYSCALLS 39931e2a1aSEd Maste 4019e252baSAlexander Leidinger #define LINUX_DTRACE linuxulator 4124593369SJonathan Lemon 4243bef515SMarcel Moolenaar /* 431b20ff34SEric Melville * Provide a separate set of types for the Linux types. 445002a60fSMarcel Moolenaar */ 455002a60fSMarcel Moolenaar typedef int l_int; 465002a60fSMarcel Moolenaar typedef int32_t l_long; 475002a60fSMarcel Moolenaar typedef int64_t l_longlong; 485002a60fSMarcel Moolenaar typedef short l_short; 495002a60fSMarcel Moolenaar typedef unsigned int l_uint; 505002a60fSMarcel Moolenaar typedef uint32_t l_ulong; 515002a60fSMarcel Moolenaar typedef uint64_t l_ulonglong; 525002a60fSMarcel Moolenaar typedef unsigned short l_ushort; 535002a60fSMarcel Moolenaar 545002a60fSMarcel Moolenaar typedef char *l_caddr_t; 550e73a962STim J. Robbins typedef l_ulong l_uintptr_t; 565002a60fSMarcel Moolenaar typedef l_long l_clock_t; 575002a60fSMarcel Moolenaar typedef l_int l_daddr_t; 585002a60fSMarcel Moolenaar typedef l_ushort l_dev_t; 595002a60fSMarcel Moolenaar typedef l_uint l_gid_t; 605002a60fSMarcel Moolenaar typedef l_ushort l_gid16_t; 615002a60fSMarcel Moolenaar typedef l_ulong l_ino_t; 625002a60fSMarcel Moolenaar typedef l_int l_key_t; 635002a60fSMarcel Moolenaar typedef l_longlong l_loff_t; 645002a60fSMarcel Moolenaar typedef l_ushort l_mode_t; 655002a60fSMarcel Moolenaar typedef l_long l_off_t; 665002a60fSMarcel Moolenaar typedef l_int l_pid_t; 675002a60fSMarcel Moolenaar typedef l_uint l_size_t; 685002a60fSMarcel Moolenaar typedef l_long l_suseconds_t; 695002a60fSMarcel Moolenaar typedef l_long l_time_t; 70bfcce1a9SDmitry Chagin typedef l_longlong l_time64_t; 715002a60fSMarcel Moolenaar typedef l_uint l_uid_t; 725002a60fSMarcel Moolenaar typedef l_ushort l_uid16_t; 73aa8b2011SKonstantin Belousov typedef l_int l_timer_t; 74aa8b2011SKonstantin Belousov typedef l_int l_mqd_t; 753e89b641SDmitry Chagin typedef l_ulong l_fd_mask; 765002a60fSMarcel Moolenaar 77af557e64SDmitry Chagin #include <compat/linux/linux_siginfo.h> 78af557e64SDmitry Chagin 795002a60fSMarcel Moolenaar typedef struct { 805002a60fSMarcel Moolenaar l_int val[2]; 815002a60fSMarcel Moolenaar } l_fsid_t; 825002a60fSMarcel Moolenaar 835002a60fSMarcel Moolenaar typedef struct { 845002a60fSMarcel Moolenaar l_time_t tv_sec; 855002a60fSMarcel Moolenaar l_suseconds_t tv_usec; 865002a60fSMarcel Moolenaar } l_timeval; 875002a60fSMarcel Moolenaar 88*0e26e54bSDmitry Chagin typedef struct { 89*0e26e54bSDmitry Chagin l_time64_t tv_sec; 90*0e26e54bSDmitry Chagin l_time64_t tv_usec; 91*0e26e54bSDmitry Chagin } l_sock_timeval; 92*0e26e54bSDmitry Chagin 935002a60fSMarcel Moolenaar #define l_fd_set fd_set 945002a60fSMarcel Moolenaar 955002a60fSMarcel Moolenaar /* 9643bef515SMarcel Moolenaar * Miscellaneous 9743bef515SMarcel Moolenaar */ 984048f59cSDmitry Chagin #define LINUX_AT_COUNT 20 /* Count of used aux entry types. 994d7c2e8aSDmitry Chagin * Keep this synchronized with 100dc858467SEd Maste * linux_fixup_elf() code. 1014d7c2e8aSDmitry Chagin */ 1025002a60fSMarcel Moolenaar struct l___sysctl_args 1035002a60fSMarcel Moolenaar { 1045002a60fSMarcel Moolenaar l_int *name; 1055002a60fSMarcel Moolenaar l_int nlen; 1065002a60fSMarcel Moolenaar void *oldval; 1075002a60fSMarcel Moolenaar l_size_t *oldlenp; 1085002a60fSMarcel Moolenaar void *newval; 1095002a60fSMarcel Moolenaar l_size_t newlen; 1105002a60fSMarcel Moolenaar l_ulong __spare[4]; 1115002a60fSMarcel Moolenaar }; 1125002a60fSMarcel Moolenaar 11343bef515SMarcel Moolenaar /* Resource limits */ 11443bef515SMarcel Moolenaar #define LINUX_RLIMIT_CPU 0 11543bef515SMarcel Moolenaar #define LINUX_RLIMIT_FSIZE 1 11643bef515SMarcel Moolenaar #define LINUX_RLIMIT_DATA 2 11743bef515SMarcel Moolenaar #define LINUX_RLIMIT_STACK 3 11843bef515SMarcel Moolenaar #define LINUX_RLIMIT_CORE 4 11943bef515SMarcel Moolenaar #define LINUX_RLIMIT_RSS 5 12043bef515SMarcel Moolenaar #define LINUX_RLIMIT_NPROC 6 12143bef515SMarcel Moolenaar #define LINUX_RLIMIT_NOFILE 7 12243bef515SMarcel Moolenaar #define LINUX_RLIMIT_MEMLOCK 8 123a4e3bad7SJung-uk Kim #define LINUX_RLIMIT_AS 9 /* Address space limit */ 12443bef515SMarcel Moolenaar 12543bef515SMarcel Moolenaar #define LINUX_RLIM_NLIMITS 10 12643bef515SMarcel Moolenaar 1275002a60fSMarcel Moolenaar struct l_rlimit { 1285002a60fSMarcel Moolenaar l_ulong rlim_cur; 1295002a60fSMarcel Moolenaar l_ulong rlim_max; 1305002a60fSMarcel Moolenaar }; 1315002a60fSMarcel Moolenaar 13210931a46SJung-uk Kim struct l_mmap_argv { 13310931a46SJung-uk Kim l_uintptr_t addr; 13410931a46SJung-uk Kim l_size_t len; 13510931a46SJung-uk Kim l_int prot; 13610931a46SJung-uk Kim l_int flags; 13710931a46SJung-uk Kim l_int fd; 13810931a46SJung-uk Kim l_off_t pgoff; 13919593f77SDmitry Chagin }; 14010931a46SJung-uk Kim 1415002a60fSMarcel Moolenaar /* 1425002a60fSMarcel Moolenaar * stat family of syscalls 1435002a60fSMarcel Moolenaar */ 1445002a60fSMarcel Moolenaar struct l_timespec { 14577424f41SJung-uk Kim l_time_t tv_sec; 14677424f41SJung-uk Kim l_long tv_nsec; 1475002a60fSMarcel Moolenaar }; 14843bef515SMarcel Moolenaar 149bfcce1a9SDmitry Chagin /* __kernel_timespec */ 150bfcce1a9SDmitry Chagin struct l_timespec64 { 151bfcce1a9SDmitry Chagin l_time64_t tv_sec; 152bfcce1a9SDmitry Chagin l_longlong tv_nsec; 153bfcce1a9SDmitry Chagin }; 154bfcce1a9SDmitry Chagin 1555002a60fSMarcel Moolenaar struct l_newstat { 1565002a60fSMarcel Moolenaar l_ushort st_dev; 1575002a60fSMarcel Moolenaar l_ushort __pad1; 1585002a60fSMarcel Moolenaar l_ulong st_ino; 1595002a60fSMarcel Moolenaar l_ushort st_mode; 1605002a60fSMarcel Moolenaar l_ushort st_nlink; 1615002a60fSMarcel Moolenaar l_ushort st_uid; 1625002a60fSMarcel Moolenaar l_ushort st_gid; 1635002a60fSMarcel Moolenaar l_ushort st_rdev; 1645002a60fSMarcel Moolenaar l_ushort __pad2; 1655002a60fSMarcel Moolenaar l_ulong st_size; 1665002a60fSMarcel Moolenaar l_ulong st_blksize; 1675002a60fSMarcel Moolenaar l_ulong st_blocks; 168510ea843SEd Schouten struct l_timespec st_atim; 169510ea843SEd Schouten struct l_timespec st_mtim; 170510ea843SEd Schouten struct l_timespec st_ctim; 1715002a60fSMarcel Moolenaar l_ulong __unused4; 1725002a60fSMarcel Moolenaar l_ulong __unused5; 1735002a60fSMarcel Moolenaar }; 17443bef515SMarcel Moolenaar 1751f7642e0SAlexander Leidinger struct l_stat { 1761f7642e0SAlexander Leidinger l_ushort st_dev; 1771f7642e0SAlexander Leidinger l_ulong st_ino; 1781f7642e0SAlexander Leidinger l_ushort st_mode; 1791f7642e0SAlexander Leidinger l_ushort st_nlink; 1801f7642e0SAlexander Leidinger l_ushort st_uid; 1811f7642e0SAlexander Leidinger l_ushort st_gid; 1821f7642e0SAlexander Leidinger l_ushort st_rdev; 1831f7642e0SAlexander Leidinger l_long st_size; 184510ea843SEd Schouten struct l_timespec st_atim; 185510ea843SEd Schouten struct l_timespec st_mtim; 186510ea843SEd Schouten struct l_timespec st_ctim; 1871f7642e0SAlexander Leidinger l_long st_blksize; 1881f7642e0SAlexander Leidinger l_long st_blocks; 1891f7642e0SAlexander Leidinger l_ulong st_flags; 1901f7642e0SAlexander Leidinger l_ulong st_gen; 1911f7642e0SAlexander Leidinger }; 1921f7642e0SAlexander Leidinger 1935002a60fSMarcel Moolenaar struct l_stat64 { 1945002a60fSMarcel Moolenaar l_ushort st_dev; 1955002a60fSMarcel Moolenaar u_char __pad0[10]; 1965002a60fSMarcel Moolenaar l_ulong __st_ino; 1975002a60fSMarcel Moolenaar l_uint st_mode; 1985002a60fSMarcel Moolenaar l_uint st_nlink; 1995002a60fSMarcel Moolenaar l_ulong st_uid; 2005002a60fSMarcel Moolenaar l_ulong st_gid; 2015002a60fSMarcel Moolenaar l_ushort st_rdev; 2025002a60fSMarcel Moolenaar u_char __pad3[10]; 2035002a60fSMarcel Moolenaar l_longlong st_size; 2045002a60fSMarcel Moolenaar l_ulong st_blksize; 2055002a60fSMarcel Moolenaar l_ulong st_blocks; 2065002a60fSMarcel Moolenaar l_ulong __pad4; 207510ea843SEd Schouten struct l_timespec st_atim; 208510ea843SEd Schouten struct l_timespec st_mtim; 209510ea843SEd Schouten struct l_timespec st_ctim; 2105002a60fSMarcel Moolenaar l_ulonglong st_ino; 2115002a60fSMarcel Moolenaar }; 2125002a60fSMarcel Moolenaar 2133ab85269SDavid Malone struct l_statfs64 { 2143ab85269SDavid Malone l_int f_type; 2153ab85269SDavid Malone l_int f_bsize; 2163ab85269SDavid Malone uint64_t f_blocks; 2173ab85269SDavid Malone uint64_t f_bfree; 2183ab85269SDavid Malone uint64_t f_bavail; 2193ab85269SDavid Malone uint64_t f_files; 2203ab85269SDavid Malone uint64_t f_ffree; 2213ab85269SDavid Malone l_fsid_t f_fsid; 2223ab85269SDavid Malone l_int f_namelen; 223e801ac78SEdward Tomasz Napierala l_int f_frsize; 224e801ac78SEdward Tomasz Napierala l_int f_flags; 225e801ac78SEdward Tomasz Napierala l_int f_spare[4]; 2263ab85269SDavid Malone }; 2273ab85269SDavid Malone 22843bef515SMarcel Moolenaar /* sigaction flags */ 22943bef515SMarcel Moolenaar #define LINUX_SA_NOCLDSTOP 0x00000001 23043bef515SMarcel Moolenaar #define LINUX_SA_NOCLDWAIT 0x00000002 23143bef515SMarcel Moolenaar #define LINUX_SA_SIGINFO 0x00000004 23243bef515SMarcel Moolenaar #define LINUX_SA_RESTORER 0x04000000 23343bef515SMarcel Moolenaar #define LINUX_SA_ONSTACK 0x08000000 23443bef515SMarcel Moolenaar #define LINUX_SA_RESTART 0x10000000 23543bef515SMarcel Moolenaar #define LINUX_SA_INTERRUPT 0x20000000 23643bef515SMarcel Moolenaar #define LINUX_SA_NOMASK 0x40000000 23743bef515SMarcel Moolenaar #define LINUX_SA_ONESHOT 0x80000000 23843bef515SMarcel Moolenaar 23943bef515SMarcel Moolenaar /* sigprocmask actions */ 24043bef515SMarcel Moolenaar #define LINUX_SIG_BLOCK 0 24143bef515SMarcel Moolenaar #define LINUX_SIG_UNBLOCK 1 24243bef515SMarcel Moolenaar #define LINUX_SIG_SETMASK 2 24343bef515SMarcel Moolenaar 244dee4ec33SMarcel Moolenaar /* sigaltstack */ 245dee4ec33SMarcel Moolenaar #define LINUX_MINSIGSTKSZ 2048 246931a7258SAndrew Gallatin 2475002a60fSMarcel Moolenaar typedef void (*l_handler_t)(l_int); 2485002a60fSMarcel Moolenaar typedef l_ulong l_osigset_t; 249956d3333SMarcel Moolenaar 25006ebbe77SMarcel Moolenaar typedef struct { 2515002a60fSMarcel Moolenaar l_handler_t lsa_handler; 2525002a60fSMarcel Moolenaar l_osigset_t lsa_mask; 2535002a60fSMarcel Moolenaar l_ulong lsa_flags; 254956d3333SMarcel Moolenaar void (*lsa_restorer)(void); 2555002a60fSMarcel Moolenaar } l_osigaction_t; 256956d3333SMarcel Moolenaar 25706ebbe77SMarcel Moolenaar typedef struct { 2585002a60fSMarcel Moolenaar l_handler_t lsa_handler; 2595002a60fSMarcel Moolenaar l_ulong lsa_flags; 26006ebbe77SMarcel Moolenaar void (*lsa_restorer)(void); 2615002a60fSMarcel Moolenaar l_sigset_t lsa_mask; 2625002a60fSMarcel Moolenaar } l_sigaction_t; 26306ebbe77SMarcel Moolenaar 26443bef515SMarcel Moolenaar typedef struct { 26530c6d982SEdward Tomasz Napierala l_uintptr_t ss_sp; 2665002a60fSMarcel Moolenaar l_int ss_flags; 2675002a60fSMarcel Moolenaar l_size_t ss_size; 2685002a60fSMarcel Moolenaar } l_stack_t; 269ec99e322SMarcel Moolenaar 270d323ddf3SMatthew Dillon extern struct sysentvec linux_sysvec; 271c21dee17SSøren Schmidt 27243bef515SMarcel Moolenaar /* 2734d0f380dSDmitry Chagin * arch specific open/fcntl flags 27443bef515SMarcel Moolenaar */ 275aaaefc6bSRobert Drehmel #define LINUX_F_GETLK64 12 276aaaefc6bSRobert Drehmel #define LINUX_F_SETLK64 13 277aaaefc6bSRobert Drehmel #define LINUX_F_SETLKW64 14 278aaaefc6bSRobert Drehmel 2795002a60fSMarcel Moolenaar union l_semun { 2805002a60fSMarcel Moolenaar l_int val; 281f730d606SDmitry Chagin l_uintptr_t buf; 2825002a60fSMarcel Moolenaar l_ushort *array; 283f730d606SDmitry Chagin l_uintptr_t __buf; 284f730d606SDmitry Chagin l_uintptr_t __pad; 2855002a60fSMarcel Moolenaar }; 2865002a60fSMarcel Moolenaar 2875002a60fSMarcel Moolenaar struct l_ifmap { 2885002a60fSMarcel Moolenaar l_ulong mem_start; 2895002a60fSMarcel Moolenaar l_ulong mem_end; 2905002a60fSMarcel Moolenaar l_ushort base_addr; 29143bef515SMarcel Moolenaar u_char irq; 29243bef515SMarcel Moolenaar u_char dma; 29343bef515SMarcel Moolenaar u_char port; 2943713cbffSMike Smith }; 2953713cbffSMike Smith 2965002a60fSMarcel Moolenaar struct l_ifreq { 29743bef515SMarcel Moolenaar union { 29843bef515SMarcel Moolenaar char ifrn_name[LINUX_IFNAMSIZ]; 2993713cbffSMike Smith } ifr_ifrn; 3003713cbffSMike Smith 3013713cbffSMike Smith union { 3025002a60fSMarcel Moolenaar struct l_sockaddr ifru_addr; 3035002a60fSMarcel Moolenaar struct l_sockaddr ifru_dstaddr; 3045002a60fSMarcel Moolenaar struct l_sockaddr ifru_broadaddr; 3055002a60fSMarcel Moolenaar struct l_sockaddr ifru_netmask; 3065002a60fSMarcel Moolenaar struct l_sockaddr ifru_hwaddr; 307268aeb1eSDag-Erling Smørgrav l_short ifru_flags[1]; 3087ece126eSTai-hwa Liang l_int ifru_ivalue; 3095002a60fSMarcel Moolenaar l_int ifru_mtu; 3105002a60fSMarcel Moolenaar struct l_ifmap ifru_map; 3115002a60fSMarcel Moolenaar char ifru_slave[LINUX_IFNAMSIZ]; 3125002a60fSMarcel Moolenaar l_caddr_t ifru_data; 3133713cbffSMike Smith } ifr_ifru; 3143713cbffSMike Smith }; 3153713cbffSMike Smith 316a4e3bad7SJung-uk Kim #define ifr_name ifr_ifrn.ifrn_name /* Interface name */ 3173713cbffSMike Smith #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ 3187ece126eSTai-hwa Liang #define ifr_ifindex ifr_ifru.ifru_ivalue /* Interface index */ 3193713cbffSMike Smith 3209b44bfc5SAlexander Leidinger struct l_user_desc { 3219b44bfc5SAlexander Leidinger l_uint entry_number; 3229b44bfc5SAlexander Leidinger l_uint base_addr; 3239b44bfc5SAlexander Leidinger l_uint limit; 3249b44bfc5SAlexander Leidinger l_uint seg_32bit:1; 3259b44bfc5SAlexander Leidinger l_uint contents:2; 3269b44bfc5SAlexander Leidinger l_uint read_exec_only:1; 3279b44bfc5SAlexander Leidinger l_uint limit_in_pages:1; 3289b44bfc5SAlexander Leidinger l_uint seg_not_present:1; 3299b44bfc5SAlexander Leidinger l_uint useable:1; 3309b44bfc5SAlexander Leidinger }; 3319b44bfc5SAlexander Leidinger 3329b44bfc5SAlexander Leidinger struct l_desc_struct { 3339b44bfc5SAlexander Leidinger unsigned long a, b; 3349b44bfc5SAlexander Leidinger }; 3359b44bfc5SAlexander Leidinger 3369b44bfc5SAlexander Leidinger #define LINUX_LOWERWORD 0x0000ffff 3379b44bfc5SAlexander Leidinger 3380eef2f8aSAlexander Leidinger /* 339a4e3bad7SJung-uk Kim * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h. 340a4e3bad7SJung-uk Kim * These convert Linux user space descriptor to machine one. 3419b44bfc5SAlexander Leidinger */ 342a4e3bad7SJung-uk Kim #define LINUX_LDT_entry_a(info) \ 343a4e3bad7SJung-uk Kim ((((info)->base_addr & LINUX_LOWERWORD) << 16) | \ 344a4e3bad7SJung-uk Kim ((info)->limit & LINUX_LOWERWORD)) 3459b44bfc5SAlexander Leidinger 346a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_READ_EXEC_ONLY 9 347a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_CONTENTS 10 348a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_SEG_NOT_PRESENT 15 349a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_BASE_ADDR 16 350a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_USEABLE 20 351a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_SEG32BIT 22 352a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_LIMIT 23 3539b44bfc5SAlexander Leidinger 354a4e3bad7SJung-uk Kim #define LINUX_LDT_entry_b(info) \ 3559b44bfc5SAlexander Leidinger (((info)->base_addr & 0xff000000) | \ 3569b44bfc5SAlexander Leidinger ((info)->limit & 0xf0000) | \ 357a4e3bad7SJung-uk Kim ((info)->contents << LINUX_ENTRY_B_CONTENTS) | \ 358a4e3bad7SJung-uk Kim (((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) | \ 359a4e3bad7SJung-uk Kim (((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) | \ 360a4e3bad7SJung-uk Kim (((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) | \ 361a4e3bad7SJung-uk Kim ((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) | \ 362a4e3bad7SJung-uk Kim ((info)->useable << LINUX_ENTRY_B_USEABLE) | \ 363a4e3bad7SJung-uk Kim ((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000) 3649b44bfc5SAlexander Leidinger 365a4e3bad7SJung-uk Kim #define LINUX_LDT_empty(info) \ 366a4e3bad7SJung-uk Kim ((info)->base_addr == 0 && \ 3679b44bfc5SAlexander Leidinger (info)->limit == 0 && \ 3689b44bfc5SAlexander Leidinger (info)->contents == 0 && \ 3699b44bfc5SAlexander Leidinger (info)->seg_not_present == 1 && \ 3709b44bfc5SAlexander Leidinger (info)->read_exec_only == 1 && \ 3719b44bfc5SAlexander Leidinger (info)->seg_32bit == 0 && \ 3729b44bfc5SAlexander Leidinger (info)->limit_in_pages == 0 && \ 3739b44bfc5SAlexander Leidinger (info)->useable == 0) 3749b44bfc5SAlexander Leidinger 375a4e3bad7SJung-uk Kim /* 376a4e3bad7SJung-uk Kim * Macros for converting segments. 377a4e3bad7SJung-uk Kim * They do the same as those in arch/i386/kernel/process.c in Linux. 378a4e3bad7SJung-uk Kim */ 379a4e3bad7SJung-uk Kim #define LINUX_GET_BASE(desc) \ 380a4e3bad7SJung-uk Kim ((((desc)->a >> 16) & LINUX_LOWERWORD) | \ 3819b44bfc5SAlexander Leidinger (((desc)->b << 16) & 0x00ff0000) | \ 3829b44bfc5SAlexander Leidinger ((desc)->b & 0xff000000)) 3839b44bfc5SAlexander Leidinger 384a4e3bad7SJung-uk Kim #define LINUX_GET_LIMIT(desc) \ 385a4e3bad7SJung-uk Kim (((desc)->a & LINUX_LOWERWORD) | \ 3869b44bfc5SAlexander Leidinger ((desc)->b & 0xf0000)) 3879b44bfc5SAlexander Leidinger 388a4e3bad7SJung-uk Kim #define LINUX_GET_32BIT(desc) \ 389a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1) 390a4e3bad7SJung-uk Kim #define LINUX_GET_CONTENTS(desc) \ 391a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3) 392a4e3bad7SJung-uk Kim #define LINUX_GET_WRITABLE(desc) \ 393a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1) 394a4e3bad7SJung-uk Kim #define LINUX_GET_LIMIT_PAGES(desc) \ 395a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1) 396a4e3bad7SJung-uk Kim #define LINUX_GET_PRESENT(desc) \ 397a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1) 398a4e3bad7SJung-uk Kim #define LINUX_GET_USEABLE(desc) \ 399a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1) 4009b44bfc5SAlexander Leidinger 401001398c4SDmitry Chagin #define linux_copyout_rusage(r, u) copyout(r, u, sizeof(*r)) 402001398c4SDmitry Chagin 403175c6c31SKonstantin Belousov /* robust futexes */ 404175c6c31SKonstantin Belousov struct linux_robust_list { 405175c6c31SKonstantin Belousov struct linux_robust_list *next; 406175c6c31SKonstantin Belousov }; 407175c6c31SKonstantin Belousov 408175c6c31SKonstantin Belousov struct linux_robust_list_head { 409175c6c31SKonstantin Belousov struct linux_robust_list list; 41062162dfcSKonstantin Belousov l_long futex_offset; 411175c6c31SKonstantin Belousov struct linux_robust_list *pending_list; 412175c6c31SKonstantin Belousov }; 413175c6c31SKonstantin Belousov 414a4e3bad7SJung-uk Kim #endif /* !_I386_LINUX_H_ */ 415