1995-06-25 13:32:43 -04:00
|
|
|
/*-
|
2018-03-19 22:50:11 -04:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
2017-11-27 10:08:52 -05:00
|
|
|
*
|
2012-01-15 08:23:18 -05:00
|
|
|
* Copyright (c) 1994-1996 Søren Schmidt
|
1995-06-25 13:32:43 -04:00
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
2018-03-19 22:50:11 -04:00
|
|
|
* notice, this list of conditions and the following disclaimer.
|
1995-06-25 13:32:43 -04:00
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
|
*
|
2018-03-19 22:50:11 -04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGE.
|
1999-08-27 21:08:13 -04:00
|
|
|
* $FreeBSD$
|
1995-06-25 13:32:43 -04:00
|
|
|
*/
|
|
|
|
|
|
2007-03-01 19:08:47 -05:00
|
|
|
#ifndef _I386_LINUX_H_
|
|
|
|
|
#define _I386_LINUX_H_
|
1996-10-15 15:22:46 -04:00
|
|
|
|
2020-04-14 16:30:48 -04:00
|
|
|
#include <sys/abi_compat.h>
|
2000-10-16 20:00:20 -04:00
|
|
|
|
2015-05-24 13:47:20 -04:00
|
|
|
#include <compat/linux/linux.h>
|
2000-11-10 16:30:19 -05:00
|
|
|
#include <i386/linux/linux_syscall.h>
|
1995-06-25 13:32:43 -04:00
|
|
|
|
2018-06-15 10:41:51 -04:00
|
|
|
#define LINUX_LEGACY_SYSCALLS
|
|
|
|
|
|
2012-05-05 15:42:38 -04:00
|
|
|
#define LINUX_DTRACE linuxulator
|
2001-02-16 11:40:43 -05:00
|
|
|
|
2001-09-08 15:07:04 -04:00
|
|
|
/*
|
2002-04-04 19:04:56 -05:00
|
|
|
* Provide a separate set of types for the Linux types.
|
2001-09-08 15:07:04 -04:00
|
|
|
*/
|
|
|
|
|
typedef int l_int;
|
|
|
|
|
typedef int32_t l_long;
|
|
|
|
|
typedef int64_t l_longlong;
|
|
|
|
|
typedef short l_short;
|
|
|
|
|
typedef unsigned int l_uint;
|
|
|
|
|
typedef uint32_t l_ulong;
|
|
|
|
|
typedef uint64_t l_ulonglong;
|
|
|
|
|
typedef unsigned short l_ushort;
|
|
|
|
|
|
|
|
|
|
typedef char *l_caddr_t;
|
2004-08-16 03:05:44 -04:00
|
|
|
typedef l_ulong l_uintptr_t;
|
2001-09-08 15:07:04 -04:00
|
|
|
typedef l_long l_clock_t;
|
|
|
|
|
typedef l_int l_daddr_t;
|
|
|
|
|
typedef l_ushort l_dev_t;
|
|
|
|
|
typedef l_uint l_gid_t;
|
|
|
|
|
typedef l_ushort l_gid16_t;
|
|
|
|
|
typedef l_ulong l_ino_t;
|
|
|
|
|
typedef l_int l_key_t;
|
|
|
|
|
typedef l_longlong l_loff_t;
|
|
|
|
|
typedef l_ushort l_mode_t;
|
|
|
|
|
typedef l_long l_off_t;
|
|
|
|
|
typedef l_int l_pid_t;
|
|
|
|
|
typedef l_uint l_size_t;
|
|
|
|
|
typedef l_long l_suseconds_t;
|
|
|
|
|
typedef l_long l_time_t;
|
2021-06-06 21:47:12 -04:00
|
|
|
typedef l_longlong l_time64_t;
|
2001-09-08 15:07:04 -04:00
|
|
|
typedef l_uint l_uid_t;
|
|
|
|
|
typedef l_ushort l_uid16_t;
|
2008-10-19 06:02:26 -04:00
|
|
|
typedef l_int l_timer_t;
|
|
|
|
|
typedef l_int l_mqd_t;
|
2015-05-24 12:47:13 -04:00
|
|
|
typedef l_ulong l_fd_mask;
|
2001-09-08 15:07:04 -04:00
|
|
|
|
2022-05-15 14:05:01 -04:00
|
|
|
#include <compat/linux/linux_siginfo.h>
|
|
|
|
|
|
2001-09-08 15:07:04 -04:00
|
|
|
typedef struct {
|
|
|
|
|
l_int val[2];
|
|
|
|
|
} l_fsid_t;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
l_time_t tv_sec;
|
|
|
|
|
l_suseconds_t tv_usec;
|
|
|
|
|
} l_timeval;
|
|
|
|
|
|
2022-05-28 16:45:39 -04:00
|
|
|
typedef struct {
|
|
|
|
|
l_time64_t tv_sec;
|
|
|
|
|
l_time64_t tv_usec;
|
|
|
|
|
} l_sock_timeval;
|
|
|
|
|
|
2001-09-08 15:07:04 -04:00
|
|
|
#define l_fd_set fd_set
|
|
|
|
|
|
1999-12-04 06:10:22 -05:00
|
|
|
/*
|
|
|
|
|
* Miscellaneous
|
|
|
|
|
*/
|
2015-05-24 12:24:24 -04:00
|
|
|
#define LINUX_AT_COUNT 20 /* Count of used aux entry types.
|
2009-03-04 07:14:33 -05:00
|
|
|
* Keep this synchronized with
|
2018-03-19 17:26:32 -04:00
|
|
|
* linux_fixup_elf() code.
|
2009-03-04 07:14:33 -05:00
|
|
|
*/
|
2001-09-08 15:07:04 -04:00
|
|
|
struct l___sysctl_args
|
|
|
|
|
{
|
|
|
|
|
l_int *name;
|
|
|
|
|
l_int nlen;
|
|
|
|
|
void *oldval;
|
|
|
|
|
l_size_t *oldlenp;
|
|
|
|
|
void *newval;
|
|
|
|
|
l_size_t newlen;
|
|
|
|
|
l_ulong __spare[4];
|
|
|
|
|
};
|
|
|
|
|
|
1999-12-04 06:10:22 -05:00
|
|
|
/* Resource limits */
|
|
|
|
|
#define LINUX_RLIMIT_CPU 0
|
|
|
|
|
#define LINUX_RLIMIT_FSIZE 1
|
|
|
|
|
#define LINUX_RLIMIT_DATA 2
|
|
|
|
|
#define LINUX_RLIMIT_STACK 3
|
|
|
|
|
#define LINUX_RLIMIT_CORE 4
|
|
|
|
|
#define LINUX_RLIMIT_RSS 5
|
|
|
|
|
#define LINUX_RLIMIT_NPROC 6
|
|
|
|
|
#define LINUX_RLIMIT_NOFILE 7
|
|
|
|
|
#define LINUX_RLIMIT_MEMLOCK 8
|
2007-03-01 19:08:47 -05:00
|
|
|
#define LINUX_RLIMIT_AS 9 /* Address space limit */
|
1999-12-04 06:10:22 -05:00
|
|
|
|
|
|
|
|
#define LINUX_RLIM_NLIMITS 10
|
|
|
|
|
|
2001-09-08 15:07:04 -04:00
|
|
|
struct l_rlimit {
|
|
|
|
|
l_ulong rlim_cur;
|
|
|
|
|
l_ulong rlim_max;
|
|
|
|
|
};
|
|
|
|
|
|
2007-02-14 19:54:40 -05:00
|
|
|
struct l_mmap_argv {
|
|
|
|
|
l_uintptr_t addr;
|
|
|
|
|
l_size_t len;
|
|
|
|
|
l_int prot;
|
|
|
|
|
l_int flags;
|
|
|
|
|
l_int fd;
|
|
|
|
|
l_off_t pgoff;
|
2021-05-31 14:56:34 -04:00
|
|
|
};
|
2007-02-14 19:54:40 -05:00
|
|
|
|
2001-09-08 15:07:04 -04:00
|
|
|
/*
|
|
|
|
|
* stat family of syscalls
|
|
|
|
|
*/
|
|
|
|
|
struct l_timespec {
|
2006-12-20 15:17:35 -05:00
|
|
|
l_time_t tv_sec;
|
|
|
|
|
l_long tv_nsec;
|
2001-09-08 15:07:04 -04:00
|
|
|
};
|
1999-12-04 06:10:22 -05:00
|
|
|
|
2021-06-06 21:47:12 -04:00
|
|
|
/* __kernel_timespec */
|
|
|
|
|
struct l_timespec64 {
|
|
|
|
|
l_time64_t tv_sec;
|
|
|
|
|
l_longlong tv_nsec;
|
|
|
|
|
};
|
|
|
|
|
|
2001-09-08 15:07:04 -04:00
|
|
|
struct l_newstat {
|
|
|
|
|
l_ushort st_dev;
|
|
|
|
|
l_ushort __pad1;
|
|
|
|
|
l_ulong st_ino;
|
|
|
|
|
l_ushort st_mode;
|
|
|
|
|
l_ushort st_nlink;
|
|
|
|
|
l_ushort st_uid;
|
|
|
|
|
l_ushort st_gid;
|
|
|
|
|
l_ushort st_rdev;
|
|
|
|
|
l_ushort __pad2;
|
|
|
|
|
l_ulong st_size;
|
|
|
|
|
l_ulong st_blksize;
|
|
|
|
|
l_ulong st_blocks;
|
2010-03-28 09:13:22 -04:00
|
|
|
struct l_timespec st_atim;
|
|
|
|
|
struct l_timespec st_mtim;
|
|
|
|
|
struct l_timespec st_ctim;
|
2001-09-08 15:07:04 -04:00
|
|
|
l_ulong __unused4;
|
|
|
|
|
l_ulong __unused5;
|
|
|
|
|
};
|
|
|
|
|
|
2006-03-18 13:24:38 -05:00
|
|
|
struct l_stat {
|
2007-03-01 19:08:47 -05:00
|
|
|
l_ushort st_dev;
|
|
|
|
|
l_ulong st_ino;
|
|
|
|
|
l_ushort st_mode;
|
|
|
|
|
l_ushort st_nlink;
|
|
|
|
|
l_ushort st_uid;
|
|
|
|
|
l_ushort st_gid;
|
|
|
|
|
l_ushort st_rdev;
|
|
|
|
|
l_long st_size;
|
2010-03-28 09:13:22 -04:00
|
|
|
struct l_timespec st_atim;
|
|
|
|
|
struct l_timespec st_mtim;
|
|
|
|
|
struct l_timespec st_ctim;
|
2007-03-01 19:08:47 -05:00
|
|
|
l_long st_blksize;
|
|
|
|
|
l_long st_blocks;
|
|
|
|
|
l_ulong st_flags;
|
|
|
|
|
l_ulong st_gen;
|
2006-03-18 13:24:38 -05:00
|
|
|
};
|
|
|
|
|
|
2001-09-08 15:07:04 -04:00
|
|
|
struct l_stat64 {
|
|
|
|
|
l_ushort st_dev;
|
|
|
|
|
u_char __pad0[10];
|
|
|
|
|
l_ulong __st_ino;
|
|
|
|
|
l_uint st_mode;
|
|
|
|
|
l_uint st_nlink;
|
|
|
|
|
l_ulong st_uid;
|
|
|
|
|
l_ulong st_gid;
|
|
|
|
|
l_ushort st_rdev;
|
|
|
|
|
u_char __pad3[10];
|
|
|
|
|
l_longlong st_size;
|
|
|
|
|
l_ulong st_blksize;
|
|
|
|
|
l_ulong st_blocks;
|
|
|
|
|
l_ulong __pad4;
|
2010-03-28 09:13:22 -04:00
|
|
|
struct l_timespec st_atim;
|
|
|
|
|
struct l_timespec st_mtim;
|
|
|
|
|
struct l_timespec st_ctim;
|
2001-09-08 15:07:04 -04:00
|
|
|
l_ulonglong st_ino;
|
|
|
|
|
};
|
1999-12-04 06:10:22 -05:00
|
|
|
|
2018-02-05 12:29:12 -05:00
|
|
|
struct l_statfs64 {
|
|
|
|
|
l_int f_type;
|
|
|
|
|
l_int f_bsize;
|
|
|
|
|
uint64_t f_blocks;
|
|
|
|
|
uint64_t f_bfree;
|
|
|
|
|
uint64_t f_bavail;
|
|
|
|
|
uint64_t f_files;
|
|
|
|
|
uint64_t f_ffree;
|
|
|
|
|
l_fsid_t f_fsid;
|
|
|
|
|
l_int f_namelen;
|
|
|
|
|
l_int f_frsize;
|
|
|
|
|
l_int f_flags;
|
|
|
|
|
l_int f_spare[4];
|
2007-09-18 15:50:33 -04:00
|
|
|
};
|
|
|
|
|
|
1999-12-04 06:10:22 -05:00
|
|
|
/* sigaction flags */
|
|
|
|
|
#define LINUX_SA_NOCLDSTOP 0x00000001
|
|
|
|
|
#define LINUX_SA_NOCLDWAIT 0x00000002
|
|
|
|
|
#define LINUX_SA_SIGINFO 0x00000004
|
|
|
|
|
#define LINUX_SA_RESTORER 0x04000000
|
|
|
|
|
#define LINUX_SA_ONSTACK 0x08000000
|
|
|
|
|
#define LINUX_SA_RESTART 0x10000000
|
|
|
|
|
#define LINUX_SA_INTERRUPT 0x20000000
|
|
|
|
|
#define LINUX_SA_NOMASK 0x40000000
|
|
|
|
|
#define LINUX_SA_ONESHOT 0x80000000
|
|
|
|
|
|
2000-09-06 02:08:54 -04:00
|
|
|
/* sigaltstack */
|
2007-03-01 19:08:47 -05:00
|
|
|
#define LINUX_MINSIGSTKSZ 2048
|
2000-10-12 21:57:43 -04:00
|
|
|
|
2001-09-08 15:07:04 -04:00
|
|
|
typedef void (*l_handler_t)(l_int);
|
|
|
|
|
typedef l_ulong l_osigset_t;
|
1999-09-29 11:12:18 -04:00
|
|
|
|
1999-08-14 13:28:46 -04:00
|
|
|
typedef struct {
|
2001-09-08 15:07:04 -04:00
|
|
|
l_handler_t lsa_handler;
|
|
|
|
|
l_osigset_t lsa_mask;
|
|
|
|
|
l_ulong lsa_flags;
|
1999-12-04 06:10:22 -05:00
|
|
|
void (*lsa_restorer)(void);
|
2001-09-08 15:07:04 -04:00
|
|
|
} l_osigaction_t;
|
1999-08-14 13:28:46 -04:00
|
|
|
|
1999-09-29 11:12:18 -04:00
|
|
|
typedef struct {
|
2001-09-08 15:07:04 -04:00
|
|
|
l_handler_t lsa_handler;
|
|
|
|
|
l_ulong lsa_flags;
|
1999-12-04 06:10:22 -05:00
|
|
|
void (*lsa_restorer)(void);
|
2001-09-08 15:07:04 -04:00
|
|
|
l_sigset_t lsa_mask;
|
|
|
|
|
} l_sigaction_t;
|
1999-08-14 13:28:46 -04:00
|
|
|
|
1999-12-04 06:10:22 -05:00
|
|
|
typedef struct {
|
2021-07-26 19:43:09 -04:00
|
|
|
l_uintptr_t ss_sp;
|
2001-09-08 15:07:04 -04:00
|
|
|
l_int ss_flags;
|
|
|
|
|
l_size_t ss_size;
|
|
|
|
|
} l_stack_t;
|
1999-11-30 10:02:28 -05:00
|
|
|
|
2000-04-26 16:58:40 -04:00
|
|
|
extern struct sysentvec linux_sysvec;
|
1995-06-25 13:32:43 -04:00
|
|
|
|
1999-12-04 06:10:22 -05:00
|
|
|
/*
|
2015-05-24 12:31:44 -04:00
|
|
|
* arch specific open/fcntl flags
|
1999-12-04 06:10:22 -05:00
|
|
|
*/
|
2002-07-09 11:57:12 -04:00
|
|
|
#define LINUX_F_GETLK64 12
|
|
|
|
|
#define LINUX_F_SETLK64 13
|
|
|
|
|
#define LINUX_F_SETLKW64 14
|
|
|
|
|
|
2001-09-08 15:07:04 -04:00
|
|
|
union l_semun {
|
|
|
|
|
l_int val;
|
2019-03-24 10:50:02 -04:00
|
|
|
l_uintptr_t buf;
|
2001-09-08 15:07:04 -04:00
|
|
|
l_ushort *array;
|
2019-03-24 10:50:02 -04:00
|
|
|
l_uintptr_t __buf;
|
|
|
|
|
l_uintptr_t __pad;
|
2001-09-08 15:07:04 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct l_ifmap {
|
|
|
|
|
l_ulong mem_start;
|
|
|
|
|
l_ulong mem_end;
|
|
|
|
|
l_ushort base_addr;
|
|
|
|
|
u_char irq;
|
|
|
|
|
u_char dma;
|
|
|
|
|
u_char port;
|
1997-06-02 02:31:49 -04:00
|
|
|
};
|
|
|
|
|
|
2001-09-08 15:07:04 -04:00
|
|
|
struct l_ifreq {
|
1999-12-04 06:10:22 -05:00
|
|
|
union {
|
|
|
|
|
char ifrn_name[LINUX_IFNAMSIZ];
|
|
|
|
|
} ifr_ifrn;
|
|
|
|
|
|
|
|
|
|
union {
|
2001-09-08 15:07:04 -04:00
|
|
|
struct l_sockaddr ifru_addr;
|
|
|
|
|
struct l_sockaddr ifru_dstaddr;
|
|
|
|
|
struct l_sockaddr ifru_broadaddr;
|
|
|
|
|
struct l_sockaddr ifru_netmask;
|
|
|
|
|
struct l_sockaddr ifru_hwaddr;
|
2001-10-15 16:06:34 -04:00
|
|
|
l_short ifru_flags[1];
|
2017-04-08 10:41:39 -04:00
|
|
|
l_int ifru_ivalue;
|
2001-09-08 15:07:04 -04:00
|
|
|
l_int ifru_mtu;
|
|
|
|
|
struct l_ifmap ifru_map;
|
|
|
|
|
char ifru_slave[LINUX_IFNAMSIZ];
|
|
|
|
|
l_caddr_t ifru_data;
|
1999-12-04 06:10:22 -05:00
|
|
|
} ifr_ifru;
|
1997-06-02 02:31:49 -04:00
|
|
|
};
|
|
|
|
|
|
2007-03-01 19:08:47 -05:00
|
|
|
#define ifr_name ifr_ifrn.ifrn_name /* Interface name */
|
1999-12-04 06:10:22 -05:00
|
|
|
#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
|
2017-04-08 10:41:39 -04:00
|
|
|
#define ifr_ifindex ifr_ifru.ifru_ivalue /* Interface index */
|
1999-08-15 13:28:40 -04:00
|
|
|
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 08:54:30 -04:00
|
|
|
struct l_user_desc {
|
|
|
|
|
l_uint entry_number;
|
|
|
|
|
l_uint base_addr;
|
|
|
|
|
l_uint limit;
|
|
|
|
|
l_uint seg_32bit:1;
|
|
|
|
|
l_uint contents:2;
|
|
|
|
|
l_uint read_exec_only:1;
|
|
|
|
|
l_uint limit_in_pages:1;
|
|
|
|
|
l_uint seg_not_present:1;
|
|
|
|
|
l_uint useable:1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct l_desc_struct {
|
2007-03-01 19:08:47 -05:00
|
|
|
unsigned long a, b;
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 08:54:30 -04:00
|
|
|
};
|
|
|
|
|
|
2007-03-01 19:08:47 -05:00
|
|
|
#define LINUX_LOWERWORD 0x0000ffff
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 08:54:30 -04:00
|
|
|
|
2007-03-01 19:08:47 -05:00
|
|
|
/*
|
|
|
|
|
* Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h.
|
|
|
|
|
* These convert Linux user space descriptor to machine one.
|
|
|
|
|
*/
|
|
|
|
|
#define LINUX_LDT_entry_a(info) \
|
|
|
|
|
((((info)->base_addr & LINUX_LOWERWORD) << 16) | \
|
|
|
|
|
((info)->limit & LINUX_LOWERWORD))
|
|
|
|
|
|
|
|
|
|
#define LINUX_ENTRY_B_READ_EXEC_ONLY 9
|
|
|
|
|
#define LINUX_ENTRY_B_CONTENTS 10
|
|
|
|
|
#define LINUX_ENTRY_B_SEG_NOT_PRESENT 15
|
|
|
|
|
#define LINUX_ENTRY_B_BASE_ADDR 16
|
|
|
|
|
#define LINUX_ENTRY_B_USEABLE 20
|
|
|
|
|
#define LINUX_ENTRY_B_SEG32BIT 22
|
|
|
|
|
#define LINUX_ENTRY_B_LIMIT 23
|
|
|
|
|
|
|
|
|
|
#define LINUX_LDT_entry_b(info) \
|
|
|
|
|
(((info)->base_addr & 0xff000000) | \
|
|
|
|
|
((info)->limit & 0xf0000) | \
|
|
|
|
|
((info)->contents << LINUX_ENTRY_B_CONTENTS) | \
|
|
|
|
|
(((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) | \
|
|
|
|
|
(((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) | \
|
|
|
|
|
(((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) | \
|
|
|
|
|
((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) | \
|
|
|
|
|
((info)->useable << LINUX_ENTRY_B_USEABLE) | \
|
|
|
|
|
((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000)
|
|
|
|
|
|
|
|
|
|
#define LINUX_LDT_empty(info) \
|
|
|
|
|
((info)->base_addr == 0 && \
|
|
|
|
|
(info)->limit == 0 && \
|
|
|
|
|
(info)->contents == 0 && \
|
|
|
|
|
(info)->seg_not_present == 1 && \
|
|
|
|
|
(info)->read_exec_only == 1 && \
|
|
|
|
|
(info)->seg_32bit == 0 && \
|
|
|
|
|
(info)->limit_in_pages == 0 && \
|
|
|
|
|
(info)->useable == 0)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Macros for converting segments.
|
|
|
|
|
* They do the same as those in arch/i386/kernel/process.c in Linux.
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 08:54:30 -04:00
|
|
|
*/
|
2007-03-01 19:08:47 -05:00
|
|
|
#define LINUX_GET_BASE(desc) \
|
|
|
|
|
((((desc)->a >> 16) & LINUX_LOWERWORD) | \
|
|
|
|
|
(((desc)->b << 16) & 0x00ff0000) | \
|
|
|
|
|
((desc)->b & 0xff000000))
|
|
|
|
|
|
|
|
|
|
#define LINUX_GET_LIMIT(desc) \
|
|
|
|
|
(((desc)->a & LINUX_LOWERWORD) | \
|
|
|
|
|
((desc)->b & 0xf0000))
|
|
|
|
|
|
|
|
|
|
#define LINUX_GET_32BIT(desc) \
|
|
|
|
|
(((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1)
|
|
|
|
|
#define LINUX_GET_CONTENTS(desc) \
|
|
|
|
|
(((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3)
|
|
|
|
|
#define LINUX_GET_WRITABLE(desc) \
|
|
|
|
|
(((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1)
|
|
|
|
|
#define LINUX_GET_LIMIT_PAGES(desc) \
|
|
|
|
|
(((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1)
|
|
|
|
|
#define LINUX_GET_PRESENT(desc) \
|
|
|
|
|
(((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1)
|
|
|
|
|
#define LINUX_GET_USEABLE(desc) \
|
|
|
|
|
(((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1)
|
|
|
|
|
|
2015-05-24 11:03:09 -04:00
|
|
|
#define linux_copyout_rusage(r, u) copyout(r, u, sizeof(*r))
|
|
|
|
|
|
2008-10-14 03:59:23 -04:00
|
|
|
/* robust futexes */
|
|
|
|
|
struct linux_robust_list {
|
|
|
|
|
struct linux_robust_list *next;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct linux_robust_list_head {
|
|
|
|
|
struct linux_robust_list list;
|
2008-11-16 10:45:41 -05:00
|
|
|
l_long futex_offset;
|
2008-10-14 03:59:23 -04:00
|
|
|
struct linux_robust_list *pending_list;
|
|
|
|
|
};
|
|
|
|
|
|
2007-03-01 19:08:47 -05:00
|
|
|
#endif /* !_I386_LINUX_H_ */
|