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 311f3dad5aSBruce Evans #ifndef _I386_LINUX_LINUX_H_ 321f3dad5aSBruce Evans #define _I386_LINUX_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; 835002a60fSMarcel Moolenaar 845002a60fSMarcel Moolenaar typedef struct { 855002a60fSMarcel Moolenaar l_int val[2]; 865002a60fSMarcel Moolenaar } l_fsid_t; 875002a60fSMarcel Moolenaar 885002a60fSMarcel Moolenaar typedef struct { 895002a60fSMarcel Moolenaar l_time_t tv_sec; 905002a60fSMarcel Moolenaar l_suseconds_t tv_usec; 915002a60fSMarcel Moolenaar } l_timeval; 925002a60fSMarcel Moolenaar 935002a60fSMarcel Moolenaar #define l_fd_set fd_set 945002a60fSMarcel Moolenaar 955002a60fSMarcel Moolenaar /* 9643bef515SMarcel Moolenaar * Miscellaneous 9743bef515SMarcel Moolenaar */ 9843bef515SMarcel Moolenaar #define LINUX_NAME_MAX 255 9943bef515SMarcel Moolenaar #define LINUX_MAX_UTSNAME 65 10043bef515SMarcel Moolenaar 1015002a60fSMarcel Moolenaar #define LINUX_CTL_MAXNAME 10 1025002a60fSMarcel Moolenaar 1035002a60fSMarcel Moolenaar struct l___sysctl_args 1045002a60fSMarcel Moolenaar { 1055002a60fSMarcel Moolenaar l_int *name; 1065002a60fSMarcel Moolenaar l_int nlen; 1075002a60fSMarcel Moolenaar void *oldval; 1085002a60fSMarcel Moolenaar l_size_t *oldlenp; 1095002a60fSMarcel Moolenaar void *newval; 1105002a60fSMarcel Moolenaar l_size_t newlen; 1115002a60fSMarcel Moolenaar l_ulong __spare[4]; 1125002a60fSMarcel Moolenaar }; 1135002a60fSMarcel Moolenaar 11443bef515SMarcel Moolenaar /* Scheduling policies */ 11543bef515SMarcel Moolenaar #define LINUX_SCHED_OTHER 0 11643bef515SMarcel Moolenaar #define LINUX_SCHED_FIFO 1 11743bef515SMarcel Moolenaar #define LINUX_SCHED_RR 2 11843bef515SMarcel Moolenaar 11943bef515SMarcel Moolenaar /* Resource limits */ 12043bef515SMarcel Moolenaar #define LINUX_RLIMIT_CPU 0 12143bef515SMarcel Moolenaar #define LINUX_RLIMIT_FSIZE 1 12243bef515SMarcel Moolenaar #define LINUX_RLIMIT_DATA 2 12343bef515SMarcel Moolenaar #define LINUX_RLIMIT_STACK 3 12443bef515SMarcel Moolenaar #define LINUX_RLIMIT_CORE 4 12543bef515SMarcel Moolenaar #define LINUX_RLIMIT_RSS 5 12643bef515SMarcel Moolenaar #define LINUX_RLIMIT_NPROC 6 12743bef515SMarcel Moolenaar #define LINUX_RLIMIT_NOFILE 7 12843bef515SMarcel Moolenaar #define LINUX_RLIMIT_MEMLOCK 8 12943bef515SMarcel Moolenaar #define LINUX_RLIMIT_AS 9 /* address space limit */ 13043bef515SMarcel Moolenaar 13143bef515SMarcel Moolenaar #define LINUX_RLIM_NLIMITS 10 13243bef515SMarcel Moolenaar 1335002a60fSMarcel Moolenaar struct l_rlimit { 1345002a60fSMarcel Moolenaar l_ulong rlim_cur; 1355002a60fSMarcel Moolenaar l_ulong rlim_max; 1365002a60fSMarcel Moolenaar }; 1375002a60fSMarcel Moolenaar 13843bef515SMarcel Moolenaar /* mmap options */ 13943bef515SMarcel Moolenaar #define LINUX_MAP_SHARED 0x0001 14043bef515SMarcel Moolenaar #define LINUX_MAP_PRIVATE 0x0002 14143bef515SMarcel Moolenaar #define LINUX_MAP_FIXED 0x0010 14243bef515SMarcel Moolenaar #define LINUX_MAP_ANON 0x0020 14343bef515SMarcel Moolenaar #define LINUX_MAP_GROWSDOWN 0x0100 14443bef515SMarcel Moolenaar 1455002a60fSMarcel Moolenaar /* 1465002a60fSMarcel Moolenaar * stat family of syscalls 1475002a60fSMarcel Moolenaar */ 1485002a60fSMarcel Moolenaar struct l_timespec { 14977424f41SJung-uk Kim l_time_t tv_sec; 15077424f41SJung-uk Kim l_long tv_nsec; 1515002a60fSMarcel Moolenaar }; 15243bef515SMarcel Moolenaar 1535002a60fSMarcel Moolenaar struct l_newstat { 1545002a60fSMarcel Moolenaar l_ushort st_dev; 1555002a60fSMarcel Moolenaar l_ushort __pad1; 1565002a60fSMarcel Moolenaar l_ulong st_ino; 1575002a60fSMarcel Moolenaar l_ushort st_mode; 1585002a60fSMarcel Moolenaar l_ushort st_nlink; 1595002a60fSMarcel Moolenaar l_ushort st_uid; 1605002a60fSMarcel Moolenaar l_ushort st_gid; 1615002a60fSMarcel Moolenaar l_ushort st_rdev; 1625002a60fSMarcel Moolenaar l_ushort __pad2; 1635002a60fSMarcel Moolenaar l_ulong st_size; 1645002a60fSMarcel Moolenaar l_ulong st_blksize; 1655002a60fSMarcel Moolenaar l_ulong st_blocks; 1665002a60fSMarcel Moolenaar struct l_timespec st_atimespec; 1675002a60fSMarcel Moolenaar struct l_timespec st_mtimespec; 1685002a60fSMarcel Moolenaar struct l_timespec st_ctimespec; 1695002a60fSMarcel Moolenaar l_ulong __unused4; 1705002a60fSMarcel Moolenaar l_ulong __unused5; 1715002a60fSMarcel Moolenaar }; 17243bef515SMarcel Moolenaar 1731f7642e0SAlexander Leidinger struct l_stat { 1741f7642e0SAlexander Leidinger l_ushort st_dev; 1751f7642e0SAlexander Leidinger l_ulong st_ino; 1761f7642e0SAlexander Leidinger l_ushort st_mode; 1771f7642e0SAlexander Leidinger l_ushort st_nlink; 1781f7642e0SAlexander Leidinger l_ushort st_uid; 1791f7642e0SAlexander Leidinger l_ushort st_gid; 1801f7642e0SAlexander Leidinger l_ushort st_rdev; 1811f7642e0SAlexander Leidinger l_long st_size; 1821f7642e0SAlexander Leidinger struct l_timespec st_atimespec; 1831f7642e0SAlexander Leidinger struct l_timespec st_mtimespec; 1841f7642e0SAlexander Leidinger struct l_timespec st_ctimespec; 1851f7642e0SAlexander Leidinger l_long st_blksize; 1861f7642e0SAlexander Leidinger l_long st_blocks; 1871f7642e0SAlexander Leidinger l_ulong st_flags; 1881f7642e0SAlexander Leidinger l_ulong st_gen; 1891f7642e0SAlexander Leidinger }; 1901f7642e0SAlexander Leidinger 1915002a60fSMarcel Moolenaar struct l_stat64 { 1925002a60fSMarcel Moolenaar l_ushort st_dev; 1935002a60fSMarcel Moolenaar u_char __pad0[10]; 1945002a60fSMarcel Moolenaar l_ulong __st_ino; 1955002a60fSMarcel Moolenaar l_uint st_mode; 1965002a60fSMarcel Moolenaar l_uint st_nlink; 1975002a60fSMarcel Moolenaar l_ulong st_uid; 1985002a60fSMarcel Moolenaar l_ulong st_gid; 1995002a60fSMarcel Moolenaar l_ushort st_rdev; 2005002a60fSMarcel Moolenaar u_char __pad3[10]; 2015002a60fSMarcel Moolenaar l_longlong st_size; 2025002a60fSMarcel Moolenaar l_ulong st_blksize; 2035002a60fSMarcel Moolenaar l_ulong st_blocks; 2045002a60fSMarcel Moolenaar l_ulong __pad4; 2055002a60fSMarcel Moolenaar struct l_timespec st_atimespec; 2065002a60fSMarcel Moolenaar struct l_timespec st_mtimespec; 2075002a60fSMarcel Moolenaar struct l_timespec st_ctimespec; 2085002a60fSMarcel Moolenaar l_ulonglong st_ino; 2095002a60fSMarcel Moolenaar }; 2105002a60fSMarcel Moolenaar 2115002a60fSMarcel Moolenaar struct l_new_utsname { 21243bef515SMarcel Moolenaar char sysname[LINUX_MAX_UTSNAME]; 21343bef515SMarcel Moolenaar char nodename[LINUX_MAX_UTSNAME]; 21443bef515SMarcel Moolenaar char release[LINUX_MAX_UTSNAME]; 21543bef515SMarcel Moolenaar char version[LINUX_MAX_UTSNAME]; 21643bef515SMarcel Moolenaar char machine[LINUX_MAX_UTSNAME]; 21743bef515SMarcel Moolenaar char domainname[LINUX_MAX_UTSNAME]; 21843bef515SMarcel Moolenaar }; 219c21dee17SSøren Schmidt 220956d3333SMarcel Moolenaar /* 22143bef515SMarcel Moolenaar * Signalling 222956d3333SMarcel Moolenaar */ 22343bef515SMarcel Moolenaar #define LINUX_SIGHUP 1 22443bef515SMarcel Moolenaar #define LINUX_SIGINT 2 22543bef515SMarcel Moolenaar #define LINUX_SIGQUIT 3 22643bef515SMarcel Moolenaar #define LINUX_SIGILL 4 22743bef515SMarcel Moolenaar #define LINUX_SIGTRAP 5 22843bef515SMarcel Moolenaar #define LINUX_SIGABRT 6 22943bef515SMarcel Moolenaar #define LINUX_SIGIOT LINUX_SIGABRT 23043bef515SMarcel Moolenaar #define LINUX_SIGBUS 7 23143bef515SMarcel Moolenaar #define LINUX_SIGFPE 8 23243bef515SMarcel Moolenaar #define LINUX_SIGKILL 9 23343bef515SMarcel Moolenaar #define LINUX_SIGUSR1 10 23443bef515SMarcel Moolenaar #define LINUX_SIGSEGV 11 23543bef515SMarcel Moolenaar #define LINUX_SIGUSR2 12 23643bef515SMarcel Moolenaar #define LINUX_SIGPIPE 13 23743bef515SMarcel Moolenaar #define LINUX_SIGALRM 14 23843bef515SMarcel Moolenaar #define LINUX_SIGTERM 15 23943bef515SMarcel Moolenaar #define LINUX_SIGSTKFLT 16 24043bef515SMarcel Moolenaar #define LINUX_SIGCHLD 17 24143bef515SMarcel Moolenaar #define LINUX_SIGCONT 18 24243bef515SMarcel Moolenaar #define LINUX_SIGSTOP 19 24343bef515SMarcel Moolenaar #define LINUX_SIGTSTP 20 24443bef515SMarcel Moolenaar #define LINUX_SIGTTIN 21 24543bef515SMarcel Moolenaar #define LINUX_SIGTTOU 22 24643bef515SMarcel Moolenaar #define LINUX_SIGURG 23 24743bef515SMarcel Moolenaar #define LINUX_SIGXCPU 24 24843bef515SMarcel Moolenaar #define LINUX_SIGXFSZ 25 24943bef515SMarcel Moolenaar #define LINUX_SIGVTALRM 26 25043bef515SMarcel Moolenaar #define LINUX_SIGPROF 27 25143bef515SMarcel Moolenaar #define LINUX_SIGWINCH 28 25243bef515SMarcel Moolenaar #define LINUX_SIGIO 29 25343bef515SMarcel Moolenaar #define LINUX_SIGPOLL LINUX_SIGIO 25443bef515SMarcel Moolenaar #define LINUX_SIGPWR 30 255ba873f4cSAlexander Kabaev #define LINUX_SIGSYS 31 256956d3333SMarcel Moolenaar 25743bef515SMarcel Moolenaar #define LINUX_SIGTBLSZ 31 2582c4ab9ddSAndrew Gallatin #define LINUX_NSIG_WORDS 2 2592c4ab9ddSAndrew Gallatin #define LINUX_NBPW 32 2602c4ab9ddSAndrew Gallatin #define LINUX_NSIG (LINUX_NBPW * LINUX_NSIG_WORDS) 26143bef515SMarcel Moolenaar 26243bef515SMarcel Moolenaar /* sigaction flags */ 26343bef515SMarcel Moolenaar #define LINUX_SA_NOCLDSTOP 0x00000001 26443bef515SMarcel Moolenaar #define LINUX_SA_NOCLDWAIT 0x00000002 26543bef515SMarcel Moolenaar #define LINUX_SA_SIGINFO 0x00000004 26643bef515SMarcel Moolenaar #define LINUX_SA_RESTORER 0x04000000 26743bef515SMarcel Moolenaar #define LINUX_SA_ONSTACK 0x08000000 26843bef515SMarcel Moolenaar #define LINUX_SA_RESTART 0x10000000 26943bef515SMarcel Moolenaar #define LINUX_SA_INTERRUPT 0x20000000 27043bef515SMarcel Moolenaar #define LINUX_SA_NOMASK 0x40000000 27143bef515SMarcel Moolenaar #define LINUX_SA_ONESHOT 0x80000000 27243bef515SMarcel Moolenaar 27343bef515SMarcel Moolenaar /* sigprocmask actions */ 27443bef515SMarcel Moolenaar #define LINUX_SIG_BLOCK 0 27543bef515SMarcel Moolenaar #define LINUX_SIG_UNBLOCK 1 27643bef515SMarcel Moolenaar #define LINUX_SIG_SETMASK 2 27743bef515SMarcel Moolenaar 27843bef515SMarcel Moolenaar /* sigset_t macros */ 27943bef515SMarcel Moolenaar #define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0 28043bef515SMarcel Moolenaar #define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig) 28143bef515SMarcel Moolenaar #define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig) 28243bef515SMarcel Moolenaar 283dee4ec33SMarcel Moolenaar /* sigaltstack */ 284dee4ec33SMarcel Moolenaar #define LINUX_MINSIGSTKSZ 2048 285931a7258SAndrew Gallatin #define LINUX_SS_ONSTACK 1 286931a7258SAndrew Gallatin #define LINUX_SS_DISABLE 2 287931a7258SAndrew Gallatin 288931a7258SAndrew Gallatin int linux_to_bsd_sigaltstack(int lsa); 289931a7258SAndrew Gallatin int bsd_to_linux_sigaltstack(int bsa); 290931a7258SAndrew Gallatin 2915002a60fSMarcel Moolenaar typedef void (*l_handler_t)(l_int); 2925002a60fSMarcel Moolenaar typedef l_ulong l_osigset_t; 293956d3333SMarcel Moolenaar 29406ebbe77SMarcel Moolenaar typedef struct { 2955002a60fSMarcel Moolenaar l_uint __bits[LINUX_NSIG_WORDS]; 2965002a60fSMarcel Moolenaar } l_sigset_t; 297956d3333SMarcel Moolenaar 298956d3333SMarcel Moolenaar typedef struct { 2995002a60fSMarcel Moolenaar l_handler_t lsa_handler; 3005002a60fSMarcel Moolenaar l_osigset_t lsa_mask; 3015002a60fSMarcel Moolenaar l_ulong lsa_flags; 302956d3333SMarcel Moolenaar void (*lsa_restorer)(void); 3035002a60fSMarcel Moolenaar } l_osigaction_t; 304956d3333SMarcel Moolenaar 30506ebbe77SMarcel Moolenaar typedef struct { 3065002a60fSMarcel Moolenaar l_handler_t lsa_handler; 3075002a60fSMarcel Moolenaar l_ulong lsa_flags; 30806ebbe77SMarcel Moolenaar void (*lsa_restorer)(void); 3095002a60fSMarcel Moolenaar l_sigset_t lsa_mask; 3105002a60fSMarcel Moolenaar } l_sigaction_t; 31106ebbe77SMarcel Moolenaar 31243bef515SMarcel Moolenaar typedef struct { 313ec99e322SMarcel Moolenaar void *ss_sp; 3145002a60fSMarcel Moolenaar l_int ss_flags; 3155002a60fSMarcel Moolenaar l_size_t ss_size; 3165002a60fSMarcel Moolenaar } l_stack_t; 317ec99e322SMarcel Moolenaar 31843bef515SMarcel Moolenaar /* The Linux sigcontext, pretty much a standard 386 trapframe. */ 3195002a60fSMarcel Moolenaar struct l_sigcontext { 3205002a60fSMarcel Moolenaar l_int sc_gs; 3215002a60fSMarcel Moolenaar l_int sc_fs; 3225002a60fSMarcel Moolenaar l_int sc_es; 3235002a60fSMarcel Moolenaar l_int sc_ds; 3245002a60fSMarcel Moolenaar l_int sc_edi; 3255002a60fSMarcel Moolenaar l_int sc_esi; 3265002a60fSMarcel Moolenaar l_int sc_ebp; 3275002a60fSMarcel Moolenaar l_int sc_esp; 3285002a60fSMarcel Moolenaar l_int sc_ebx; 3295002a60fSMarcel Moolenaar l_int sc_edx; 3305002a60fSMarcel Moolenaar l_int sc_ecx; 3315002a60fSMarcel Moolenaar l_int sc_eax; 3325002a60fSMarcel Moolenaar l_int sc_trapno; 3335002a60fSMarcel Moolenaar l_int sc_err; 3345002a60fSMarcel Moolenaar l_int sc_eip; 3355002a60fSMarcel Moolenaar l_int sc_cs; 3365002a60fSMarcel Moolenaar l_int sc_eflags; 3375002a60fSMarcel Moolenaar l_int sc_esp_at_signal; 3385002a60fSMarcel Moolenaar l_int sc_ss; 3395002a60fSMarcel Moolenaar l_int sc_387; 3405002a60fSMarcel Moolenaar l_int sc_mask; 3415002a60fSMarcel Moolenaar l_int sc_cr2; 342d66a5066SPeter Wemm }; 343d66a5066SPeter Wemm 3445002a60fSMarcel Moolenaar struct l_ucontext { 3455002a60fSMarcel Moolenaar l_ulong uc_flags; 34679363394SAndrew Gallatin void *uc_link; 3475002a60fSMarcel Moolenaar l_stack_t uc_stack; 3485002a60fSMarcel Moolenaar struct l_sigcontext uc_mcontext; 3495002a60fSMarcel Moolenaar l_sigset_t uc_sigmask; 35079363394SAndrew Gallatin }; 35179363394SAndrew Gallatin 35279363394SAndrew Gallatin #define LINUX_SI_MAX_SIZE 128 3535002a60fSMarcel Moolenaar #define LINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3) 35479363394SAndrew Gallatin 3555002a60fSMarcel Moolenaar typedef struct l_siginfo { 3565002a60fSMarcel Moolenaar l_int lsi_signo; 3575002a60fSMarcel Moolenaar l_int lsi_errno; 3585002a60fSMarcel Moolenaar l_int lsi_code; 35979363394SAndrew Gallatin union { 3605002a60fSMarcel Moolenaar l_int _pad[LINUX_SI_PAD_SIZE]; 3615002a60fSMarcel Moolenaar 36279363394SAndrew Gallatin struct { 3635002a60fSMarcel Moolenaar l_pid_t _pid; 3645002a60fSMarcel Moolenaar l_uid16_t _uid; 36579363394SAndrew Gallatin } _kill; 36679363394SAndrew Gallatin 36779363394SAndrew Gallatin struct { 3685002a60fSMarcel Moolenaar l_uint _timer1; 3695002a60fSMarcel Moolenaar l_uint _timer2; 37079363394SAndrew Gallatin } _timer; 37179363394SAndrew Gallatin 37279363394SAndrew Gallatin struct { 3735002a60fSMarcel Moolenaar l_pid_t _pid; /* sender's pid */ 3745002a60fSMarcel Moolenaar l_uid16_t _uid; /* sender's uid */ 37579363394SAndrew Gallatin union sigval _sigval; 37679363394SAndrew Gallatin } _rt; 37779363394SAndrew Gallatin 37879363394SAndrew Gallatin struct { 3795002a60fSMarcel Moolenaar l_pid_t _pid; /* which child */ 3805002a60fSMarcel Moolenaar l_uid16_t _uid; /* sender's uid */ 3815002a60fSMarcel Moolenaar l_int _status; /* exit code */ 3825002a60fSMarcel Moolenaar l_clock_t _utime; 3835002a60fSMarcel Moolenaar l_clock_t _stime; 38479363394SAndrew Gallatin } _sigchld; 38579363394SAndrew Gallatin 38679363394SAndrew Gallatin struct { 38779363394SAndrew Gallatin void *_addr; /* faulting insn/memory ref. */ 38879363394SAndrew Gallatin } _sigfault; 38979363394SAndrew Gallatin 39079363394SAndrew Gallatin struct { 3915002a60fSMarcel Moolenaar l_int _band; /* POLL_IN,POLL_OUT,POLL_MSG */ 3925002a60fSMarcel Moolenaar l_int _fd; 39379363394SAndrew Gallatin } _sigpoll; 39479363394SAndrew Gallatin } _sifields; 3955002a60fSMarcel Moolenaar } l_siginfo_t; 39679363394SAndrew Gallatin 39779363394SAndrew Gallatin #define lsi_pid _sifields._kill._pid 39879363394SAndrew Gallatin #define lsi_uid _sifields._kill._uid 39979363394SAndrew Gallatin #define lsi_status _sifields._sigchld._status 40079363394SAndrew Gallatin #define lsi_utime _sifields._sigchld._utime 40179363394SAndrew Gallatin #define lsi_stime _sifields._sigchld._stime 40279363394SAndrew Gallatin #define lsi_value _sifields._rt._sigval 40379363394SAndrew Gallatin #define lsi_int _sifields._rt._sigval.sival_int 40479363394SAndrew Gallatin #define lsi_ptr _sifields._rt._sigval.sival_ptr 40579363394SAndrew Gallatin #define lsi_addr _sifields._sigfault._addr 40679363394SAndrew Gallatin #define lsi_band _sifields._sigpoll._band 40779363394SAndrew Gallatin #define lsi_fd _sifields._sigpoll._fd 40879363394SAndrew Gallatin 4095002a60fSMarcel Moolenaar struct l_fpreg { 4102c4ab9ddSAndrew Gallatin u_int16_t significand[4]; 4112c4ab9ddSAndrew Gallatin u_int16_t exponent; 4122c4ab9ddSAndrew Gallatin }; 4132c4ab9ddSAndrew Gallatin 4145002a60fSMarcel Moolenaar struct l_fpxreg { 4152c4ab9ddSAndrew Gallatin u_int16_t significand[4]; 4162c4ab9ddSAndrew Gallatin u_int16_t exponent; 4172c4ab9ddSAndrew Gallatin u_int16_t padding[3]; 4182c4ab9ddSAndrew Gallatin }; 4192c4ab9ddSAndrew Gallatin 4205002a60fSMarcel Moolenaar struct l_xmmreg { 4212c4ab9ddSAndrew Gallatin u_int32_t element[4]; 4222c4ab9ddSAndrew Gallatin }; 4232c4ab9ddSAndrew Gallatin 4245002a60fSMarcel Moolenaar struct l_fpstate { 4252c4ab9ddSAndrew Gallatin /* Regular FPU environment */ 4262c4ab9ddSAndrew Gallatin u_int32_t cw; 4272c4ab9ddSAndrew Gallatin u_int32_t sw; 4282c4ab9ddSAndrew Gallatin u_int32_t tag; 4292c4ab9ddSAndrew Gallatin u_int32_t ipoff; 4302c4ab9ddSAndrew Gallatin u_int32_t cssel; 4312c4ab9ddSAndrew Gallatin u_int32_t dataoff; 4322c4ab9ddSAndrew Gallatin u_int32_t datasel; 4335002a60fSMarcel Moolenaar struct l_fpreg _st[8]; 4342c4ab9ddSAndrew Gallatin u_int16_t status; 4352c4ab9ddSAndrew Gallatin u_int16_t magic; /* 0xffff = regular FPU data */ 4362c4ab9ddSAndrew Gallatin 4372c4ab9ddSAndrew Gallatin /* FXSR FPU environment */ 4382c4ab9ddSAndrew Gallatin u_int32_t _fxsr_env[6]; /* env is ignored */ 4392c4ab9ddSAndrew Gallatin u_int32_t mxcsr; 4402c4ab9ddSAndrew Gallatin u_int32_t reserved; 4415002a60fSMarcel Moolenaar struct l_fpxreg _fxsr_st[8]; /* reg data is ignored */ 4425002a60fSMarcel Moolenaar struct l_xmmreg _xmm[8]; 4432c4ab9ddSAndrew Gallatin u_int32_t padding[56]; 4442c4ab9ddSAndrew Gallatin }; 44579363394SAndrew Gallatin 446d66a5066SPeter Wemm /* 447d66a5066SPeter Wemm * We make the stack look like Linux expects it when calling a signal 448d66a5066SPeter Wemm * handler, but use the BSD way of calling the handler and sigreturn(). 449d66a5066SPeter Wemm * This means that we need to pass the pointer to the handler too. 450d66a5066SPeter Wemm * It is appended to the frame to not interfere with the rest of it. 451d66a5066SPeter Wemm */ 4525002a60fSMarcel Moolenaar struct l_sigframe { 4535002a60fSMarcel Moolenaar l_int sf_sig; 4545002a60fSMarcel Moolenaar struct l_sigcontext sf_sc; 4555002a60fSMarcel Moolenaar struct l_fpstate sf_fpstate; 4565002a60fSMarcel Moolenaar l_uint sf_extramask[LINUX_NSIG_WORDS-1]; 4575002a60fSMarcel Moolenaar l_handler_t sf_handler; 458d66a5066SPeter Wemm }; 459d66a5066SPeter Wemm 4605002a60fSMarcel Moolenaar struct l_rt_sigframe { 4615002a60fSMarcel Moolenaar l_int sf_sig; 4625002a60fSMarcel Moolenaar l_siginfo_t *sf_siginfo; 4635002a60fSMarcel Moolenaar struct l_ucontext *sf_ucontext; 4645002a60fSMarcel Moolenaar l_siginfo_t sf_si; 4655002a60fSMarcel Moolenaar struct l_ucontext sf_sc; 4665002a60fSMarcel Moolenaar l_handler_t sf_handler; 46779363394SAndrew Gallatin }; 46879363394SAndrew Gallatin 469c21dee17SSøren Schmidt extern int bsd_to_linux_signal[]; 470c21dee17SSøren Schmidt extern int linux_to_bsd_signal[]; 471d323ddf3SMatthew Dillon extern struct sysentvec linux_sysvec; 472d323ddf3SMatthew Dillon extern struct sysentvec elf_linux_sysvec; 473c21dee17SSøren Schmidt 47443bef515SMarcel Moolenaar /* 47543bef515SMarcel Moolenaar * Pluggable ioctl handlers 47643bef515SMarcel Moolenaar */ 47743bef515SMarcel Moolenaar struct linux_ioctl_args; 478b40ce416SJulian Elischer struct thread; 479c21dee17SSøren Schmidt 480b40ce416SJulian Elischer typedef int linux_ioctl_function_t(struct thread *, struct linux_ioctl_args *); 481c21dee17SSøren Schmidt 48243bef515SMarcel Moolenaar struct linux_ioctl_handler { 48343bef515SMarcel Moolenaar linux_ioctl_function_t *func; 48443bef515SMarcel Moolenaar int low, high; 485956d3333SMarcel Moolenaar }; 486956d3333SMarcel Moolenaar 48743bef515SMarcel Moolenaar int linux_ioctl_register_handler(struct linux_ioctl_handler *h); 48843bef515SMarcel Moolenaar int linux_ioctl_unregister_handler(struct linux_ioctl_handler *h); 489956d3333SMarcel Moolenaar 49043bef515SMarcel Moolenaar /* 49143bef515SMarcel Moolenaar * open/fcntl flags 49243bef515SMarcel Moolenaar */ 493c21dee17SSøren Schmidt #define LINUX_O_RDONLY 00 494c21dee17SSøren Schmidt #define LINUX_O_WRONLY 01 495c21dee17SSøren Schmidt #define LINUX_O_RDWR 02 496c21dee17SSøren Schmidt #define LINUX_O_CREAT 0100 497c21dee17SSøren Schmidt #define LINUX_O_EXCL 0200 498c21dee17SSøren Schmidt #define LINUX_O_NOCTTY 0400 499c21dee17SSøren Schmidt #define LINUX_O_TRUNC 01000 500c21dee17SSøren Schmidt #define LINUX_O_APPEND 02000 501c21dee17SSøren Schmidt #define LINUX_O_NONBLOCK 04000 502c21dee17SSøren Schmidt #define LINUX_O_NDELAY LINUX_O_NONBLOCK 503c21dee17SSøren Schmidt #define LINUX_O_SYNC 010000 504c21dee17SSøren Schmidt #define LINUX_FASYNC 020000 50573c730a6SMatthew N. Dodd #define LINUX_O_DIRECT 040000 /* direct disk access hint */ 50673c730a6SMatthew N. Dodd #define LINUX_O_LARGEFILE 0100000 50773c730a6SMatthew N. Dodd #define LINUX_O_DIRECTORY 0200000 /* must be a directory */ 50873c730a6SMatthew N. Dodd #define LINUX_O_NOFOLLOW 0400000 /* don't follow links */ 50973c730a6SMatthew N. Dodd #define LINUX_O_NOATIME 01000000 510c21dee17SSøren Schmidt 511c21dee17SSøren Schmidt #define LINUX_F_DUPFD 0 512c21dee17SSøren Schmidt #define LINUX_F_GETFD 1 513c21dee17SSøren Schmidt #define LINUX_F_SETFD 2 514c21dee17SSøren Schmidt #define LINUX_F_GETFL 3 515c21dee17SSøren Schmidt #define LINUX_F_SETFL 4 516c21dee17SSøren Schmidt #define LINUX_F_GETLK 5 517c21dee17SSøren Schmidt #define LINUX_F_SETLK 6 518c21dee17SSøren Schmidt #define LINUX_F_SETLKW 7 519c21dee17SSøren Schmidt #define LINUX_F_SETOWN 8 520c21dee17SSøren Schmidt #define LINUX_F_GETOWN 9 521c21dee17SSøren Schmidt 522aaaefc6bSRobert Drehmel #define LINUX_F_GETLK64 12 523aaaefc6bSRobert Drehmel #define LINUX_F_SETLK64 13 524aaaefc6bSRobert Drehmel #define LINUX_F_SETLKW64 14 525aaaefc6bSRobert Drehmel 526c21dee17SSøren Schmidt #define LINUX_F_RDLCK 0 527c21dee17SSøren Schmidt #define LINUX_F_WRLCK 1 528c21dee17SSøren Schmidt #define LINUX_F_UNLCK 2 529c21dee17SSøren Schmidt 53043bef515SMarcel Moolenaar /* 531705deb78SJonathan Lemon * mount flags 532705deb78SJonathan Lemon */ 533705deb78SJonathan Lemon #define LINUX_MS_RDONLY 0x0001 534705deb78SJonathan Lemon #define LINUX_MS_NOSUID 0x0002 535705deb78SJonathan Lemon #define LINUX_MS_NODEV 0x0004 536705deb78SJonathan Lemon #define LINUX_MS_NOEXEC 0x0008 537705deb78SJonathan Lemon #define LINUX_MS_REMOUNT 0x0020 538705deb78SJonathan Lemon 539705deb78SJonathan Lemon /* 54043bef515SMarcel Moolenaar * SystemV IPC defines 54143bef515SMarcel Moolenaar */ 542c21dee17SSøren Schmidt #define LINUX_SEMOP 1 543c21dee17SSøren Schmidt #define LINUX_SEMGET 2 544c21dee17SSøren Schmidt #define LINUX_SEMCTL 3 545c21dee17SSøren Schmidt #define LINUX_MSGSND 11 546c21dee17SSøren Schmidt #define LINUX_MSGRCV 12 547c21dee17SSøren Schmidt #define LINUX_MSGGET 13 548c21dee17SSøren Schmidt #define LINUX_MSGCTL 14 549c21dee17SSøren Schmidt #define LINUX_SHMAT 21 550c21dee17SSøren Schmidt #define LINUX_SHMDT 22 551c21dee17SSøren Schmidt #define LINUX_SHMGET 23 552c21dee17SSøren Schmidt #define LINUX_SHMCTL 24 553c21dee17SSøren Schmidt 554c21dee17SSøren Schmidt #define LINUX_IPC_RMID 0 555c21dee17SSøren Schmidt #define LINUX_IPC_SET 1 556c21dee17SSøren Schmidt #define LINUX_IPC_STAT 2 557c21dee17SSøren Schmidt #define LINUX_IPC_INFO 3 558c21dee17SSøren Schmidt 559c21dee17SSøren Schmidt #define LINUX_SHM_LOCK 11 560c21dee17SSøren Schmidt #define LINUX_SHM_UNLOCK 12 561c21dee17SSøren Schmidt #define LINUX_SHM_STAT 13 562c21dee17SSøren Schmidt #define LINUX_SHM_INFO 14 563c21dee17SSøren Schmidt 564c21dee17SSøren Schmidt #define LINUX_SHM_RDONLY 0x1000 565c21dee17SSøren Schmidt #define LINUX_SHM_RND 0x2000 566c21dee17SSøren Schmidt #define LINUX_SHM_REMAP 0x4000 567c21dee17SSøren Schmidt 56843bef515SMarcel Moolenaar /* semctl commands */ 5699b86a416SKATO Takenori #define LINUX_GETPID 11 5709b86a416SKATO Takenori #define LINUX_GETVAL 12 5719b86a416SKATO Takenori #define LINUX_GETALL 13 5729b86a416SKATO Takenori #define LINUX_GETNCNT 14 5739b86a416SKATO Takenori #define LINUX_GETZCNT 15 5749b86a416SKATO Takenori #define LINUX_SETVAL 16 5759b86a416SKATO Takenori #define LINUX_SETALL 17 576a6e5348eSMichael Reifenberger #define LINUX_SEM_STAT 18 577a6e5348eSMichael Reifenberger #define LINUX_SEM_INFO 19 5789b86a416SKATO Takenori 5795002a60fSMarcel Moolenaar union l_semun { 5805002a60fSMarcel Moolenaar l_int val; 5815002a60fSMarcel Moolenaar struct l_semid_ds *buf; 5825002a60fSMarcel Moolenaar l_ushort *array; 5835002a60fSMarcel Moolenaar struct l_seminfo *__buf; 5845002a60fSMarcel Moolenaar void *__pad; 5855002a60fSMarcel Moolenaar }; 5865002a60fSMarcel Moolenaar 58743bef515SMarcel Moolenaar /* 58843bef515SMarcel Moolenaar * Socket defines 58943bef515SMarcel Moolenaar */ 590c21dee17SSøren Schmidt #define LINUX_SOCKET 1 591c21dee17SSøren Schmidt #define LINUX_BIND 2 592c21dee17SSøren Schmidt #define LINUX_CONNECT 3 593c21dee17SSøren Schmidt #define LINUX_LISTEN 4 594c21dee17SSøren Schmidt #define LINUX_ACCEPT 5 595c21dee17SSøren Schmidt #define LINUX_GETSOCKNAME 6 596c21dee17SSøren Schmidt #define LINUX_GETPEERNAME 7 597c21dee17SSøren Schmidt #define LINUX_SOCKETPAIR 8 598c21dee17SSøren Schmidt #define LINUX_SEND 9 599c21dee17SSøren Schmidt #define LINUX_RECV 10 600c21dee17SSøren Schmidt #define LINUX_SENDTO 11 601c21dee17SSøren Schmidt #define LINUX_RECVFROM 12 602c21dee17SSøren Schmidt #define LINUX_SHUTDOWN 13 603c21dee17SSøren Schmidt #define LINUX_SETSOCKOPT 14 604c21dee17SSøren Schmidt #define LINUX_GETSOCKOPT 15 605e76bba09SSøren Schmidt #define LINUX_SENDMSG 16 606e76bba09SSøren Schmidt #define LINUX_RECVMSG 17 607c21dee17SSøren Schmidt 608c21dee17SSøren Schmidt #define LINUX_AF_UNSPEC 0 609c21dee17SSøren Schmidt #define LINUX_AF_UNIX 1 610c21dee17SSøren Schmidt #define LINUX_AF_INET 2 611c21dee17SSøren Schmidt #define LINUX_AF_AX25 3 612c21dee17SSøren Schmidt #define LINUX_AF_IPX 4 613c21dee17SSøren Schmidt #define LINUX_AF_APPLETALK 5 614ca26842eSHajimu UMEMOTO #define LINUX_AF_INET6 10 615c21dee17SSøren Schmidt 616c21dee17SSøren Schmidt #define LINUX_SOL_SOCKET 1 617c21dee17SSøren Schmidt #define LINUX_SOL_IP 0 618c21dee17SSøren Schmidt #define LINUX_SOL_IPX 256 619c21dee17SSøren Schmidt #define LINUX_SOL_AX25 257 620c21dee17SSøren Schmidt #define LINUX_SOL_TCP 6 621c21dee17SSøren Schmidt #define LINUX_SOL_UDP 17 622c21dee17SSøren Schmidt 623c21dee17SSøren Schmidt #define LINUX_SO_DEBUG 1 624c21dee17SSøren Schmidt #define LINUX_SO_REUSEADDR 2 625c21dee17SSøren Schmidt #define LINUX_SO_TYPE 3 626c21dee17SSøren Schmidt #define LINUX_SO_ERROR 4 627c21dee17SSøren Schmidt #define LINUX_SO_DONTROUTE 5 628c21dee17SSøren Schmidt #define LINUX_SO_BROADCAST 6 629c21dee17SSøren Schmidt #define LINUX_SO_SNDBUF 7 630c21dee17SSøren Schmidt #define LINUX_SO_RCVBUF 8 631c21dee17SSøren Schmidt #define LINUX_SO_KEEPALIVE 9 632c21dee17SSøren Schmidt #define LINUX_SO_OOBINLINE 10 633c21dee17SSøren Schmidt #define LINUX_SO_NO_CHECK 11 634c21dee17SSøren Schmidt #define LINUX_SO_PRIORITY 12 635c21dee17SSøren Schmidt #define LINUX_SO_LINGER 13 636c21dee17SSøren Schmidt 637c21dee17SSøren Schmidt #define LINUX_IP_TOS 1 638c21dee17SSøren Schmidt #define LINUX_IP_TTL 2 63966ff6a3cSBill Fenner #define LINUX_IP_HDRINCL 3 64066ff6a3cSBill Fenner #define LINUX_IP_OPTIONS 4 64166ff6a3cSBill Fenner 64266ff6a3cSBill Fenner #define LINUX_IP_MULTICAST_IF 32 64366ff6a3cSBill Fenner #define LINUX_IP_MULTICAST_TTL 33 64466ff6a3cSBill Fenner #define LINUX_IP_MULTICAST_LOOP 34 64566ff6a3cSBill Fenner #define LINUX_IP_ADD_MEMBERSHIP 35 64666ff6a3cSBill Fenner #define LINUX_IP_DROP_MEMBERSHIP 36 647c21dee17SSøren Schmidt 6485002a60fSMarcel Moolenaar struct l_sockaddr { 6495002a60fSMarcel Moolenaar l_ushort sa_family; 6503713cbffSMike Smith char sa_data[14]; 6513713cbffSMike Smith }; 6523713cbffSMike Smith 6535002a60fSMarcel Moolenaar struct l_ifmap { 6545002a60fSMarcel Moolenaar l_ulong mem_start; 6555002a60fSMarcel Moolenaar l_ulong mem_end; 6565002a60fSMarcel Moolenaar l_ushort base_addr; 65743bef515SMarcel Moolenaar u_char irq; 65843bef515SMarcel Moolenaar u_char dma; 65943bef515SMarcel Moolenaar u_char port; 6603713cbffSMike Smith }; 6613713cbffSMike Smith 6623713cbffSMike Smith #define LINUX_IFHWADDRLEN 6 6633713cbffSMike Smith #define LINUX_IFNAMSIZ 16 66443bef515SMarcel Moolenaar 6655002a60fSMarcel Moolenaar struct l_ifreq { 66643bef515SMarcel Moolenaar union { 66743bef515SMarcel Moolenaar char ifrn_name[LINUX_IFNAMSIZ]; 6683713cbffSMike Smith } ifr_ifrn; 6693713cbffSMike Smith 6703713cbffSMike Smith union { 6715002a60fSMarcel Moolenaar struct l_sockaddr ifru_addr; 6725002a60fSMarcel Moolenaar struct l_sockaddr ifru_dstaddr; 6735002a60fSMarcel Moolenaar struct l_sockaddr ifru_broadaddr; 6745002a60fSMarcel Moolenaar struct l_sockaddr ifru_netmask; 6755002a60fSMarcel Moolenaar struct l_sockaddr ifru_hwaddr; 676268aeb1eSDag-Erling Smørgrav l_short ifru_flags[1]; 6775002a60fSMarcel Moolenaar l_int ifru_metric; 6785002a60fSMarcel Moolenaar l_int ifru_mtu; 6795002a60fSMarcel Moolenaar struct l_ifmap ifru_map; 6805002a60fSMarcel Moolenaar char ifru_slave[LINUX_IFNAMSIZ]; 6815002a60fSMarcel Moolenaar l_caddr_t ifru_data; 6823713cbffSMike Smith } ifr_ifru; 6833713cbffSMike Smith }; 6843713cbffSMike Smith 6853713cbffSMike Smith #define ifr_name ifr_ifrn.ifrn_name /* interface name */ 6863713cbffSMike Smith #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ 6873713cbffSMike Smith 6885002a60fSMarcel Moolenaar /* 6895002a60fSMarcel Moolenaar * poll() 6905002a60fSMarcel Moolenaar */ 6915002a60fSMarcel Moolenaar #define LINUX_POLLIN 0x0001 6925002a60fSMarcel Moolenaar #define LINUX_POLLPRI 0x0002 6935002a60fSMarcel Moolenaar #define LINUX_POLLOUT 0x0004 6945002a60fSMarcel Moolenaar #define LINUX_POLLERR 0x0008 6955002a60fSMarcel Moolenaar #define LINUX_POLLHUP 0x0010 6965002a60fSMarcel Moolenaar #define LINUX_POLLNVAL 0x0020 6975002a60fSMarcel Moolenaar #define LINUX_POLLRDNORM 0x0040 6985002a60fSMarcel Moolenaar #define LINUX_POLLRDBAND 0x0080 6995002a60fSMarcel Moolenaar #define LINUX_POLLWRNORM 0x0100 7005002a60fSMarcel Moolenaar #define LINUX_POLLWRBAND 0x0200 7015002a60fSMarcel Moolenaar #define LINUX_POLLMSG 0x0400 7025002a60fSMarcel Moolenaar 7035002a60fSMarcel Moolenaar struct l_pollfd { 7045002a60fSMarcel Moolenaar l_int fd; 7055002a60fSMarcel Moolenaar l_short events; 7065002a60fSMarcel Moolenaar l_short revents; 7075002a60fSMarcel Moolenaar }; 7085002a60fSMarcel Moolenaar 7099b44bfc5SAlexander Leidinger struct l_user_desc { 7109b44bfc5SAlexander Leidinger l_uint entry_number; 7119b44bfc5SAlexander Leidinger l_uint base_addr; 7129b44bfc5SAlexander Leidinger l_uint limit; 7139b44bfc5SAlexander Leidinger l_uint seg_32bit:1; 7149b44bfc5SAlexander Leidinger l_uint contents:2; 7159b44bfc5SAlexander Leidinger l_uint read_exec_only:1; 7169b44bfc5SAlexander Leidinger l_uint limit_in_pages:1; 7179b44bfc5SAlexander Leidinger l_uint seg_not_present:1; 7189b44bfc5SAlexander Leidinger l_uint useable:1; 7199b44bfc5SAlexander Leidinger }; 7209b44bfc5SAlexander Leidinger 7219b44bfc5SAlexander Leidinger struct l_desc_struct { 7229b44bfc5SAlexander Leidinger unsigned long a,b; 7239b44bfc5SAlexander Leidinger }; 7249b44bfc5SAlexander Leidinger 7259b44bfc5SAlexander Leidinger 7269b44bfc5SAlexander Leidinger #define LINUX_LOWERWORD 0x0000ffff 7279b44bfc5SAlexander Leidinger 7280eef2f8aSAlexander Leidinger /* 7290eef2f8aSAlexander Leidinger * macros which does the same thing as those in linux include/asm-um/ldt-i386.h 7309b44bfc5SAlexander Leidinger * these convert linux user-space descriptor to machine one 7319b44bfc5SAlexander Leidinger */ 7329b44bfc5SAlexander Leidinger #define LDT_entry_a(info) \ 7339b44bfc5SAlexander Leidinger ((((info)->base_addr & LINUX_LOWERWORD) << 16) | ((info)->limit & LINUX_LOWERWORD)) 7349b44bfc5SAlexander Leidinger 7359b44bfc5SAlexander Leidinger #define ENTRY_B_READ_EXEC_ONLY 9 7369b44bfc5SAlexander Leidinger #define ENTRY_B_CONTENTS 10 7379b44bfc5SAlexander Leidinger #define ENTRY_B_SEG_NOT_PRESENT 15 7389b44bfc5SAlexander Leidinger #define ENTRY_B_BASE_ADDR 16 7399b44bfc5SAlexander Leidinger #define ENTRY_B_USEABLE 20 7409b44bfc5SAlexander Leidinger #define ENTRY_B_SEG32BIT 22 7419b44bfc5SAlexander Leidinger #define ENTRY_B_LIMIT 23 7429b44bfc5SAlexander Leidinger 7439b44bfc5SAlexander Leidinger #define LDT_entry_b(info) \ 7449b44bfc5SAlexander Leidinger (((info)->base_addr & 0xff000000) | \ 7459b44bfc5SAlexander Leidinger ((info)->limit & 0xf0000) | \ 7469b44bfc5SAlexander Leidinger ((info)->contents << ENTRY_B_CONTENTS) | \ 7479b44bfc5SAlexander Leidinger (((info)->seg_not_present == 0) << ENTRY_B_SEG_NOT_PRESENT) | \ 7489b44bfc5SAlexander Leidinger (((info)->base_addr & 0x00ff0000) >> ENTRY_B_BASE_ADDR) | \ 7499b44bfc5SAlexander Leidinger (((info)->read_exec_only == 0) << ENTRY_B_READ_EXEC_ONLY) | \ 7509b44bfc5SAlexander Leidinger ((info)->seg_32bit << ENTRY_B_SEG32BIT) | \ 7519b44bfc5SAlexander Leidinger ((info)->useable << ENTRY_B_USEABLE) | \ 7529b44bfc5SAlexander Leidinger ((info)->limit_in_pages << ENTRY_B_LIMIT) | 0x7000) 7539b44bfc5SAlexander Leidinger 7549b44bfc5SAlexander Leidinger #define LDT_empty(info) (\ 7559b44bfc5SAlexander Leidinger (info)->base_addr == 0 && \ 7569b44bfc5SAlexander Leidinger (info)->limit == 0 && \ 7579b44bfc5SAlexander Leidinger (info)->contents == 0 && \ 7589b44bfc5SAlexander Leidinger (info)->seg_not_present == 1 && \ 7599b44bfc5SAlexander Leidinger (info)->read_exec_only == 1 && \ 7609b44bfc5SAlexander Leidinger (info)->seg_32bit == 0 && \ 7619b44bfc5SAlexander Leidinger (info)->limit_in_pages == 0 && \ 7629b44bfc5SAlexander Leidinger (info)->useable == 0 ) 7639b44bfc5SAlexander Leidinger 7649b44bfc5SAlexander Leidinger /* macros for converting segments, they do the same as those in arch/i386/kernel/process.c */ 7659b44bfc5SAlexander Leidinger #define GET_BASE(desc) ( \ 7669b44bfc5SAlexander Leidinger (((desc)->a >> 16) & LINUX_LOWERWORD) | \ 7679b44bfc5SAlexander Leidinger (((desc)->b << 16) & 0x00ff0000) | \ 7689b44bfc5SAlexander Leidinger ( (desc)->b & 0xff000000) ) 7699b44bfc5SAlexander Leidinger 7709b44bfc5SAlexander Leidinger #define GET_LIMIT(desc) ( \ 7719b44bfc5SAlexander Leidinger ((desc)->a & LINUX_LOWERWORD) | \ 7729b44bfc5SAlexander Leidinger ((desc)->b & 0xf0000) ) 7739b44bfc5SAlexander Leidinger 7749b44bfc5SAlexander Leidinger #define GET_32BIT(desc) (((desc)->b >> ENTRY_B_SEG32BIT) & 1) 7759b44bfc5SAlexander Leidinger #define GET_CONTENTS(desc) (((desc)->b >> ENTRY_B_CONTENTS) & 3) 7769b44bfc5SAlexander Leidinger #define GET_WRITABLE(desc) (((desc)->b >> ENTRY_B_READ_EXEC_ONLY) & 1) 7779b44bfc5SAlexander Leidinger #define GET_LIMIT_PAGES(desc) (((desc)->b >> ENTRY_B_LIMIT) & 1) 7789b44bfc5SAlexander Leidinger #define GET_PRESENT(desc) (((desc)->b >> ENTRY_B_SEG_NOT_PRESENT) & 1) 7799b44bfc5SAlexander Leidinger #define GET_USEABLE(desc) (((desc)->b >> ENTRY_B_USEABLE) & 1) 7809b44bfc5SAlexander Leidinger 7819b44bfc5SAlexander Leidinger #define LINUX_CLOCK_REALTIME 0 7829b44bfc5SAlexander Leidinger #define LINUX_CLOCK_MONOTONIC 1 7839b44bfc5SAlexander Leidinger #define LINUX_CLOCK_PROCESS_CPUTIME_ID 2 7849b44bfc5SAlexander Leidinger #define LINUX_CLOCK_THREAD_CPUTIME_ID 3 7859b44bfc5SAlexander Leidinger #define LINUX_CLOCK_REALTIME_HR 4 7869b44bfc5SAlexander Leidinger #define LINUX_CLOCK_MONOTONIC_HR 5 7879b44bfc5SAlexander Leidinger 7889b44bfc5SAlexander Leidinger typedef int l_timer_t; 7899b44bfc5SAlexander Leidinger typedef int l_mqd_t; 7909b44bfc5SAlexander Leidinger 7919b44bfc5SAlexander Leidinger #define CLONE_VM 0x100 7929b44bfc5SAlexander Leidinger #define CLONE_FS 0x200 7939b44bfc5SAlexander Leidinger #define CLONE_FILES 0x400 7949b44bfc5SAlexander Leidinger #define CLONE_SIGHAND 0x800 7959b44bfc5SAlexander Leidinger #define CLONE_PID 0x1000 /* this flag does not exist in linux anymore */ 7960a62e035SAlexander Leidinger #define CLONE_VFORK 0x4000 7979b44bfc5SAlexander Leidinger #define CLONE_PARENT 0x00008000 7989b44bfc5SAlexander Leidinger #define CLONE_THREAD 0x10000 7999b44bfc5SAlexander Leidinger #define CLONE_SETTLS 0x80000 8009b44bfc5SAlexander Leidinger #define CLONE_CHILD_CLEARTID 0x00200000 8019b44bfc5SAlexander Leidinger #define CLONE_CHILD_SETTID 0x01000000 8029b44bfc5SAlexander Leidinger #define CLONE_PARENT_SETTID 0x00100000 8039b44bfc5SAlexander Leidinger 8049b44bfc5SAlexander Leidinger #define THREADING_FLAGS (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND) 8059b44bfc5SAlexander Leidinger 8061f3dad5aSBruce Evans #endif /* !_I386_LINUX_LINUX_H_ */ 807