xref: /freebsd/sys/i386/linux/linux.h (revision aa8b201112c871e10cb119d371688098b5395916)
1c21dee17SSøren Schmidt /*-
2e1743d02SSøren Schmidt  * 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)
43b40ce416SJulian Elischer #define	ARGS(nm, fmt)	"linux(%ld): "#nm"("fmt")\n", (long)td->td_proc->p_pid
44b40ce416SJulian Elischer #define	LMSG(fmt)	"linux(%ld): "fmt"\n", (long)td->td_proc->p_pid
4524593369SJonathan Lemon 
4643bef515SMarcel Moolenaar #ifdef MALLOC_DECLARE
4743bef515SMarcel Moolenaar MALLOC_DECLARE(M_LINUX);
4843bef515SMarcel Moolenaar #endif
4943bef515SMarcel Moolenaar 
500e73a962STim J. Robbins #define	PTRIN(v)	(void *)(v)
510e73a962STim J. Robbins #define	PTROUT(v)	(l_uintptr_t)(v)
520e73a962STim J. Robbins 
5343bef515SMarcel Moolenaar /*
541b20ff34SEric Melville  * Provide a separate set of types for the Linux types.
555002a60fSMarcel Moolenaar  */
565002a60fSMarcel Moolenaar typedef int		l_int;
575002a60fSMarcel Moolenaar typedef int32_t		l_long;
585002a60fSMarcel Moolenaar typedef int64_t		l_longlong;
595002a60fSMarcel Moolenaar typedef short		l_short;
605002a60fSMarcel Moolenaar typedef unsigned int	l_uint;
615002a60fSMarcel Moolenaar typedef uint32_t	l_ulong;
625002a60fSMarcel Moolenaar typedef uint64_t	l_ulonglong;
635002a60fSMarcel Moolenaar typedef unsigned short	l_ushort;
645002a60fSMarcel Moolenaar 
655002a60fSMarcel Moolenaar typedef char		*l_caddr_t;
660e73a962STim J. Robbins typedef l_ulong		l_uintptr_t;
675002a60fSMarcel Moolenaar typedef l_long		l_clock_t;
685002a60fSMarcel Moolenaar typedef l_int		l_daddr_t;
695002a60fSMarcel Moolenaar typedef l_ushort	l_dev_t;
705002a60fSMarcel Moolenaar typedef l_uint		l_gid_t;
715002a60fSMarcel Moolenaar typedef l_ushort	l_gid16_t;
725002a60fSMarcel Moolenaar typedef l_ulong		l_ino_t;
735002a60fSMarcel Moolenaar typedef l_int		l_key_t;
745002a60fSMarcel Moolenaar typedef l_longlong	l_loff_t;
755002a60fSMarcel Moolenaar typedef l_ushort	l_mode_t;
765002a60fSMarcel Moolenaar typedef l_long		l_off_t;
775002a60fSMarcel Moolenaar typedef l_int		l_pid_t;
785002a60fSMarcel Moolenaar typedef l_uint		l_size_t;
795002a60fSMarcel Moolenaar typedef l_long		l_suseconds_t;
805002a60fSMarcel Moolenaar typedef l_long		l_time_t;
815002a60fSMarcel Moolenaar typedef l_uint		l_uid_t;
825002a60fSMarcel Moolenaar typedef l_ushort	l_uid16_t;
83aa8b2011SKonstantin Belousov typedef l_int		l_timer_t;
84aa8b2011SKonstantin Belousov typedef l_int		l_mqd_t;
855002a60fSMarcel Moolenaar 
865002a60fSMarcel Moolenaar typedef struct {
875002a60fSMarcel Moolenaar 	l_int		val[2];
885002a60fSMarcel Moolenaar } l_fsid_t;
895002a60fSMarcel Moolenaar 
905002a60fSMarcel Moolenaar typedef struct {
915002a60fSMarcel Moolenaar 	l_time_t	tv_sec;
925002a60fSMarcel Moolenaar 	l_suseconds_t	tv_usec;
935002a60fSMarcel Moolenaar } l_timeval;
945002a60fSMarcel Moolenaar 
955002a60fSMarcel Moolenaar #define	l_fd_set	fd_set
965002a60fSMarcel Moolenaar 
975002a60fSMarcel Moolenaar /*
9843bef515SMarcel Moolenaar  * Miscellaneous
9943bef515SMarcel Moolenaar  */
10043bef515SMarcel Moolenaar #define	LINUX_NAME_MAX		255
10143bef515SMarcel Moolenaar #define	LINUX_MAX_UTSNAME	65
10243bef515SMarcel Moolenaar 
1035002a60fSMarcel Moolenaar #define	LINUX_CTL_MAXNAME	10
1045002a60fSMarcel Moolenaar 
1055002a60fSMarcel Moolenaar struct l___sysctl_args
1065002a60fSMarcel Moolenaar {
1075002a60fSMarcel Moolenaar 	l_int		*name;
1085002a60fSMarcel Moolenaar 	l_int		nlen;
1095002a60fSMarcel Moolenaar 	void		*oldval;
1105002a60fSMarcel Moolenaar 	l_size_t	*oldlenp;
1115002a60fSMarcel Moolenaar 	void		*newval;
1125002a60fSMarcel Moolenaar 	l_size_t	newlen;
1135002a60fSMarcel Moolenaar 	l_ulong		__spare[4];
1145002a60fSMarcel Moolenaar };
1155002a60fSMarcel Moolenaar 
11643bef515SMarcel Moolenaar /* Scheduling policies */
11743bef515SMarcel Moolenaar #define	LINUX_SCHED_OTHER	0
11843bef515SMarcel Moolenaar #define	LINUX_SCHED_FIFO	1
11943bef515SMarcel Moolenaar #define	LINUX_SCHED_RR		2
12043bef515SMarcel Moolenaar 
12143bef515SMarcel Moolenaar /* Resource limits */
12243bef515SMarcel Moolenaar #define	LINUX_RLIMIT_CPU	0
12343bef515SMarcel Moolenaar #define	LINUX_RLIMIT_FSIZE	1
12443bef515SMarcel Moolenaar #define	LINUX_RLIMIT_DATA	2
12543bef515SMarcel Moolenaar #define	LINUX_RLIMIT_STACK	3
12643bef515SMarcel Moolenaar #define	LINUX_RLIMIT_CORE	4
12743bef515SMarcel Moolenaar #define	LINUX_RLIMIT_RSS	5
12843bef515SMarcel Moolenaar #define	LINUX_RLIMIT_NPROC	6
12943bef515SMarcel Moolenaar #define	LINUX_RLIMIT_NOFILE	7
13043bef515SMarcel Moolenaar #define	LINUX_RLIMIT_MEMLOCK	8
131a4e3bad7SJung-uk Kim #define	LINUX_RLIMIT_AS		9	/* Address space limit */
13243bef515SMarcel Moolenaar 
13343bef515SMarcel Moolenaar #define	LINUX_RLIM_NLIMITS	10
13443bef515SMarcel Moolenaar 
1355002a60fSMarcel Moolenaar struct l_rlimit {
1365002a60fSMarcel Moolenaar 	l_ulong rlim_cur;
1375002a60fSMarcel Moolenaar 	l_ulong rlim_max;
1385002a60fSMarcel Moolenaar };
1395002a60fSMarcel Moolenaar 
14043bef515SMarcel Moolenaar /* mmap options */
14143bef515SMarcel Moolenaar #define	LINUX_MAP_SHARED	0x0001
14243bef515SMarcel Moolenaar #define	LINUX_MAP_PRIVATE	0x0002
14343bef515SMarcel Moolenaar #define	LINUX_MAP_FIXED		0x0010
14443bef515SMarcel Moolenaar #define	LINUX_MAP_ANON		0x0020
14543bef515SMarcel Moolenaar #define	LINUX_MAP_GROWSDOWN	0x0100
14643bef515SMarcel Moolenaar 
14710931a46SJung-uk Kim struct l_mmap_argv {
14810931a46SJung-uk Kim 	l_uintptr_t	addr;
14910931a46SJung-uk Kim 	l_size_t	len;
15010931a46SJung-uk Kim 	l_int		prot;
15110931a46SJung-uk Kim 	l_int		flags;
15210931a46SJung-uk Kim 	l_int		fd;
15310931a46SJung-uk Kim 	l_off_t		pgoff;
15410931a46SJung-uk Kim } __packed;
15510931a46SJung-uk Kim 
1565002a60fSMarcel Moolenaar /*
1575002a60fSMarcel Moolenaar  * stat family of syscalls
1585002a60fSMarcel Moolenaar  */
1595002a60fSMarcel Moolenaar struct l_timespec {
16077424f41SJung-uk Kim 	l_time_t	tv_sec;
16177424f41SJung-uk Kim 	l_long		tv_nsec;
1625002a60fSMarcel Moolenaar };
16343bef515SMarcel Moolenaar 
1645002a60fSMarcel Moolenaar struct l_newstat {
1655002a60fSMarcel Moolenaar 	l_ushort	st_dev;
1665002a60fSMarcel Moolenaar 	l_ushort	__pad1;
1675002a60fSMarcel Moolenaar 	l_ulong		st_ino;
1685002a60fSMarcel Moolenaar 	l_ushort	st_mode;
1695002a60fSMarcel Moolenaar 	l_ushort	st_nlink;
1705002a60fSMarcel Moolenaar 	l_ushort	st_uid;
1715002a60fSMarcel Moolenaar 	l_ushort	st_gid;
1725002a60fSMarcel Moolenaar 	l_ushort	st_rdev;
1735002a60fSMarcel Moolenaar 	l_ushort	__pad2;
1745002a60fSMarcel Moolenaar 	l_ulong		st_size;
1755002a60fSMarcel Moolenaar 	l_ulong		st_blksize;
1765002a60fSMarcel Moolenaar 	l_ulong		st_blocks;
1775002a60fSMarcel Moolenaar 	struct l_timespec	st_atimespec;
1785002a60fSMarcel Moolenaar 	struct l_timespec	st_mtimespec;
1795002a60fSMarcel Moolenaar 	struct l_timespec	st_ctimespec;
1805002a60fSMarcel Moolenaar 	l_ulong		__unused4;
1815002a60fSMarcel Moolenaar 	l_ulong		__unused5;
1825002a60fSMarcel Moolenaar };
18343bef515SMarcel Moolenaar 
1841f7642e0SAlexander Leidinger struct l_stat {
1851f7642e0SAlexander Leidinger 	l_ushort	st_dev;
1861f7642e0SAlexander Leidinger 	l_ulong		st_ino;
1871f7642e0SAlexander Leidinger 	l_ushort	st_mode;
1881f7642e0SAlexander Leidinger 	l_ushort	st_nlink;
1891f7642e0SAlexander Leidinger 	l_ushort	st_uid;
1901f7642e0SAlexander Leidinger 	l_ushort	st_gid;
1911f7642e0SAlexander Leidinger 	l_ushort	st_rdev;
1921f7642e0SAlexander Leidinger 	l_long		st_size;
1931f7642e0SAlexander Leidinger 	struct l_timespec	st_atimespec;
1941f7642e0SAlexander Leidinger 	struct l_timespec	st_mtimespec;
1951f7642e0SAlexander Leidinger 	struct l_timespec	st_ctimespec;
1961f7642e0SAlexander Leidinger 	l_long		st_blksize;
1971f7642e0SAlexander Leidinger 	l_long		st_blocks;
1981f7642e0SAlexander Leidinger 	l_ulong		st_flags;
1991f7642e0SAlexander Leidinger 	l_ulong		st_gen;
2001f7642e0SAlexander Leidinger };
2011f7642e0SAlexander Leidinger 
2025002a60fSMarcel Moolenaar struct l_stat64 {
2035002a60fSMarcel Moolenaar 	l_ushort	st_dev;
2045002a60fSMarcel Moolenaar 	u_char		__pad0[10];
2055002a60fSMarcel Moolenaar 	l_ulong		__st_ino;
2065002a60fSMarcel Moolenaar 	l_uint		st_mode;
2075002a60fSMarcel Moolenaar 	l_uint		st_nlink;
2085002a60fSMarcel Moolenaar 	l_ulong		st_uid;
2095002a60fSMarcel Moolenaar 	l_ulong		st_gid;
2105002a60fSMarcel Moolenaar 	l_ushort	st_rdev;
2115002a60fSMarcel Moolenaar 	u_char		__pad3[10];
2125002a60fSMarcel Moolenaar 	l_longlong	st_size;
2135002a60fSMarcel Moolenaar 	l_ulong		st_blksize;
2145002a60fSMarcel Moolenaar 	l_ulong		st_blocks;
2155002a60fSMarcel Moolenaar 	l_ulong		__pad4;
2165002a60fSMarcel Moolenaar 	struct l_timespec	st_atimespec;
2175002a60fSMarcel Moolenaar 	struct l_timespec	st_mtimespec;
2185002a60fSMarcel Moolenaar 	struct l_timespec	st_ctimespec;
2195002a60fSMarcel Moolenaar 	l_ulonglong	st_ino;
2205002a60fSMarcel Moolenaar };
2215002a60fSMarcel Moolenaar 
2223ab85269SDavid Malone struct l_statfs64 {
2233ab85269SDavid Malone         l_int           f_type;
2243ab85269SDavid Malone         l_int           f_bsize;
2253ab85269SDavid Malone         uint64_t        f_blocks;
2263ab85269SDavid Malone         uint64_t        f_bfree;
2273ab85269SDavid Malone         uint64_t        f_bavail;
2283ab85269SDavid Malone         uint64_t        f_files;
2293ab85269SDavid Malone         uint64_t        f_ffree;
2303ab85269SDavid Malone         l_fsid_t        f_fsid;
2313ab85269SDavid Malone         l_int           f_namelen;
2323ab85269SDavid Malone         l_int           f_spare[6];
2333ab85269SDavid Malone };
2343ab85269SDavid Malone 
2355002a60fSMarcel Moolenaar struct l_new_utsname {
23643bef515SMarcel Moolenaar 	char	sysname[LINUX_MAX_UTSNAME];
23743bef515SMarcel Moolenaar 	char	nodename[LINUX_MAX_UTSNAME];
23843bef515SMarcel Moolenaar 	char	release[LINUX_MAX_UTSNAME];
23943bef515SMarcel Moolenaar 	char	version[LINUX_MAX_UTSNAME];
24043bef515SMarcel Moolenaar 	char	machine[LINUX_MAX_UTSNAME];
24143bef515SMarcel Moolenaar 	char	domainname[LINUX_MAX_UTSNAME];
24243bef515SMarcel Moolenaar };
243c21dee17SSøren Schmidt 
244956d3333SMarcel Moolenaar /*
24543bef515SMarcel Moolenaar  * Signalling
246956d3333SMarcel Moolenaar  */
24743bef515SMarcel Moolenaar #define	LINUX_SIGHUP		1
24843bef515SMarcel Moolenaar #define	LINUX_SIGINT		2
24943bef515SMarcel Moolenaar #define	LINUX_SIGQUIT		3
25043bef515SMarcel Moolenaar #define	LINUX_SIGILL		4
25143bef515SMarcel Moolenaar #define	LINUX_SIGTRAP		5
25243bef515SMarcel Moolenaar #define	LINUX_SIGABRT		6
25343bef515SMarcel Moolenaar #define	LINUX_SIGIOT		LINUX_SIGABRT
25443bef515SMarcel Moolenaar #define	LINUX_SIGBUS		7
25543bef515SMarcel Moolenaar #define	LINUX_SIGFPE		8
25643bef515SMarcel Moolenaar #define	LINUX_SIGKILL		9
25743bef515SMarcel Moolenaar #define	LINUX_SIGUSR1		10
25843bef515SMarcel Moolenaar #define	LINUX_SIGSEGV		11
25943bef515SMarcel Moolenaar #define	LINUX_SIGUSR2		12
26043bef515SMarcel Moolenaar #define	LINUX_SIGPIPE		13
26143bef515SMarcel Moolenaar #define	LINUX_SIGALRM		14
26243bef515SMarcel Moolenaar #define	LINUX_SIGTERM		15
26343bef515SMarcel Moolenaar #define	LINUX_SIGSTKFLT		16
26443bef515SMarcel Moolenaar #define	LINUX_SIGCHLD		17
26543bef515SMarcel Moolenaar #define	LINUX_SIGCONT		18
26643bef515SMarcel Moolenaar #define	LINUX_SIGSTOP		19
26743bef515SMarcel Moolenaar #define	LINUX_SIGTSTP		20
26843bef515SMarcel Moolenaar #define	LINUX_SIGTTIN		21
26943bef515SMarcel Moolenaar #define	LINUX_SIGTTOU		22
27043bef515SMarcel Moolenaar #define	LINUX_SIGURG		23
27143bef515SMarcel Moolenaar #define	LINUX_SIGXCPU		24
27243bef515SMarcel Moolenaar #define	LINUX_SIGXFSZ		25
27343bef515SMarcel Moolenaar #define	LINUX_SIGVTALRM		26
27443bef515SMarcel Moolenaar #define	LINUX_SIGPROF		27
27543bef515SMarcel Moolenaar #define	LINUX_SIGWINCH		28
27643bef515SMarcel Moolenaar #define	LINUX_SIGIO		29
27743bef515SMarcel Moolenaar #define	LINUX_SIGPOLL		LINUX_SIGIO
27843bef515SMarcel Moolenaar #define	LINUX_SIGPWR		30
279ba873f4cSAlexander Kabaev #define	LINUX_SIGSYS		31
280956d3333SMarcel Moolenaar 
28143bef515SMarcel Moolenaar #define	LINUX_SIGTBLSZ		31
2822c4ab9ddSAndrew Gallatin #define	LINUX_NSIG_WORDS	2
2832c4ab9ddSAndrew Gallatin #define	LINUX_NBPW		32
2842c4ab9ddSAndrew Gallatin #define	LINUX_NSIG		(LINUX_NBPW * LINUX_NSIG_WORDS)
28543bef515SMarcel Moolenaar 
28643bef515SMarcel Moolenaar /* sigaction flags */
28743bef515SMarcel Moolenaar #define	LINUX_SA_NOCLDSTOP	0x00000001
28843bef515SMarcel Moolenaar #define	LINUX_SA_NOCLDWAIT	0x00000002
28943bef515SMarcel Moolenaar #define	LINUX_SA_SIGINFO	0x00000004
29043bef515SMarcel Moolenaar #define	LINUX_SA_RESTORER	0x04000000
29143bef515SMarcel Moolenaar #define	LINUX_SA_ONSTACK	0x08000000
29243bef515SMarcel Moolenaar #define	LINUX_SA_RESTART	0x10000000
29343bef515SMarcel Moolenaar #define	LINUX_SA_INTERRUPT	0x20000000
29443bef515SMarcel Moolenaar #define	LINUX_SA_NOMASK		0x40000000
29543bef515SMarcel Moolenaar #define	LINUX_SA_ONESHOT	0x80000000
29643bef515SMarcel Moolenaar 
29743bef515SMarcel Moolenaar /* sigprocmask actions */
29843bef515SMarcel Moolenaar #define	LINUX_SIG_BLOCK		0
29943bef515SMarcel Moolenaar #define	LINUX_SIG_UNBLOCK	1
30043bef515SMarcel Moolenaar #define	LINUX_SIG_SETMASK	2
30143bef515SMarcel Moolenaar 
30243bef515SMarcel Moolenaar /* sigset_t macros */
30343bef515SMarcel Moolenaar #define	LINUX_SIGEMPTYSET(set)		(set).__bits[0] = (set).__bits[1] = 0
30443bef515SMarcel Moolenaar #define	LINUX_SIGISMEMBER(set, sig)	SIGISMEMBER(set, sig)
30543bef515SMarcel Moolenaar #define	LINUX_SIGADDSET(set, sig)	SIGADDSET(set, sig)
30643bef515SMarcel Moolenaar 
307dee4ec33SMarcel Moolenaar /* sigaltstack */
308dee4ec33SMarcel Moolenaar #define	LINUX_MINSIGSTKSZ	2048
309931a7258SAndrew Gallatin #define	LINUX_SS_ONSTACK	1
310931a7258SAndrew Gallatin #define	LINUX_SS_DISABLE	2
311931a7258SAndrew Gallatin 
312931a7258SAndrew Gallatin int linux_to_bsd_sigaltstack(int lsa);
313931a7258SAndrew Gallatin int bsd_to_linux_sigaltstack(int bsa);
314931a7258SAndrew Gallatin 
3155002a60fSMarcel Moolenaar typedef void	(*l_handler_t)(l_int);
3165002a60fSMarcel Moolenaar typedef l_ulong	l_osigset_t;
317956d3333SMarcel Moolenaar 
31806ebbe77SMarcel Moolenaar typedef struct {
3195002a60fSMarcel Moolenaar 	l_uint	__bits[LINUX_NSIG_WORDS];
3205002a60fSMarcel Moolenaar } l_sigset_t;
321956d3333SMarcel Moolenaar 
322956d3333SMarcel Moolenaar typedef struct {
3235002a60fSMarcel Moolenaar 	l_handler_t	lsa_handler;
3245002a60fSMarcel Moolenaar 	l_osigset_t	lsa_mask;
3255002a60fSMarcel Moolenaar 	l_ulong		lsa_flags;
326956d3333SMarcel Moolenaar 	void	(*lsa_restorer)(void);
3275002a60fSMarcel Moolenaar } l_osigaction_t;
328956d3333SMarcel Moolenaar 
32906ebbe77SMarcel Moolenaar typedef struct {
3305002a60fSMarcel Moolenaar 	l_handler_t	lsa_handler;
3315002a60fSMarcel Moolenaar 	l_ulong		lsa_flags;
33206ebbe77SMarcel Moolenaar 	void	(*lsa_restorer)(void);
3335002a60fSMarcel Moolenaar 	l_sigset_t	lsa_mask;
3345002a60fSMarcel Moolenaar } l_sigaction_t;
33506ebbe77SMarcel Moolenaar 
33643bef515SMarcel Moolenaar typedef struct {
337ec99e322SMarcel Moolenaar 	void		*ss_sp;
3385002a60fSMarcel Moolenaar 	l_int		ss_flags;
3395002a60fSMarcel Moolenaar 	l_size_t	ss_size;
3405002a60fSMarcel Moolenaar } l_stack_t;
341ec99e322SMarcel Moolenaar 
34243bef515SMarcel Moolenaar /* The Linux sigcontext, pretty much a standard 386 trapframe. */
3435002a60fSMarcel Moolenaar struct l_sigcontext {
3445002a60fSMarcel Moolenaar 	l_int		sc_gs;
3455002a60fSMarcel Moolenaar 	l_int		sc_fs;
3465002a60fSMarcel Moolenaar 	l_int		sc_es;
3475002a60fSMarcel Moolenaar 	l_int		sc_ds;
3485002a60fSMarcel Moolenaar 	l_int		sc_edi;
3495002a60fSMarcel Moolenaar 	l_int		sc_esi;
3505002a60fSMarcel Moolenaar 	l_int		sc_ebp;
3515002a60fSMarcel Moolenaar 	l_int		sc_esp;
3525002a60fSMarcel Moolenaar 	l_int		sc_ebx;
3535002a60fSMarcel Moolenaar 	l_int		sc_edx;
3545002a60fSMarcel Moolenaar 	l_int		sc_ecx;
3555002a60fSMarcel Moolenaar 	l_int		sc_eax;
3565002a60fSMarcel Moolenaar 	l_int		sc_trapno;
3575002a60fSMarcel Moolenaar 	l_int		sc_err;
3585002a60fSMarcel Moolenaar 	l_int		sc_eip;
3595002a60fSMarcel Moolenaar 	l_int		sc_cs;
3605002a60fSMarcel Moolenaar 	l_int		sc_eflags;
3615002a60fSMarcel Moolenaar 	l_int		sc_esp_at_signal;
3625002a60fSMarcel Moolenaar 	l_int		sc_ss;
3635002a60fSMarcel Moolenaar 	l_int		sc_387;
3645002a60fSMarcel Moolenaar 	l_int		sc_mask;
3655002a60fSMarcel Moolenaar 	l_int		sc_cr2;
366d66a5066SPeter Wemm };
367d66a5066SPeter Wemm 
3685002a60fSMarcel Moolenaar struct l_ucontext {
3695002a60fSMarcel Moolenaar 	l_ulong		uc_flags;
37079363394SAndrew Gallatin 	void		*uc_link;
3715002a60fSMarcel Moolenaar 	l_stack_t	uc_stack;
3725002a60fSMarcel Moolenaar 	struct l_sigcontext	uc_mcontext;
3735002a60fSMarcel Moolenaar 	l_sigset_t	uc_sigmask;
37479363394SAndrew Gallatin };
37579363394SAndrew Gallatin 
37679363394SAndrew Gallatin #define	LINUX_SI_MAX_SIZE	128
3775002a60fSMarcel Moolenaar #define	LINUX_SI_PAD_SIZE	((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3)
37879363394SAndrew Gallatin 
379aa8b2011SKonstantin Belousov typedef union l_sigval {
380aa8b2011SKonstantin Belousov 	l_int		sival_int;
381aa8b2011SKonstantin Belousov 	l_uintptr_t	sival_ptr;
382aa8b2011SKonstantin Belousov } l_sigval_t;
383aa8b2011SKonstantin Belousov 
3845002a60fSMarcel Moolenaar typedef struct l_siginfo {
3855002a60fSMarcel Moolenaar 	l_int		lsi_signo;
3865002a60fSMarcel Moolenaar 	l_int		lsi_errno;
3875002a60fSMarcel Moolenaar 	l_int		lsi_code;
38879363394SAndrew Gallatin 	union {
3895002a60fSMarcel Moolenaar 		l_int	_pad[LINUX_SI_PAD_SIZE];
3905002a60fSMarcel Moolenaar 
39179363394SAndrew Gallatin 		struct {
3925002a60fSMarcel Moolenaar 			l_pid_t		_pid;
393aa8b2011SKonstantin Belousov 			l_uid_t		_uid;
39479363394SAndrew Gallatin 		} _kill;
39579363394SAndrew Gallatin 
39679363394SAndrew Gallatin 		struct {
397aa8b2011SKonstantin Belousov 			l_timer_t	_tid;
398aa8b2011SKonstantin Belousov 			l_int		_overrun;
399aa8b2011SKonstantin Belousov 			char		_pad[sizeof(l_uid_t) - sizeof(l_int)];
400aa8b2011SKonstantin Belousov 			l_sigval_t	_sigval;
401aa8b2011SKonstantin Belousov 			l_int		_sys_private;
40279363394SAndrew Gallatin 		} _timer;
40379363394SAndrew Gallatin 
40479363394SAndrew Gallatin 		struct {
4055002a60fSMarcel Moolenaar 			l_pid_t		_pid;		/* sender's pid */
406aa8b2011SKonstantin Belousov 			l_uid_t		_uid;		/* sender's uid */
407aa8b2011SKonstantin Belousov 			l_sigval_t	_sigval;
40879363394SAndrew Gallatin 		} _rt;
40979363394SAndrew Gallatin 
41079363394SAndrew Gallatin 		struct {
4115002a60fSMarcel Moolenaar 			l_pid_t		_pid;		/* which child */
412aa8b2011SKonstantin Belousov 			l_uid_t		_uid;		/* sender's uid */
4135002a60fSMarcel Moolenaar 			l_int		_status;	/* exit code */
4145002a60fSMarcel Moolenaar 			l_clock_t	_utime;
4155002a60fSMarcel Moolenaar 			l_clock_t	_stime;
41679363394SAndrew Gallatin 		} _sigchld;
41779363394SAndrew Gallatin 
41879363394SAndrew Gallatin 		struct {
419aa8b2011SKonstantin Belousov 			l_uintptr_t	_addr;	/* Faulting insn/memory ref. */
42079363394SAndrew Gallatin 		} _sigfault;
42179363394SAndrew Gallatin 
42279363394SAndrew Gallatin 		struct {
423aa8b2011SKonstantin Belousov 			l_long		_band;	/* POLL_IN,POLL_OUT,POLL_MSG */
4245002a60fSMarcel Moolenaar 			l_int		_fd;
42579363394SAndrew Gallatin 		} _sigpoll;
42679363394SAndrew Gallatin 	} _sifields;
4275002a60fSMarcel Moolenaar } l_siginfo_t;
42879363394SAndrew Gallatin 
42979363394SAndrew Gallatin #define	lsi_pid		_sifields._kill._pid
43079363394SAndrew Gallatin #define	lsi_uid		_sifields._kill._uid
431aa8b2011SKonstantin Belousov #define	lsi_tid		_sifields._timer._tid
432aa8b2011SKonstantin Belousov #define	lsi_overrun	_sifields._timer._overrun
433aa8b2011SKonstantin Belousov #define	lsi_sys_private	_sifields._timer._sys_private
43479363394SAndrew Gallatin #define	lsi_status	_sifields._sigchld._status
43579363394SAndrew Gallatin #define	lsi_utime	_sifields._sigchld._utime
43679363394SAndrew Gallatin #define	lsi_stime	_sifields._sigchld._stime
43779363394SAndrew Gallatin #define	lsi_value	_sifields._rt._sigval
43879363394SAndrew Gallatin #define	lsi_int		_sifields._rt._sigval.sival_int
43979363394SAndrew Gallatin #define	lsi_ptr		_sifields._rt._sigval.sival_ptr
44079363394SAndrew Gallatin #define	lsi_addr	_sifields._sigfault._addr
44179363394SAndrew Gallatin #define	lsi_band	_sifields._sigpoll._band
44279363394SAndrew Gallatin #define	lsi_fd		_sifields._sigpoll._fd
44379363394SAndrew Gallatin 
4445002a60fSMarcel Moolenaar struct l_fpreg {
4452c4ab9ddSAndrew Gallatin 	u_int16_t	significand[4];
4462c4ab9ddSAndrew Gallatin 	u_int16_t	exponent;
4472c4ab9ddSAndrew Gallatin };
4482c4ab9ddSAndrew Gallatin 
4495002a60fSMarcel Moolenaar struct l_fpxreg {
4502c4ab9ddSAndrew Gallatin 	u_int16_t	significand[4];
4512c4ab9ddSAndrew Gallatin 	u_int16_t	exponent;
4522c4ab9ddSAndrew Gallatin 	u_int16_t	padding[3];
4532c4ab9ddSAndrew Gallatin };
4542c4ab9ddSAndrew Gallatin 
4555002a60fSMarcel Moolenaar struct l_xmmreg {
4562c4ab9ddSAndrew Gallatin 	u_int32_t	element[4];
4572c4ab9ddSAndrew Gallatin };
4582c4ab9ddSAndrew Gallatin 
4595002a60fSMarcel Moolenaar struct l_fpstate {
4602c4ab9ddSAndrew Gallatin 	/* Regular FPU environment */
4612c4ab9ddSAndrew Gallatin 	u_int32_t		cw;
4622c4ab9ddSAndrew Gallatin 	u_int32_t		sw;
4632c4ab9ddSAndrew Gallatin 	u_int32_t		tag;
4642c4ab9ddSAndrew Gallatin 	u_int32_t		ipoff;
4652c4ab9ddSAndrew Gallatin 	u_int32_t		cssel;
4662c4ab9ddSAndrew Gallatin 	u_int32_t		dataoff;
4672c4ab9ddSAndrew Gallatin 	u_int32_t		datasel;
4685002a60fSMarcel Moolenaar 	struct l_fpreg		_st[8];
4692c4ab9ddSAndrew Gallatin 	u_int16_t		status;
4702c4ab9ddSAndrew Gallatin 	u_int16_t		magic;		/* 0xffff = regular FPU data */
4712c4ab9ddSAndrew Gallatin 
4722c4ab9ddSAndrew Gallatin 	/* FXSR FPU environment */
473a4e3bad7SJung-uk Kim 	u_int32_t		_fxsr_env[6];	/* env is ignored. */
4742c4ab9ddSAndrew Gallatin 	u_int32_t		mxcsr;
4752c4ab9ddSAndrew Gallatin 	u_int32_t		reserved;
476a4e3bad7SJung-uk Kim 	struct l_fpxreg		_fxsr_st[8];	/* reg data is ignored. */
4775002a60fSMarcel Moolenaar 	struct l_xmmreg		_xmm[8];
4782c4ab9ddSAndrew Gallatin 	u_int32_t		padding[56];
4792c4ab9ddSAndrew Gallatin };
48079363394SAndrew Gallatin 
481d66a5066SPeter Wemm /*
482d66a5066SPeter Wemm  * We make the stack look like Linux expects it when calling a signal
483d66a5066SPeter Wemm  * handler, but use the BSD way of calling the handler and sigreturn().
484d66a5066SPeter Wemm  * This means that we need to pass the pointer to the handler too.
485d66a5066SPeter Wemm  * It is appended to the frame to not interfere with the rest of it.
486d66a5066SPeter Wemm  */
4875002a60fSMarcel Moolenaar struct l_sigframe {
4885002a60fSMarcel Moolenaar 	l_int			sf_sig;
4895002a60fSMarcel Moolenaar 	struct l_sigcontext	sf_sc;
4905002a60fSMarcel Moolenaar 	struct l_fpstate	sf_fpstate;
4915002a60fSMarcel Moolenaar 	l_uint			sf_extramask[LINUX_NSIG_WORDS-1];
4925002a60fSMarcel Moolenaar 	l_handler_t		sf_handler;
493d66a5066SPeter Wemm };
494d66a5066SPeter Wemm 
4955002a60fSMarcel Moolenaar struct l_rt_sigframe {
4965002a60fSMarcel Moolenaar 	l_int			sf_sig;
4975002a60fSMarcel Moolenaar 	l_siginfo_t 		*sf_siginfo;
4985002a60fSMarcel Moolenaar 	struct l_ucontext	*sf_ucontext;
4995002a60fSMarcel Moolenaar 	l_siginfo_t		sf_si;
5005002a60fSMarcel Moolenaar 	struct l_ucontext 	sf_sc;
5015002a60fSMarcel Moolenaar 	l_handler_t 		sf_handler;
50279363394SAndrew Gallatin };
50379363394SAndrew Gallatin 
504c21dee17SSøren Schmidt extern int bsd_to_linux_signal[];
505c21dee17SSøren Schmidt extern int linux_to_bsd_signal[];
506d323ddf3SMatthew Dillon extern struct sysentvec linux_sysvec;
507d323ddf3SMatthew Dillon extern struct sysentvec elf_linux_sysvec;
508c21dee17SSøren Schmidt 
50943bef515SMarcel Moolenaar /*
51043bef515SMarcel Moolenaar  * Pluggable ioctl handlers
51143bef515SMarcel Moolenaar  */
51243bef515SMarcel Moolenaar struct linux_ioctl_args;
513b40ce416SJulian Elischer struct thread;
514c21dee17SSøren Schmidt 
515b40ce416SJulian Elischer typedef int linux_ioctl_function_t(struct thread *, struct linux_ioctl_args *);
516c21dee17SSøren Schmidt 
51743bef515SMarcel Moolenaar struct linux_ioctl_handler {
51843bef515SMarcel Moolenaar 	linux_ioctl_function_t *func;
51943bef515SMarcel Moolenaar 	int	low, high;
520956d3333SMarcel Moolenaar };
521956d3333SMarcel Moolenaar 
52243bef515SMarcel Moolenaar int	linux_ioctl_register_handler(struct linux_ioctl_handler *h);
52343bef515SMarcel Moolenaar int	linux_ioctl_unregister_handler(struct linux_ioctl_handler *h);
524956d3333SMarcel Moolenaar 
52543bef515SMarcel Moolenaar /*
52643bef515SMarcel Moolenaar  * open/fcntl flags
52743bef515SMarcel Moolenaar  */
528a4e3bad7SJung-uk Kim #define	LINUX_O_RDONLY		00000000
529a4e3bad7SJung-uk Kim #define	LINUX_O_WRONLY		00000001
530a4e3bad7SJung-uk Kim #define	LINUX_O_RDWR		00000002
5316734f35eSJulian Elischer #define	LINUX_O_ACCMODE		00000003
532a4e3bad7SJung-uk Kim #define	LINUX_O_CREAT		00000100
533a4e3bad7SJung-uk Kim #define	LINUX_O_EXCL		00000200
534a4e3bad7SJung-uk Kim #define	LINUX_O_NOCTTY		00000400
535a4e3bad7SJung-uk Kim #define	LINUX_O_TRUNC		00001000
536a4e3bad7SJung-uk Kim #define	LINUX_O_APPEND		00002000
537a4e3bad7SJung-uk Kim #define	LINUX_O_NONBLOCK	00004000
538c21dee17SSøren Schmidt #define	LINUX_O_NDELAY		LINUX_O_NONBLOCK
539a4e3bad7SJung-uk Kim #define	LINUX_O_SYNC		00010000
540a4e3bad7SJung-uk Kim #define	LINUX_FASYNC		00020000
541a4e3bad7SJung-uk Kim #define	LINUX_O_DIRECT		00040000	/* Direct disk access hint */
542a4e3bad7SJung-uk Kim #define	LINUX_O_LARGEFILE	00100000
543a4e3bad7SJung-uk Kim #define	LINUX_O_DIRECTORY	00200000	/* Must be a directory */
544a4e3bad7SJung-uk Kim #define	LINUX_O_NOFOLLOW	00400000	/* Do not follow links */
54573c730a6SMatthew N. Dodd #define	LINUX_O_NOATIME		01000000
546c21dee17SSøren Schmidt 
547c21dee17SSøren Schmidt #define	LINUX_F_DUPFD		0
548c21dee17SSøren Schmidt #define	LINUX_F_GETFD		1
549c21dee17SSøren Schmidt #define	LINUX_F_SETFD		2
550c21dee17SSøren Schmidt #define	LINUX_F_GETFL		3
551c21dee17SSøren Schmidt #define	LINUX_F_SETFL		4
552c21dee17SSøren Schmidt #define	LINUX_F_GETLK		5
553c21dee17SSøren Schmidt #define	LINUX_F_SETLK		6
554c21dee17SSøren Schmidt #define	LINUX_F_SETLKW		7
555c21dee17SSøren Schmidt #define	LINUX_F_SETOWN		8
556c21dee17SSøren Schmidt #define	LINUX_F_GETOWN		9
557c21dee17SSøren Schmidt 
558aaaefc6bSRobert Drehmel #define	LINUX_F_GETLK64		12
559aaaefc6bSRobert Drehmel #define	LINUX_F_SETLK64		13
560aaaefc6bSRobert Drehmel #define	LINUX_F_SETLKW64	14
561aaaefc6bSRobert Drehmel 
562c21dee17SSøren Schmidt #define	LINUX_F_RDLCK		0
563c21dee17SSøren Schmidt #define	LINUX_F_WRLCK		1
564c21dee17SSøren Schmidt #define	LINUX_F_UNLCK		2
565c21dee17SSøren Schmidt 
56643bef515SMarcel Moolenaar /*
567705deb78SJonathan Lemon  * mount flags
568705deb78SJonathan Lemon  */
569705deb78SJonathan Lemon #define	LINUX_MS_RDONLY		0x0001
570705deb78SJonathan Lemon #define	LINUX_MS_NOSUID		0x0002
571705deb78SJonathan Lemon #define	LINUX_MS_NODEV		0x0004
572705deb78SJonathan Lemon #define	LINUX_MS_NOEXEC		0x0008
573705deb78SJonathan Lemon #define	LINUX_MS_REMOUNT	0x0020
574705deb78SJonathan Lemon 
575705deb78SJonathan Lemon /*
57643bef515SMarcel Moolenaar  * SystemV IPC defines
57743bef515SMarcel Moolenaar  */
578c21dee17SSøren Schmidt #define	LINUX_SEMOP		1
579c21dee17SSøren Schmidt #define	LINUX_SEMGET		2
580c21dee17SSøren Schmidt #define	LINUX_SEMCTL		3
581c21dee17SSøren Schmidt #define	LINUX_MSGSND		11
582c21dee17SSøren Schmidt #define	LINUX_MSGRCV		12
583c21dee17SSøren Schmidt #define	LINUX_MSGGET		13
584c21dee17SSøren Schmidt #define	LINUX_MSGCTL		14
585c21dee17SSøren Schmidt #define	LINUX_SHMAT		21
586c21dee17SSøren Schmidt #define	LINUX_SHMDT		22
587c21dee17SSøren Schmidt #define	LINUX_SHMGET		23
588c21dee17SSøren Schmidt #define	LINUX_SHMCTL		24
589c21dee17SSøren Schmidt 
590c21dee17SSøren Schmidt #define	LINUX_IPC_RMID		0
591c21dee17SSøren Schmidt #define	LINUX_IPC_SET		1
592c21dee17SSøren Schmidt #define	LINUX_IPC_STAT		2
593c21dee17SSøren Schmidt #define	LINUX_IPC_INFO		3
594c21dee17SSøren Schmidt 
595c21dee17SSøren Schmidt #define	LINUX_SHM_LOCK		11
596c21dee17SSøren Schmidt #define	LINUX_SHM_UNLOCK	12
597c21dee17SSøren Schmidt #define	LINUX_SHM_STAT		13
598c21dee17SSøren Schmidt #define	LINUX_SHM_INFO		14
599c21dee17SSøren Schmidt 
600c21dee17SSøren Schmidt #define	LINUX_SHM_RDONLY	0x1000
601c21dee17SSøren Schmidt #define	LINUX_SHM_RND		0x2000
602c21dee17SSøren Schmidt #define	LINUX_SHM_REMAP		0x4000
603c21dee17SSøren Schmidt 
60443bef515SMarcel Moolenaar /* semctl commands */
6059b86a416SKATO Takenori #define	LINUX_GETPID		11
6069b86a416SKATO Takenori #define	LINUX_GETVAL		12
6079b86a416SKATO Takenori #define	LINUX_GETALL		13
6089b86a416SKATO Takenori #define	LINUX_GETNCNT		14
6099b86a416SKATO Takenori #define	LINUX_GETZCNT		15
6109b86a416SKATO Takenori #define	LINUX_SETVAL		16
6119b86a416SKATO Takenori #define	LINUX_SETALL		17
612a6e5348eSMichael Reifenberger #define	LINUX_SEM_STAT		18
613a6e5348eSMichael Reifenberger #define	LINUX_SEM_INFO		19
6149b86a416SKATO Takenori 
6155002a60fSMarcel Moolenaar union l_semun {
6165002a60fSMarcel Moolenaar 	l_int		val;
6175002a60fSMarcel Moolenaar 	struct l_semid_ds	*buf;
6185002a60fSMarcel Moolenaar 	l_ushort	*array;
6195002a60fSMarcel Moolenaar 	struct l_seminfo	*__buf;
6205002a60fSMarcel Moolenaar 	void		*__pad;
6215002a60fSMarcel Moolenaar };
6225002a60fSMarcel Moolenaar 
62343bef515SMarcel Moolenaar /*
62443bef515SMarcel Moolenaar  * Socket defines
62543bef515SMarcel Moolenaar  */
626c21dee17SSøren Schmidt #define	LINUX_SOCKET 		1
627c21dee17SSøren Schmidt #define	LINUX_BIND		2
628c21dee17SSøren Schmidt #define	LINUX_CONNECT 		3
629c21dee17SSøren Schmidt #define	LINUX_LISTEN 		4
630c21dee17SSøren Schmidt #define	LINUX_ACCEPT 		5
631c21dee17SSøren Schmidt #define	LINUX_GETSOCKNAME	6
632c21dee17SSøren Schmidt #define	LINUX_GETPEERNAME	7
633c21dee17SSøren Schmidt #define	LINUX_SOCKETPAIR	8
634c21dee17SSøren Schmidt #define	LINUX_SEND		9
635c21dee17SSøren Schmidt #define	LINUX_RECV		10
636c21dee17SSøren Schmidt #define	LINUX_SENDTO 		11
637c21dee17SSøren Schmidt #define	LINUX_RECVFROM 		12
638c21dee17SSøren Schmidt #define	LINUX_SHUTDOWN 		13
639c21dee17SSøren Schmidt #define	LINUX_SETSOCKOPT	14
640c21dee17SSøren Schmidt #define	LINUX_GETSOCKOPT	15
641e76bba09SSøren Schmidt #define	LINUX_SENDMSG		16
642e76bba09SSøren Schmidt #define	LINUX_RECVMSG		17
643c21dee17SSøren Schmidt 
644c21dee17SSøren Schmidt #define	LINUX_AF_UNSPEC		0
645c21dee17SSøren Schmidt #define	LINUX_AF_UNIX		1
646c21dee17SSøren Schmidt #define	LINUX_AF_INET		2
647c21dee17SSøren Schmidt #define	LINUX_AF_AX25		3
648c21dee17SSøren Schmidt #define	LINUX_AF_IPX		4
649c21dee17SSøren Schmidt #define	LINUX_AF_APPLETALK	5
650ca26842eSHajimu UMEMOTO #define	LINUX_AF_INET6		10
651c21dee17SSøren Schmidt 
652c21dee17SSøren Schmidt #define	LINUX_SOL_SOCKET	1
653c21dee17SSøren Schmidt #define	LINUX_SOL_IP		0
654c21dee17SSøren Schmidt #define	LINUX_SOL_IPX		256
655c21dee17SSøren Schmidt #define	LINUX_SOL_AX25		257
656c21dee17SSøren Schmidt #define	LINUX_SOL_TCP		6
657c21dee17SSøren Schmidt #define	LINUX_SOL_UDP		17
658c21dee17SSøren Schmidt 
659c21dee17SSøren Schmidt #define	LINUX_SO_DEBUG		1
660c21dee17SSøren Schmidt #define	LINUX_SO_REUSEADDR	2
661c21dee17SSøren Schmidt #define	LINUX_SO_TYPE		3
662c21dee17SSøren Schmidt #define	LINUX_SO_ERROR		4
663c21dee17SSøren Schmidt #define	LINUX_SO_DONTROUTE	5
664c21dee17SSøren Schmidt #define	LINUX_SO_BROADCAST	6
665c21dee17SSøren Schmidt #define	LINUX_SO_SNDBUF		7
666c21dee17SSøren Schmidt #define	LINUX_SO_RCVBUF		8
667c21dee17SSøren Schmidt #define	LINUX_SO_KEEPALIVE	9
668c21dee17SSøren Schmidt #define	LINUX_SO_OOBINLINE	10
669c21dee17SSøren Schmidt #define	LINUX_SO_NO_CHECK	11
670c21dee17SSøren Schmidt #define	LINUX_SO_PRIORITY	12
671c21dee17SSøren Schmidt #define	LINUX_SO_LINGER		13
672d0b2365eSKonstantin Belousov #define	LINUX_SO_PEERCRED	17
673d0b2365eSKonstantin Belousov #define	LINUX_SO_RCVLOWAT	18
674d0b2365eSKonstantin Belousov #define	LINUX_SO_SNDLOWAT	19
675d0b2365eSKonstantin Belousov #define	LINUX_SO_RCVTIMEO	20
676d0b2365eSKonstantin Belousov #define	LINUX_SO_SNDTIMEO	21
677d0b2365eSKonstantin Belousov #define	LINUX_SO_TIMESTAMP	29
678d0b2365eSKonstantin Belousov #define	LINUX_SO_ACCEPTCONN	30
679c21dee17SSøren Schmidt 
680c21dee17SSøren Schmidt #define	LINUX_IP_TOS		1
681c21dee17SSøren Schmidt #define	LINUX_IP_TTL		2
68266ff6a3cSBill Fenner #define	LINUX_IP_HDRINCL	3
68366ff6a3cSBill Fenner #define	LINUX_IP_OPTIONS	4
68466ff6a3cSBill Fenner 
68566ff6a3cSBill Fenner #define	LINUX_IP_MULTICAST_IF		32
68666ff6a3cSBill Fenner #define	LINUX_IP_MULTICAST_TTL		33
68766ff6a3cSBill Fenner #define	LINUX_IP_MULTICAST_LOOP		34
68866ff6a3cSBill Fenner #define	LINUX_IP_ADD_MEMBERSHIP		35
68966ff6a3cSBill Fenner #define	LINUX_IP_DROP_MEMBERSHIP	36
690c21dee17SSøren Schmidt 
6915002a60fSMarcel Moolenaar struct l_sockaddr {
6925002a60fSMarcel Moolenaar 	l_ushort	sa_family;
6933713cbffSMike Smith 	char		sa_data[14];
6943713cbffSMike Smith };
6953713cbffSMike Smith 
6965002a60fSMarcel Moolenaar struct l_ifmap {
6975002a60fSMarcel Moolenaar 	l_ulong		mem_start;
6985002a60fSMarcel Moolenaar 	l_ulong		mem_end;
6995002a60fSMarcel Moolenaar 	l_ushort	base_addr;
70043bef515SMarcel Moolenaar 	u_char		irq;
70143bef515SMarcel Moolenaar 	u_char		dma;
70243bef515SMarcel Moolenaar 	u_char		port;
7033713cbffSMike Smith };
7043713cbffSMike Smith 
7053713cbffSMike Smith #define	LINUX_IFHWADDRLEN	6
7063713cbffSMike Smith #define	LINUX_IFNAMSIZ		16
70743bef515SMarcel Moolenaar 
7085002a60fSMarcel Moolenaar struct l_ifreq {
70943bef515SMarcel Moolenaar 	union {
71043bef515SMarcel Moolenaar 		char	ifrn_name[LINUX_IFNAMSIZ];
7113713cbffSMike Smith 	} ifr_ifrn;
7123713cbffSMike Smith 
7133713cbffSMike Smith 	union {
7145002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_addr;
7155002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_dstaddr;
7165002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_broadaddr;
7175002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_netmask;
7185002a60fSMarcel Moolenaar 		struct l_sockaddr	ifru_hwaddr;
719268aeb1eSDag-Erling Smørgrav 		l_short		ifru_flags[1];
7205002a60fSMarcel Moolenaar 		l_int		ifru_metric;
7215002a60fSMarcel Moolenaar 		l_int		ifru_mtu;
7225002a60fSMarcel Moolenaar 		struct l_ifmap	ifru_map;
7235002a60fSMarcel Moolenaar 		char		ifru_slave[LINUX_IFNAMSIZ];
7245002a60fSMarcel Moolenaar 		l_caddr_t	ifru_data;
7253713cbffSMike Smith 	} ifr_ifru;
7263713cbffSMike Smith };
7273713cbffSMike Smith 
728a4e3bad7SJung-uk Kim #define	ifr_name	ifr_ifrn.ifrn_name	/* Interface name */
7293713cbffSMike Smith #define	ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address */
7303713cbffSMike Smith 
7315002a60fSMarcel Moolenaar /*
7325002a60fSMarcel Moolenaar  * poll()
7335002a60fSMarcel Moolenaar  */
7345002a60fSMarcel Moolenaar #define	LINUX_POLLIN		0x0001
7355002a60fSMarcel Moolenaar #define	LINUX_POLLPRI		0x0002
7365002a60fSMarcel Moolenaar #define	LINUX_POLLOUT		0x0004
7375002a60fSMarcel Moolenaar #define	LINUX_POLLERR		0x0008
7385002a60fSMarcel Moolenaar #define	LINUX_POLLHUP		0x0010
7395002a60fSMarcel Moolenaar #define	LINUX_POLLNVAL		0x0020
7405002a60fSMarcel Moolenaar #define	LINUX_POLLRDNORM	0x0040
7415002a60fSMarcel Moolenaar #define	LINUX_POLLRDBAND	0x0080
7425002a60fSMarcel Moolenaar #define	LINUX_POLLWRNORM	0x0100
7435002a60fSMarcel Moolenaar #define	LINUX_POLLWRBAND	0x0200
7445002a60fSMarcel Moolenaar #define	LINUX_POLLMSG		0x0400
7455002a60fSMarcel Moolenaar 
7465002a60fSMarcel Moolenaar struct l_pollfd {
7475002a60fSMarcel Moolenaar 	l_int		fd;
7485002a60fSMarcel Moolenaar 	l_short		events;
7495002a60fSMarcel Moolenaar 	l_short		revents;
7505002a60fSMarcel Moolenaar };
7515002a60fSMarcel Moolenaar 
7529b44bfc5SAlexander Leidinger struct l_user_desc {
7539b44bfc5SAlexander Leidinger 	l_uint		entry_number;
7549b44bfc5SAlexander Leidinger 	l_uint		base_addr;
7559b44bfc5SAlexander Leidinger 	l_uint		limit;
7569b44bfc5SAlexander Leidinger 	l_uint		seg_32bit:1;
7579b44bfc5SAlexander Leidinger 	l_uint		contents:2;
7589b44bfc5SAlexander Leidinger 	l_uint		read_exec_only:1;
7599b44bfc5SAlexander Leidinger 	l_uint		limit_in_pages:1;
7609b44bfc5SAlexander Leidinger 	l_uint		seg_not_present:1;
7619b44bfc5SAlexander Leidinger 	l_uint		useable:1;
7629b44bfc5SAlexander Leidinger };
7639b44bfc5SAlexander Leidinger 
7649b44bfc5SAlexander Leidinger struct l_desc_struct {
7659b44bfc5SAlexander Leidinger 	unsigned long	a, b;
7669b44bfc5SAlexander Leidinger };
7679b44bfc5SAlexander Leidinger 
7689b44bfc5SAlexander Leidinger 
7699b44bfc5SAlexander Leidinger #define	LINUX_LOWERWORD	0x0000ffff
7709b44bfc5SAlexander Leidinger 
7710eef2f8aSAlexander Leidinger /*
772a4e3bad7SJung-uk Kim  * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h.
773a4e3bad7SJung-uk Kim  * These convert Linux user space descriptor to machine one.
7749b44bfc5SAlexander Leidinger  */
775a4e3bad7SJung-uk Kim #define	LINUX_LDT_entry_a(info)					\
776a4e3bad7SJung-uk Kim 	((((info)->base_addr & LINUX_LOWERWORD) << 16) |	\
777a4e3bad7SJung-uk Kim 	((info)->limit & LINUX_LOWERWORD))
7789b44bfc5SAlexander Leidinger 
779a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_READ_EXEC_ONLY	9
780a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_CONTENTS		10
781a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_SEG_NOT_PRESENT	15
782a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_BASE_ADDR		16
783a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_USEABLE		20
784a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_SEG32BIT		22
785a4e3bad7SJung-uk Kim #define	LINUX_ENTRY_B_LIMIT		23
7869b44bfc5SAlexander Leidinger 
787a4e3bad7SJung-uk Kim #define	LINUX_LDT_entry_b(info)							\
7889b44bfc5SAlexander Leidinger 	(((info)->base_addr & 0xff000000) |					\
7899b44bfc5SAlexander Leidinger 	((info)->limit & 0xf0000) |						\
790a4e3bad7SJung-uk Kim 	((info)->contents << LINUX_ENTRY_B_CONTENTS) |				\
791a4e3bad7SJung-uk Kim 	(((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) |	\
792a4e3bad7SJung-uk Kim 	(((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) |		\
793a4e3bad7SJung-uk Kim 	(((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) |	\
794a4e3bad7SJung-uk Kim 	((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) |				\
795a4e3bad7SJung-uk Kim 	((info)->useable << LINUX_ENTRY_B_USEABLE) |				\
796a4e3bad7SJung-uk Kim 	((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000)
7979b44bfc5SAlexander Leidinger 
798a4e3bad7SJung-uk Kim #define	LINUX_LDT_empty(info)		\
799a4e3bad7SJung-uk Kim 	((info)->base_addr == 0 &&	\
8009b44bfc5SAlexander Leidinger 	(info)->limit == 0 &&		\
8019b44bfc5SAlexander Leidinger 	(info)->contents == 0 &&	\
8029b44bfc5SAlexander Leidinger 	(info)->seg_not_present == 1 &&	\
8039b44bfc5SAlexander Leidinger 	(info)->read_exec_only == 1 &&	\
8049b44bfc5SAlexander Leidinger 	(info)->seg_32bit == 0 &&	\
8059b44bfc5SAlexander Leidinger 	(info)->limit_in_pages == 0 &&	\
8069b44bfc5SAlexander Leidinger 	(info)->useable == 0)
8079b44bfc5SAlexander Leidinger 
808a4e3bad7SJung-uk Kim /*
809a4e3bad7SJung-uk Kim  * Macros for converting segments.
810a4e3bad7SJung-uk Kim  * They do the same as those in arch/i386/kernel/process.c in Linux.
811a4e3bad7SJung-uk Kim  */
812a4e3bad7SJung-uk Kim #define	LINUX_GET_BASE(desc)				\
813a4e3bad7SJung-uk Kim 	((((desc)->a >> 16) & LINUX_LOWERWORD) |	\
8149b44bfc5SAlexander Leidinger 	(((desc)->b << 16) & 0x00ff0000) |		\
8159b44bfc5SAlexander Leidinger 	((desc)->b & 0xff000000))
8169b44bfc5SAlexander Leidinger 
817a4e3bad7SJung-uk Kim #define	LINUX_GET_LIMIT(desc)			\
818a4e3bad7SJung-uk Kim 	(((desc)->a & LINUX_LOWERWORD) |	\
8199b44bfc5SAlexander Leidinger 	((desc)->b & 0xf0000))
8209b44bfc5SAlexander Leidinger 
821a4e3bad7SJung-uk Kim #define	LINUX_GET_32BIT(desc)		\
822a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1)
823a4e3bad7SJung-uk Kim #define	LINUX_GET_CONTENTS(desc)	\
824a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3)
825a4e3bad7SJung-uk Kim #define	LINUX_GET_WRITABLE(desc)	\
826a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1)
827a4e3bad7SJung-uk Kim #define	LINUX_GET_LIMIT_PAGES(desc)	\
828a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1)
829a4e3bad7SJung-uk Kim #define	LINUX_GET_PRESENT(desc)		\
830a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1)
831a4e3bad7SJung-uk Kim #define	LINUX_GET_USEABLE(desc)		\
832a4e3bad7SJung-uk Kim 	(((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1)
8339b44bfc5SAlexander Leidinger 
8349b44bfc5SAlexander Leidinger #define	LINUX_CLOCK_REALTIME		0
8359b44bfc5SAlexander Leidinger #define	LINUX_CLOCK_MONOTONIC		1
8369b44bfc5SAlexander Leidinger #define	LINUX_CLOCK_PROCESS_CPUTIME_ID	2
8379b44bfc5SAlexander Leidinger #define	LINUX_CLOCK_THREAD_CPUTIME_ID	3
8389b44bfc5SAlexander Leidinger #define	LINUX_CLOCK_REALTIME_HR		4
8399b44bfc5SAlexander Leidinger #define	LINUX_CLOCK_MONOTONIC_HR	5
8409b44bfc5SAlexander Leidinger 
841a4e3bad7SJung-uk Kim #define	LINUX_CLONE_VM			0x00000100
842a4e3bad7SJung-uk Kim #define	LINUX_CLONE_FS			0x00000200
843a4e3bad7SJung-uk Kim #define	LINUX_CLONE_FILES		0x00000400
844a4e3bad7SJung-uk Kim #define	LINUX_CLONE_SIGHAND		0x00000800
845a4e3bad7SJung-uk Kim #define	LINUX_CLONE_PID			0x00001000	/* No longer exist in Linux */
846a4e3bad7SJung-uk Kim #define	LINUX_CLONE_VFORK		0x00004000
847a4e3bad7SJung-uk Kim #define	LINUX_CLONE_PARENT		0x00008000
848a4e3bad7SJung-uk Kim #define	LINUX_CLONE_THREAD		0x00010000
849a4e3bad7SJung-uk Kim #define	LINUX_CLONE_SETTLS		0x00080000
850a4e3bad7SJung-uk Kim #define	LINUX_CLONE_PARENT_SETTID	0x00100000
851a4e3bad7SJung-uk Kim #define	LINUX_CLONE_CHILD_CLEARTID	0x00200000
852a4e3bad7SJung-uk Kim #define	LINUX_CLONE_CHILD_SETTID	0x01000000
8539b44bfc5SAlexander Leidinger 
854a4e3bad7SJung-uk Kim #define	LINUX_THREADING_FLAGS					\
855a4e3bad7SJung-uk Kim 	(LINUX_CLONE_VM | LINUX_CLONE_FS | LINUX_CLONE_FILES |	\
856a4e3bad7SJung-uk Kim 	LINUX_CLONE_SIGHAND | LINUX_CLONE_THREAD)
8579b44bfc5SAlexander Leidinger 
858175c6c31SKonstantin Belousov /* robust futexes */
859175c6c31SKonstantin Belousov struct linux_robust_list {
860175c6c31SKonstantin Belousov 	struct linux_robust_list	*next;
861175c6c31SKonstantin Belousov };
862175c6c31SKonstantin Belousov 
863175c6c31SKonstantin Belousov struct linux_robust_list_head {
864175c6c31SKonstantin Belousov 	struct linux_robust_list	list;
865175c6c31SKonstantin Belousov 	l_ulong				futex_offset;
866175c6c31SKonstantin Belousov 	struct linux_robust_list	*pending_list;
867175c6c31SKonstantin Belousov };
868175c6c31SKonstantin Belousov 
869a4e3bad7SJung-uk Kim #endif /* !_I386_LINUX_H_ */
870