xref: /freebsd/sys/i386/linux/linux.h (revision 30c6d982190482857883fc96eefafcc6fd769fa0)
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 
775002a60fSMarcel Moolenaar typedef struct {
785002a60fSMarcel Moolenaar 	l_int		val[2];
795002a60fSMarcel Moolenaar } l_fsid_t;
805002a60fSMarcel Moolenaar 
815002a60fSMarcel Moolenaar typedef struct {
825002a60fSMarcel Moolenaar 	l_time_t	tv_sec;
835002a60fSMarcel Moolenaar 	l_suseconds_t	tv_usec;
845002a60fSMarcel Moolenaar } l_timeval;
855002a60fSMarcel Moolenaar 
865002a60fSMarcel Moolenaar #define	l_fd_set	fd_set
875002a60fSMarcel Moolenaar 
885002a60fSMarcel Moolenaar /*
8943bef515SMarcel Moolenaar  * Miscellaneous
9043bef515SMarcel Moolenaar  */
914048f59cSDmitry Chagin #define LINUX_AT_COUNT		20	/* Count of used aux entry types.
924d7c2e8aSDmitry Chagin 					 * Keep this synchronized with
93dc858467SEd Maste 					 * linux_fixup_elf() code.
944d7c2e8aSDmitry Chagin 					 */
955002a60fSMarcel Moolenaar struct l___sysctl_args
965002a60fSMarcel Moolenaar {
975002a60fSMarcel Moolenaar 	l_int		*name;
985002a60fSMarcel Moolenaar 	l_int		nlen;
995002a60fSMarcel Moolenaar 	void		*oldval;
1005002a60fSMarcel Moolenaar 	l_size_t	*oldlenp;
1015002a60fSMarcel Moolenaar 	void		*newval;
1025002a60fSMarcel Moolenaar 	l_size_t	newlen;
1035002a60fSMarcel Moolenaar 	l_ulong		__spare[4];
1045002a60fSMarcel Moolenaar };
1055002a60fSMarcel Moolenaar 
10643bef515SMarcel Moolenaar /* Resource limits */
10743bef515SMarcel Moolenaar #define	LINUX_RLIMIT_CPU	0
10843bef515SMarcel Moolenaar #define	LINUX_RLIMIT_FSIZE	1
10943bef515SMarcel Moolenaar #define	LINUX_RLIMIT_DATA	2
11043bef515SMarcel Moolenaar #define	LINUX_RLIMIT_STACK	3
11143bef515SMarcel Moolenaar #define	LINUX_RLIMIT_CORE	4
11243bef515SMarcel Moolenaar #define	LINUX_RLIMIT_RSS	5
11343bef515SMarcel Moolenaar #define	LINUX_RLIMIT_NPROC	6
11443bef515SMarcel Moolenaar #define	LINUX_RLIMIT_NOFILE	7
11543bef515SMarcel Moolenaar #define	LINUX_RLIMIT_MEMLOCK	8
116a4e3bad7SJung-uk Kim #define	LINUX_RLIMIT_AS		9	/* Address space limit */
11743bef515SMarcel Moolenaar 
11843bef515SMarcel Moolenaar #define	LINUX_RLIM_NLIMITS	10
11943bef515SMarcel Moolenaar 
1205002a60fSMarcel Moolenaar struct l_rlimit {
1215002a60fSMarcel Moolenaar 	l_ulong rlim_cur;
1225002a60fSMarcel Moolenaar 	l_ulong rlim_max;
1235002a60fSMarcel Moolenaar };
1245002a60fSMarcel Moolenaar 
12510931a46SJung-uk Kim struct l_mmap_argv {
12610931a46SJung-uk Kim 	l_uintptr_t	addr;
12710931a46SJung-uk Kim 	l_size_t	len;
12810931a46SJung-uk Kim 	l_int		prot;
12910931a46SJung-uk Kim 	l_int		flags;
13010931a46SJung-uk Kim 	l_int		fd;
13110931a46SJung-uk Kim 	l_off_t		pgoff;
13219593f77SDmitry Chagin };
13310931a46SJung-uk Kim 
1345002a60fSMarcel Moolenaar /*
1355002a60fSMarcel Moolenaar  * stat family of syscalls
1365002a60fSMarcel Moolenaar  */
1375002a60fSMarcel Moolenaar struct l_timespec {
13877424f41SJung-uk Kim 	l_time_t	tv_sec;
13977424f41SJung-uk Kim 	l_long		tv_nsec;
1405002a60fSMarcel Moolenaar };
14143bef515SMarcel Moolenaar 
142bfcce1a9SDmitry Chagin /* __kernel_timespec */
143bfcce1a9SDmitry Chagin struct l_timespec64 {
144bfcce1a9SDmitry Chagin 	l_time64_t	tv_sec;
145bfcce1a9SDmitry Chagin 	l_longlong	tv_nsec;
146bfcce1a9SDmitry Chagin };
147bfcce1a9SDmitry Chagin 
1485002a60fSMarcel Moolenaar struct l_newstat {
1495002a60fSMarcel Moolenaar 	l_ushort	st_dev;
1505002a60fSMarcel Moolenaar 	l_ushort	__pad1;
1515002a60fSMarcel Moolenaar 	l_ulong		st_ino;
1525002a60fSMarcel Moolenaar 	l_ushort	st_mode;
1535002a60fSMarcel Moolenaar 	l_ushort	st_nlink;
1545002a60fSMarcel Moolenaar 	l_ushort	st_uid;
1555002a60fSMarcel Moolenaar 	l_ushort	st_gid;
1565002a60fSMarcel Moolenaar 	l_ushort	st_rdev;
1575002a60fSMarcel Moolenaar 	l_ushort	__pad2;
1585002a60fSMarcel Moolenaar 	l_ulong		st_size;
1595002a60fSMarcel Moolenaar 	l_ulong		st_blksize;
1605002a60fSMarcel Moolenaar 	l_ulong		st_blocks;
161510ea843SEd Schouten 	struct l_timespec	st_atim;
162510ea843SEd Schouten 	struct l_timespec	st_mtim;
163510ea843SEd Schouten 	struct l_timespec	st_ctim;
1645002a60fSMarcel Moolenaar 	l_ulong		__unused4;
1655002a60fSMarcel Moolenaar 	l_ulong		__unused5;
1665002a60fSMarcel Moolenaar };
16743bef515SMarcel Moolenaar 
1681f7642e0SAlexander Leidinger struct l_stat {
1691f7642e0SAlexander Leidinger 	l_ushort	st_dev;
1701f7642e0SAlexander Leidinger 	l_ulong		st_ino;
1711f7642e0SAlexander Leidinger 	l_ushort	st_mode;
1721f7642e0SAlexander Leidinger 	l_ushort	st_nlink;
1731f7642e0SAlexander Leidinger 	l_ushort	st_uid;
1741f7642e0SAlexander Leidinger 	l_ushort	st_gid;
1751f7642e0SAlexander Leidinger 	l_ushort	st_rdev;
1761f7642e0SAlexander Leidinger 	l_long		st_size;
177510ea843SEd Schouten 	struct l_timespec	st_atim;
178510ea843SEd Schouten 	struct l_timespec	st_mtim;
179510ea843SEd Schouten 	struct l_timespec	st_ctim;
1801f7642e0SAlexander Leidinger 	l_long		st_blksize;
1811f7642e0SAlexander Leidinger 	l_long		st_blocks;
1821f7642e0SAlexander Leidinger 	l_ulong		st_flags;
1831f7642e0SAlexander Leidinger 	l_ulong		st_gen;
1841f7642e0SAlexander Leidinger };
1851f7642e0SAlexander Leidinger 
1865002a60fSMarcel Moolenaar struct l_stat64 {
1875002a60fSMarcel Moolenaar 	l_ushort	st_dev;
1885002a60fSMarcel Moolenaar 	u_char		__pad0[10];
1895002a60fSMarcel Moolenaar 	l_ulong		__st_ino;
1905002a60fSMarcel Moolenaar 	l_uint		st_mode;
1915002a60fSMarcel Moolenaar 	l_uint		st_nlink;
1925002a60fSMarcel Moolenaar 	l_ulong		st_uid;
1935002a60fSMarcel Moolenaar 	l_ulong		st_gid;
1945002a60fSMarcel Moolenaar 	l_ushort	st_rdev;
1955002a60fSMarcel Moolenaar 	u_char		__pad3[10];
1965002a60fSMarcel Moolenaar 	l_longlong	st_size;
1975002a60fSMarcel Moolenaar 	l_ulong		st_blksize;
1985002a60fSMarcel Moolenaar 	l_ulong		st_blocks;
1995002a60fSMarcel Moolenaar 	l_ulong		__pad4;
200510ea843SEd Schouten 	struct l_timespec	st_atim;
201510ea843SEd Schouten 	struct l_timespec	st_mtim;
202510ea843SEd Schouten 	struct l_timespec	st_ctim;
2035002a60fSMarcel Moolenaar 	l_ulonglong	st_ino;
2045002a60fSMarcel Moolenaar };
2055002a60fSMarcel Moolenaar 
2063ab85269SDavid Malone struct l_statfs64 {
2073ab85269SDavid Malone 	l_int		f_type;
2083ab85269SDavid Malone 	l_int		f_bsize;
2093ab85269SDavid Malone 	uint64_t	f_blocks;
2103ab85269SDavid Malone 	uint64_t	f_bfree;
2113ab85269SDavid Malone 	uint64_t	f_bavail;
2123ab85269SDavid Malone 	uint64_t	f_files;
2133ab85269SDavid Malone 	uint64_t	f_ffree;
2143ab85269SDavid Malone 	l_fsid_t	f_fsid;
2153ab85269SDavid Malone 	l_int		f_namelen;
216e801ac78SEdward Tomasz Napierala 	l_int		f_frsize;
217e801ac78SEdward Tomasz Napierala 	l_int		f_flags;
218e801ac78SEdward Tomasz Napierala 	l_int		f_spare[4];
2193ab85269SDavid Malone };
2203ab85269SDavid Malone 
2212c4ab9ddSAndrew Gallatin #define	LINUX_NSIG_WORDS	2
22243bef515SMarcel Moolenaar 
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 {
260*30c6d982SEdward 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 
26543bef515SMarcel Moolenaar /* The Linux sigcontext, pretty much a standard 386 trapframe. */
2665002a60fSMarcel Moolenaar struct l_sigcontext {
2675002a60fSMarcel Moolenaar 	l_int		sc_gs;
2685002a60fSMarcel Moolenaar 	l_int		sc_fs;
2695002a60fSMarcel Moolenaar 	l_int		sc_es;
2705002a60fSMarcel Moolenaar 	l_int		sc_ds;
2715002a60fSMarcel Moolenaar 	l_int		sc_edi;
2725002a60fSMarcel Moolenaar 	l_int		sc_esi;
2735002a60fSMarcel Moolenaar 	l_int		sc_ebp;
2745002a60fSMarcel Moolenaar 	l_int		sc_esp;
2755002a60fSMarcel Moolenaar 	l_int		sc_ebx;
2765002a60fSMarcel Moolenaar 	l_int		sc_edx;
2775002a60fSMarcel Moolenaar 	l_int		sc_ecx;
2785002a60fSMarcel Moolenaar 	l_int		sc_eax;
2795002a60fSMarcel Moolenaar 	l_int		sc_trapno;
2805002a60fSMarcel Moolenaar 	l_int		sc_err;
2815002a60fSMarcel Moolenaar 	l_int		sc_eip;
2825002a60fSMarcel Moolenaar 	l_int		sc_cs;
2835002a60fSMarcel Moolenaar 	l_int		sc_eflags;
2845002a60fSMarcel Moolenaar 	l_int		sc_esp_at_signal;
2855002a60fSMarcel Moolenaar 	l_int		sc_ss;
2865002a60fSMarcel Moolenaar 	l_int		sc_387;
2875002a60fSMarcel Moolenaar 	l_int		sc_mask;
2885002a60fSMarcel Moolenaar 	l_int		sc_cr2;
289d66a5066SPeter Wemm };
290d66a5066SPeter Wemm 
2915002a60fSMarcel Moolenaar struct l_ucontext {
2925002a60fSMarcel Moolenaar 	l_ulong		uc_flags;
29379363394SAndrew Gallatin 	void		*uc_link;
2945002a60fSMarcel Moolenaar 	l_stack_t	uc_stack;
2955002a60fSMarcel Moolenaar 	struct l_sigcontext	uc_mcontext;
2965002a60fSMarcel Moolenaar 	l_sigset_t	uc_sigmask;
29779363394SAndrew Gallatin };
29879363394SAndrew Gallatin 
29979363394SAndrew Gallatin #define	LINUX_SI_MAX_SIZE	128
3005002a60fSMarcel Moolenaar #define	LINUX_SI_PAD_SIZE	((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3)
30179363394SAndrew Gallatin 
302aa8b2011SKonstantin Belousov typedef union l_sigval {
303aa8b2011SKonstantin Belousov 	l_int		sival_int;
304aa8b2011SKonstantin Belousov 	l_uintptr_t	sival_ptr;
305aa8b2011SKonstantin Belousov } l_sigval_t;
306aa8b2011SKonstantin Belousov 
3075002a60fSMarcel Moolenaar typedef struct l_siginfo {
3085002a60fSMarcel Moolenaar 	l_int		lsi_signo;
3095002a60fSMarcel Moolenaar 	l_int		lsi_errno;
3105002a60fSMarcel Moolenaar 	l_int		lsi_code;
31179363394SAndrew Gallatin 	union {
3125002a60fSMarcel Moolenaar 		l_int	_pad[LINUX_SI_PAD_SIZE];
3135002a60fSMarcel Moolenaar 
31479363394SAndrew Gallatin 		struct {
3155002a60fSMarcel Moolenaar 			l_pid_t		_pid;
316aa8b2011SKonstantin Belousov 			l_uid_t		_uid;
31779363394SAndrew Gallatin 		} _kill;
31879363394SAndrew Gallatin 
31979363394SAndrew Gallatin 		struct {
320aa8b2011SKonstantin Belousov 			l_timer_t	_tid;
321aa8b2011SKonstantin Belousov 			l_int		_overrun;
322aa8b2011SKonstantin Belousov 			char		_pad[sizeof(l_uid_t) - sizeof(l_int)];
323aa8b2011SKonstantin Belousov 			l_sigval_t	_sigval;
324aa8b2011SKonstantin Belousov 			l_int		_sys_private;
32579363394SAndrew Gallatin 		} _timer;
32679363394SAndrew Gallatin 
32779363394SAndrew Gallatin 		struct {
3285002a60fSMarcel Moolenaar 			l_pid_t		_pid;		/* sender's pid */
329aa8b2011SKonstantin Belousov 			l_uid_t		_uid;		/* sender's uid */
330aa8b2011SKonstantin Belousov 			l_sigval_t	_sigval;
33179363394SAndrew Gallatin 		} _rt;
33279363394SAndrew Gallatin 
33379363394SAndrew Gallatin 		struct {
3345002a60fSMarcel Moolenaar 			l_pid_t		_pid;		/* which child */
335aa8b2011SKonstantin Belousov 			l_uid_t		_uid;		/* sender's uid */
3365002a60fSMarcel Moolenaar 			l_int		_status;	/* exit code */
3375002a60fSMarcel Moolenaar 			l_clock_t	_utime;
3385002a60fSMarcel Moolenaar 			l_clock_t	_stime;
33979363394SAndrew Gallatin 		} _sigchld;
34079363394SAndrew Gallatin 
34179363394SAndrew Gallatin 		struct {
342aa8b2011SKonstantin Belousov 			l_uintptr_t	_addr;	/* Faulting insn/memory ref. */
34379363394SAndrew Gallatin 		} _sigfault;
34479363394SAndrew Gallatin 
34579363394SAndrew Gallatin 		struct {
346aa8b2011SKonstantin Belousov 			l_long		_band;	/* POLL_IN,POLL_OUT,POLL_MSG */
3475002a60fSMarcel Moolenaar 			l_int		_fd;
34879363394SAndrew Gallatin 		} _sigpoll;
34979363394SAndrew Gallatin 	} _sifields;
3505002a60fSMarcel Moolenaar } l_siginfo_t;
35179363394SAndrew Gallatin 
35279363394SAndrew Gallatin #define	lsi_pid		_sifields._kill._pid
35379363394SAndrew Gallatin #define	lsi_uid		_sifields._kill._uid
354aa8b2011SKonstantin Belousov #define	lsi_tid		_sifields._timer._tid
355aa8b2011SKonstantin Belousov #define	lsi_overrun	_sifields._timer._overrun
356aa8b2011SKonstantin Belousov #define	lsi_sys_private	_sifields._timer._sys_private
35779363394SAndrew Gallatin #define	lsi_status	_sifields._sigchld._status
35879363394SAndrew Gallatin #define	lsi_utime	_sifields._sigchld._utime
35979363394SAndrew Gallatin #define	lsi_stime	_sifields._sigchld._stime
36079363394SAndrew Gallatin #define	lsi_value	_sifields._rt._sigval
36179363394SAndrew Gallatin #define	lsi_int		_sifields._rt._sigval.sival_int
36279363394SAndrew Gallatin #define	lsi_ptr		_sifields._rt._sigval.sival_ptr
36379363394SAndrew Gallatin #define	lsi_addr	_sifields._sigfault._addr
36479363394SAndrew Gallatin #define	lsi_band	_sifields._sigpoll._band
36579363394SAndrew Gallatin #define	lsi_fd		_sifields._sigpoll._fd
36679363394SAndrew Gallatin 
3675002a60fSMarcel Moolenaar struct l_fpreg {
3682c4ab9ddSAndrew Gallatin 	u_int16_t	significand[4];
3692c4ab9ddSAndrew Gallatin 	u_int16_t	exponent;
3702c4ab9ddSAndrew Gallatin };
3712c4ab9ddSAndrew Gallatin 
3725002a60fSMarcel Moolenaar struct l_fpxreg {
3732c4ab9ddSAndrew Gallatin 	u_int16_t	significand[4];
3742c4ab9ddSAndrew Gallatin 	u_int16_t	exponent;
3752c4ab9ddSAndrew Gallatin 	u_int16_t	padding[3];
3762c4ab9ddSAndrew Gallatin };
3772c4ab9ddSAndrew Gallatin 
3785002a60fSMarcel Moolenaar struct l_xmmreg {
3792c4ab9ddSAndrew Gallatin 	u_int32_t	element[4];
3802c4ab9ddSAndrew Gallatin };
3812c4ab9ddSAndrew Gallatin 
3825002a60fSMarcel Moolenaar struct l_fpstate {
3832c4ab9ddSAndrew Gallatin 	/* Regular FPU environment */
3842c4ab9ddSAndrew Gallatin 	u_int32_t		cw;
3852c4ab9ddSAndrew Gallatin 	u_int32_t		sw;
3862c4ab9ddSAndrew Gallatin 	u_int32_t		tag;
3872c4ab9ddSAndrew Gallatin 	u_int32_t		ipoff;
3882c4ab9ddSAndrew Gallatin 	u_int32_t		cssel;
3892c4ab9ddSAndrew Gallatin 	u_int32_t		dataoff;
3902c4ab9ddSAndrew Gallatin 	u_int32_t		datasel;
3915002a60fSMarcel Moolenaar 	struct l_fpreg		_st[8];
3922c4ab9ddSAndrew Gallatin 	u_int16_t		status;
3932c4ab9ddSAndrew Gallatin 	u_int16_t		magic;		/* 0xffff = regular FPU data */
3942c4ab9ddSAndrew Gallatin 
3952c4ab9ddSAndrew Gallatin 	/* FXSR FPU environment */
396a4e3bad7SJung-uk Kim 	u_int32_t		_fxsr_env[6];	/* env is ignored. */
3972c4ab9ddSAndrew Gallatin 	u_int32_t		mxcsr;
3982c4ab9ddSAndrew Gallatin 	u_int32_t		reserved;
399a4e3bad7SJung-uk Kim 	struct l_fpxreg		_fxsr_st[8];	/* reg data is ignored. */
4005002a60fSMarcel Moolenaar 	struct l_xmmreg		_xmm[8];
4012c4ab9ddSAndrew Gallatin 	u_int32_t		padding[56];
4022c4ab9ddSAndrew Gallatin };
40379363394SAndrew Gallatin 
404d66a5066SPeter Wemm /*
405d66a5066SPeter Wemm  * We make the stack look like Linux expects it when calling a signal
406d66a5066SPeter Wemm  * handler, but use the BSD way of calling the handler and sigreturn().
407d66a5066SPeter Wemm  * This means that we need to pass the pointer to the handler too.
408d66a5066SPeter Wemm  * It is appended to the frame to not interfere with the rest of it.
409d66a5066SPeter Wemm  */
4105002a60fSMarcel Moolenaar struct l_sigframe {
4115002a60fSMarcel Moolenaar 	l_int			sf_sig;
4125002a60fSMarcel Moolenaar 	struct l_sigcontext	sf_sc;
4135002a60fSMarcel Moolenaar 	struct l_fpstate	sf_fpstate;
4145002a60fSMarcel Moolenaar 	l_uint			sf_extramask[LINUX_NSIG_WORDS-1];
4155002a60fSMarcel Moolenaar 	l_handler_t		sf_handler;
416d66a5066SPeter Wemm };
417d66a5066SPeter Wemm 
4185002a60fSMarcel Moolenaar struct l_rt_sigframe {
4195002a60fSMarcel Moolenaar 	l_int			sf_sig;
4205002a60fSMarcel Moolenaar 	l_siginfo_t		*sf_siginfo;
4215002a60fSMarcel Moolenaar 	struct l_ucontext	*sf_ucontext;
4225002a60fSMarcel Moolenaar 	l_siginfo_t		sf_si;
4235002a60fSMarcel Moolenaar 	struct l_ucontext	sf_sc;
4245002a60fSMarcel Moolenaar 	l_handler_t		sf_handler;
42579363394SAndrew Gallatin };
42679363394SAndrew Gallatin 
427d323ddf3SMatthew Dillon extern struct sysentvec linux_sysvec;
428c21dee17SSøren Schmidt 
42943bef515SMarcel Moolenaar /*
4304d0f380dSDmitry Chagin  * arch specific open/fcntl flags
43143bef515SMarcel Moolenaar  */
432aaaefc6bSRobert Drehmel #define	LINUX_F_GETLK64		12
433aaaefc6bSRobert Drehmel #define	LINUX_F_SETLK64		13
434aaaefc6bSRobert Drehmel #define	LINUX_F_SETLKW64	14
435aaaefc6bSRobert Drehmel 
4365002a60fSMarcel Moolenaar union l_semun {
4375002a60fSMarcel Moolenaar 	l_int		val;
438f730d606SDmitry Chagin 	l_uintptr_t	buf;
4395002a60fSMarcel Moolenaar 	l_ushort	*array;
440f730d606SDmitry Chagin 	l_uintptr_t	__buf;
441f730d606SDmitry Chagin 	l_uintptr_t	__pad;
4425002a60fSMarcel Moolenaar };
4435002a60fSMarcel Moolenaar 
4445002a60fSMarcel Moolenaar struct l_ifmap {
4455002a60fSMarcel Moolenaar 	l_ulong		mem_start;
4465002a60fSMarcel Moolenaar 	l_ulong		mem_end;
4475002a60fSMarcel Moolenaar 	l_ushort	base_addr;
44843bef515SMarcel Moolenaar 	u_char		irq;
44943bef515SMarcel Moolenaar 	u_char		dma;
45043bef515SMarcel Moolenaar 	u_char		port;
4513713cbffSMike Smith };
4523713cbffSMike Smith 
4535002a60fSMarcel Moolenaar struct l_ifreq {
45443bef515SMarcel Moolenaar 	union {
45543bef515SMarcel Moolenaar 		char	ifrn_name[LINUX_IFNAMSIZ];
4563713cbffSMike Smith 	} ifr_ifrn;
4573713cbffSMike Smith 
4583713cbffSMike Smith 	union {
4595002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_addr;
4605002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_dstaddr;
4615002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_broadaddr;
4625002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_netmask;
4635002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_hwaddr;
464268aeb1eSDag-Erling Smørgrav 		l_short		ifru_flags[1];
4657ece126eSTai-hwa Liang 		l_int		ifru_ivalue;
4665002a60fSMarcel Moolenaar 		l_int		ifru_mtu;
4675002a60fSMarcel Moolenaar 		struct l_ifmap	ifru_map;
4685002a60fSMarcel Moolenaar 		char		ifru_slave[LINUX_IFNAMSIZ];
4695002a60fSMarcel Moolenaar 		l_caddr_t	ifru_data;
4703713cbffSMike Smith 	} ifr_ifru;
4713713cbffSMike Smith };
4723713cbffSMike Smith 
473a4e3bad7SJung-uk Kim #define	ifr_name	ifr_ifrn.ifrn_name	/* Interface name */
4743713cbffSMike Smith #define	ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address */
4757ece126eSTai-hwa Liang #define	ifr_ifindex	ifr_ifru.ifru_ivalue	/* Interface index */
4763713cbffSMike Smith 
4779b44bfc5SAlexander Leidinger struct l_user_desc {
4789b44bfc5SAlexander Leidinger 	l_uint		entry_number;
4799b44bfc5SAlexander Leidinger 	l_uint		base_addr;
4809b44bfc5SAlexander Leidinger 	l_uint		limit;
4819b44bfc5SAlexander Leidinger 	l_uint		seg_32bit:1;
4829b44bfc5SAlexander Leidinger 	l_uint		contents:2;
4839b44bfc5SAlexander Leidinger 	l_uint		read_exec_only:1;
4849b44bfc5SAlexander Leidinger 	l_uint		limit_in_pages:1;
4859b44bfc5SAlexander Leidinger 	l_uint		seg_not_present:1;
4869b44bfc5SAlexander Leidinger 	l_uint		useable:1;
4879b44bfc5SAlexander Leidinger };
4889b44bfc5SAlexander Leidinger 
4899b44bfc5SAlexander Leidinger struct l_desc_struct {
4909b44bfc5SAlexander Leidinger 	unsigned long	a, b;
4919b44bfc5SAlexander Leidinger };
4929b44bfc5SAlexander Leidinger 
4939b44bfc5SAlexander Leidinger #define	LINUX_LOWERWORD	0x0000ffff
4949b44bfc5SAlexander Leidinger 
4950eef2f8aSAlexander Leidinger /*
496a4e3bad7SJung-uk Kim  * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h.
497a4e3bad7SJung-uk Kim  * These convert Linux user space descriptor to machine one.
4989b44bfc5SAlexander Leidinger  */
499a4e3bad7SJung-uk Kim #define	LINUX_LDT_entry_a(info)					\
500a4e3bad7SJung-uk Kim 	((((info)->base_addr & LINUX_LOWERWORD) << 16) |	\
501a4e3bad7SJung-uk Kim 	((info)->limit & LINUX_LOWERWORD))
5029b44bfc5SAlexander Leidinger 
503a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_READ_EXEC_ONLY	9
504a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_CONTENTS		10
505a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_SEG_NOT_PRESENT	15
506a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_BASE_ADDR		16
507a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_USEABLE		20
508a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_SEG32BIT		22
509a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_LIMIT		23
5109b44bfc5SAlexander Leidinger 
511a4e3bad7SJung-uk Kim #define	LINUX_LDT_entry_b(info)							\
5129b44bfc5SAlexander Leidinger 	(((info)->base_addr & 0xff000000) |					\
5139b44bfc5SAlexander Leidinger 	((info)->limit & 0xf0000) |						\
514a4e3bad7SJung-uk Kim 	((info)->contents << LINUX_ENTRY_B_CONTENTS) |				\
515a4e3bad7SJung-uk Kim 	(((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) |	\
516a4e3bad7SJung-uk Kim 	(((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) |		\
517a4e3bad7SJung-uk Kim 	(((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) |	\
518a4e3bad7SJung-uk Kim 	((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) |				\
519a4e3bad7SJung-uk Kim 	((info)->useable << LINUX_ENTRY_B_USEABLE) |				\
520a4e3bad7SJung-uk Kim 	((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000)
5219b44bfc5SAlexander Leidinger 
522a4e3bad7SJung-uk Kim #define	LINUX_LDT_empty(info)		\
523a4e3bad7SJung-uk Kim 	((info)->base_addr == 0 &&	\
5249b44bfc5SAlexander Leidinger 	(info)->limit == 0 &&		\
5259b44bfc5SAlexander Leidinger 	(info)->contents == 0 &&	\
5269b44bfc5SAlexander Leidinger 	(info)->seg_not_present == 1 &&	\
5279b44bfc5SAlexander Leidinger 	(info)->read_exec_only == 1 &&	\
5289b44bfc5SAlexander Leidinger 	(info)->seg_32bit == 0 &&	\
5299b44bfc5SAlexander Leidinger 	(info)->limit_in_pages == 0 &&	\
5309b44bfc5SAlexander Leidinger 	(info)->useable == 0)
5319b44bfc5SAlexander Leidinger 
532a4e3bad7SJung-uk Kim /*
533a4e3bad7SJung-uk Kim  * Macros for converting segments.
534a4e3bad7SJung-uk Kim  * They do the same as those in arch/i386/kernel/process.c in Linux.
535a4e3bad7SJung-uk Kim  */
536a4e3bad7SJung-uk Kim #define	LINUX_GET_BASE(desc)				\
537a4e3bad7SJung-uk Kim 	((((desc)->a >> 16) & LINUX_LOWERWORD) |	\
5389b44bfc5SAlexander Leidinger 	(((desc)->b << 16) & 0x00ff0000) |		\
5399b44bfc5SAlexander Leidinger 	((desc)->b & 0xff000000))
5409b44bfc5SAlexander Leidinger 
541a4e3bad7SJung-uk Kim #define	LINUX_GET_LIMIT(desc)			\
542a4e3bad7SJung-uk Kim 	(((desc)->a & LINUX_LOWERWORD) |	\
5439b44bfc5SAlexander Leidinger 	((desc)->b & 0xf0000))
5449b44bfc5SAlexander Leidinger 
545a4e3bad7SJung-uk Kim #define	LINUX_GET_32BIT(desc)		\
546a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1)
547a4e3bad7SJung-uk Kim #define	LINUX_GET_CONTENTS(desc)	\
548a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3)
549a4e3bad7SJung-uk Kim #define	LINUX_GET_WRITABLE(desc)	\
550a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1)
551a4e3bad7SJung-uk Kim #define	LINUX_GET_LIMIT_PAGES(desc)	\
552a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1)
553a4e3bad7SJung-uk Kim #define	LINUX_GET_PRESENT(desc)		\
554a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1)
555a4e3bad7SJung-uk Kim #define	LINUX_GET_USEABLE(desc)		\
556a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1)
5579b44bfc5SAlexander Leidinger 
558001398c4SDmitry Chagin #define	linux_copyout_rusage(r, u)	copyout(r, u, sizeof(*r))
559001398c4SDmitry Chagin 
560175c6c31SKonstantin Belousov /* robust futexes */
561175c6c31SKonstantin Belousov struct linux_robust_list {
562175c6c31SKonstantin Belousov 	struct linux_robust_list	*next;
563175c6c31SKonstantin Belousov };
564175c6c31SKonstantin Belousov 
565175c6c31SKonstantin Belousov struct linux_robust_list_head {
566175c6c31SKonstantin Belousov 	struct linux_robust_list	list;
56762162dfcSKonstantin Belousov 	l_long				futex_offset;
568175c6c31SKonstantin Belousov 	struct linux_robust_list	*pending_list;
569175c6c31SKonstantin Belousov };
570175c6c31SKonstantin Belousov 
571a4e3bad7SJung-uk Kim #endif /* !_I386_LINUX_H_ */
572