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 */ 359b44bfc5SAlexander Leidinger #include <sys/param.h> 369b44bfc5SAlexander Leidinger #include <sys/lock.h> 379b44bfc5SAlexander Leidinger #include <sys/mutex.h> 389b44bfc5SAlexander Leidinger #include <sys/sx.h> 3979363394SAndrew Gallatin 40ebea8660SMarcel Moolenaar #include <i386/linux/linux_syscall.h> 41c21dee17SSøren Schmidt 4224593369SJonathan Lemon /* 4324593369SJonathan Lemon * debugging support 4424593369SJonathan Lemon */ 4524593369SJonathan Lemon extern u_char linux_debug_map[]; 4624593369SJonathan Lemon #define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name) 47b40ce416SJulian Elischer #define ARGS(nm, fmt) "linux(%ld): "#nm"("fmt")\n", (long)td->td_proc->p_pid 48b40ce416SJulian Elischer #define LMSG(fmt) "linux(%ld): "fmt"\n", (long)td->td_proc->p_pid 4924593369SJonathan Lemon 5043bef515SMarcel Moolenaar #ifdef MALLOC_DECLARE 5143bef515SMarcel Moolenaar MALLOC_DECLARE(M_LINUX); 5243bef515SMarcel Moolenaar #endif 5343bef515SMarcel Moolenaar 540e73a962STim J. Robbins #define PTRIN(v) (void *)(v) 550e73a962STim J. Robbins #define PTROUT(v) (l_uintptr_t)(v) 560e73a962STim J. Robbins 5743bef515SMarcel Moolenaar /* 581b20ff34SEric Melville * Provide a separate set of types for the Linux types. 595002a60fSMarcel Moolenaar */ 605002a60fSMarcel Moolenaar typedef int l_int; 615002a60fSMarcel Moolenaar typedef int32_t l_long; 625002a60fSMarcel Moolenaar typedef int64_t l_longlong; 635002a60fSMarcel Moolenaar typedef short l_short; 645002a60fSMarcel Moolenaar typedef unsigned int l_uint; 655002a60fSMarcel Moolenaar typedef uint32_t l_ulong; 665002a60fSMarcel Moolenaar typedef uint64_t l_ulonglong; 675002a60fSMarcel Moolenaar typedef unsigned short l_ushort; 685002a60fSMarcel Moolenaar 695002a60fSMarcel Moolenaar typedef char *l_caddr_t; 700e73a962STim J. Robbins typedef l_ulong l_uintptr_t; 715002a60fSMarcel Moolenaar typedef l_long l_clock_t; 725002a60fSMarcel Moolenaar typedef l_int l_daddr_t; 735002a60fSMarcel Moolenaar typedef l_ushort l_dev_t; 745002a60fSMarcel Moolenaar typedef l_uint l_gid_t; 755002a60fSMarcel Moolenaar typedef l_ushort l_gid16_t; 765002a60fSMarcel Moolenaar typedef l_ulong l_ino_t; 775002a60fSMarcel Moolenaar typedef l_int l_key_t; 785002a60fSMarcel Moolenaar typedef l_longlong l_loff_t; 795002a60fSMarcel Moolenaar typedef l_ushort l_mode_t; 805002a60fSMarcel Moolenaar typedef l_long l_off_t; 815002a60fSMarcel Moolenaar typedef l_int l_pid_t; 825002a60fSMarcel Moolenaar typedef l_uint l_size_t; 835002a60fSMarcel Moolenaar typedef l_long l_suseconds_t; 845002a60fSMarcel Moolenaar typedef l_long l_time_t; 855002a60fSMarcel Moolenaar typedef l_uint l_uid_t; 865002a60fSMarcel Moolenaar typedef l_ushort l_uid16_t; 875002a60fSMarcel Moolenaar 885002a60fSMarcel Moolenaar typedef struct { 895002a60fSMarcel Moolenaar l_int val[2]; 905002a60fSMarcel Moolenaar } l_fsid_t; 915002a60fSMarcel Moolenaar 925002a60fSMarcel Moolenaar typedef struct { 935002a60fSMarcel Moolenaar l_time_t tv_sec; 945002a60fSMarcel Moolenaar l_suseconds_t tv_usec; 955002a60fSMarcel Moolenaar } l_timeval; 965002a60fSMarcel Moolenaar 975002a60fSMarcel Moolenaar #define l_fd_set fd_set 985002a60fSMarcel Moolenaar 995002a60fSMarcel Moolenaar /* 10043bef515SMarcel Moolenaar * Miscellaneous 10143bef515SMarcel Moolenaar */ 10243bef515SMarcel Moolenaar #define LINUX_NAME_MAX 255 10343bef515SMarcel Moolenaar #define LINUX_MAX_UTSNAME 65 10443bef515SMarcel Moolenaar 1055002a60fSMarcel Moolenaar #define LINUX_CTL_MAXNAME 10 1065002a60fSMarcel Moolenaar 1075002a60fSMarcel Moolenaar struct l___sysctl_args 1085002a60fSMarcel Moolenaar { 1095002a60fSMarcel Moolenaar l_int *name; 1105002a60fSMarcel Moolenaar l_int nlen; 1115002a60fSMarcel Moolenaar void *oldval; 1125002a60fSMarcel Moolenaar l_size_t *oldlenp; 1135002a60fSMarcel Moolenaar void *newval; 1145002a60fSMarcel Moolenaar l_size_t newlen; 1155002a60fSMarcel Moolenaar l_ulong __spare[4]; 1165002a60fSMarcel Moolenaar }; 1175002a60fSMarcel Moolenaar 11843bef515SMarcel Moolenaar /* Scheduling policies */ 11943bef515SMarcel Moolenaar #define LINUX_SCHED_OTHER 0 12043bef515SMarcel Moolenaar #define LINUX_SCHED_FIFO 1 12143bef515SMarcel Moolenaar #define LINUX_SCHED_RR 2 12243bef515SMarcel Moolenaar 12343bef515SMarcel Moolenaar /* Resource limits */ 12443bef515SMarcel Moolenaar #define LINUX_RLIMIT_CPU 0 12543bef515SMarcel Moolenaar #define LINUX_RLIMIT_FSIZE 1 12643bef515SMarcel Moolenaar #define LINUX_RLIMIT_DATA 2 12743bef515SMarcel Moolenaar #define LINUX_RLIMIT_STACK 3 12843bef515SMarcel Moolenaar #define LINUX_RLIMIT_CORE 4 12943bef515SMarcel Moolenaar #define LINUX_RLIMIT_RSS 5 13043bef515SMarcel Moolenaar #define LINUX_RLIMIT_NPROC 6 13143bef515SMarcel Moolenaar #define LINUX_RLIMIT_NOFILE 7 13243bef515SMarcel Moolenaar #define LINUX_RLIMIT_MEMLOCK 8 13343bef515SMarcel Moolenaar #define LINUX_RLIMIT_AS 9 /* address space limit */ 13443bef515SMarcel Moolenaar 13543bef515SMarcel Moolenaar #define LINUX_RLIM_NLIMITS 10 13643bef515SMarcel Moolenaar 1375002a60fSMarcel Moolenaar struct l_rlimit { 1385002a60fSMarcel Moolenaar l_ulong rlim_cur; 1395002a60fSMarcel Moolenaar l_ulong rlim_max; 1405002a60fSMarcel Moolenaar }; 1415002a60fSMarcel Moolenaar 14243bef515SMarcel Moolenaar /* mmap options */ 14343bef515SMarcel Moolenaar #define LINUX_MAP_SHARED 0x0001 14443bef515SMarcel Moolenaar #define LINUX_MAP_PRIVATE 0x0002 14543bef515SMarcel Moolenaar #define LINUX_MAP_FIXED 0x0010 14643bef515SMarcel Moolenaar #define LINUX_MAP_ANON 0x0020 14743bef515SMarcel Moolenaar #define LINUX_MAP_GROWSDOWN 0x0100 14843bef515SMarcel Moolenaar 1495002a60fSMarcel Moolenaar /* 1505002a60fSMarcel Moolenaar * stat family of syscalls 1515002a60fSMarcel Moolenaar */ 1525002a60fSMarcel Moolenaar struct l_timespec { 1535002a60fSMarcel Moolenaar l_ulong tv_sec; 1545002a60fSMarcel Moolenaar l_ulong tv_nsec; 1555002a60fSMarcel Moolenaar }; 15643bef515SMarcel Moolenaar 1575002a60fSMarcel Moolenaar struct l_newstat { 1585002a60fSMarcel Moolenaar l_ushort st_dev; 1595002a60fSMarcel Moolenaar l_ushort __pad1; 1605002a60fSMarcel Moolenaar l_ulong st_ino; 1615002a60fSMarcel Moolenaar l_ushort st_mode; 1625002a60fSMarcel Moolenaar l_ushort st_nlink; 1635002a60fSMarcel Moolenaar l_ushort st_uid; 1645002a60fSMarcel Moolenaar l_ushort st_gid; 1655002a60fSMarcel Moolenaar l_ushort st_rdev; 1665002a60fSMarcel Moolenaar l_ushort __pad2; 1675002a60fSMarcel Moolenaar l_ulong st_size; 1685002a60fSMarcel Moolenaar l_ulong st_blksize; 1695002a60fSMarcel Moolenaar l_ulong st_blocks; 1705002a60fSMarcel Moolenaar struct l_timespec st_atimespec; 1715002a60fSMarcel Moolenaar struct l_timespec st_mtimespec; 1725002a60fSMarcel Moolenaar struct l_timespec st_ctimespec; 1735002a60fSMarcel Moolenaar l_ulong __unused4; 1745002a60fSMarcel Moolenaar l_ulong __unused5; 1755002a60fSMarcel Moolenaar }; 17643bef515SMarcel Moolenaar 1771f7642e0SAlexander Leidinger struct l_stat { 1781f7642e0SAlexander Leidinger l_ushort st_dev; 1791f7642e0SAlexander Leidinger l_ulong st_ino; 1801f7642e0SAlexander Leidinger l_ushort st_mode; 1811f7642e0SAlexander Leidinger l_ushort st_nlink; 1821f7642e0SAlexander Leidinger l_ushort st_uid; 1831f7642e0SAlexander Leidinger l_ushort st_gid; 1841f7642e0SAlexander Leidinger l_ushort st_rdev; 1851f7642e0SAlexander Leidinger l_long st_size; 1861f7642e0SAlexander Leidinger struct l_timespec st_atimespec; 1871f7642e0SAlexander Leidinger struct l_timespec st_mtimespec; 1881f7642e0SAlexander Leidinger struct l_timespec st_ctimespec; 1891f7642e0SAlexander Leidinger l_long st_blksize; 1901f7642e0SAlexander Leidinger l_long st_blocks; 1911f7642e0SAlexander Leidinger l_ulong st_flags; 1921f7642e0SAlexander Leidinger l_ulong st_gen; 1931f7642e0SAlexander Leidinger }; 1941f7642e0SAlexander Leidinger 1955002a60fSMarcel Moolenaar struct l_stat64 { 1965002a60fSMarcel Moolenaar l_ushort st_dev; 1975002a60fSMarcel Moolenaar u_char __pad0[10]; 1985002a60fSMarcel Moolenaar l_ulong __st_ino; 1995002a60fSMarcel Moolenaar l_uint st_mode; 2005002a60fSMarcel Moolenaar l_uint st_nlink; 2015002a60fSMarcel Moolenaar l_ulong st_uid; 2025002a60fSMarcel Moolenaar l_ulong st_gid; 2035002a60fSMarcel Moolenaar l_ushort st_rdev; 2045002a60fSMarcel Moolenaar u_char __pad3[10]; 2055002a60fSMarcel Moolenaar l_longlong st_size; 2065002a60fSMarcel Moolenaar l_ulong st_blksize; 2075002a60fSMarcel Moolenaar l_ulong st_blocks; 2085002a60fSMarcel Moolenaar l_ulong __pad4; 2095002a60fSMarcel Moolenaar struct l_timespec st_atimespec; 2105002a60fSMarcel Moolenaar struct l_timespec st_mtimespec; 2115002a60fSMarcel Moolenaar struct l_timespec st_ctimespec; 2125002a60fSMarcel Moolenaar l_ulonglong st_ino; 2135002a60fSMarcel Moolenaar }; 2145002a60fSMarcel Moolenaar 2155002a60fSMarcel Moolenaar struct l_new_utsname { 21643bef515SMarcel Moolenaar char sysname[LINUX_MAX_UTSNAME]; 21743bef515SMarcel Moolenaar char nodename[LINUX_MAX_UTSNAME]; 21843bef515SMarcel Moolenaar char release[LINUX_MAX_UTSNAME]; 21943bef515SMarcel Moolenaar char version[LINUX_MAX_UTSNAME]; 22043bef515SMarcel Moolenaar char machine[LINUX_MAX_UTSNAME]; 22143bef515SMarcel Moolenaar char domainname[LINUX_MAX_UTSNAME]; 22243bef515SMarcel Moolenaar }; 223c21dee17SSøren Schmidt 224956d3333SMarcel Moolenaar /* 22543bef515SMarcel Moolenaar * Signalling 226956d3333SMarcel Moolenaar */ 22743bef515SMarcel Moolenaar #define LINUX_SIGHUP 1 22843bef515SMarcel Moolenaar #define LINUX_SIGINT 2 22943bef515SMarcel Moolenaar #define LINUX_SIGQUIT 3 23043bef515SMarcel Moolenaar #define LINUX_SIGILL 4 23143bef515SMarcel Moolenaar #define LINUX_SIGTRAP 5 23243bef515SMarcel Moolenaar #define LINUX_SIGABRT 6 23343bef515SMarcel Moolenaar #define LINUX_SIGIOT LINUX_SIGABRT 23443bef515SMarcel Moolenaar #define LINUX_SIGBUS 7 23543bef515SMarcel Moolenaar #define LINUX_SIGFPE 8 23643bef515SMarcel Moolenaar #define LINUX_SIGKILL 9 23743bef515SMarcel Moolenaar #define LINUX_SIGUSR1 10 23843bef515SMarcel Moolenaar #define LINUX_SIGSEGV 11 23943bef515SMarcel Moolenaar #define LINUX_SIGUSR2 12 24043bef515SMarcel Moolenaar #define LINUX_SIGPIPE 13 24143bef515SMarcel Moolenaar #define LINUX_SIGALRM 14 24243bef515SMarcel Moolenaar #define LINUX_SIGTERM 15 24343bef515SMarcel Moolenaar #define LINUX_SIGSTKFLT 16 24443bef515SMarcel Moolenaar #define LINUX_SIGCHLD 17 24543bef515SMarcel Moolenaar #define LINUX_SIGCONT 18 24643bef515SMarcel Moolenaar #define LINUX_SIGSTOP 19 24743bef515SMarcel Moolenaar #define LINUX_SIGTSTP 20 24843bef515SMarcel Moolenaar #define LINUX_SIGTTIN 21 24943bef515SMarcel Moolenaar #define LINUX_SIGTTOU 22 25043bef515SMarcel Moolenaar #define LINUX_SIGURG 23 25143bef515SMarcel Moolenaar #define LINUX_SIGXCPU 24 25243bef515SMarcel Moolenaar #define LINUX_SIGXFSZ 25 25343bef515SMarcel Moolenaar #define LINUX_SIGVTALRM 26 25443bef515SMarcel Moolenaar #define LINUX_SIGPROF 27 25543bef515SMarcel Moolenaar #define LINUX_SIGWINCH 28 25643bef515SMarcel Moolenaar #define LINUX_SIGIO 29 25743bef515SMarcel Moolenaar #define LINUX_SIGPOLL LINUX_SIGIO 25843bef515SMarcel Moolenaar #define LINUX_SIGPWR 30 259ba873f4cSAlexander Kabaev #define LINUX_SIGSYS 31 260956d3333SMarcel Moolenaar 26143bef515SMarcel Moolenaar #define LINUX_SIGTBLSZ 31 2622c4ab9ddSAndrew Gallatin #define LINUX_NSIG_WORDS 2 2632c4ab9ddSAndrew Gallatin #define LINUX_NBPW 32 2642c4ab9ddSAndrew Gallatin #define LINUX_NSIG (LINUX_NBPW * LINUX_NSIG_WORDS) 26543bef515SMarcel Moolenaar 26643bef515SMarcel Moolenaar /* sigaction flags */ 26743bef515SMarcel Moolenaar #define LINUX_SA_NOCLDSTOP 0x00000001 26843bef515SMarcel Moolenaar #define LINUX_SA_NOCLDWAIT 0x00000002 26943bef515SMarcel Moolenaar #define LINUX_SA_SIGINFO 0x00000004 27043bef515SMarcel Moolenaar #define LINUX_SA_RESTORER 0x04000000 27143bef515SMarcel Moolenaar #define LINUX_SA_ONSTACK 0x08000000 27243bef515SMarcel Moolenaar #define LINUX_SA_RESTART 0x10000000 27343bef515SMarcel Moolenaar #define LINUX_SA_INTERRUPT 0x20000000 27443bef515SMarcel Moolenaar #define LINUX_SA_NOMASK 0x40000000 27543bef515SMarcel Moolenaar #define LINUX_SA_ONESHOT 0x80000000 27643bef515SMarcel Moolenaar 27743bef515SMarcel Moolenaar /* sigprocmask actions */ 27843bef515SMarcel Moolenaar #define LINUX_SIG_BLOCK 0 27943bef515SMarcel Moolenaar #define LINUX_SIG_UNBLOCK 1 28043bef515SMarcel Moolenaar #define LINUX_SIG_SETMASK 2 28143bef515SMarcel Moolenaar 28243bef515SMarcel Moolenaar /* sigset_t macros */ 28343bef515SMarcel Moolenaar #define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0 28443bef515SMarcel Moolenaar #define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig) 28543bef515SMarcel Moolenaar #define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig) 28643bef515SMarcel Moolenaar 287dee4ec33SMarcel Moolenaar /* sigaltstack */ 288dee4ec33SMarcel Moolenaar #define LINUX_MINSIGSTKSZ 2048 289931a7258SAndrew Gallatin #define LINUX_SS_ONSTACK 1 290931a7258SAndrew Gallatin #define LINUX_SS_DISABLE 2 291931a7258SAndrew Gallatin 292931a7258SAndrew Gallatin int linux_to_bsd_sigaltstack(int lsa); 293931a7258SAndrew Gallatin int bsd_to_linux_sigaltstack(int bsa); 294931a7258SAndrew Gallatin 2955002a60fSMarcel Moolenaar typedef void (*l_handler_t)(l_int); 2965002a60fSMarcel Moolenaar typedef l_ulong l_osigset_t; 297956d3333SMarcel Moolenaar 29806ebbe77SMarcel Moolenaar typedef struct { 2995002a60fSMarcel Moolenaar l_uint __bits[LINUX_NSIG_WORDS]; 3005002a60fSMarcel Moolenaar } l_sigset_t; 301956d3333SMarcel Moolenaar 302956d3333SMarcel Moolenaar typedef struct { 3035002a60fSMarcel Moolenaar l_handler_t lsa_handler; 3045002a60fSMarcel Moolenaar l_osigset_t lsa_mask; 3055002a60fSMarcel Moolenaar l_ulong lsa_flags; 306956d3333SMarcel Moolenaar void (*lsa_restorer)(void); 3075002a60fSMarcel Moolenaar } l_osigaction_t; 308956d3333SMarcel Moolenaar 30906ebbe77SMarcel Moolenaar typedef struct { 3105002a60fSMarcel Moolenaar l_handler_t lsa_handler; 3115002a60fSMarcel Moolenaar l_ulong lsa_flags; 31206ebbe77SMarcel Moolenaar void (*lsa_restorer)(void); 3135002a60fSMarcel Moolenaar l_sigset_t lsa_mask; 3145002a60fSMarcel Moolenaar } l_sigaction_t; 31506ebbe77SMarcel Moolenaar 31643bef515SMarcel Moolenaar typedef struct { 317ec99e322SMarcel Moolenaar void *ss_sp; 3185002a60fSMarcel Moolenaar l_int ss_flags; 3195002a60fSMarcel Moolenaar l_size_t ss_size; 3205002a60fSMarcel Moolenaar } l_stack_t; 321ec99e322SMarcel Moolenaar 32243bef515SMarcel Moolenaar /* The Linux sigcontext, pretty much a standard 386 trapframe. */ 3235002a60fSMarcel Moolenaar struct l_sigcontext { 3245002a60fSMarcel Moolenaar l_int sc_gs; 3255002a60fSMarcel Moolenaar l_int sc_fs; 3265002a60fSMarcel Moolenaar l_int sc_es; 3275002a60fSMarcel Moolenaar l_int sc_ds; 3285002a60fSMarcel Moolenaar l_int sc_edi; 3295002a60fSMarcel Moolenaar l_int sc_esi; 3305002a60fSMarcel Moolenaar l_int sc_ebp; 3315002a60fSMarcel Moolenaar l_int sc_esp; 3325002a60fSMarcel Moolenaar l_int sc_ebx; 3335002a60fSMarcel Moolenaar l_int sc_edx; 3345002a60fSMarcel Moolenaar l_int sc_ecx; 3355002a60fSMarcel Moolenaar l_int sc_eax; 3365002a60fSMarcel Moolenaar l_int sc_trapno; 3375002a60fSMarcel Moolenaar l_int sc_err; 3385002a60fSMarcel Moolenaar l_int sc_eip; 3395002a60fSMarcel Moolenaar l_int sc_cs; 3405002a60fSMarcel Moolenaar l_int sc_eflags; 3415002a60fSMarcel Moolenaar l_int sc_esp_at_signal; 3425002a60fSMarcel Moolenaar l_int sc_ss; 3435002a60fSMarcel Moolenaar l_int sc_387; 3445002a60fSMarcel Moolenaar l_int sc_mask; 3455002a60fSMarcel Moolenaar l_int sc_cr2; 346d66a5066SPeter Wemm }; 347d66a5066SPeter Wemm 3485002a60fSMarcel Moolenaar struct l_ucontext { 3495002a60fSMarcel Moolenaar l_ulong uc_flags; 35079363394SAndrew Gallatin void *uc_link; 3515002a60fSMarcel Moolenaar l_stack_t uc_stack; 3525002a60fSMarcel Moolenaar struct l_sigcontext uc_mcontext; 3535002a60fSMarcel Moolenaar l_sigset_t uc_sigmask; 35479363394SAndrew Gallatin }; 35579363394SAndrew Gallatin 35679363394SAndrew Gallatin #define LINUX_SI_MAX_SIZE 128 3575002a60fSMarcel Moolenaar #define LINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3) 35879363394SAndrew Gallatin 3595002a60fSMarcel Moolenaar typedef struct l_siginfo { 3605002a60fSMarcel Moolenaar l_int lsi_signo; 3615002a60fSMarcel Moolenaar l_int lsi_errno; 3625002a60fSMarcel Moolenaar l_int lsi_code; 36379363394SAndrew Gallatin union { 3645002a60fSMarcel Moolenaar l_int _pad[LINUX_SI_PAD_SIZE]; 3655002a60fSMarcel Moolenaar 36679363394SAndrew Gallatin struct { 3675002a60fSMarcel Moolenaar l_pid_t _pid; 3685002a60fSMarcel Moolenaar l_uid16_t _uid; 36979363394SAndrew Gallatin } _kill; 37079363394SAndrew Gallatin 37179363394SAndrew Gallatin struct { 3725002a60fSMarcel Moolenaar l_uint _timer1; 3735002a60fSMarcel Moolenaar l_uint _timer2; 37479363394SAndrew Gallatin } _timer; 37579363394SAndrew Gallatin 37679363394SAndrew Gallatin struct { 3775002a60fSMarcel Moolenaar l_pid_t _pid; /* sender's pid */ 3785002a60fSMarcel Moolenaar l_uid16_t _uid; /* sender's uid */ 37979363394SAndrew Gallatin union sigval _sigval; 38079363394SAndrew Gallatin } _rt; 38179363394SAndrew Gallatin 38279363394SAndrew Gallatin struct { 3835002a60fSMarcel Moolenaar l_pid_t _pid; /* which child */ 3845002a60fSMarcel Moolenaar l_uid16_t _uid; /* sender's uid */ 3855002a60fSMarcel Moolenaar l_int _status; /* exit code */ 3865002a60fSMarcel Moolenaar l_clock_t _utime; 3875002a60fSMarcel Moolenaar l_clock_t _stime; 38879363394SAndrew Gallatin } _sigchld; 38979363394SAndrew Gallatin 39079363394SAndrew Gallatin struct { 39179363394SAndrew Gallatin void *_addr; /* faulting insn/memory ref. */ 39279363394SAndrew Gallatin } _sigfault; 39379363394SAndrew Gallatin 39479363394SAndrew Gallatin struct { 3955002a60fSMarcel Moolenaar l_int _band; /* POLL_IN,POLL_OUT,POLL_MSG */ 3965002a60fSMarcel Moolenaar l_int _fd; 39779363394SAndrew Gallatin } _sigpoll; 39879363394SAndrew Gallatin } _sifields; 3995002a60fSMarcel Moolenaar } l_siginfo_t; 40079363394SAndrew Gallatin 40179363394SAndrew Gallatin #define lsi_pid _sifields._kill._pid 40279363394SAndrew Gallatin #define lsi_uid _sifields._kill._uid 40379363394SAndrew Gallatin #define lsi_status _sifields._sigchld._status 40479363394SAndrew Gallatin #define lsi_utime _sifields._sigchld._utime 40579363394SAndrew Gallatin #define lsi_stime _sifields._sigchld._stime 40679363394SAndrew Gallatin #define lsi_value _sifields._rt._sigval 40779363394SAndrew Gallatin #define lsi_int _sifields._rt._sigval.sival_int 40879363394SAndrew Gallatin #define lsi_ptr _sifields._rt._sigval.sival_ptr 40979363394SAndrew Gallatin #define lsi_addr _sifields._sigfault._addr 41079363394SAndrew Gallatin #define lsi_band _sifields._sigpoll._band 41179363394SAndrew Gallatin #define lsi_fd _sifields._sigpoll._fd 41279363394SAndrew Gallatin 4135002a60fSMarcel Moolenaar struct l_fpreg { 4142c4ab9ddSAndrew Gallatin u_int16_t significand[4]; 4152c4ab9ddSAndrew Gallatin u_int16_t exponent; 4162c4ab9ddSAndrew Gallatin }; 4172c4ab9ddSAndrew Gallatin 4185002a60fSMarcel Moolenaar struct l_fpxreg { 4192c4ab9ddSAndrew Gallatin u_int16_t significand[4]; 4202c4ab9ddSAndrew Gallatin u_int16_t exponent; 4212c4ab9ddSAndrew Gallatin u_int16_t padding[3]; 4222c4ab9ddSAndrew Gallatin }; 4232c4ab9ddSAndrew Gallatin 4245002a60fSMarcel Moolenaar struct l_xmmreg { 4252c4ab9ddSAndrew Gallatin u_int32_t element[4]; 4262c4ab9ddSAndrew Gallatin }; 4272c4ab9ddSAndrew Gallatin 4285002a60fSMarcel Moolenaar struct l_fpstate { 4292c4ab9ddSAndrew Gallatin /* Regular FPU environment */ 4302c4ab9ddSAndrew Gallatin u_int32_t cw; 4312c4ab9ddSAndrew Gallatin u_int32_t sw; 4322c4ab9ddSAndrew Gallatin u_int32_t tag; 4332c4ab9ddSAndrew Gallatin u_int32_t ipoff; 4342c4ab9ddSAndrew Gallatin u_int32_t cssel; 4352c4ab9ddSAndrew Gallatin u_int32_t dataoff; 4362c4ab9ddSAndrew Gallatin u_int32_t datasel; 4375002a60fSMarcel Moolenaar struct l_fpreg _st[8]; 4382c4ab9ddSAndrew Gallatin u_int16_t status; 4392c4ab9ddSAndrew Gallatin u_int16_t magic; /* 0xffff = regular FPU data */ 4402c4ab9ddSAndrew Gallatin 4412c4ab9ddSAndrew Gallatin /* FXSR FPU environment */ 4422c4ab9ddSAndrew Gallatin u_int32_t _fxsr_env[6]; /* env is ignored */ 4432c4ab9ddSAndrew Gallatin u_int32_t mxcsr; 4442c4ab9ddSAndrew Gallatin u_int32_t reserved; 4455002a60fSMarcel Moolenaar struct l_fpxreg _fxsr_st[8]; /* reg data is ignored */ 4465002a60fSMarcel Moolenaar struct l_xmmreg _xmm[8]; 4472c4ab9ddSAndrew Gallatin u_int32_t padding[56]; 4482c4ab9ddSAndrew Gallatin }; 44979363394SAndrew Gallatin 450d66a5066SPeter Wemm /* 451d66a5066SPeter Wemm * We make the stack look like Linux expects it when calling a signal 452d66a5066SPeter Wemm * handler, but use the BSD way of calling the handler and sigreturn(). 453d66a5066SPeter Wemm * This means that we need to pass the pointer to the handler too. 454d66a5066SPeter Wemm * It is appended to the frame to not interfere with the rest of it. 455d66a5066SPeter Wemm */ 4565002a60fSMarcel Moolenaar struct l_sigframe { 4575002a60fSMarcel Moolenaar l_int sf_sig; 4585002a60fSMarcel Moolenaar struct l_sigcontext sf_sc; 4595002a60fSMarcel Moolenaar struct l_fpstate sf_fpstate; 4605002a60fSMarcel Moolenaar l_uint sf_extramask[LINUX_NSIG_WORDS-1]; 4615002a60fSMarcel Moolenaar l_handler_t sf_handler; 462d66a5066SPeter Wemm }; 463d66a5066SPeter Wemm 4645002a60fSMarcel Moolenaar struct l_rt_sigframe { 4655002a60fSMarcel Moolenaar l_int sf_sig; 4665002a60fSMarcel Moolenaar l_siginfo_t *sf_siginfo; 4675002a60fSMarcel Moolenaar struct l_ucontext *sf_ucontext; 4685002a60fSMarcel Moolenaar l_siginfo_t sf_si; 4695002a60fSMarcel Moolenaar struct l_ucontext sf_sc; 4705002a60fSMarcel Moolenaar l_handler_t sf_handler; 47179363394SAndrew Gallatin }; 47279363394SAndrew Gallatin 473c21dee17SSøren Schmidt extern int bsd_to_linux_signal[]; 474c21dee17SSøren Schmidt extern int linux_to_bsd_signal[]; 475d323ddf3SMatthew Dillon extern struct sysentvec linux_sysvec; 476d323ddf3SMatthew Dillon extern struct sysentvec elf_linux_sysvec; 477c21dee17SSøren Schmidt 47843bef515SMarcel Moolenaar /* 47943bef515SMarcel Moolenaar * Pluggable ioctl handlers 48043bef515SMarcel Moolenaar */ 48143bef515SMarcel Moolenaar struct linux_ioctl_args; 482b40ce416SJulian Elischer struct thread; 483c21dee17SSøren Schmidt 484b40ce416SJulian Elischer typedef int linux_ioctl_function_t(struct thread *, struct linux_ioctl_args *); 485c21dee17SSøren Schmidt 48643bef515SMarcel Moolenaar struct linux_ioctl_handler { 48743bef515SMarcel Moolenaar linux_ioctl_function_t *func; 48843bef515SMarcel Moolenaar int low, high; 489956d3333SMarcel Moolenaar }; 490956d3333SMarcel Moolenaar 49143bef515SMarcel Moolenaar int linux_ioctl_register_handler(struct linux_ioctl_handler *h); 49243bef515SMarcel Moolenaar int linux_ioctl_unregister_handler(struct linux_ioctl_handler *h); 493956d3333SMarcel Moolenaar 49443bef515SMarcel Moolenaar /* 49543bef515SMarcel Moolenaar * open/fcntl flags 49643bef515SMarcel Moolenaar */ 497c21dee17SSøren Schmidt #define LINUX_O_RDONLY 00 498c21dee17SSøren Schmidt #define LINUX_O_WRONLY 01 499c21dee17SSøren Schmidt #define LINUX_O_RDWR 02 500c21dee17SSøren Schmidt #define LINUX_O_CREAT 0100 501c21dee17SSøren Schmidt #define LINUX_O_EXCL 0200 502c21dee17SSøren Schmidt #define LINUX_O_NOCTTY 0400 503c21dee17SSøren Schmidt #define LINUX_O_TRUNC 01000 504c21dee17SSøren Schmidt #define LINUX_O_APPEND 02000 505c21dee17SSøren Schmidt #define LINUX_O_NONBLOCK 04000 506c21dee17SSøren Schmidt #define LINUX_O_NDELAY LINUX_O_NONBLOCK 507c21dee17SSøren Schmidt #define LINUX_O_SYNC 010000 508c21dee17SSøren Schmidt #define LINUX_FASYNC 020000 50973c730a6SMatthew N. Dodd #define LINUX_O_DIRECT 040000 /* direct disk access hint */ 51073c730a6SMatthew N. Dodd #define LINUX_O_LARGEFILE 0100000 51173c730a6SMatthew N. Dodd #define LINUX_O_DIRECTORY 0200000 /* must be a directory */ 51273c730a6SMatthew N. Dodd #define LINUX_O_NOFOLLOW 0400000 /* don't follow links */ 51373c730a6SMatthew N. Dodd #define LINUX_O_NOATIME 01000000 514c21dee17SSøren Schmidt 515c21dee17SSøren Schmidt #define LINUX_F_DUPFD 0 516c21dee17SSøren Schmidt #define LINUX_F_GETFD 1 517c21dee17SSøren Schmidt #define LINUX_F_SETFD 2 518c21dee17SSøren Schmidt #define LINUX_F_GETFL 3 519c21dee17SSøren Schmidt #define LINUX_F_SETFL 4 520c21dee17SSøren Schmidt #define LINUX_F_GETLK 5 521c21dee17SSøren Schmidt #define LINUX_F_SETLK 6 522c21dee17SSøren Schmidt #define LINUX_F_SETLKW 7 523c21dee17SSøren Schmidt #define LINUX_F_SETOWN 8 524c21dee17SSøren Schmidt #define LINUX_F_GETOWN 9 525c21dee17SSøren Schmidt 526aaaefc6bSRobert Drehmel #define LINUX_F_GETLK64 12 527aaaefc6bSRobert Drehmel #define LINUX_F_SETLK64 13 528aaaefc6bSRobert Drehmel #define LINUX_F_SETLKW64 14 529aaaefc6bSRobert Drehmel 530c21dee17SSøren Schmidt #define LINUX_F_RDLCK 0 531c21dee17SSøren Schmidt #define LINUX_F_WRLCK 1 532c21dee17SSøren Schmidt #define LINUX_F_UNLCK 2 533c21dee17SSøren Schmidt 53443bef515SMarcel Moolenaar /* 535705deb78SJonathan Lemon * mount flags 536705deb78SJonathan Lemon */ 537705deb78SJonathan Lemon #define LINUX_MS_RDONLY 0x0001 538705deb78SJonathan Lemon #define LINUX_MS_NOSUID 0x0002 539705deb78SJonathan Lemon #define LINUX_MS_NODEV 0x0004 540705deb78SJonathan Lemon #define LINUX_MS_NOEXEC 0x0008 541705deb78SJonathan Lemon #define LINUX_MS_REMOUNT 0x0020 542705deb78SJonathan Lemon 543705deb78SJonathan Lemon /* 54443bef515SMarcel Moolenaar * SystemV IPC defines 54543bef515SMarcel Moolenaar */ 546c21dee17SSøren Schmidt #define LINUX_SEMOP 1 547c21dee17SSøren Schmidt #define LINUX_SEMGET 2 548c21dee17SSøren Schmidt #define LINUX_SEMCTL 3 549c21dee17SSøren Schmidt #define LINUX_MSGSND 11 550c21dee17SSøren Schmidt #define LINUX_MSGRCV 12 551c21dee17SSøren Schmidt #define LINUX_MSGGET 13 552c21dee17SSøren Schmidt #define LINUX_MSGCTL 14 553c21dee17SSøren Schmidt #define LINUX_SHMAT 21 554c21dee17SSøren Schmidt #define LINUX_SHMDT 22 555c21dee17SSøren Schmidt #define LINUX_SHMGET 23 556c21dee17SSøren Schmidt #define LINUX_SHMCTL 24 557c21dee17SSøren Schmidt 558c21dee17SSøren Schmidt #define LINUX_IPC_RMID 0 559c21dee17SSøren Schmidt #define LINUX_IPC_SET 1 560c21dee17SSøren Schmidt #define LINUX_IPC_STAT 2 561c21dee17SSøren Schmidt #define LINUX_IPC_INFO 3 562c21dee17SSøren Schmidt 563c21dee17SSøren Schmidt #define LINUX_SHM_LOCK 11 564c21dee17SSøren Schmidt #define LINUX_SHM_UNLOCK 12 565c21dee17SSøren Schmidt #define LINUX_SHM_STAT 13 566c21dee17SSøren Schmidt #define LINUX_SHM_INFO 14 567c21dee17SSøren Schmidt 568c21dee17SSøren Schmidt #define LINUX_SHM_RDONLY 0x1000 569c21dee17SSøren Schmidt #define LINUX_SHM_RND 0x2000 570c21dee17SSøren Schmidt #define LINUX_SHM_REMAP 0x4000 571c21dee17SSøren Schmidt 57243bef515SMarcel Moolenaar /* semctl commands */ 5739b86a416SKATO Takenori #define LINUX_GETPID 11 5749b86a416SKATO Takenori #define LINUX_GETVAL 12 5759b86a416SKATO Takenori #define LINUX_GETALL 13 5769b86a416SKATO Takenori #define LINUX_GETNCNT 14 5779b86a416SKATO Takenori #define LINUX_GETZCNT 15 5789b86a416SKATO Takenori #define LINUX_SETVAL 16 5799b86a416SKATO Takenori #define LINUX_SETALL 17 580a6e5348eSMichael Reifenberger #define LINUX_SEM_STAT 18 581a6e5348eSMichael Reifenberger #define LINUX_SEM_INFO 19 5829b86a416SKATO Takenori 5835002a60fSMarcel Moolenaar union l_semun { 5845002a60fSMarcel Moolenaar l_int val; 5855002a60fSMarcel Moolenaar struct l_semid_ds *buf; 5865002a60fSMarcel Moolenaar l_ushort *array; 5875002a60fSMarcel Moolenaar struct l_seminfo *__buf; 5885002a60fSMarcel Moolenaar void *__pad; 5895002a60fSMarcel Moolenaar }; 5905002a60fSMarcel Moolenaar 59143bef515SMarcel Moolenaar /* 59243bef515SMarcel Moolenaar * Socket defines 59343bef515SMarcel Moolenaar */ 594c21dee17SSøren Schmidt #define LINUX_SOCKET 1 595c21dee17SSøren Schmidt #define LINUX_BIND 2 596c21dee17SSøren Schmidt #define LINUX_CONNECT 3 597c21dee17SSøren Schmidt #define LINUX_LISTEN 4 598c21dee17SSøren Schmidt #define LINUX_ACCEPT 5 599c21dee17SSøren Schmidt #define LINUX_GETSOCKNAME 6 600c21dee17SSøren Schmidt #define LINUX_GETPEERNAME 7 601c21dee17SSøren Schmidt #define LINUX_SOCKETPAIR 8 602c21dee17SSøren Schmidt #define LINUX_SEND 9 603c21dee17SSøren Schmidt #define LINUX_RECV 10 604c21dee17SSøren Schmidt #define LINUX_SENDTO 11 605c21dee17SSøren Schmidt #define LINUX_RECVFROM 12 606c21dee17SSøren Schmidt #define LINUX_SHUTDOWN 13 607c21dee17SSøren Schmidt #define LINUX_SETSOCKOPT 14 608c21dee17SSøren Schmidt #define LINUX_GETSOCKOPT 15 609e76bba09SSøren Schmidt #define LINUX_SENDMSG 16 610e76bba09SSøren Schmidt #define LINUX_RECVMSG 17 611c21dee17SSøren Schmidt 612c21dee17SSøren Schmidt #define LINUX_AF_UNSPEC 0 613c21dee17SSøren Schmidt #define LINUX_AF_UNIX 1 614c21dee17SSøren Schmidt #define LINUX_AF_INET 2 615c21dee17SSøren Schmidt #define LINUX_AF_AX25 3 616c21dee17SSøren Schmidt #define LINUX_AF_IPX 4 617c21dee17SSøren Schmidt #define LINUX_AF_APPLETALK 5 618ca26842eSHajimu UMEMOTO #define LINUX_AF_INET6 10 619c21dee17SSøren Schmidt 620c21dee17SSøren Schmidt #define LINUX_SOL_SOCKET 1 621c21dee17SSøren Schmidt #define LINUX_SOL_IP 0 622c21dee17SSøren Schmidt #define LINUX_SOL_IPX 256 623c21dee17SSøren Schmidt #define LINUX_SOL_AX25 257 624c21dee17SSøren Schmidt #define LINUX_SOL_TCP 6 625c21dee17SSøren Schmidt #define LINUX_SOL_UDP 17 626c21dee17SSøren Schmidt 627c21dee17SSøren Schmidt #define LINUX_SO_DEBUG 1 628c21dee17SSøren Schmidt #define LINUX_SO_REUSEADDR 2 629c21dee17SSøren Schmidt #define LINUX_SO_TYPE 3 630c21dee17SSøren Schmidt #define LINUX_SO_ERROR 4 631c21dee17SSøren Schmidt #define LINUX_SO_DONTROUTE 5 632c21dee17SSøren Schmidt #define LINUX_SO_BROADCAST 6 633c21dee17SSøren Schmidt #define LINUX_SO_SNDBUF 7 634c21dee17SSøren Schmidt #define LINUX_SO_RCVBUF 8 635c21dee17SSøren Schmidt #define LINUX_SO_KEEPALIVE 9 636c21dee17SSøren Schmidt #define LINUX_SO_OOBINLINE 10 637c21dee17SSøren Schmidt #define LINUX_SO_NO_CHECK 11 638c21dee17SSøren Schmidt #define LINUX_SO_PRIORITY 12 639c21dee17SSøren Schmidt #define LINUX_SO_LINGER 13 640c21dee17SSøren Schmidt 641c21dee17SSøren Schmidt #define LINUX_IP_TOS 1 642c21dee17SSøren Schmidt #define LINUX_IP_TTL 2 64366ff6a3cSBill Fenner #define LINUX_IP_HDRINCL 3 64466ff6a3cSBill Fenner #define LINUX_IP_OPTIONS 4 64566ff6a3cSBill Fenner 64666ff6a3cSBill Fenner #define LINUX_IP_MULTICAST_IF 32 64766ff6a3cSBill Fenner #define LINUX_IP_MULTICAST_TTL 33 64866ff6a3cSBill Fenner #define LINUX_IP_MULTICAST_LOOP 34 64966ff6a3cSBill Fenner #define LINUX_IP_ADD_MEMBERSHIP 35 65066ff6a3cSBill Fenner #define LINUX_IP_DROP_MEMBERSHIP 36 651c21dee17SSøren Schmidt 6525002a60fSMarcel Moolenaar struct l_sockaddr { 6535002a60fSMarcel Moolenaar l_ushort sa_family; 6543713cbffSMike Smith char sa_data[14]; 6553713cbffSMike Smith }; 6563713cbffSMike Smith 6575002a60fSMarcel Moolenaar struct l_ifmap { 6585002a60fSMarcel Moolenaar l_ulong mem_start; 6595002a60fSMarcel Moolenaar l_ulong mem_end; 6605002a60fSMarcel Moolenaar l_ushort base_addr; 66143bef515SMarcel Moolenaar u_char irq; 66243bef515SMarcel Moolenaar u_char dma; 66343bef515SMarcel Moolenaar u_char port; 6643713cbffSMike Smith }; 6653713cbffSMike Smith 6663713cbffSMike Smith #define LINUX_IFHWADDRLEN 6 6673713cbffSMike Smith #define LINUX_IFNAMSIZ 16 66843bef515SMarcel Moolenaar 6695002a60fSMarcel Moolenaar struct l_ifreq { 67043bef515SMarcel Moolenaar union { 67143bef515SMarcel Moolenaar char ifrn_name[LINUX_IFNAMSIZ]; 6723713cbffSMike Smith } ifr_ifrn; 6733713cbffSMike Smith 6743713cbffSMike Smith union { 6755002a60fSMarcel Moolenaar struct l_sockaddr ifru_addr; 6765002a60fSMarcel Moolenaar struct l_sockaddr ifru_dstaddr; 6775002a60fSMarcel Moolenaar struct l_sockaddr ifru_broadaddr; 6785002a60fSMarcel Moolenaar struct l_sockaddr ifru_netmask; 6795002a60fSMarcel Moolenaar struct l_sockaddr ifru_hwaddr; 680268aeb1eSDag-Erling Smørgrav l_short ifru_flags[1]; 6815002a60fSMarcel Moolenaar l_int ifru_metric; 6825002a60fSMarcel Moolenaar l_int ifru_mtu; 6835002a60fSMarcel Moolenaar struct l_ifmap ifru_map; 6845002a60fSMarcel Moolenaar char ifru_slave[LINUX_IFNAMSIZ]; 6855002a60fSMarcel Moolenaar l_caddr_t ifru_data; 6863713cbffSMike Smith } ifr_ifru; 6873713cbffSMike Smith }; 6883713cbffSMike Smith 6893713cbffSMike Smith #define ifr_name ifr_ifrn.ifrn_name /* interface name */ 6903713cbffSMike Smith #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ 6913713cbffSMike Smith 6925002a60fSMarcel Moolenaar /* 6935002a60fSMarcel Moolenaar * poll() 6945002a60fSMarcel Moolenaar */ 6955002a60fSMarcel Moolenaar #define LINUX_POLLIN 0x0001 6965002a60fSMarcel Moolenaar #define LINUX_POLLPRI 0x0002 6975002a60fSMarcel Moolenaar #define LINUX_POLLOUT 0x0004 6985002a60fSMarcel Moolenaar #define LINUX_POLLERR 0x0008 6995002a60fSMarcel Moolenaar #define LINUX_POLLHUP 0x0010 7005002a60fSMarcel Moolenaar #define LINUX_POLLNVAL 0x0020 7015002a60fSMarcel Moolenaar #define LINUX_POLLRDNORM 0x0040 7025002a60fSMarcel Moolenaar #define LINUX_POLLRDBAND 0x0080 7035002a60fSMarcel Moolenaar #define LINUX_POLLWRNORM 0x0100 7045002a60fSMarcel Moolenaar #define LINUX_POLLWRBAND 0x0200 7055002a60fSMarcel Moolenaar #define LINUX_POLLMSG 0x0400 7065002a60fSMarcel Moolenaar 7075002a60fSMarcel Moolenaar struct l_pollfd { 7085002a60fSMarcel Moolenaar l_int fd; 7095002a60fSMarcel Moolenaar l_short events; 7105002a60fSMarcel Moolenaar l_short revents; 7115002a60fSMarcel Moolenaar }; 7125002a60fSMarcel Moolenaar 7139b44bfc5SAlexander Leidinger struct l_user_desc { 7149b44bfc5SAlexander Leidinger l_uint entry_number; 7159b44bfc5SAlexander Leidinger l_uint base_addr; 7169b44bfc5SAlexander Leidinger l_uint limit; 7179b44bfc5SAlexander Leidinger l_uint seg_32bit:1; 7189b44bfc5SAlexander Leidinger l_uint contents:2; 7199b44bfc5SAlexander Leidinger l_uint read_exec_only:1; 7209b44bfc5SAlexander Leidinger l_uint limit_in_pages:1; 7219b44bfc5SAlexander Leidinger l_uint seg_not_present:1; 7229b44bfc5SAlexander Leidinger l_uint useable:1; 7239b44bfc5SAlexander Leidinger }; 7249b44bfc5SAlexander Leidinger 7259b44bfc5SAlexander Leidinger struct l_desc_struct { 7269b44bfc5SAlexander Leidinger unsigned long a,b; 7279b44bfc5SAlexander Leidinger }; 7289b44bfc5SAlexander Leidinger 7299b44bfc5SAlexander Leidinger 7309b44bfc5SAlexander Leidinger #define LINUX_LOWERWORD 0x0000ffff 7319b44bfc5SAlexander Leidinger 7329b44bfc5SAlexander Leidinger /* macros which does the same thing as those in linux include/asm-um/ldt-i386.h 7339b44bfc5SAlexander Leidinger * these convert linux user-space descriptor to machine one 7349b44bfc5SAlexander Leidinger */ 7359b44bfc5SAlexander Leidinger #define LDT_entry_a(info) \ 7369b44bfc5SAlexander Leidinger ((((info)->base_addr & LINUX_LOWERWORD) << 16) | ((info)->limit & LINUX_LOWERWORD)) 7379b44bfc5SAlexander Leidinger 7389b44bfc5SAlexander Leidinger #define ENTRY_B_READ_EXEC_ONLY 9 7399b44bfc5SAlexander Leidinger #define ENTRY_B_CONTENTS 10 7409b44bfc5SAlexander Leidinger #define ENTRY_B_SEG_NOT_PRESENT 15 7419b44bfc5SAlexander Leidinger #define ENTRY_B_BASE_ADDR 16 7429b44bfc5SAlexander Leidinger #define ENTRY_B_USEABLE 20 7439b44bfc5SAlexander Leidinger #define ENTRY_B_SEG32BIT 22 7449b44bfc5SAlexander Leidinger #define ENTRY_B_LIMIT 23 7459b44bfc5SAlexander Leidinger 7469b44bfc5SAlexander Leidinger #define LDT_entry_b(info) \ 7479b44bfc5SAlexander Leidinger (((info)->base_addr & 0xff000000) | \ 7489b44bfc5SAlexander Leidinger ((info)->limit & 0xf0000) | \ 7499b44bfc5SAlexander Leidinger ((info)->contents << ENTRY_B_CONTENTS) | \ 7509b44bfc5SAlexander Leidinger (((info)->seg_not_present == 0) << ENTRY_B_SEG_NOT_PRESENT) | \ 7519b44bfc5SAlexander Leidinger (((info)->base_addr & 0x00ff0000) >> ENTRY_B_BASE_ADDR) | \ 7529b44bfc5SAlexander Leidinger (((info)->read_exec_only == 0) << ENTRY_B_READ_EXEC_ONLY) | \ 7539b44bfc5SAlexander Leidinger ((info)->seg_32bit << ENTRY_B_SEG32BIT) | \ 7549b44bfc5SAlexander Leidinger ((info)->useable << ENTRY_B_USEABLE) | \ 7559b44bfc5SAlexander Leidinger ((info)->limit_in_pages << ENTRY_B_LIMIT) | 0x7000) 7569b44bfc5SAlexander Leidinger 7579b44bfc5SAlexander Leidinger #define LDT_empty(info) (\ 7589b44bfc5SAlexander Leidinger (info)->base_addr == 0 && \ 7599b44bfc5SAlexander Leidinger (info)->limit == 0 && \ 7609b44bfc5SAlexander Leidinger (info)->contents == 0 && \ 7619b44bfc5SAlexander Leidinger (info)->seg_not_present == 1 && \ 7629b44bfc5SAlexander Leidinger (info)->read_exec_only == 1 && \ 7639b44bfc5SAlexander Leidinger (info)->seg_32bit == 0 && \ 7649b44bfc5SAlexander Leidinger (info)->limit_in_pages == 0 && \ 7659b44bfc5SAlexander Leidinger (info)->useable == 0 ) 7669b44bfc5SAlexander Leidinger 7679b44bfc5SAlexander Leidinger /* macros for converting segments, they do the same as those in arch/i386/kernel/process.c */ 7689b44bfc5SAlexander Leidinger #define GET_BASE(desc) ( \ 7699b44bfc5SAlexander Leidinger (((desc)->a >> 16) & LINUX_LOWERWORD) | \ 7709b44bfc5SAlexander Leidinger (((desc)->b << 16) & 0x00ff0000) | \ 7719b44bfc5SAlexander Leidinger ( (desc)->b & 0xff000000) ) 7729b44bfc5SAlexander Leidinger 7739b44bfc5SAlexander Leidinger #define GET_LIMIT(desc) ( \ 7749b44bfc5SAlexander Leidinger ((desc)->a & LINUX_LOWERWORD) | \ 7759b44bfc5SAlexander Leidinger ((desc)->b & 0xf0000) ) 7769b44bfc5SAlexander Leidinger 7779b44bfc5SAlexander Leidinger #define GET_32BIT(desc) (((desc)->b >> ENTRY_B_SEG32BIT) & 1) 7789b44bfc5SAlexander Leidinger #define GET_CONTENTS(desc) (((desc)->b >> ENTRY_B_CONTENTS) & 3) 7799b44bfc5SAlexander Leidinger #define GET_WRITABLE(desc) (((desc)->b >> ENTRY_B_READ_EXEC_ONLY) & 1) 7809b44bfc5SAlexander Leidinger #define GET_LIMIT_PAGES(desc) (((desc)->b >> ENTRY_B_LIMIT) & 1) 7819b44bfc5SAlexander Leidinger #define GET_PRESENT(desc) (((desc)->b >> ENTRY_B_SEG_NOT_PRESENT) & 1) 7829b44bfc5SAlexander Leidinger #define GET_USEABLE(desc) (((desc)->b >> ENTRY_B_USEABLE) & 1) 7839b44bfc5SAlexander Leidinger 7849b44bfc5SAlexander Leidinger #define LINUX_CLOCK_REALTIME 0 7859b44bfc5SAlexander Leidinger #define LINUX_CLOCK_MONOTONIC 1 7869b44bfc5SAlexander Leidinger #define LINUX_CLOCK_PROCESS_CPUTIME_ID 2 7879b44bfc5SAlexander Leidinger #define LINUX_CLOCK_THREAD_CPUTIME_ID 3 7889b44bfc5SAlexander Leidinger #define LINUX_CLOCK_REALTIME_HR 4 7899b44bfc5SAlexander Leidinger #define LINUX_CLOCK_MONOTONIC_HR 5 7909b44bfc5SAlexander Leidinger 7919b44bfc5SAlexander Leidinger typedef int l_timer_t; 7929b44bfc5SAlexander Leidinger typedef int l_mqd_t; 7939b44bfc5SAlexander Leidinger 7949b44bfc5SAlexander Leidinger #define CLONE_VM 0x100 7959b44bfc5SAlexander Leidinger #define CLONE_FS 0x200 7969b44bfc5SAlexander Leidinger #define CLONE_FILES 0x400 7979b44bfc5SAlexander Leidinger #define CLONE_SIGHAND 0x800 7989b44bfc5SAlexander Leidinger #define CLONE_PID 0x1000 /* this flag does not exist in linux anymore */ 7999b44bfc5SAlexander Leidinger #define CLONE_PARENT 0x00008000 8009b44bfc5SAlexander Leidinger #define CLONE_THREAD 0x10000 8019b44bfc5SAlexander Leidinger #define CLONE_SETTLS 0x80000 8029b44bfc5SAlexander Leidinger #define CLONE_CHILD_CLEARTID 0x00200000 8039b44bfc5SAlexander Leidinger #define CLONE_CHILD_SETTID 0x01000000 8049b44bfc5SAlexander Leidinger #define CLONE_PARENT_SETTID 0x00100000 8059b44bfc5SAlexander Leidinger 8069b44bfc5SAlexander Leidinger #define THREADING_FLAGS (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND) 8079b44bfc5SAlexander Leidinger 8081f3dad5aSBruce Evans #endif /* !_I386_LINUX_LINUX_H_ */ 809