xref: /freebsd/sys/i386/linux/linux.h (revision af557e649cf229e45a83767c3c4a7daeb92f0b01)
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 
77*af557e64SDmitry Chagin #include <compat/linux/linux_siginfo.h>
78*af557e64SDmitry 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 
885002a60fSMarcel Moolenaar #define	l_fd_set	fd_set
895002a60fSMarcel Moolenaar 
905002a60fSMarcel Moolenaar /*
9143bef515SMarcel Moolenaar  * Miscellaneous
9243bef515SMarcel Moolenaar  */
934048f59cSDmitry Chagin #define LINUX_AT_COUNT		20	/* Count of used aux entry types.
944d7c2e8aSDmitry Chagin 					 * Keep this synchronized with
95dc858467SEd Maste 					 * linux_fixup_elf() code.
964d7c2e8aSDmitry Chagin 					 */
975002a60fSMarcel Moolenaar struct l___sysctl_args
985002a60fSMarcel Moolenaar {
995002a60fSMarcel Moolenaar 	l_int		*name;
1005002a60fSMarcel Moolenaar 	l_int		nlen;
1015002a60fSMarcel Moolenaar 	void		*oldval;
1025002a60fSMarcel Moolenaar 	l_size_t	*oldlenp;
1035002a60fSMarcel Moolenaar 	void		*newval;
1045002a60fSMarcel Moolenaar 	l_size_t	newlen;
1055002a60fSMarcel Moolenaar 	l_ulong		__spare[4];
1065002a60fSMarcel Moolenaar };
1075002a60fSMarcel Moolenaar 
10843bef515SMarcel Moolenaar /* Resource limits */
10943bef515SMarcel Moolenaar #define	LINUX_RLIMIT_CPU	0
11043bef515SMarcel Moolenaar #define	LINUX_RLIMIT_FSIZE	1
11143bef515SMarcel Moolenaar #define	LINUX_RLIMIT_DATA	2
11243bef515SMarcel Moolenaar #define	LINUX_RLIMIT_STACK	3
11343bef515SMarcel Moolenaar #define	LINUX_RLIMIT_CORE	4
11443bef515SMarcel Moolenaar #define	LINUX_RLIMIT_RSS	5
11543bef515SMarcel Moolenaar #define	LINUX_RLIMIT_NPROC	6
11643bef515SMarcel Moolenaar #define	LINUX_RLIMIT_NOFILE	7
11743bef515SMarcel Moolenaar #define	LINUX_RLIMIT_MEMLOCK	8
118a4e3bad7SJung-uk Kim #define	LINUX_RLIMIT_AS		9	/* Address space limit */
11943bef515SMarcel Moolenaar 
12043bef515SMarcel Moolenaar #define	LINUX_RLIM_NLIMITS	10
12143bef515SMarcel Moolenaar 
1225002a60fSMarcel Moolenaar struct l_rlimit {
1235002a60fSMarcel Moolenaar 	l_ulong rlim_cur;
1245002a60fSMarcel Moolenaar 	l_ulong rlim_max;
1255002a60fSMarcel Moolenaar };
1265002a60fSMarcel Moolenaar 
12710931a46SJung-uk Kim struct l_mmap_argv {
12810931a46SJung-uk Kim 	l_uintptr_t	addr;
12910931a46SJung-uk Kim 	l_size_t	len;
13010931a46SJung-uk Kim 	l_int		prot;
13110931a46SJung-uk Kim 	l_int		flags;
13210931a46SJung-uk Kim 	l_int		fd;
13310931a46SJung-uk Kim 	l_off_t		pgoff;
13419593f77SDmitry Chagin };
13510931a46SJung-uk Kim 
1365002a60fSMarcel Moolenaar /*
1375002a60fSMarcel Moolenaar  * stat family of syscalls
1385002a60fSMarcel Moolenaar  */
1395002a60fSMarcel Moolenaar struct l_timespec {
14077424f41SJung-uk Kim 	l_time_t	tv_sec;
14177424f41SJung-uk Kim 	l_long		tv_nsec;
1425002a60fSMarcel Moolenaar };
14343bef515SMarcel Moolenaar 
144bfcce1a9SDmitry Chagin /* __kernel_timespec */
145bfcce1a9SDmitry Chagin struct l_timespec64 {
146bfcce1a9SDmitry Chagin 	l_time64_t	tv_sec;
147bfcce1a9SDmitry Chagin 	l_longlong	tv_nsec;
148bfcce1a9SDmitry Chagin };
149bfcce1a9SDmitry Chagin 
1505002a60fSMarcel Moolenaar struct l_newstat {
1515002a60fSMarcel Moolenaar 	l_ushort	st_dev;
1525002a60fSMarcel Moolenaar 	l_ushort	__pad1;
1535002a60fSMarcel Moolenaar 	l_ulong		st_ino;
1545002a60fSMarcel Moolenaar 	l_ushort	st_mode;
1555002a60fSMarcel Moolenaar 	l_ushort	st_nlink;
1565002a60fSMarcel Moolenaar 	l_ushort	st_uid;
1575002a60fSMarcel Moolenaar 	l_ushort	st_gid;
1585002a60fSMarcel Moolenaar 	l_ushort	st_rdev;
1595002a60fSMarcel Moolenaar 	l_ushort	__pad2;
1605002a60fSMarcel Moolenaar 	l_ulong		st_size;
1615002a60fSMarcel Moolenaar 	l_ulong		st_blksize;
1625002a60fSMarcel Moolenaar 	l_ulong		st_blocks;
163510ea843SEd Schouten 	struct l_timespec	st_atim;
164510ea843SEd Schouten 	struct l_timespec	st_mtim;
165510ea843SEd Schouten 	struct l_timespec	st_ctim;
1665002a60fSMarcel Moolenaar 	l_ulong		__unused4;
1675002a60fSMarcel Moolenaar 	l_ulong		__unused5;
1685002a60fSMarcel Moolenaar };
16943bef515SMarcel Moolenaar 
1701f7642e0SAlexander Leidinger struct l_stat {
1711f7642e0SAlexander Leidinger 	l_ushort	st_dev;
1721f7642e0SAlexander Leidinger 	l_ulong		st_ino;
1731f7642e0SAlexander Leidinger 	l_ushort	st_mode;
1741f7642e0SAlexander Leidinger 	l_ushort	st_nlink;
1751f7642e0SAlexander Leidinger 	l_ushort	st_uid;
1761f7642e0SAlexander Leidinger 	l_ushort	st_gid;
1771f7642e0SAlexander Leidinger 	l_ushort	st_rdev;
1781f7642e0SAlexander Leidinger 	l_long		st_size;
179510ea843SEd Schouten 	struct l_timespec	st_atim;
180510ea843SEd Schouten 	struct l_timespec	st_mtim;
181510ea843SEd Schouten 	struct l_timespec	st_ctim;
1821f7642e0SAlexander Leidinger 	l_long		st_blksize;
1831f7642e0SAlexander Leidinger 	l_long		st_blocks;
1841f7642e0SAlexander Leidinger 	l_ulong		st_flags;
1851f7642e0SAlexander Leidinger 	l_ulong		st_gen;
1861f7642e0SAlexander Leidinger };
1871f7642e0SAlexander Leidinger 
1885002a60fSMarcel Moolenaar struct l_stat64 {
1895002a60fSMarcel Moolenaar 	l_ushort	st_dev;
1905002a60fSMarcel Moolenaar 	u_char		__pad0[10];
1915002a60fSMarcel Moolenaar 	l_ulong		__st_ino;
1925002a60fSMarcel Moolenaar 	l_uint		st_mode;
1935002a60fSMarcel Moolenaar 	l_uint		st_nlink;
1945002a60fSMarcel Moolenaar 	l_ulong		st_uid;
1955002a60fSMarcel Moolenaar 	l_ulong		st_gid;
1965002a60fSMarcel Moolenaar 	l_ushort	st_rdev;
1975002a60fSMarcel Moolenaar 	u_char		__pad3[10];
1985002a60fSMarcel Moolenaar 	l_longlong	st_size;
1995002a60fSMarcel Moolenaar 	l_ulong		st_blksize;
2005002a60fSMarcel Moolenaar 	l_ulong		st_blocks;
2015002a60fSMarcel Moolenaar 	l_ulong		__pad4;
202510ea843SEd Schouten 	struct l_timespec	st_atim;
203510ea843SEd Schouten 	struct l_timespec	st_mtim;
204510ea843SEd Schouten 	struct l_timespec	st_ctim;
2055002a60fSMarcel Moolenaar 	l_ulonglong	st_ino;
2065002a60fSMarcel Moolenaar };
2075002a60fSMarcel Moolenaar 
2083ab85269SDavid Malone struct l_statfs64 {
2093ab85269SDavid Malone 	l_int		f_type;
2103ab85269SDavid Malone 	l_int		f_bsize;
2113ab85269SDavid Malone 	uint64_t	f_blocks;
2123ab85269SDavid Malone 	uint64_t	f_bfree;
2133ab85269SDavid Malone 	uint64_t	f_bavail;
2143ab85269SDavid Malone 	uint64_t	f_files;
2153ab85269SDavid Malone 	uint64_t	f_ffree;
2163ab85269SDavid Malone 	l_fsid_t	f_fsid;
2173ab85269SDavid Malone 	l_int		f_namelen;
218e801ac78SEdward Tomasz Napierala 	l_int		f_frsize;
219e801ac78SEdward Tomasz Napierala 	l_int		f_flags;
220e801ac78SEdward Tomasz Napierala 	l_int		f_spare[4];
2213ab85269SDavid Malone };
2223ab85269SDavid Malone 
22343bef515SMarcel Moolenaar /* sigaction flags */
22443bef515SMarcel Moolenaar #define	LINUX_SA_NOCLDSTOP	0x00000001
22543bef515SMarcel Moolenaar #define	LINUX_SA_NOCLDWAIT	0x00000002
22643bef515SMarcel Moolenaar #define	LINUX_SA_SIGINFO	0x00000004
22743bef515SMarcel Moolenaar #define	LINUX_SA_RESTORER	0x04000000
22843bef515SMarcel Moolenaar #define	LINUX_SA_ONSTACK	0x08000000
22943bef515SMarcel Moolenaar #define	LINUX_SA_RESTART	0x10000000
23043bef515SMarcel Moolenaar #define	LINUX_SA_INTERRUPT	0x20000000
23143bef515SMarcel Moolenaar #define	LINUX_SA_NOMASK		0x40000000
23243bef515SMarcel Moolenaar #define	LINUX_SA_ONESHOT	0x80000000
23343bef515SMarcel Moolenaar 
23443bef515SMarcel Moolenaar /* sigprocmask actions */
23543bef515SMarcel Moolenaar #define	LINUX_SIG_BLOCK		0
23643bef515SMarcel Moolenaar #define	LINUX_SIG_UNBLOCK	1
23743bef515SMarcel Moolenaar #define	LINUX_SIG_SETMASK	2
23843bef515SMarcel Moolenaar 
239dee4ec33SMarcel Moolenaar /* sigaltstack */
240dee4ec33SMarcel Moolenaar #define	LINUX_MINSIGSTKSZ	2048
241931a7258SAndrew Gallatin 
2425002a60fSMarcel Moolenaar typedef void	(*l_handler_t)(l_int);
2435002a60fSMarcel Moolenaar typedef l_ulong	l_osigset_t;
244956d3333SMarcel Moolenaar 
24506ebbe77SMarcel Moolenaar typedef struct {
2465002a60fSMarcel Moolenaar 	l_handler_t	lsa_handler;
2475002a60fSMarcel Moolenaar 	l_osigset_t	lsa_mask;
2485002a60fSMarcel Moolenaar 	l_ulong		lsa_flags;
249956d3333SMarcel Moolenaar 	void	(*lsa_restorer)(void);
2505002a60fSMarcel Moolenaar } l_osigaction_t;
251956d3333SMarcel Moolenaar 
25206ebbe77SMarcel Moolenaar typedef struct {
2535002a60fSMarcel Moolenaar 	l_handler_t	lsa_handler;
2545002a60fSMarcel Moolenaar 	l_ulong		lsa_flags;
25506ebbe77SMarcel Moolenaar 	void	(*lsa_restorer)(void);
2565002a60fSMarcel Moolenaar 	l_sigset_t	lsa_mask;
2575002a60fSMarcel Moolenaar } l_sigaction_t;
25806ebbe77SMarcel Moolenaar 
25943bef515SMarcel Moolenaar typedef struct {
26030c6d982SEdward Tomasz Napierala 	l_uintptr_t	ss_sp;
2615002a60fSMarcel Moolenaar 	l_int		ss_flags;
2625002a60fSMarcel Moolenaar 	l_size_t	ss_size;
2635002a60fSMarcel Moolenaar } l_stack_t;
264ec99e322SMarcel Moolenaar 
265d323ddf3SMatthew Dillon extern struct sysentvec linux_sysvec;
266c21dee17SSøren Schmidt 
26743bef515SMarcel Moolenaar /*
2684d0f380dSDmitry Chagin  * arch specific open/fcntl flags
26943bef515SMarcel Moolenaar  */
270aaaefc6bSRobert Drehmel #define	LINUX_F_GETLK64		12
271aaaefc6bSRobert Drehmel #define	LINUX_F_SETLK64		13
272aaaefc6bSRobert Drehmel #define	LINUX_F_SETLKW64	14
273aaaefc6bSRobert Drehmel 
2745002a60fSMarcel Moolenaar union l_semun {
2755002a60fSMarcel Moolenaar 	l_int		val;
276f730d606SDmitry Chagin 	l_uintptr_t	buf;
2775002a60fSMarcel Moolenaar 	l_ushort	*array;
278f730d606SDmitry Chagin 	l_uintptr_t	__buf;
279f730d606SDmitry Chagin 	l_uintptr_t	__pad;
2805002a60fSMarcel Moolenaar };
2815002a60fSMarcel Moolenaar 
2825002a60fSMarcel Moolenaar struct l_ifmap {
2835002a60fSMarcel Moolenaar 	l_ulong		mem_start;
2845002a60fSMarcel Moolenaar 	l_ulong		mem_end;
2855002a60fSMarcel Moolenaar 	l_ushort	base_addr;
28643bef515SMarcel Moolenaar 	u_char		irq;
28743bef515SMarcel Moolenaar 	u_char		dma;
28843bef515SMarcel Moolenaar 	u_char		port;
2893713cbffSMike Smith };
2903713cbffSMike Smith 
2915002a60fSMarcel Moolenaar struct l_ifreq {
29243bef515SMarcel Moolenaar 	union {
29343bef515SMarcel Moolenaar 		char	ifrn_name[LINUX_IFNAMSIZ];
2943713cbffSMike Smith 	} ifr_ifrn;
2953713cbffSMike Smith 
2963713cbffSMike Smith 	union {
2975002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_addr;
2985002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_dstaddr;
2995002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_broadaddr;
3005002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_netmask;
3015002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_hwaddr;
302268aeb1eSDag-Erling Smørgrav 		l_short		ifru_flags[1];
3037ece126eSTai-hwa Liang 		l_int		ifru_ivalue;
3045002a60fSMarcel Moolenaar 		l_int		ifru_mtu;
3055002a60fSMarcel Moolenaar 		struct l_ifmap	ifru_map;
3065002a60fSMarcel Moolenaar 		char		ifru_slave[LINUX_IFNAMSIZ];
3075002a60fSMarcel Moolenaar 		l_caddr_t	ifru_data;
3083713cbffSMike Smith 	} ifr_ifru;
3093713cbffSMike Smith };
3103713cbffSMike Smith 
311a4e3bad7SJung-uk Kim #define	ifr_name	ifr_ifrn.ifrn_name	/* Interface name */
3123713cbffSMike Smith #define	ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address */
3137ece126eSTai-hwa Liang #define	ifr_ifindex	ifr_ifru.ifru_ivalue	/* Interface index */
3143713cbffSMike Smith 
3159b44bfc5SAlexander Leidinger struct l_user_desc {
3169b44bfc5SAlexander Leidinger 	l_uint		entry_number;
3179b44bfc5SAlexander Leidinger 	l_uint		base_addr;
3189b44bfc5SAlexander Leidinger 	l_uint		limit;
3199b44bfc5SAlexander Leidinger 	l_uint		seg_32bit:1;
3209b44bfc5SAlexander Leidinger 	l_uint		contents:2;
3219b44bfc5SAlexander Leidinger 	l_uint		read_exec_only:1;
3229b44bfc5SAlexander Leidinger 	l_uint		limit_in_pages:1;
3239b44bfc5SAlexander Leidinger 	l_uint		seg_not_present:1;
3249b44bfc5SAlexander Leidinger 	l_uint		useable:1;
3259b44bfc5SAlexander Leidinger };
3269b44bfc5SAlexander Leidinger 
3279b44bfc5SAlexander Leidinger struct l_desc_struct {
3289b44bfc5SAlexander Leidinger 	unsigned long	a, b;
3299b44bfc5SAlexander Leidinger };
3309b44bfc5SAlexander Leidinger 
3319b44bfc5SAlexander Leidinger #define	LINUX_LOWERWORD	0x0000ffff
3329b44bfc5SAlexander Leidinger 
3330eef2f8aSAlexander Leidinger /*
334a4e3bad7SJung-uk Kim  * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h.
335a4e3bad7SJung-uk Kim  * These convert Linux user space descriptor to machine one.
3369b44bfc5SAlexander Leidinger  */
337a4e3bad7SJung-uk Kim #define	LINUX_LDT_entry_a(info)					\
338a4e3bad7SJung-uk Kim 	((((info)->base_addr & LINUX_LOWERWORD) << 16) |	\
339a4e3bad7SJung-uk Kim 	((info)->limit & LINUX_LOWERWORD))
3409b44bfc5SAlexander Leidinger 
341a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_READ_EXEC_ONLY	9
342a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_CONTENTS		10
343a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_SEG_NOT_PRESENT	15
344a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_BASE_ADDR		16
345a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_USEABLE		20
346a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_SEG32BIT		22
347a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_LIMIT		23
3489b44bfc5SAlexander Leidinger 
349a4e3bad7SJung-uk Kim #define	LINUX_LDT_entry_b(info)							\
3509b44bfc5SAlexander Leidinger 	(((info)->base_addr & 0xff000000) |					\
3519b44bfc5SAlexander Leidinger 	((info)->limit & 0xf0000) |						\
352a4e3bad7SJung-uk Kim 	((info)->contents << LINUX_ENTRY_B_CONTENTS) |				\
353a4e3bad7SJung-uk Kim 	(((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) |	\
354a4e3bad7SJung-uk Kim 	(((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) |		\
355a4e3bad7SJung-uk Kim 	(((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) |	\
356a4e3bad7SJung-uk Kim 	((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) |				\
357a4e3bad7SJung-uk Kim 	((info)->useable << LINUX_ENTRY_B_USEABLE) |				\
358a4e3bad7SJung-uk Kim 	((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000)
3599b44bfc5SAlexander Leidinger 
360a4e3bad7SJung-uk Kim #define	LINUX_LDT_empty(info)		\
361a4e3bad7SJung-uk Kim 	((info)->base_addr == 0 &&	\
3629b44bfc5SAlexander Leidinger 	(info)->limit == 0 &&		\
3639b44bfc5SAlexander Leidinger 	(info)->contents == 0 &&	\
3649b44bfc5SAlexander Leidinger 	(info)->seg_not_present == 1 &&	\
3659b44bfc5SAlexander Leidinger 	(info)->read_exec_only == 1 &&	\
3669b44bfc5SAlexander Leidinger 	(info)->seg_32bit == 0 &&	\
3679b44bfc5SAlexander Leidinger 	(info)->limit_in_pages == 0 &&	\
3689b44bfc5SAlexander Leidinger 	(info)->useable == 0)
3699b44bfc5SAlexander Leidinger 
370a4e3bad7SJung-uk Kim /*
371a4e3bad7SJung-uk Kim  * Macros for converting segments.
372a4e3bad7SJung-uk Kim  * They do the same as those in arch/i386/kernel/process.c in Linux.
373a4e3bad7SJung-uk Kim  */
374a4e3bad7SJung-uk Kim #define	LINUX_GET_BASE(desc)				\
375a4e3bad7SJung-uk Kim 	((((desc)->a >> 16) & LINUX_LOWERWORD) |	\
3769b44bfc5SAlexander Leidinger 	(((desc)->b << 16) & 0x00ff0000) |		\
3779b44bfc5SAlexander Leidinger 	((desc)->b & 0xff000000))
3789b44bfc5SAlexander Leidinger 
379a4e3bad7SJung-uk Kim #define	LINUX_GET_LIMIT(desc)			\
380a4e3bad7SJung-uk Kim 	(((desc)->a & LINUX_LOWERWORD) |	\
3819b44bfc5SAlexander Leidinger 	((desc)->b & 0xf0000))
3829b44bfc5SAlexander Leidinger 
383a4e3bad7SJung-uk Kim #define	LINUX_GET_32BIT(desc)		\
384a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1)
385a4e3bad7SJung-uk Kim #define	LINUX_GET_CONTENTS(desc)	\
386a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3)
387a4e3bad7SJung-uk Kim #define	LINUX_GET_WRITABLE(desc)	\
388a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1)
389a4e3bad7SJung-uk Kim #define	LINUX_GET_LIMIT_PAGES(desc)	\
390a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1)
391a4e3bad7SJung-uk Kim #define	LINUX_GET_PRESENT(desc)		\
392a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1)
393a4e3bad7SJung-uk Kim #define	LINUX_GET_USEABLE(desc)		\
394a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1)
3959b44bfc5SAlexander Leidinger 
396001398c4SDmitry Chagin #define	linux_copyout_rusage(r, u)	copyout(r, u, sizeof(*r))
397001398c4SDmitry Chagin 
398175c6c31SKonstantin Belousov /* robust futexes */
399175c6c31SKonstantin Belousov struct linux_robust_list {
400175c6c31SKonstantin Belousov 	struct linux_robust_list	*next;
401175c6c31SKonstantin Belousov };
402175c6c31SKonstantin Belousov 
403175c6c31SKonstantin Belousov struct linux_robust_list_head {
404175c6c31SKonstantin Belousov 	struct linux_robust_list	list;
40562162dfcSKonstantin Belousov 	l_long				futex_offset;
406175c6c31SKonstantin Belousov 	struct linux_robust_list	*pending_list;
407175c6c31SKonstantin Belousov };
408175c6c31SKonstantin Belousov 
409a4e3bad7SJung-uk Kim #endif /* !_I386_LINUX_H_ */
410