xref: /freebsd/sys/i386/linux/linux.h (revision 2a1cf1b6b55c8326bbe85d0fdf17b0f2fb9b34ce)
1c21dee17SSøren Schmidt /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
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.
27c21dee17SSøren Schmidt  */
28c21dee17SSøren Schmidt 
29a4e3bad7SJung-uk Kim #ifndef _I386_LINUX_H_
30a4e3bad7SJung-uk Kim #define	_I386_LINUX_H_
3162c3734cSBruce Evans 
32562894f0SBrooks Davis #include <sys/abi_compat.h>
3379363394SAndrew Gallatin 
344ab7403bSDmitry Chagin #include <compat/linux/linux.h>
35ebea8660SMarcel Moolenaar #include <i386/linux/linux_syscall.h>
36c21dee17SSøren Schmidt 
37931e2a1aSEd Maste #define LINUX_LEGACY_SYSCALLS
38931e2a1aSEd Maste 
3919e252baSAlexander Leidinger #define	LINUX_DTRACE	linuxulator
4024593369SJonathan Lemon 
41*2a1cf1b6SDmitry Chagin #define	LINUX_ARCHWANT_MMAP2PGOFF	1
42*2a1cf1b6SDmitry Chagin 
4343bef515SMarcel Moolenaar /*
441b20ff34SEric Melville  * Provide a separate set of types for the Linux types.
455002a60fSMarcel Moolenaar  */
465002a60fSMarcel Moolenaar typedef int		l_int;
475002a60fSMarcel Moolenaar typedef int32_t		l_long;
485002a60fSMarcel Moolenaar typedef int64_t		l_longlong;
495002a60fSMarcel Moolenaar typedef short		l_short;
505002a60fSMarcel Moolenaar typedef unsigned int	l_uint;
515002a60fSMarcel Moolenaar typedef uint32_t	l_ulong;
525002a60fSMarcel Moolenaar typedef uint64_t	l_ulonglong;
535002a60fSMarcel Moolenaar typedef unsigned short	l_ushort;
545002a60fSMarcel Moolenaar 
555002a60fSMarcel Moolenaar typedef char		*l_caddr_t;
560e73a962STim J. Robbins typedef l_ulong		l_uintptr_t;
575002a60fSMarcel Moolenaar typedef l_long		l_clock_t;
585002a60fSMarcel Moolenaar typedef l_int		l_daddr_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 
880e26e54bSDmitry Chagin typedef struct {
890e26e54bSDmitry Chagin 	l_time64_t	tv_sec;
900e26e54bSDmitry Chagin 	l_time64_t	tv_usec;
910e26e54bSDmitry Chagin } l_sock_timeval;
920e26e54bSDmitry Chagin 
935002a60fSMarcel Moolenaar #define	l_fd_set	fd_set
945002a60fSMarcel Moolenaar 
955002a60fSMarcel Moolenaar /*
9643bef515SMarcel Moolenaar  * Miscellaneous
9743bef515SMarcel Moolenaar  */
984281dab8SDmitry Chagin #define LINUX_AT_COUNT		22	/* Count of used aux entry types.
994d7c2e8aSDmitry Chagin 					 * Keep this synchronized with
10056c5230aSDmitry Chagin 					 * linux_copyout_auxargs() 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 {
156e0bfe0d6SDmitry Chagin 	l_ulong		st_dev;
1575002a60fSMarcel Moolenaar 	l_ulong		st_ino;
1585002a60fSMarcel Moolenaar 	l_ushort	st_mode;
1595002a60fSMarcel Moolenaar 	l_ushort	st_nlink;
1605002a60fSMarcel Moolenaar 	l_ushort	st_uid;
1615002a60fSMarcel Moolenaar 	l_ushort	st_gid;
162e0bfe0d6SDmitry Chagin 	l_ulong		st_rdev;
1635002a60fSMarcel Moolenaar 	l_ulong		st_size;
1645002a60fSMarcel Moolenaar 	l_ulong		st_blksize;
1655002a60fSMarcel Moolenaar 	l_ulong		st_blocks;
166510ea843SEd Schouten 	struct l_timespec	st_atim;
167510ea843SEd Schouten 	struct l_timespec	st_mtim;
168510ea843SEd Schouten 	struct l_timespec	st_ctim;
1695002a60fSMarcel Moolenaar 	l_ulong		__unused4;
1705002a60fSMarcel Moolenaar 	l_ulong		__unused5;
1715002a60fSMarcel Moolenaar };
17243bef515SMarcel Moolenaar 
173a408fc09SDmitry Chagin /* __old_kernel_stat now */
174a408fc09SDmitry Chagin struct l_old_stat {
1751f7642e0SAlexander Leidinger 	l_ushort	st_dev;
1761f7642e0SAlexander Leidinger 	l_ulong		st_ino;
1771f7642e0SAlexander Leidinger 	l_ushort	st_mode;
1781f7642e0SAlexander Leidinger 	l_ushort	st_nlink;
1791f7642e0SAlexander Leidinger 	l_ushort	st_uid;
1801f7642e0SAlexander Leidinger 	l_ushort	st_gid;
1811f7642e0SAlexander Leidinger 	l_ushort	st_rdev;
1821f7642e0SAlexander Leidinger 	l_long		st_size;
183510ea843SEd Schouten 	struct l_timespec	st_atim;
184510ea843SEd Schouten 	struct l_timespec	st_mtim;
185510ea843SEd Schouten 	struct l_timespec	st_ctim;
1861f7642e0SAlexander Leidinger 	l_long		st_blksize;
1871f7642e0SAlexander Leidinger 	l_long		st_blocks;
1881f7642e0SAlexander Leidinger 	l_ulong		st_flags;
1891f7642e0SAlexander Leidinger 	l_ulong		st_gen;
1901f7642e0SAlexander Leidinger };
1911f7642e0SAlexander Leidinger 
1925002a60fSMarcel Moolenaar struct l_stat64 {
19380d8a4a0SDmitry Chagin 	l_ulonglong	st_dev;
19480d8a4a0SDmitry Chagin 	u_char		__pad0[4];
1955002a60fSMarcel Moolenaar 	l_ulong		__st_ino;
1965002a60fSMarcel Moolenaar 	l_uint		st_mode;
1975002a60fSMarcel Moolenaar 	l_uint		st_nlink;
1985002a60fSMarcel Moolenaar 	l_ulong		st_uid;
1995002a60fSMarcel Moolenaar 	l_ulong		st_gid;
20080d8a4a0SDmitry Chagin 	l_ulonglong	st_rdev;
20180d8a4a0SDmitry Chagin 	u_char		__pad3[4];
2025002a60fSMarcel Moolenaar 	l_longlong	st_size;
2035002a60fSMarcel Moolenaar 	l_ulong		st_blksize;
20480d8a4a0SDmitry Chagin 	l_ulonglong	st_blocks;
205510ea843SEd Schouten 	struct l_timespec	st_atim;
206510ea843SEd Schouten 	struct l_timespec	st_mtim;
207510ea843SEd Schouten 	struct l_timespec	st_ctim;
2085002a60fSMarcel Moolenaar 	l_ulonglong	st_ino;
2095002a60fSMarcel Moolenaar };
2105002a60fSMarcel Moolenaar 
2113ab85269SDavid Malone struct l_statfs64 {
2123ab85269SDavid Malone 	l_int		f_type;
2133ab85269SDavid Malone 	l_int		f_bsize;
2143ab85269SDavid Malone 	uint64_t	f_blocks;
2153ab85269SDavid Malone 	uint64_t	f_bfree;
2163ab85269SDavid Malone 	uint64_t	f_bavail;
2173ab85269SDavid Malone 	uint64_t	f_files;
2183ab85269SDavid Malone 	uint64_t	f_ffree;
2193ab85269SDavid Malone 	l_fsid_t	f_fsid;
2203ab85269SDavid Malone 	l_int		f_namelen;
221e801ac78SEdward Tomasz Napierala 	l_int		f_frsize;
222e801ac78SEdward Tomasz Napierala 	l_int		f_flags;
223e801ac78SEdward Tomasz Napierala 	l_int		f_spare[4];
2243ab85269SDavid Malone };
2253ab85269SDavid Malone 
22643bef515SMarcel Moolenaar /* sigaction flags */
22743bef515SMarcel Moolenaar #define	LINUX_SA_NOCLDSTOP	0x00000001
22843bef515SMarcel Moolenaar #define	LINUX_SA_NOCLDWAIT	0x00000002
22943bef515SMarcel Moolenaar #define	LINUX_SA_SIGINFO	0x00000004
23043bef515SMarcel Moolenaar #define	LINUX_SA_RESTORER	0x04000000
23143bef515SMarcel Moolenaar #define	LINUX_SA_ONSTACK	0x08000000
23243bef515SMarcel Moolenaar #define	LINUX_SA_RESTART	0x10000000
23343bef515SMarcel Moolenaar #define	LINUX_SA_INTERRUPT	0x20000000
23443bef515SMarcel Moolenaar #define	LINUX_SA_NOMASK		0x40000000
23543bef515SMarcel Moolenaar #define	LINUX_SA_ONESHOT	0x80000000
23643bef515SMarcel Moolenaar 
237dee4ec33SMarcel Moolenaar /* sigaltstack */
238dee4ec33SMarcel Moolenaar #define	LINUX_MINSIGSTKSZ	2048
239931a7258SAndrew Gallatin 
2405002a60fSMarcel Moolenaar typedef void	(*l_handler_t)(l_int);
2415002a60fSMarcel Moolenaar typedef l_ulong	l_osigset_t;
242956d3333SMarcel Moolenaar 
24306ebbe77SMarcel Moolenaar typedef struct {
2445002a60fSMarcel Moolenaar 	l_handler_t	lsa_handler;
2455002a60fSMarcel Moolenaar 	l_osigset_t	lsa_mask;
2465002a60fSMarcel Moolenaar 	l_ulong		lsa_flags;
247956d3333SMarcel Moolenaar 	void	(*lsa_restorer)(void);
2485002a60fSMarcel Moolenaar } l_osigaction_t;
249956d3333SMarcel Moolenaar 
25006ebbe77SMarcel Moolenaar typedef struct {
2515002a60fSMarcel Moolenaar 	l_handler_t	lsa_handler;
2525002a60fSMarcel Moolenaar 	l_ulong		lsa_flags;
25306ebbe77SMarcel Moolenaar 	void	(*lsa_restorer)(void);
2545002a60fSMarcel Moolenaar 	l_sigset_t	lsa_mask;
2555002a60fSMarcel Moolenaar } l_sigaction_t;
25606ebbe77SMarcel Moolenaar 
25743bef515SMarcel Moolenaar typedef struct {
25830c6d982SEdward Tomasz Napierala 	l_uintptr_t	ss_sp;
2595002a60fSMarcel Moolenaar 	l_int		ss_flags;
2605002a60fSMarcel Moolenaar 	l_size_t	ss_size;
2615002a60fSMarcel Moolenaar } l_stack_t;
262ec99e322SMarcel Moolenaar 
263d323ddf3SMatthew Dillon extern struct sysentvec linux_sysvec;
264c21dee17SSøren Schmidt 
26543bef515SMarcel Moolenaar /*
2664d0f380dSDmitry Chagin  * arch specific open/fcntl flags
26743bef515SMarcel Moolenaar  */
268aaaefc6bSRobert Drehmel #define	LINUX_F_GETLK64		12
269aaaefc6bSRobert Drehmel #define	LINUX_F_SETLK64		13
270aaaefc6bSRobert Drehmel #define	LINUX_F_SETLKW64	14
271aaaefc6bSRobert Drehmel 
2725002a60fSMarcel Moolenaar union l_semun {
2735002a60fSMarcel Moolenaar 	l_int		val;
274f730d606SDmitry Chagin 	l_uintptr_t	buf;
2755002a60fSMarcel Moolenaar 	l_ushort	*array;
276f730d606SDmitry Chagin 	l_uintptr_t	__buf;
277f730d606SDmitry Chagin 	l_uintptr_t	__pad;
2785002a60fSMarcel Moolenaar };
2795002a60fSMarcel Moolenaar 
2809b44bfc5SAlexander Leidinger struct l_user_desc {
2819b44bfc5SAlexander Leidinger 	l_uint		entry_number;
2829b44bfc5SAlexander Leidinger 	l_uint		base_addr;
2839b44bfc5SAlexander Leidinger 	l_uint		limit;
2849b44bfc5SAlexander Leidinger 	l_uint		seg_32bit:1;
2859b44bfc5SAlexander Leidinger 	l_uint		contents:2;
2869b44bfc5SAlexander Leidinger 	l_uint		read_exec_only:1;
2879b44bfc5SAlexander Leidinger 	l_uint		limit_in_pages:1;
2889b44bfc5SAlexander Leidinger 	l_uint		seg_not_present:1;
2899b44bfc5SAlexander Leidinger 	l_uint		useable:1;
2909b44bfc5SAlexander Leidinger };
2919b44bfc5SAlexander Leidinger 
2929b44bfc5SAlexander Leidinger struct l_desc_struct {
2939b44bfc5SAlexander Leidinger 	unsigned long	a, b;
2949b44bfc5SAlexander Leidinger };
2959b44bfc5SAlexander Leidinger 
2969b44bfc5SAlexander Leidinger #define	LINUX_LOWERWORD	0x0000ffff
2979b44bfc5SAlexander Leidinger 
2980eef2f8aSAlexander Leidinger /*
299a4e3bad7SJung-uk Kim  * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h.
300a4e3bad7SJung-uk Kim  * These convert Linux user space descriptor to machine one.
3019b44bfc5SAlexander Leidinger  */
302a4e3bad7SJung-uk Kim #define	LINUX_LDT_entry_a(info)					\
303a4e3bad7SJung-uk Kim 	((((info)->base_addr & LINUX_LOWERWORD) << 16) |	\
304a4e3bad7SJung-uk Kim 	((info)->limit & LINUX_LOWERWORD))
3059b44bfc5SAlexander Leidinger 
306a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_READ_EXEC_ONLY	9
307a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_CONTENTS		10
308a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_SEG_NOT_PRESENT	15
309a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_BASE_ADDR		16
310a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_USEABLE		20
311a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_SEG32BIT		22
312a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_LIMIT		23
3139b44bfc5SAlexander Leidinger 
314a4e3bad7SJung-uk Kim #define	LINUX_LDT_entry_b(info)							\
3159b44bfc5SAlexander Leidinger 	(((info)->base_addr & 0xff000000) |					\
3169b44bfc5SAlexander Leidinger 	((info)->limit & 0xf0000) |						\
317a4e3bad7SJung-uk Kim 	((info)->contents << LINUX_ENTRY_B_CONTENTS) |				\
318a4e3bad7SJung-uk Kim 	(((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) |	\
319a4e3bad7SJung-uk Kim 	(((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) |		\
320a4e3bad7SJung-uk Kim 	(((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) |	\
321a4e3bad7SJung-uk Kim 	((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) |				\
322a4e3bad7SJung-uk Kim 	((info)->useable << LINUX_ENTRY_B_USEABLE) |				\
323a4e3bad7SJung-uk Kim 	((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000)
3249b44bfc5SAlexander Leidinger 
325a4e3bad7SJung-uk Kim #define	LINUX_LDT_empty(info)		\
326a4e3bad7SJung-uk Kim 	((info)->base_addr == 0 &&	\
3279b44bfc5SAlexander Leidinger 	(info)->limit == 0 &&		\
3289b44bfc5SAlexander Leidinger 	(info)->contents == 0 &&	\
3299b44bfc5SAlexander Leidinger 	(info)->seg_not_present == 1 &&	\
3309b44bfc5SAlexander Leidinger 	(info)->read_exec_only == 1 &&	\
3319b44bfc5SAlexander Leidinger 	(info)->seg_32bit == 0 &&	\
3329b44bfc5SAlexander Leidinger 	(info)->limit_in_pages == 0 &&	\
3339b44bfc5SAlexander Leidinger 	(info)->useable == 0)
3349b44bfc5SAlexander Leidinger 
335a4e3bad7SJung-uk Kim /*
336a4e3bad7SJung-uk Kim  * Macros for converting segments.
337a4e3bad7SJung-uk Kim  * They do the same as those in arch/i386/kernel/process.c in Linux.
338a4e3bad7SJung-uk Kim  */
339a4e3bad7SJung-uk Kim #define	LINUX_GET_BASE(desc)				\
340a4e3bad7SJung-uk Kim 	((((desc)->a >> 16) & LINUX_LOWERWORD) |	\
3419b44bfc5SAlexander Leidinger 	(((desc)->b << 16) & 0x00ff0000) |		\
3429b44bfc5SAlexander Leidinger 	((desc)->b & 0xff000000))
3439b44bfc5SAlexander Leidinger 
344a4e3bad7SJung-uk Kim #define	LINUX_GET_LIMIT(desc)			\
345a4e3bad7SJung-uk Kim 	(((desc)->a & LINUX_LOWERWORD) |	\
3469b44bfc5SAlexander Leidinger 	((desc)->b & 0xf0000))
3479b44bfc5SAlexander Leidinger 
348a4e3bad7SJung-uk Kim #define	LINUX_GET_32BIT(desc)		\
349a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1)
350a4e3bad7SJung-uk Kim #define	LINUX_GET_CONTENTS(desc)	\
351a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3)
352a4e3bad7SJung-uk Kim #define	LINUX_GET_WRITABLE(desc)	\
353a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1)
354a4e3bad7SJung-uk Kim #define	LINUX_GET_LIMIT_PAGES(desc)	\
355a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1)
356a4e3bad7SJung-uk Kim #define	LINUX_GET_PRESENT(desc)		\
357a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1)
358a4e3bad7SJung-uk Kim #define	LINUX_GET_USEABLE(desc)		\
359a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1)
3609b44bfc5SAlexander Leidinger 
361001398c4SDmitry Chagin #define	linux_copyout_rusage(r, u)	copyout(r, u, sizeof(*r))
362001398c4SDmitry Chagin 
363cc1b0f7dSDmitry Chagin /* This corresponds to 'struct user_regs_struct' in Linux. */
364cc1b0f7dSDmitry Chagin struct linux_pt_regset {
365cc1b0f7dSDmitry Chagin 	l_uint ebx;
366cc1b0f7dSDmitry Chagin 	l_uint ecx;
367cc1b0f7dSDmitry Chagin 	l_uint edx;
368cc1b0f7dSDmitry Chagin 	l_uint esi;
369cc1b0f7dSDmitry Chagin 	l_uint edi;
370cc1b0f7dSDmitry Chagin 	l_uint ebp;
371cc1b0f7dSDmitry Chagin 	l_uint eax;
372cc1b0f7dSDmitry Chagin 	l_uint ds;
373cc1b0f7dSDmitry Chagin 	l_uint es;
374cc1b0f7dSDmitry Chagin 	l_uint fs;
375cc1b0f7dSDmitry Chagin 	l_uint gs;
376cc1b0f7dSDmitry Chagin 	l_uint orig_eax;
377cc1b0f7dSDmitry Chagin 	l_uint eip;
378cc1b0f7dSDmitry Chagin 	l_uint cs;
379cc1b0f7dSDmitry Chagin 	l_uint eflags;
380cc1b0f7dSDmitry Chagin 	l_uint esp;
381cc1b0f7dSDmitry Chagin 	l_uint ss;
382cc1b0f7dSDmitry Chagin };
383cc1b0f7dSDmitry Chagin 
384cc1b0f7dSDmitry Chagin #ifdef _KERNEL
385cc1b0f7dSDmitry Chagin struct reg;
386cc1b0f7dSDmitry Chagin 
387cc1b0f7dSDmitry Chagin void	bsd_to_linux_regset(const struct reg *b_reg,
388cc1b0f7dSDmitry Chagin 	    struct linux_pt_regset *l_regset);
389cc1b0f7dSDmitry Chagin #endif /* _KERNEL */
390cc1b0f7dSDmitry Chagin 
391a4e3bad7SJung-uk Kim #endif /* !_I386_LINUX_H_ */
392