xref: /freebsd/sys/i386/linux/linux.h (revision 3e89b64168e77c413823002dd58be6a081970629)
1c21dee17SSøren Schmidt /*-
29a14aa01SUlrich Spörlein  * Copyright (c) 1994-1996 Søren Schmidt
3c21dee17SSøren Schmidt  * All rights reserved.
4c21dee17SSøren Schmidt  *
5c21dee17SSøren Schmidt  * Redistribution and use in source and binary forms, with or without
6c21dee17SSøren Schmidt  * modification, are permitted provided that the following conditions
7c21dee17SSøren Schmidt  * are met:
8c21dee17SSøren Schmidt  * 1. Redistributions of source code must retain the above copyright
9c21dee17SSøren Schmidt  *    notice, this list of conditions and the following disclaimer
10c21dee17SSøren Schmidt  *    in this position and unchanged.
11c21dee17SSøren Schmidt  * 2. Redistributions in binary form must reproduce the above copyright
12c21dee17SSøren Schmidt  *    notice, this list of conditions and the following disclaimer in the
13c21dee17SSøren Schmidt  *    documentation and/or other materials provided with the distribution.
14c21dee17SSøren Schmidt  * 3. The name of the author may not be used to endorse or promote products
156c5e9bbdSMike Pritchard  *    derived from this software without specific prior written permission
16c21dee17SSøren Schmidt  *
17c21dee17SSøren Schmidt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18c21dee17SSøren Schmidt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19c21dee17SSøren Schmidt  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20c21dee17SSøren Schmidt  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21c21dee17SSøren Schmidt  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22c21dee17SSøren Schmidt  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23c21dee17SSøren Schmidt  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24c21dee17SSøren Schmidt  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25c21dee17SSøren Schmidt  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26c21dee17SSøren Schmidt  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27c21dee17SSøren Schmidt  *
28c3aac50fSPeter Wemm  * $FreeBSD$
29c21dee17SSøren Schmidt  */
30c21dee17SSøren Schmidt 
31a4e3bad7SJung-uk Kim #ifndef _I386_LINUX_H_
32a4e3bad7SJung-uk Kim #define	_I386_LINUX_H_
3362c3734cSBruce Evans 
3479363394SAndrew Gallatin #include <sys/signal.h>	/* for sigval union */
3579363394SAndrew Gallatin 
36ebea8660SMarcel Moolenaar #include <i386/linux/linux_syscall.h>
37c21dee17SSøren Schmidt 
3824593369SJonathan Lemon /*
3924593369SJonathan Lemon  * debugging support
4024593369SJonathan Lemon  */
4124593369SJonathan Lemon extern u_char linux_debug_map[];
4224593369SJonathan Lemon #define	ldebug(name)	isclr(linux_debug_map, LINUX_SYS_linux_ ## name)
431d80c8a8SDmitry Chagin #define	ARGS(nm, fmt)	"linux(%ld/%ld): "#nm"("fmt")\n",			\
441d80c8a8SDmitry Chagin 			(long)td->td_proc->p_pid, (long)td->td_tid
451d80c8a8SDmitry Chagin #define	LMSG(fmt)	"linux(%ld/%ld): "fmt"\n",				\
461d80c8a8SDmitry Chagin 			(long)td->td_proc->p_pid, (long)td->td_tid
4719e252baSAlexander Leidinger #define	LINUX_DTRACE	linuxulator
4824593369SJonathan Lemon 
498f1e49a6SDmitry Chagin #define	LINUX_SHAREDPAGE	(VM_MAXUSER_ADDRESS - PAGE_SIZE)
508f1e49a6SDmitry Chagin #define	LINUX_USRSTACK		LINUX_SHAREDPAGE
518f1e49a6SDmitry Chagin 
520e73a962STim J. Robbins #define	PTRIN(v)	(void *)(v)
530e73a962STim J. Robbins #define	PTROUT(v)	(l_uintptr_t)(v)
540e73a962STim J. Robbins 
550a041f3bSBjoern A. Zeeb #define	CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0)
560a041f3bSBjoern A. Zeeb #define	CP2(src,dst,sfld,dfld) do { (dst).dfld = (src).sfld; } while (0)
570a041f3bSBjoern A. Zeeb #define	PTRIN_CP(src,dst,fld) \
580a041f3bSBjoern A. Zeeb 	do { (dst).fld = PTRIN((src).fld); } while (0)
590a041f3bSBjoern A. Zeeb 
6043bef515SMarcel Moolenaar /*
611b20ff34SEric Melville  * Provide a separate set of types for the Linux types.
625002a60fSMarcel Moolenaar  */
635002a60fSMarcel Moolenaar typedef int		l_int;
645002a60fSMarcel Moolenaar typedef int32_t		l_long;
655002a60fSMarcel Moolenaar typedef int64_t		l_longlong;
665002a60fSMarcel Moolenaar typedef short		l_short;
675002a60fSMarcel Moolenaar typedef unsigned int	l_uint;
685002a60fSMarcel Moolenaar typedef uint32_t	l_ulong;
695002a60fSMarcel Moolenaar typedef uint64_t	l_ulonglong;
705002a60fSMarcel Moolenaar typedef unsigned short	l_ushort;
715002a60fSMarcel Moolenaar 
725002a60fSMarcel Moolenaar typedef char		*l_caddr_t;
730e73a962STim J. Robbins typedef l_ulong		l_uintptr_t;
745002a60fSMarcel Moolenaar typedef l_long		l_clock_t;
755002a60fSMarcel Moolenaar typedef l_int		l_daddr_t;
765002a60fSMarcel Moolenaar typedef l_ushort	l_dev_t;
775002a60fSMarcel Moolenaar typedef l_uint		l_gid_t;
785002a60fSMarcel Moolenaar typedef l_ushort	l_gid16_t;
795002a60fSMarcel Moolenaar typedef l_ulong		l_ino_t;
805002a60fSMarcel Moolenaar typedef l_int		l_key_t;
815002a60fSMarcel Moolenaar typedef l_longlong	l_loff_t;
825002a60fSMarcel Moolenaar typedef l_ushort	l_mode_t;
835002a60fSMarcel Moolenaar typedef l_long		l_off_t;
845002a60fSMarcel Moolenaar typedef l_int		l_pid_t;
855002a60fSMarcel Moolenaar typedef l_uint		l_size_t;
865002a60fSMarcel Moolenaar typedef l_long		l_suseconds_t;
875002a60fSMarcel Moolenaar typedef l_long		l_time_t;
885002a60fSMarcel Moolenaar typedef l_uint		l_uid_t;
895002a60fSMarcel Moolenaar typedef l_ushort	l_uid16_t;
90aa8b2011SKonstantin Belousov typedef l_int		l_timer_t;
91aa8b2011SKonstantin Belousov typedef l_int		l_mqd_t;
92*3e89b641SDmitry Chagin typedef	l_ulong		l_fd_mask;
935002a60fSMarcel Moolenaar 
945002a60fSMarcel Moolenaar typedef struct {
955002a60fSMarcel Moolenaar 	l_int		val[2];
965002a60fSMarcel Moolenaar } l_fsid_t;
975002a60fSMarcel Moolenaar 
985002a60fSMarcel Moolenaar typedef struct {
995002a60fSMarcel Moolenaar 	l_time_t	tv_sec;
1005002a60fSMarcel Moolenaar 	l_suseconds_t	tv_usec;
1015002a60fSMarcel Moolenaar } l_timeval;
1025002a60fSMarcel Moolenaar 
1035002a60fSMarcel Moolenaar #define	l_fd_set	fd_set
1045002a60fSMarcel Moolenaar 
1055002a60fSMarcel Moolenaar /*
10643bef515SMarcel Moolenaar  * Miscellaneous
10743bef515SMarcel Moolenaar  */
1084048f59cSDmitry Chagin #define LINUX_AT_COUNT		20	/* Count of used aux entry types.
1094d7c2e8aSDmitry Chagin 					 * Keep this synchronized with
1104d7c2e8aSDmitry Chagin 					 * elf_linux_fixup() code.
1114d7c2e8aSDmitry Chagin 					 */
1125002a60fSMarcel Moolenaar struct l___sysctl_args
1135002a60fSMarcel Moolenaar {
1145002a60fSMarcel Moolenaar 	l_int		*name;
1155002a60fSMarcel Moolenaar 	l_int		nlen;
1165002a60fSMarcel Moolenaar 	void		*oldval;
1175002a60fSMarcel Moolenaar 	l_size_t	*oldlenp;
1185002a60fSMarcel Moolenaar 	void		*newval;
1195002a60fSMarcel Moolenaar 	l_size_t	newlen;
1205002a60fSMarcel Moolenaar 	l_ulong		__spare[4];
1215002a60fSMarcel Moolenaar };
1225002a60fSMarcel Moolenaar 
12343bef515SMarcel Moolenaar /* Resource limits */
12443bef515SMarcel Moolenaar #define	LINUX_RLIMIT_CPU	0
12543bef515SMarcel Moolenaar #define	LINUX_RLIMIT_FSIZE	1
12643bef515SMarcel Moolenaar #define	LINUX_RLIMIT_DATA	2
12743bef515SMarcel Moolenaar #define	LINUX_RLIMIT_STACK	3
12843bef515SMarcel Moolenaar #define	LINUX_RLIMIT_CORE	4
12943bef515SMarcel Moolenaar #define	LINUX_RLIMIT_RSS	5
13043bef515SMarcel Moolenaar #define	LINUX_RLIMIT_NPROC	6
13143bef515SMarcel Moolenaar #define	LINUX_RLIMIT_NOFILE	7
13243bef515SMarcel Moolenaar #define	LINUX_RLIMIT_MEMLOCK	8
133a4e3bad7SJung-uk Kim #define	LINUX_RLIMIT_AS		9	/* Address space limit */
13443bef515SMarcel Moolenaar 
13543bef515SMarcel Moolenaar #define	LINUX_RLIM_NLIMITS	10
13643bef515SMarcel Moolenaar 
1375002a60fSMarcel Moolenaar struct l_rlimit {
1385002a60fSMarcel Moolenaar 	l_ulong rlim_cur;
1395002a60fSMarcel Moolenaar 	l_ulong rlim_max;
1405002a60fSMarcel Moolenaar };
1415002a60fSMarcel Moolenaar 
14243bef515SMarcel Moolenaar /* mmap options */
14343bef515SMarcel Moolenaar #define	LINUX_MAP_SHARED	0x0001
14443bef515SMarcel Moolenaar #define	LINUX_MAP_PRIVATE	0x0002
14543bef515SMarcel Moolenaar #define	LINUX_MAP_FIXED		0x0010
14643bef515SMarcel Moolenaar #define	LINUX_MAP_ANON		0x0020
14743bef515SMarcel Moolenaar #define	LINUX_MAP_GROWSDOWN	0x0100
14843bef515SMarcel Moolenaar 
14910931a46SJung-uk Kim struct l_mmap_argv {
15010931a46SJung-uk Kim 	l_uintptr_t	addr;
15110931a46SJung-uk Kim 	l_size_t	len;
15210931a46SJung-uk Kim 	l_int		prot;
15310931a46SJung-uk Kim 	l_int		flags;
15410931a46SJung-uk Kim 	l_int		fd;
15510931a46SJung-uk Kim 	l_off_t		pgoff;
15610931a46SJung-uk Kim } __packed;
15710931a46SJung-uk Kim 
1585002a60fSMarcel Moolenaar /*
1595002a60fSMarcel Moolenaar  * stat family of syscalls
1605002a60fSMarcel Moolenaar  */
1615002a60fSMarcel Moolenaar struct l_timespec {
16277424f41SJung-uk Kim 	l_time_t	tv_sec;
16377424f41SJung-uk Kim 	l_long		tv_nsec;
1645002a60fSMarcel Moolenaar };
16543bef515SMarcel Moolenaar 
1665002a60fSMarcel Moolenaar struct l_newstat {
1675002a60fSMarcel Moolenaar 	l_ushort	st_dev;
1685002a60fSMarcel Moolenaar 	l_ushort	__pad1;
1695002a60fSMarcel Moolenaar 	l_ulong		st_ino;
1705002a60fSMarcel Moolenaar 	l_ushort	st_mode;
1715002a60fSMarcel Moolenaar 	l_ushort	st_nlink;
1725002a60fSMarcel Moolenaar 	l_ushort	st_uid;
1735002a60fSMarcel Moolenaar 	l_ushort	st_gid;
1745002a60fSMarcel Moolenaar 	l_ushort	st_rdev;
1755002a60fSMarcel Moolenaar 	l_ushort	__pad2;
1765002a60fSMarcel Moolenaar 	l_ulong		st_size;
1775002a60fSMarcel Moolenaar 	l_ulong		st_blksize;
1785002a60fSMarcel Moolenaar 	l_ulong		st_blocks;
179510ea843SEd Schouten 	struct l_timespec	st_atim;
180510ea843SEd Schouten 	struct l_timespec	st_mtim;
181510ea843SEd Schouten 	struct l_timespec	st_ctim;
1825002a60fSMarcel Moolenaar 	l_ulong		__unused4;
1835002a60fSMarcel Moolenaar 	l_ulong		__unused5;
1845002a60fSMarcel Moolenaar };
18543bef515SMarcel Moolenaar 
1861f7642e0SAlexander Leidinger struct l_stat {
1871f7642e0SAlexander Leidinger 	l_ushort	st_dev;
1881f7642e0SAlexander Leidinger 	l_ulong		st_ino;
1891f7642e0SAlexander Leidinger 	l_ushort	st_mode;
1901f7642e0SAlexander Leidinger 	l_ushort	st_nlink;
1911f7642e0SAlexander Leidinger 	l_ushort	st_uid;
1921f7642e0SAlexander Leidinger 	l_ushort	st_gid;
1931f7642e0SAlexander Leidinger 	l_ushort	st_rdev;
1941f7642e0SAlexander Leidinger 	l_long		st_size;
195510ea843SEd Schouten 	struct l_timespec	st_atim;
196510ea843SEd Schouten 	struct l_timespec	st_mtim;
197510ea843SEd Schouten 	struct l_timespec	st_ctim;
1981f7642e0SAlexander Leidinger 	l_long		st_blksize;
1991f7642e0SAlexander Leidinger 	l_long		st_blocks;
2001f7642e0SAlexander Leidinger 	l_ulong		st_flags;
2011f7642e0SAlexander Leidinger 	l_ulong		st_gen;
2021f7642e0SAlexander Leidinger };
2031f7642e0SAlexander Leidinger 
2045002a60fSMarcel Moolenaar struct l_stat64 {
2055002a60fSMarcel Moolenaar 	l_ushort	st_dev;
2065002a60fSMarcel Moolenaar 	u_char		__pad0[10];
2075002a60fSMarcel Moolenaar 	l_ulong		__st_ino;
2085002a60fSMarcel Moolenaar 	l_uint		st_mode;
2095002a60fSMarcel Moolenaar 	l_uint		st_nlink;
2105002a60fSMarcel Moolenaar 	l_ulong		st_uid;
2115002a60fSMarcel Moolenaar 	l_ulong		st_gid;
2125002a60fSMarcel Moolenaar 	l_ushort	st_rdev;
2135002a60fSMarcel Moolenaar 	u_char		__pad3[10];
2145002a60fSMarcel Moolenaar 	l_longlong	st_size;
2155002a60fSMarcel Moolenaar 	l_ulong		st_blksize;
2165002a60fSMarcel Moolenaar 	l_ulong		st_blocks;
2175002a60fSMarcel Moolenaar 	l_ulong		__pad4;
218510ea843SEd Schouten 	struct l_timespec	st_atim;
219510ea843SEd Schouten 	struct l_timespec	st_mtim;
220510ea843SEd Schouten 	struct l_timespec	st_ctim;
2215002a60fSMarcel Moolenaar 	l_ulonglong	st_ino;
2225002a60fSMarcel Moolenaar };
2235002a60fSMarcel Moolenaar 
2243ab85269SDavid Malone struct l_statfs64 {
2253ab85269SDavid Malone         l_int           f_type;
2263ab85269SDavid Malone         l_int           f_bsize;
2273ab85269SDavid Malone         uint64_t        f_blocks;
2283ab85269SDavid Malone         uint64_t        f_bfree;
2293ab85269SDavid Malone         uint64_t        f_bavail;
2303ab85269SDavid Malone         uint64_t        f_files;
2313ab85269SDavid Malone         uint64_t        f_ffree;
2323ab85269SDavid Malone         l_fsid_t        f_fsid;
2333ab85269SDavid Malone         l_int           f_namelen;
2343ab85269SDavid Malone         l_int           f_spare[6];
2353ab85269SDavid Malone };
2363ab85269SDavid Malone 
237956d3333SMarcel Moolenaar /*
23843bef515SMarcel Moolenaar  * Signalling
239956d3333SMarcel Moolenaar  */
24043bef515SMarcel Moolenaar #define	LINUX_SIGHUP		1
24143bef515SMarcel Moolenaar #define	LINUX_SIGINT		2
24243bef515SMarcel Moolenaar #define	LINUX_SIGQUIT		3
24343bef515SMarcel Moolenaar #define	LINUX_SIGILL		4
24443bef515SMarcel Moolenaar #define	LINUX_SIGTRAP		5
24543bef515SMarcel Moolenaar #define	LINUX_SIGABRT		6
24643bef515SMarcel Moolenaar #define	LINUX_SIGIOT		LINUX_SIGABRT
24743bef515SMarcel Moolenaar #define	LINUX_SIGBUS		7
24843bef515SMarcel Moolenaar #define	LINUX_SIGFPE		8
24943bef515SMarcel Moolenaar #define	LINUX_SIGKILL		9
25043bef515SMarcel Moolenaar #define	LINUX_SIGUSR1		10
25143bef515SMarcel Moolenaar #define	LINUX_SIGSEGV		11
25243bef515SMarcel Moolenaar #define	LINUX_SIGUSR2		12
25343bef515SMarcel Moolenaar #define	LINUX_SIGPIPE		13
25443bef515SMarcel Moolenaar #define	LINUX_SIGALRM		14
25543bef515SMarcel Moolenaar #define	LINUX_SIGTERM		15
25643bef515SMarcel Moolenaar #define	LINUX_SIGSTKFLT		16
25743bef515SMarcel Moolenaar #define	LINUX_SIGCHLD		17
25843bef515SMarcel Moolenaar #define	LINUX_SIGCONT		18
25943bef515SMarcel Moolenaar #define	LINUX_SIGSTOP		19
26043bef515SMarcel Moolenaar #define	LINUX_SIGTSTP		20
26143bef515SMarcel Moolenaar #define	LINUX_SIGTTIN		21
26243bef515SMarcel Moolenaar #define	LINUX_SIGTTOU		22
26343bef515SMarcel Moolenaar #define	LINUX_SIGURG		23
26443bef515SMarcel Moolenaar #define	LINUX_SIGXCPU		24
26543bef515SMarcel Moolenaar #define	LINUX_SIGXFSZ		25
26643bef515SMarcel Moolenaar #define	LINUX_SIGVTALRM		26
26743bef515SMarcel Moolenaar #define	LINUX_SIGPROF		27
26843bef515SMarcel Moolenaar #define	LINUX_SIGWINCH		28
26943bef515SMarcel Moolenaar #define	LINUX_SIGIO		29
27043bef515SMarcel Moolenaar #define	LINUX_SIGPOLL		LINUX_SIGIO
27143bef515SMarcel Moolenaar #define	LINUX_SIGPWR		30
272ba873f4cSAlexander Kabaev #define	LINUX_SIGSYS		31
27309d6cb0aSDmitry Chagin #define	LINUX_SIGRTMIN		32
274956d3333SMarcel Moolenaar 
27543bef515SMarcel Moolenaar #define	LINUX_SIGTBLSZ		31
2762c4ab9ddSAndrew Gallatin #define	LINUX_NSIG_WORDS	2
2772c4ab9ddSAndrew Gallatin #define	LINUX_NBPW		32
2782c4ab9ddSAndrew Gallatin #define	LINUX_NSIG		(LINUX_NBPW * LINUX_NSIG_WORDS)
27943bef515SMarcel Moolenaar 
28043bef515SMarcel Moolenaar /* sigaction flags */
28143bef515SMarcel Moolenaar #define	LINUX_SA_NOCLDSTOP	0x00000001
28243bef515SMarcel Moolenaar #define	LINUX_SA_NOCLDWAIT	0x00000002
28343bef515SMarcel Moolenaar #define	LINUX_SA_SIGINFO	0x00000004
28443bef515SMarcel Moolenaar #define	LINUX_SA_RESTORER	0x04000000
28543bef515SMarcel Moolenaar #define	LINUX_SA_ONSTACK	0x08000000
28643bef515SMarcel Moolenaar #define	LINUX_SA_RESTART	0x10000000
28743bef515SMarcel Moolenaar #define	LINUX_SA_INTERRUPT	0x20000000
28843bef515SMarcel Moolenaar #define	LINUX_SA_NOMASK		0x40000000
28943bef515SMarcel Moolenaar #define	LINUX_SA_ONESHOT	0x80000000
29043bef515SMarcel Moolenaar 
29143bef515SMarcel Moolenaar /* sigprocmask actions */
29243bef515SMarcel Moolenaar #define	LINUX_SIG_BLOCK		0
29343bef515SMarcel Moolenaar #define	LINUX_SIG_UNBLOCK	1
29443bef515SMarcel Moolenaar #define	LINUX_SIG_SETMASK	2
29543bef515SMarcel Moolenaar 
29643bef515SMarcel Moolenaar /* sigset_t macros */
29743bef515SMarcel Moolenaar #define	LINUX_SIGEMPTYSET(set)		(set).__bits[0] = (set).__bits[1] = 0
29843bef515SMarcel Moolenaar #define	LINUX_SIGISMEMBER(set, sig)	SIGISMEMBER(set, sig)
29943bef515SMarcel Moolenaar #define	LINUX_SIGADDSET(set, sig)	SIGADDSET(set, sig)
30043bef515SMarcel Moolenaar 
301dee4ec33SMarcel Moolenaar /* sigaltstack */
302dee4ec33SMarcel Moolenaar #define	LINUX_MINSIGSTKSZ	2048
303931a7258SAndrew Gallatin #define	LINUX_SS_ONSTACK	1
304931a7258SAndrew Gallatin #define	LINUX_SS_DISABLE	2
305931a7258SAndrew Gallatin 
306931a7258SAndrew Gallatin int linux_to_bsd_sigaltstack(int lsa);
307931a7258SAndrew Gallatin int bsd_to_linux_sigaltstack(int bsa);
308931a7258SAndrew Gallatin 
3095002a60fSMarcel Moolenaar typedef void	(*l_handler_t)(l_int);
3105002a60fSMarcel Moolenaar typedef l_ulong	l_osigset_t;
311956d3333SMarcel Moolenaar 
31206ebbe77SMarcel Moolenaar typedef struct {
3135002a60fSMarcel Moolenaar 	l_uint	__bits[LINUX_NSIG_WORDS];
3145002a60fSMarcel Moolenaar } l_sigset_t;
315956d3333SMarcel Moolenaar 
316956d3333SMarcel Moolenaar typedef struct {
3175002a60fSMarcel Moolenaar 	l_handler_t	lsa_handler;
3185002a60fSMarcel Moolenaar 	l_osigset_t	lsa_mask;
3195002a60fSMarcel Moolenaar 	l_ulong		lsa_flags;
320956d3333SMarcel Moolenaar 	void	(*lsa_restorer)(void);
3215002a60fSMarcel Moolenaar } l_osigaction_t;
322956d3333SMarcel Moolenaar 
32306ebbe77SMarcel Moolenaar typedef struct {
3245002a60fSMarcel Moolenaar 	l_handler_t	lsa_handler;
3255002a60fSMarcel Moolenaar 	l_ulong		lsa_flags;
32606ebbe77SMarcel Moolenaar 	void	(*lsa_restorer)(void);
3275002a60fSMarcel Moolenaar 	l_sigset_t	lsa_mask;
3285002a60fSMarcel Moolenaar } l_sigaction_t;
32906ebbe77SMarcel Moolenaar 
33043bef515SMarcel Moolenaar typedef struct {
331ec99e322SMarcel Moolenaar 	void		*ss_sp;
3325002a60fSMarcel Moolenaar 	l_int		ss_flags;
3335002a60fSMarcel Moolenaar 	l_size_t	ss_size;
3345002a60fSMarcel Moolenaar } l_stack_t;
335ec99e322SMarcel Moolenaar 
33643bef515SMarcel Moolenaar /* The Linux sigcontext, pretty much a standard 386 trapframe. */
3375002a60fSMarcel Moolenaar struct l_sigcontext {
3385002a60fSMarcel Moolenaar 	l_int		sc_gs;
3395002a60fSMarcel Moolenaar 	l_int		sc_fs;
3405002a60fSMarcel Moolenaar 	l_int		sc_es;
3415002a60fSMarcel Moolenaar 	l_int		sc_ds;
3425002a60fSMarcel Moolenaar 	l_int		sc_edi;
3435002a60fSMarcel Moolenaar 	l_int		sc_esi;
3445002a60fSMarcel Moolenaar 	l_int		sc_ebp;
3455002a60fSMarcel Moolenaar 	l_int		sc_esp;
3465002a60fSMarcel Moolenaar 	l_int		sc_ebx;
3475002a60fSMarcel Moolenaar 	l_int		sc_edx;
3485002a60fSMarcel Moolenaar 	l_int		sc_ecx;
3495002a60fSMarcel Moolenaar 	l_int		sc_eax;
3505002a60fSMarcel Moolenaar 	l_int		sc_trapno;
3515002a60fSMarcel Moolenaar 	l_int		sc_err;
3525002a60fSMarcel Moolenaar 	l_int		sc_eip;
3535002a60fSMarcel Moolenaar 	l_int		sc_cs;
3545002a60fSMarcel Moolenaar 	l_int		sc_eflags;
3555002a60fSMarcel Moolenaar 	l_int		sc_esp_at_signal;
3565002a60fSMarcel Moolenaar 	l_int		sc_ss;
3575002a60fSMarcel Moolenaar 	l_int		sc_387;
3585002a60fSMarcel Moolenaar 	l_int		sc_mask;
3595002a60fSMarcel Moolenaar 	l_int		sc_cr2;
360d66a5066SPeter Wemm };
361d66a5066SPeter Wemm 
3625002a60fSMarcel Moolenaar struct l_ucontext {
3635002a60fSMarcel Moolenaar 	l_ulong		uc_flags;
36479363394SAndrew Gallatin 	void		*uc_link;
3655002a60fSMarcel Moolenaar 	l_stack_t	uc_stack;
3665002a60fSMarcel Moolenaar 	struct l_sigcontext	uc_mcontext;
3675002a60fSMarcel Moolenaar 	l_sigset_t	uc_sigmask;
36879363394SAndrew Gallatin };
36979363394SAndrew Gallatin 
37079363394SAndrew Gallatin #define	LINUX_SI_MAX_SIZE	128
3715002a60fSMarcel Moolenaar #define	LINUX_SI_PAD_SIZE	((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3)
37279363394SAndrew Gallatin 
373aa8b2011SKonstantin Belousov typedef union l_sigval {
374aa8b2011SKonstantin Belousov 	l_int		sival_int;
375aa8b2011SKonstantin Belousov 	l_uintptr_t	sival_ptr;
376aa8b2011SKonstantin Belousov } l_sigval_t;
377aa8b2011SKonstantin Belousov 
3785002a60fSMarcel Moolenaar typedef struct l_siginfo {
3795002a60fSMarcel Moolenaar 	l_int		lsi_signo;
3805002a60fSMarcel Moolenaar 	l_int		lsi_errno;
3815002a60fSMarcel Moolenaar 	l_int		lsi_code;
38279363394SAndrew Gallatin 	union {
3835002a60fSMarcel Moolenaar 		l_int	_pad[LINUX_SI_PAD_SIZE];
3845002a60fSMarcel Moolenaar 
38579363394SAndrew Gallatin 		struct {
3865002a60fSMarcel Moolenaar 			l_pid_t		_pid;
387aa8b2011SKonstantin Belousov 			l_uid_t		_uid;
38879363394SAndrew Gallatin 		} _kill;
38979363394SAndrew Gallatin 
39079363394SAndrew Gallatin 		struct {
391aa8b2011SKonstantin Belousov 			l_timer_t	_tid;
392aa8b2011SKonstantin Belousov 			l_int		_overrun;
393aa8b2011SKonstantin Belousov 			char		_pad[sizeof(l_uid_t) - sizeof(l_int)];
394aa8b2011SKonstantin Belousov 			l_sigval_t	_sigval;
395aa8b2011SKonstantin Belousov 			l_int		_sys_private;
39679363394SAndrew Gallatin 		} _timer;
39779363394SAndrew Gallatin 
39879363394SAndrew Gallatin 		struct {
3995002a60fSMarcel Moolenaar 			l_pid_t		_pid;		/* sender's pid */
400aa8b2011SKonstantin Belousov 			l_uid_t		_uid;		/* sender's uid */
401aa8b2011SKonstantin Belousov 			l_sigval_t	_sigval;
40279363394SAndrew Gallatin 		} _rt;
40379363394SAndrew Gallatin 
40479363394SAndrew Gallatin 		struct {
4055002a60fSMarcel Moolenaar 			l_pid_t		_pid;		/* which child */
406aa8b2011SKonstantin Belousov 			l_uid_t		_uid;		/* sender's uid */
4075002a60fSMarcel Moolenaar 			l_int		_status;	/* exit code */
4085002a60fSMarcel Moolenaar 			l_clock_t	_utime;
4095002a60fSMarcel Moolenaar 			l_clock_t	_stime;
41079363394SAndrew Gallatin 		} _sigchld;
41179363394SAndrew Gallatin 
41279363394SAndrew Gallatin 		struct {
413aa8b2011SKonstantin Belousov 			l_uintptr_t	_addr;	/* Faulting insn/memory ref. */
41479363394SAndrew Gallatin 		} _sigfault;
41579363394SAndrew Gallatin 
41679363394SAndrew Gallatin 		struct {
417aa8b2011SKonstantin Belousov 			l_long		_band;	/* POLL_IN,POLL_OUT,POLL_MSG */
4185002a60fSMarcel Moolenaar 			l_int		_fd;
41979363394SAndrew Gallatin 		} _sigpoll;
42079363394SAndrew Gallatin 	} _sifields;
4215002a60fSMarcel Moolenaar } l_siginfo_t;
42279363394SAndrew Gallatin 
42379363394SAndrew Gallatin #define	lsi_pid		_sifields._kill._pid
42479363394SAndrew Gallatin #define	lsi_uid		_sifields._kill._uid
425aa8b2011SKonstantin Belousov #define	lsi_tid		_sifields._timer._tid
426aa8b2011SKonstantin Belousov #define	lsi_overrun	_sifields._timer._overrun
427aa8b2011SKonstantin Belousov #define	lsi_sys_private	_sifields._timer._sys_private
42879363394SAndrew Gallatin #define	lsi_status	_sifields._sigchld._status
42979363394SAndrew Gallatin #define	lsi_utime	_sifields._sigchld._utime
43079363394SAndrew Gallatin #define	lsi_stime	_sifields._sigchld._stime
43179363394SAndrew Gallatin #define	lsi_value	_sifields._rt._sigval
43279363394SAndrew Gallatin #define	lsi_int		_sifields._rt._sigval.sival_int
43379363394SAndrew Gallatin #define	lsi_ptr		_sifields._rt._sigval.sival_ptr
43479363394SAndrew Gallatin #define	lsi_addr	_sifields._sigfault._addr
43579363394SAndrew Gallatin #define	lsi_band	_sifields._sigpoll._band
43679363394SAndrew Gallatin #define	lsi_fd		_sifields._sigpoll._fd
43779363394SAndrew Gallatin 
4385002a60fSMarcel Moolenaar struct l_fpreg {
4392c4ab9ddSAndrew Gallatin 	u_int16_t	significand[4];
4402c4ab9ddSAndrew Gallatin 	u_int16_t	exponent;
4412c4ab9ddSAndrew Gallatin };
4422c4ab9ddSAndrew Gallatin 
4435002a60fSMarcel Moolenaar struct l_fpxreg {
4442c4ab9ddSAndrew Gallatin 	u_int16_t	significand[4];
4452c4ab9ddSAndrew Gallatin 	u_int16_t	exponent;
4462c4ab9ddSAndrew Gallatin 	u_int16_t	padding[3];
4472c4ab9ddSAndrew Gallatin };
4482c4ab9ddSAndrew Gallatin 
4495002a60fSMarcel Moolenaar struct l_xmmreg {
4502c4ab9ddSAndrew Gallatin 	u_int32_t	element[4];
4512c4ab9ddSAndrew Gallatin };
4522c4ab9ddSAndrew Gallatin 
4535002a60fSMarcel Moolenaar struct l_fpstate {
4542c4ab9ddSAndrew Gallatin 	/* Regular FPU environment */
4552c4ab9ddSAndrew Gallatin 	u_int32_t		cw;
4562c4ab9ddSAndrew Gallatin 	u_int32_t		sw;
4572c4ab9ddSAndrew Gallatin 	u_int32_t		tag;
4582c4ab9ddSAndrew Gallatin 	u_int32_t		ipoff;
4592c4ab9ddSAndrew Gallatin 	u_int32_t		cssel;
4602c4ab9ddSAndrew Gallatin 	u_int32_t		dataoff;
4612c4ab9ddSAndrew Gallatin 	u_int32_t		datasel;
4625002a60fSMarcel Moolenaar 	struct l_fpreg		_st[8];
4632c4ab9ddSAndrew Gallatin 	u_int16_t		status;
4642c4ab9ddSAndrew Gallatin 	u_int16_t		magic;		/* 0xffff = regular FPU data */
4652c4ab9ddSAndrew Gallatin 
4662c4ab9ddSAndrew Gallatin 	/* FXSR FPU environment */
467a4e3bad7SJung-uk Kim 	u_int32_t		_fxsr_env[6];	/* env is ignored. */
4682c4ab9ddSAndrew Gallatin 	u_int32_t		mxcsr;
4692c4ab9ddSAndrew Gallatin 	u_int32_t		reserved;
470a4e3bad7SJung-uk Kim 	struct l_fpxreg		_fxsr_st[8];	/* reg data is ignored. */
4715002a60fSMarcel Moolenaar 	struct l_xmmreg		_xmm[8];
4722c4ab9ddSAndrew Gallatin 	u_int32_t		padding[56];
4732c4ab9ddSAndrew Gallatin };
47479363394SAndrew Gallatin 
475d66a5066SPeter Wemm /*
476d66a5066SPeter Wemm  * We make the stack look like Linux expects it when calling a signal
477d66a5066SPeter Wemm  * handler, but use the BSD way of calling the handler and sigreturn().
478d66a5066SPeter Wemm  * This means that we need to pass the pointer to the handler too.
479d66a5066SPeter Wemm  * It is appended to the frame to not interfere with the rest of it.
480d66a5066SPeter Wemm  */
4815002a60fSMarcel Moolenaar struct l_sigframe {
4825002a60fSMarcel Moolenaar 	l_int			sf_sig;
4835002a60fSMarcel Moolenaar 	struct l_sigcontext	sf_sc;
4845002a60fSMarcel Moolenaar 	struct l_fpstate	sf_fpstate;
4855002a60fSMarcel Moolenaar 	l_uint			sf_extramask[LINUX_NSIG_WORDS-1];
4865002a60fSMarcel Moolenaar 	l_handler_t		sf_handler;
487d66a5066SPeter Wemm };
488d66a5066SPeter Wemm 
4895002a60fSMarcel Moolenaar struct l_rt_sigframe {
4905002a60fSMarcel Moolenaar 	l_int			sf_sig;
4915002a60fSMarcel Moolenaar 	l_siginfo_t 		*sf_siginfo;
4925002a60fSMarcel Moolenaar 	struct l_ucontext	*sf_ucontext;
4935002a60fSMarcel Moolenaar 	l_siginfo_t		sf_si;
4945002a60fSMarcel Moolenaar 	struct l_ucontext 	sf_sc;
4955002a60fSMarcel Moolenaar 	l_handler_t 		sf_handler;
49679363394SAndrew Gallatin };
49779363394SAndrew Gallatin 
498d323ddf3SMatthew Dillon extern struct sysentvec linux_sysvec;
499c21dee17SSøren Schmidt 
50043bef515SMarcel Moolenaar /*
5014d0f380dSDmitry Chagin  * arch specific open/fcntl flags
50243bef515SMarcel Moolenaar  */
503aaaefc6bSRobert Drehmel #define	LINUX_F_GETLK64		12
504aaaefc6bSRobert Drehmel #define	LINUX_F_SETLK64		13
505aaaefc6bSRobert Drehmel #define	LINUX_F_SETLKW64	14
506aaaefc6bSRobert Drehmel 
5075002a60fSMarcel Moolenaar union l_semun {
5085002a60fSMarcel Moolenaar 	l_int		val;
5095002a60fSMarcel Moolenaar 	struct l_semid_ds	*buf;
5105002a60fSMarcel Moolenaar 	l_ushort	*array;
5115002a60fSMarcel Moolenaar 	struct l_seminfo	*__buf;
5125002a60fSMarcel Moolenaar 	void		*__pad;
5135002a60fSMarcel Moolenaar };
5145002a60fSMarcel Moolenaar 
51531eb4388SDmitry Chagin struct l_ipc_perm {
51631eb4388SDmitry Chagin 	l_key_t		key;
51731eb4388SDmitry Chagin 	l_uid16_t	uid;
51831eb4388SDmitry Chagin 	l_gid16_t	gid;
51931eb4388SDmitry Chagin 	l_uid16_t	cuid;
52031eb4388SDmitry Chagin 	l_gid16_t	cgid;
52131eb4388SDmitry Chagin 	l_ushort	mode;
52231eb4388SDmitry Chagin 	l_ushort	seq;
52331eb4388SDmitry Chagin };
52431eb4388SDmitry Chagin 
52543bef515SMarcel Moolenaar /*
52643bef515SMarcel Moolenaar  * Socket defines
52743bef515SMarcel Moolenaar  */
528c21dee17SSøren Schmidt #define	LINUX_SOL_SOCKET	1
529c21dee17SSøren Schmidt #define	LINUX_SOL_IP		0
530c21dee17SSøren Schmidt #define	LINUX_SOL_IPX		256
531c21dee17SSøren Schmidt #define	LINUX_SOL_AX25		257
532c21dee17SSøren Schmidt #define	LINUX_SOL_TCP		6
533c21dee17SSøren Schmidt #define	LINUX_SOL_UDP		17
534c21dee17SSøren Schmidt 
535c21dee17SSøren Schmidt #define	LINUX_SO_DEBUG		1
536c21dee17SSøren Schmidt #define	LINUX_SO_REUSEADDR	2
537c21dee17SSøren Schmidt #define	LINUX_SO_TYPE		3
538c21dee17SSøren Schmidt #define	LINUX_SO_ERROR		4
539c21dee17SSøren Schmidt #define	LINUX_SO_DONTROUTE	5
540c21dee17SSøren Schmidt #define	LINUX_SO_BROADCAST	6
541c21dee17SSøren Schmidt #define	LINUX_SO_SNDBUF		7
542c21dee17SSøren Schmidt #define	LINUX_SO_RCVBUF		8
543c21dee17SSøren Schmidt #define	LINUX_SO_KEEPALIVE	9
544c21dee17SSøren Schmidt #define	LINUX_SO_OOBINLINE	10
545c21dee17SSøren Schmidt #define	LINUX_SO_NO_CHECK	11
546c21dee17SSøren Schmidt #define	LINUX_SO_PRIORITY	12
547c21dee17SSøren Schmidt #define	LINUX_SO_LINGER		13
548d0b2365eSKonstantin Belousov #define	LINUX_SO_PEERCRED	17
549d0b2365eSKonstantin Belousov #define	LINUX_SO_RCVLOWAT	18
550d0b2365eSKonstantin Belousov #define	LINUX_SO_SNDLOWAT	19
551d0b2365eSKonstantin Belousov #define	LINUX_SO_RCVTIMEO	20
552d0b2365eSKonstantin Belousov #define	LINUX_SO_SNDTIMEO	21
553d0b2365eSKonstantin Belousov #define	LINUX_SO_TIMESTAMP	29
554d0b2365eSKonstantin Belousov #define	LINUX_SO_ACCEPTCONN	30
555c21dee17SSøren Schmidt 
5565002a60fSMarcel Moolenaar struct l_sockaddr {
5575002a60fSMarcel Moolenaar 	l_ushort	sa_family;
5583713cbffSMike Smith 	char		sa_data[14];
5593713cbffSMike Smith };
5603713cbffSMike Smith 
56174f5d680SKonstantin Belousov struct l_msghdr {
56274f5d680SKonstantin Belousov 	l_uintptr_t	msg_name;
56374f5d680SKonstantin Belousov 	l_int		msg_namelen;
56474f5d680SKonstantin Belousov 	l_uintptr_t	msg_iov;
56574f5d680SKonstantin Belousov 	l_size_t	msg_iovlen;
56674f5d680SKonstantin Belousov 	l_uintptr_t	msg_control;
56774f5d680SKonstantin Belousov 	l_size_t	msg_controllen;
56874f5d680SKonstantin Belousov 	l_uint		msg_flags;
56974f5d680SKonstantin Belousov };
57074f5d680SKonstantin Belousov 
57174f5d680SKonstantin Belousov struct l_cmsghdr {
57274f5d680SKonstantin Belousov 	l_size_t	cmsg_len;
57374f5d680SKonstantin Belousov 	l_int		cmsg_level;
57474f5d680SKonstantin Belousov 	l_int		cmsg_type;
57574f5d680SKonstantin Belousov };
57674f5d680SKonstantin Belousov 
5775002a60fSMarcel Moolenaar struct l_ifmap {
5785002a60fSMarcel Moolenaar 	l_ulong		mem_start;
5795002a60fSMarcel Moolenaar 	l_ulong		mem_end;
5805002a60fSMarcel Moolenaar 	l_ushort	base_addr;
58143bef515SMarcel Moolenaar 	u_char		irq;
58243bef515SMarcel Moolenaar 	u_char		dma;
58343bef515SMarcel Moolenaar 	u_char		port;
5843713cbffSMike Smith };
5853713cbffSMike Smith 
5863713cbffSMike Smith #define	LINUX_IFHWADDRLEN	6
5873713cbffSMike Smith #define	LINUX_IFNAMSIZ		16
58843bef515SMarcel Moolenaar 
5895002a60fSMarcel Moolenaar struct l_ifreq {
59043bef515SMarcel Moolenaar 	union {
59143bef515SMarcel Moolenaar 		char	ifrn_name[LINUX_IFNAMSIZ];
5923713cbffSMike Smith 	} ifr_ifrn;
5933713cbffSMike Smith 
5943713cbffSMike Smith 	union {
5955002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_addr;
5965002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_dstaddr;
5975002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_broadaddr;
5985002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_netmask;
5995002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_hwaddr;
600268aeb1eSDag-Erling Smørgrav 		l_short		ifru_flags[1];
6015002a60fSMarcel Moolenaar 		l_int		ifru_metric;
6025002a60fSMarcel Moolenaar 		l_int		ifru_mtu;
6035002a60fSMarcel Moolenaar 		struct l_ifmap	ifru_map;
6045002a60fSMarcel Moolenaar 		char		ifru_slave[LINUX_IFNAMSIZ];
6055002a60fSMarcel Moolenaar 		l_caddr_t	ifru_data;
6063713cbffSMike Smith 	} ifr_ifru;
6073713cbffSMike Smith };
6083713cbffSMike Smith 
609a4e3bad7SJung-uk Kim #define	ifr_name	ifr_ifrn.ifrn_name	/* Interface name */
6103713cbffSMike Smith #define	ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address */
6113713cbffSMike Smith 
6125002a60fSMarcel Moolenaar /*
6135002a60fSMarcel Moolenaar  * poll()
6145002a60fSMarcel Moolenaar  */
6155002a60fSMarcel Moolenaar #define	LINUX_POLLIN		0x0001
6165002a60fSMarcel Moolenaar #define	LINUX_POLLPRI		0x0002
6175002a60fSMarcel Moolenaar #define	LINUX_POLLOUT		0x0004
6185002a60fSMarcel Moolenaar #define	LINUX_POLLERR		0x0008
6195002a60fSMarcel Moolenaar #define	LINUX_POLLHUP		0x0010
6205002a60fSMarcel Moolenaar #define	LINUX_POLLNVAL		0x0020
6215002a60fSMarcel Moolenaar #define	LINUX_POLLRDNORM	0x0040
6225002a60fSMarcel Moolenaar #define	LINUX_POLLRDBAND	0x0080
6235002a60fSMarcel Moolenaar #define	LINUX_POLLWRNORM	0x0100
6245002a60fSMarcel Moolenaar #define	LINUX_POLLWRBAND	0x0200
6255002a60fSMarcel Moolenaar #define	LINUX_POLLMSG		0x0400
6265002a60fSMarcel Moolenaar 
6275002a60fSMarcel Moolenaar struct l_pollfd {
6285002a60fSMarcel Moolenaar 	l_int		fd;
6295002a60fSMarcel Moolenaar 	l_short		events;
6305002a60fSMarcel Moolenaar 	l_short		revents;
6315002a60fSMarcel Moolenaar };
6325002a60fSMarcel Moolenaar 
6339b44bfc5SAlexander Leidinger struct l_user_desc {
6349b44bfc5SAlexander Leidinger 	l_uint		entry_number;
6359b44bfc5SAlexander Leidinger 	l_uint		base_addr;
6369b44bfc5SAlexander Leidinger 	l_uint		limit;
6379b44bfc5SAlexander Leidinger 	l_uint		seg_32bit:1;
6389b44bfc5SAlexander Leidinger 	l_uint		contents:2;
6399b44bfc5SAlexander Leidinger 	l_uint		read_exec_only:1;
6409b44bfc5SAlexander Leidinger 	l_uint		limit_in_pages:1;
6419b44bfc5SAlexander Leidinger 	l_uint		seg_not_present:1;
6429b44bfc5SAlexander Leidinger 	l_uint		useable:1;
6439b44bfc5SAlexander Leidinger };
6449b44bfc5SAlexander Leidinger 
6459b44bfc5SAlexander Leidinger struct l_desc_struct {
6469b44bfc5SAlexander Leidinger 	unsigned long	a, b;
6479b44bfc5SAlexander Leidinger };
6489b44bfc5SAlexander Leidinger 
6499b44bfc5SAlexander Leidinger 
6509b44bfc5SAlexander Leidinger #define	LINUX_LOWERWORD	0x0000ffff
6519b44bfc5SAlexander Leidinger 
6520eef2f8aSAlexander Leidinger /*
653a4e3bad7SJung-uk Kim  * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h.
654a4e3bad7SJung-uk Kim  * These convert Linux user space descriptor to machine one.
6559b44bfc5SAlexander Leidinger  */
656a4e3bad7SJung-uk Kim #define	LINUX_LDT_entry_a(info)					\
657a4e3bad7SJung-uk Kim 	((((info)->base_addr & LINUX_LOWERWORD) << 16) |	\
658a4e3bad7SJung-uk Kim 	((info)->limit & LINUX_LOWERWORD))
6599b44bfc5SAlexander Leidinger 
660a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_READ_EXEC_ONLY	9
661a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_CONTENTS		10
662a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_SEG_NOT_PRESENT	15
663a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_BASE_ADDR		16
664a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_USEABLE		20
665a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_SEG32BIT		22
666a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_LIMIT		23
6679b44bfc5SAlexander Leidinger 
668a4e3bad7SJung-uk Kim #define	LINUX_LDT_entry_b(info)							\
6699b44bfc5SAlexander Leidinger 	(((info)->base_addr & 0xff000000) |					\
6709b44bfc5SAlexander Leidinger 	((info)->limit & 0xf0000) |						\
671a4e3bad7SJung-uk Kim 	((info)->contents << LINUX_ENTRY_B_CONTENTS) |				\
672a4e3bad7SJung-uk Kim 	(((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) |	\
673a4e3bad7SJung-uk Kim 	(((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) |		\
674a4e3bad7SJung-uk Kim 	(((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) |	\
675a4e3bad7SJung-uk Kim 	((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) |				\
676a4e3bad7SJung-uk Kim 	((info)->useable << LINUX_ENTRY_B_USEABLE) |				\
677a4e3bad7SJung-uk Kim 	((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000)
6789b44bfc5SAlexander Leidinger 
679a4e3bad7SJung-uk Kim #define	LINUX_LDT_empty(info)		\
680a4e3bad7SJung-uk Kim 	((info)->base_addr == 0 &&	\
6819b44bfc5SAlexander Leidinger 	(info)->limit == 0 &&		\
6829b44bfc5SAlexander Leidinger 	(info)->contents == 0 &&	\
6839b44bfc5SAlexander Leidinger 	(info)->seg_not_present == 1 &&	\
6849b44bfc5SAlexander Leidinger 	(info)->read_exec_only == 1 &&	\
6859b44bfc5SAlexander Leidinger 	(info)->seg_32bit == 0 &&	\
6869b44bfc5SAlexander Leidinger 	(info)->limit_in_pages == 0 &&	\
6879b44bfc5SAlexander Leidinger 	(info)->useable == 0)
6889b44bfc5SAlexander Leidinger 
689a4e3bad7SJung-uk Kim /*
690a4e3bad7SJung-uk Kim  * Macros for converting segments.
691a4e3bad7SJung-uk Kim  * They do the same as those in arch/i386/kernel/process.c in Linux.
692a4e3bad7SJung-uk Kim  */
693a4e3bad7SJung-uk Kim #define	LINUX_GET_BASE(desc)				\
694a4e3bad7SJung-uk Kim 	((((desc)->a >> 16) & LINUX_LOWERWORD) |	\
6959b44bfc5SAlexander Leidinger 	(((desc)->b << 16) & 0x00ff0000) |		\
6969b44bfc5SAlexander Leidinger 	((desc)->b & 0xff000000))
6979b44bfc5SAlexander Leidinger 
698a4e3bad7SJung-uk Kim #define	LINUX_GET_LIMIT(desc)			\
699a4e3bad7SJung-uk Kim 	(((desc)->a & LINUX_LOWERWORD) |	\
7009b44bfc5SAlexander Leidinger 	((desc)->b & 0xf0000))
7019b44bfc5SAlexander Leidinger 
702a4e3bad7SJung-uk Kim #define	LINUX_GET_32BIT(desc)		\
703a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1)
704a4e3bad7SJung-uk Kim #define	LINUX_GET_CONTENTS(desc)	\
705a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3)
706a4e3bad7SJung-uk Kim #define	LINUX_GET_WRITABLE(desc)	\
707a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1)
708a4e3bad7SJung-uk Kim #define	LINUX_GET_LIMIT_PAGES(desc)	\
709a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1)
710a4e3bad7SJung-uk Kim #define	LINUX_GET_PRESENT(desc)		\
711a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1)
712a4e3bad7SJung-uk Kim #define	LINUX_GET_USEABLE(desc)		\
713a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1)
7149b44bfc5SAlexander Leidinger 
715001398c4SDmitry Chagin #define	linux_copyout_rusage(r, u)	copyout(r, u, sizeof(*r))
716001398c4SDmitry Chagin 
717175c6c31SKonstantin Belousov /* robust futexes */
718175c6c31SKonstantin Belousov struct linux_robust_list {
719175c6c31SKonstantin Belousov 	struct linux_robust_list	*next;
720175c6c31SKonstantin Belousov };
721175c6c31SKonstantin Belousov 
722175c6c31SKonstantin Belousov struct linux_robust_list_head {
723175c6c31SKonstantin Belousov 	struct linux_robust_list	list;
72462162dfcSKonstantin Belousov 	l_long				futex_offset;
725175c6c31SKonstantin Belousov 	struct linux_robust_list	*pending_list;
726175c6c31SKonstantin Belousov };
727175c6c31SKonstantin Belousov 
728a4e3bad7SJung-uk Kim #endif /* !_I386_LINUX_H_ */
729