1c21dee17SSøren Schmidt /*- 2*83ef78beSPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 3*83ef78beSPedro F. Giffuni * 49a14aa01SUlrich Spörlein * Copyright (c) 1994-1996 Søren Schmidt 5c21dee17SSøren Schmidt * All rights reserved. 6c21dee17SSøren Schmidt * 7c21dee17SSøren Schmidt * Redistribution and use in source and binary forms, with or without 8c21dee17SSøren Schmidt * modification, are permitted provided that the following conditions 9c21dee17SSøren Schmidt * are met: 10c21dee17SSøren Schmidt * 1. Redistributions of source code must retain the above copyright 11c21dee17SSøren Schmidt * notice, this list of conditions and the following disclaimer 12c21dee17SSøren Schmidt * in this position and unchanged. 13c21dee17SSøren Schmidt * 2. Redistributions in binary form must reproduce the above copyright 14c21dee17SSøren Schmidt * notice, this list of conditions and the following disclaimer in the 15c21dee17SSøren Schmidt * documentation and/or other materials provided with the distribution. 16c21dee17SSøren Schmidt * 3. The name of the author may not be used to endorse or promote products 176c5e9bbdSMike Pritchard * derived from this software without specific prior written permission 18c21dee17SSøren Schmidt * 19c21dee17SSøren Schmidt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20c21dee17SSøren Schmidt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21c21dee17SSøren Schmidt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22c21dee17SSøren Schmidt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23c21dee17SSøren Schmidt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24c21dee17SSøren Schmidt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25c21dee17SSøren Schmidt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26c21dee17SSøren Schmidt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27c21dee17SSøren Schmidt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28c21dee17SSøren Schmidt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29c21dee17SSøren Schmidt * 30c3aac50fSPeter Wemm * $FreeBSD$ 31c21dee17SSøren Schmidt */ 32c21dee17SSøren Schmidt 33a4e3bad7SJung-uk Kim #ifndef _I386_LINUX_H_ 34a4e3bad7SJung-uk Kim #define _I386_LINUX_H_ 3562c3734cSBruce Evans 3679363394SAndrew Gallatin #include <sys/signal.h> /* for sigval union */ 3779363394SAndrew Gallatin 384ab7403bSDmitry Chagin #include <compat/linux/linux.h> 39ebea8660SMarcel Moolenaar #include <i386/linux/linux_syscall.h> 40c21dee17SSøren Schmidt 4124593369SJonathan Lemon /* 4224593369SJonathan Lemon * debugging support 4324593369SJonathan Lemon */ 4424593369SJonathan Lemon extern u_char linux_debug_map[]; 4524593369SJonathan Lemon #define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name) 461d80c8a8SDmitry Chagin #define ARGS(nm, fmt) "linux(%ld/%ld): "#nm"("fmt")\n", \ 471d80c8a8SDmitry Chagin (long)td->td_proc->p_pid, (long)td->td_tid 481d80c8a8SDmitry Chagin #define LMSG(fmt) "linux(%ld/%ld): "fmt"\n", \ 491d80c8a8SDmitry Chagin (long)td->td_proc->p_pid, (long)td->td_tid 5019e252baSAlexander Leidinger #define LINUX_DTRACE linuxulator 5124593369SJonathan Lemon 528f1e49a6SDmitry Chagin #define LINUX_SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) 538f1e49a6SDmitry Chagin #define LINUX_USRSTACK LINUX_SHAREDPAGE 548f1e49a6SDmitry Chagin 550e73a962STim J. Robbins #define PTRIN(v) (void *)(v) 560e73a962STim J. Robbins #define PTROUT(v) (l_uintptr_t)(v) 570e73a962STim J. Robbins 580a041f3bSBjoern A. Zeeb #define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0) 590a041f3bSBjoern A. Zeeb #define CP2(src,dst,sfld,dfld) do { (dst).dfld = (src).sfld; } while (0) 600a041f3bSBjoern A. Zeeb #define PTRIN_CP(src,dst,fld) \ 610a041f3bSBjoern A. Zeeb do { (dst).fld = PTRIN((src).fld); } while (0) 620a041f3bSBjoern A. Zeeb 6343bef515SMarcel Moolenaar /* 641b20ff34SEric Melville * Provide a separate set of types for the Linux types. 655002a60fSMarcel Moolenaar */ 665002a60fSMarcel Moolenaar typedef int l_int; 675002a60fSMarcel Moolenaar typedef int32_t l_long; 685002a60fSMarcel Moolenaar typedef int64_t l_longlong; 695002a60fSMarcel Moolenaar typedef short l_short; 705002a60fSMarcel Moolenaar typedef unsigned int l_uint; 715002a60fSMarcel Moolenaar typedef uint32_t l_ulong; 725002a60fSMarcel Moolenaar typedef uint64_t l_ulonglong; 735002a60fSMarcel Moolenaar typedef unsigned short l_ushort; 745002a60fSMarcel Moolenaar 755002a60fSMarcel Moolenaar typedef char *l_caddr_t; 760e73a962STim J. Robbins typedef l_ulong l_uintptr_t; 775002a60fSMarcel Moolenaar typedef l_long l_clock_t; 785002a60fSMarcel Moolenaar typedef l_int l_daddr_t; 795002a60fSMarcel Moolenaar typedef l_ushort l_dev_t; 805002a60fSMarcel Moolenaar typedef l_uint l_gid_t; 815002a60fSMarcel Moolenaar typedef l_ushort l_gid16_t; 825002a60fSMarcel Moolenaar typedef l_ulong l_ino_t; 835002a60fSMarcel Moolenaar typedef l_int l_key_t; 845002a60fSMarcel Moolenaar typedef l_longlong l_loff_t; 855002a60fSMarcel Moolenaar typedef l_ushort l_mode_t; 865002a60fSMarcel Moolenaar typedef l_long l_off_t; 875002a60fSMarcel Moolenaar typedef l_int l_pid_t; 885002a60fSMarcel Moolenaar typedef l_uint l_size_t; 895002a60fSMarcel Moolenaar typedef l_long l_suseconds_t; 905002a60fSMarcel Moolenaar typedef l_long l_time_t; 915002a60fSMarcel Moolenaar typedef l_uint l_uid_t; 925002a60fSMarcel Moolenaar typedef l_ushort l_uid16_t; 93aa8b2011SKonstantin Belousov typedef l_int l_timer_t; 94aa8b2011SKonstantin Belousov typedef l_int l_mqd_t; 953e89b641SDmitry Chagin typedef l_ulong l_fd_mask; 965002a60fSMarcel Moolenaar 975002a60fSMarcel Moolenaar typedef struct { 985002a60fSMarcel Moolenaar l_int val[2]; 995002a60fSMarcel Moolenaar } l_fsid_t; 1005002a60fSMarcel Moolenaar 1015002a60fSMarcel Moolenaar typedef struct { 1025002a60fSMarcel Moolenaar l_time_t tv_sec; 1035002a60fSMarcel Moolenaar l_suseconds_t tv_usec; 1045002a60fSMarcel Moolenaar } l_timeval; 1055002a60fSMarcel Moolenaar 1065002a60fSMarcel Moolenaar #define l_fd_set fd_set 1075002a60fSMarcel Moolenaar 1085002a60fSMarcel Moolenaar /* 10943bef515SMarcel Moolenaar * Miscellaneous 11043bef515SMarcel Moolenaar */ 1114048f59cSDmitry Chagin #define LINUX_AT_COUNT 20 /* Count of used aux entry types. 1124d7c2e8aSDmitry Chagin * Keep this synchronized with 1134d7c2e8aSDmitry Chagin * elf_linux_fixup() code. 1144d7c2e8aSDmitry Chagin */ 1155002a60fSMarcel Moolenaar struct l___sysctl_args 1165002a60fSMarcel Moolenaar { 1175002a60fSMarcel Moolenaar l_int *name; 1185002a60fSMarcel Moolenaar l_int nlen; 1195002a60fSMarcel Moolenaar void *oldval; 1205002a60fSMarcel Moolenaar l_size_t *oldlenp; 1215002a60fSMarcel Moolenaar void *newval; 1225002a60fSMarcel Moolenaar l_size_t newlen; 1235002a60fSMarcel Moolenaar l_ulong __spare[4]; 1245002a60fSMarcel Moolenaar }; 1255002a60fSMarcel Moolenaar 12643bef515SMarcel Moolenaar /* Resource limits */ 12743bef515SMarcel Moolenaar #define LINUX_RLIMIT_CPU 0 12843bef515SMarcel Moolenaar #define LINUX_RLIMIT_FSIZE 1 12943bef515SMarcel Moolenaar #define LINUX_RLIMIT_DATA 2 13043bef515SMarcel Moolenaar #define LINUX_RLIMIT_STACK 3 13143bef515SMarcel Moolenaar #define LINUX_RLIMIT_CORE 4 13243bef515SMarcel Moolenaar #define LINUX_RLIMIT_RSS 5 13343bef515SMarcel Moolenaar #define LINUX_RLIMIT_NPROC 6 13443bef515SMarcel Moolenaar #define LINUX_RLIMIT_NOFILE 7 13543bef515SMarcel Moolenaar #define LINUX_RLIMIT_MEMLOCK 8 136a4e3bad7SJung-uk Kim #define LINUX_RLIMIT_AS 9 /* Address space limit */ 13743bef515SMarcel Moolenaar 13843bef515SMarcel Moolenaar #define LINUX_RLIM_NLIMITS 10 13943bef515SMarcel Moolenaar 1405002a60fSMarcel Moolenaar struct l_rlimit { 1415002a60fSMarcel Moolenaar l_ulong rlim_cur; 1425002a60fSMarcel Moolenaar l_ulong rlim_max; 1435002a60fSMarcel Moolenaar }; 1445002a60fSMarcel Moolenaar 14510931a46SJung-uk Kim struct l_mmap_argv { 14610931a46SJung-uk Kim l_uintptr_t addr; 14710931a46SJung-uk Kim l_size_t len; 14810931a46SJung-uk Kim l_int prot; 14910931a46SJung-uk Kim l_int flags; 15010931a46SJung-uk Kim l_int fd; 15110931a46SJung-uk Kim l_off_t pgoff; 15210931a46SJung-uk Kim } __packed; 15310931a46SJung-uk Kim 1545002a60fSMarcel Moolenaar /* 1555002a60fSMarcel Moolenaar * stat family of syscalls 1565002a60fSMarcel Moolenaar */ 1575002a60fSMarcel Moolenaar struct l_timespec { 15877424f41SJung-uk Kim l_time_t tv_sec; 15977424f41SJung-uk Kim l_long tv_nsec; 1605002a60fSMarcel Moolenaar }; 16143bef515SMarcel Moolenaar 1625002a60fSMarcel Moolenaar struct l_newstat { 1635002a60fSMarcel Moolenaar l_ushort st_dev; 1645002a60fSMarcel Moolenaar l_ushort __pad1; 1655002a60fSMarcel Moolenaar l_ulong st_ino; 1665002a60fSMarcel Moolenaar l_ushort st_mode; 1675002a60fSMarcel Moolenaar l_ushort st_nlink; 1685002a60fSMarcel Moolenaar l_ushort st_uid; 1695002a60fSMarcel Moolenaar l_ushort st_gid; 1705002a60fSMarcel Moolenaar l_ushort st_rdev; 1715002a60fSMarcel Moolenaar l_ushort __pad2; 1725002a60fSMarcel Moolenaar l_ulong st_size; 1735002a60fSMarcel Moolenaar l_ulong st_blksize; 1745002a60fSMarcel Moolenaar l_ulong st_blocks; 175510ea843SEd Schouten struct l_timespec st_atim; 176510ea843SEd Schouten struct l_timespec st_mtim; 177510ea843SEd Schouten struct l_timespec st_ctim; 1785002a60fSMarcel Moolenaar l_ulong __unused4; 1795002a60fSMarcel Moolenaar l_ulong __unused5; 1805002a60fSMarcel Moolenaar }; 18143bef515SMarcel Moolenaar 1821f7642e0SAlexander Leidinger struct l_stat { 1831f7642e0SAlexander Leidinger l_ushort st_dev; 1841f7642e0SAlexander Leidinger l_ulong st_ino; 1851f7642e0SAlexander Leidinger l_ushort st_mode; 1861f7642e0SAlexander Leidinger l_ushort st_nlink; 1871f7642e0SAlexander Leidinger l_ushort st_uid; 1881f7642e0SAlexander Leidinger l_ushort st_gid; 1891f7642e0SAlexander Leidinger l_ushort st_rdev; 1901f7642e0SAlexander Leidinger l_long st_size; 191510ea843SEd Schouten struct l_timespec st_atim; 192510ea843SEd Schouten struct l_timespec st_mtim; 193510ea843SEd Schouten struct l_timespec st_ctim; 1941f7642e0SAlexander Leidinger l_long st_blksize; 1951f7642e0SAlexander Leidinger l_long st_blocks; 1961f7642e0SAlexander Leidinger l_ulong st_flags; 1971f7642e0SAlexander Leidinger l_ulong st_gen; 1981f7642e0SAlexander Leidinger }; 1991f7642e0SAlexander Leidinger 2005002a60fSMarcel Moolenaar struct l_stat64 { 2015002a60fSMarcel Moolenaar l_ushort st_dev; 2025002a60fSMarcel Moolenaar u_char __pad0[10]; 2035002a60fSMarcel Moolenaar l_ulong __st_ino; 2045002a60fSMarcel Moolenaar l_uint st_mode; 2055002a60fSMarcel Moolenaar l_uint st_nlink; 2065002a60fSMarcel Moolenaar l_ulong st_uid; 2075002a60fSMarcel Moolenaar l_ulong st_gid; 2085002a60fSMarcel Moolenaar l_ushort st_rdev; 2095002a60fSMarcel Moolenaar u_char __pad3[10]; 2105002a60fSMarcel Moolenaar l_longlong st_size; 2115002a60fSMarcel Moolenaar l_ulong st_blksize; 2125002a60fSMarcel Moolenaar l_ulong st_blocks; 2135002a60fSMarcel Moolenaar l_ulong __pad4; 214510ea843SEd Schouten struct l_timespec st_atim; 215510ea843SEd Schouten struct l_timespec st_mtim; 216510ea843SEd Schouten struct l_timespec st_ctim; 2175002a60fSMarcel Moolenaar l_ulonglong st_ino; 2185002a60fSMarcel Moolenaar }; 2195002a60fSMarcel Moolenaar 2203ab85269SDavid Malone struct l_statfs64 { 2213ab85269SDavid Malone l_int f_type; 2223ab85269SDavid Malone l_int f_bsize; 2233ab85269SDavid Malone uint64_t f_blocks; 2243ab85269SDavid Malone uint64_t f_bfree; 2253ab85269SDavid Malone uint64_t f_bavail; 2263ab85269SDavid Malone uint64_t f_files; 2273ab85269SDavid Malone uint64_t f_ffree; 2283ab85269SDavid Malone l_fsid_t f_fsid; 2293ab85269SDavid Malone l_int f_namelen; 230e801ac78SEdward Tomasz Napierala l_int f_frsize; 231e801ac78SEdward Tomasz Napierala l_int f_flags; 232e801ac78SEdward Tomasz Napierala l_int f_spare[4]; 2333ab85269SDavid Malone }; 2343ab85269SDavid Malone 2352c4ab9ddSAndrew Gallatin #define LINUX_NSIG_WORDS 2 23643bef515SMarcel Moolenaar 23743bef515SMarcel Moolenaar /* sigaction flags */ 23843bef515SMarcel Moolenaar #define LINUX_SA_NOCLDSTOP 0x00000001 23943bef515SMarcel Moolenaar #define LINUX_SA_NOCLDWAIT 0x00000002 24043bef515SMarcel Moolenaar #define LINUX_SA_SIGINFO 0x00000004 24143bef515SMarcel Moolenaar #define LINUX_SA_RESTORER 0x04000000 24243bef515SMarcel Moolenaar #define LINUX_SA_ONSTACK 0x08000000 24343bef515SMarcel Moolenaar #define LINUX_SA_RESTART 0x10000000 24443bef515SMarcel Moolenaar #define LINUX_SA_INTERRUPT 0x20000000 24543bef515SMarcel Moolenaar #define LINUX_SA_NOMASK 0x40000000 24643bef515SMarcel Moolenaar #define LINUX_SA_ONESHOT 0x80000000 24743bef515SMarcel Moolenaar 24843bef515SMarcel Moolenaar /* sigprocmask actions */ 24943bef515SMarcel Moolenaar #define LINUX_SIG_BLOCK 0 25043bef515SMarcel Moolenaar #define LINUX_SIG_UNBLOCK 1 25143bef515SMarcel Moolenaar #define LINUX_SIG_SETMASK 2 25243bef515SMarcel Moolenaar 253dee4ec33SMarcel Moolenaar /* sigaltstack */ 254dee4ec33SMarcel Moolenaar #define LINUX_MINSIGSTKSZ 2048 255931a7258SAndrew Gallatin 2565002a60fSMarcel Moolenaar typedef void (*l_handler_t)(l_int); 2575002a60fSMarcel Moolenaar typedef l_ulong l_osigset_t; 258956d3333SMarcel Moolenaar 25906ebbe77SMarcel Moolenaar typedef struct { 2605002a60fSMarcel Moolenaar l_handler_t lsa_handler; 2615002a60fSMarcel Moolenaar l_osigset_t lsa_mask; 2625002a60fSMarcel Moolenaar l_ulong lsa_flags; 263956d3333SMarcel Moolenaar void (*lsa_restorer)(void); 2645002a60fSMarcel Moolenaar } l_osigaction_t; 265956d3333SMarcel Moolenaar 26606ebbe77SMarcel Moolenaar typedef struct { 2675002a60fSMarcel Moolenaar l_handler_t lsa_handler; 2685002a60fSMarcel Moolenaar l_ulong lsa_flags; 26906ebbe77SMarcel Moolenaar void (*lsa_restorer)(void); 2705002a60fSMarcel Moolenaar l_sigset_t lsa_mask; 2715002a60fSMarcel Moolenaar } l_sigaction_t; 27206ebbe77SMarcel Moolenaar 27343bef515SMarcel Moolenaar typedef struct { 274ec99e322SMarcel Moolenaar void *ss_sp; 2755002a60fSMarcel Moolenaar l_int ss_flags; 2765002a60fSMarcel Moolenaar l_size_t ss_size; 2775002a60fSMarcel Moolenaar } l_stack_t; 278ec99e322SMarcel Moolenaar 27943bef515SMarcel Moolenaar /* The Linux sigcontext, pretty much a standard 386 trapframe. */ 2805002a60fSMarcel Moolenaar struct l_sigcontext { 2815002a60fSMarcel Moolenaar l_int sc_gs; 2825002a60fSMarcel Moolenaar l_int sc_fs; 2835002a60fSMarcel Moolenaar l_int sc_es; 2845002a60fSMarcel Moolenaar l_int sc_ds; 2855002a60fSMarcel Moolenaar l_int sc_edi; 2865002a60fSMarcel Moolenaar l_int sc_esi; 2875002a60fSMarcel Moolenaar l_int sc_ebp; 2885002a60fSMarcel Moolenaar l_int sc_esp; 2895002a60fSMarcel Moolenaar l_int sc_ebx; 2905002a60fSMarcel Moolenaar l_int sc_edx; 2915002a60fSMarcel Moolenaar l_int sc_ecx; 2925002a60fSMarcel Moolenaar l_int sc_eax; 2935002a60fSMarcel Moolenaar l_int sc_trapno; 2945002a60fSMarcel Moolenaar l_int sc_err; 2955002a60fSMarcel Moolenaar l_int sc_eip; 2965002a60fSMarcel Moolenaar l_int sc_cs; 2975002a60fSMarcel Moolenaar l_int sc_eflags; 2985002a60fSMarcel Moolenaar l_int sc_esp_at_signal; 2995002a60fSMarcel Moolenaar l_int sc_ss; 3005002a60fSMarcel Moolenaar l_int sc_387; 3015002a60fSMarcel Moolenaar l_int sc_mask; 3025002a60fSMarcel Moolenaar l_int sc_cr2; 303d66a5066SPeter Wemm }; 304d66a5066SPeter Wemm 3055002a60fSMarcel Moolenaar struct l_ucontext { 3065002a60fSMarcel Moolenaar l_ulong uc_flags; 30779363394SAndrew Gallatin void *uc_link; 3085002a60fSMarcel Moolenaar l_stack_t uc_stack; 3095002a60fSMarcel Moolenaar struct l_sigcontext uc_mcontext; 3105002a60fSMarcel Moolenaar l_sigset_t uc_sigmask; 31179363394SAndrew Gallatin }; 31279363394SAndrew Gallatin 31379363394SAndrew Gallatin #define LINUX_SI_MAX_SIZE 128 3145002a60fSMarcel Moolenaar #define LINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3) 31579363394SAndrew Gallatin 316aa8b2011SKonstantin Belousov typedef union l_sigval { 317aa8b2011SKonstantin Belousov l_int sival_int; 318aa8b2011SKonstantin Belousov l_uintptr_t sival_ptr; 319aa8b2011SKonstantin Belousov } l_sigval_t; 320aa8b2011SKonstantin Belousov 3215002a60fSMarcel Moolenaar typedef struct l_siginfo { 3225002a60fSMarcel Moolenaar l_int lsi_signo; 3235002a60fSMarcel Moolenaar l_int lsi_errno; 3245002a60fSMarcel Moolenaar l_int lsi_code; 32579363394SAndrew Gallatin union { 3265002a60fSMarcel Moolenaar l_int _pad[LINUX_SI_PAD_SIZE]; 3275002a60fSMarcel Moolenaar 32879363394SAndrew Gallatin struct { 3295002a60fSMarcel Moolenaar l_pid_t _pid; 330aa8b2011SKonstantin Belousov l_uid_t _uid; 33179363394SAndrew Gallatin } _kill; 33279363394SAndrew Gallatin 33379363394SAndrew Gallatin struct { 334aa8b2011SKonstantin Belousov l_timer_t _tid; 335aa8b2011SKonstantin Belousov l_int _overrun; 336aa8b2011SKonstantin Belousov char _pad[sizeof(l_uid_t) - sizeof(l_int)]; 337aa8b2011SKonstantin Belousov l_sigval_t _sigval; 338aa8b2011SKonstantin Belousov l_int _sys_private; 33979363394SAndrew Gallatin } _timer; 34079363394SAndrew Gallatin 34179363394SAndrew Gallatin struct { 3425002a60fSMarcel Moolenaar l_pid_t _pid; /* sender's pid */ 343aa8b2011SKonstantin Belousov l_uid_t _uid; /* sender's uid */ 344aa8b2011SKonstantin Belousov l_sigval_t _sigval; 34579363394SAndrew Gallatin } _rt; 34679363394SAndrew Gallatin 34779363394SAndrew Gallatin struct { 3485002a60fSMarcel Moolenaar l_pid_t _pid; /* which child */ 349aa8b2011SKonstantin Belousov l_uid_t _uid; /* sender's uid */ 3505002a60fSMarcel Moolenaar l_int _status; /* exit code */ 3515002a60fSMarcel Moolenaar l_clock_t _utime; 3525002a60fSMarcel Moolenaar l_clock_t _stime; 35379363394SAndrew Gallatin } _sigchld; 35479363394SAndrew Gallatin 35579363394SAndrew Gallatin struct { 356aa8b2011SKonstantin Belousov l_uintptr_t _addr; /* Faulting insn/memory ref. */ 35779363394SAndrew Gallatin } _sigfault; 35879363394SAndrew Gallatin 35979363394SAndrew Gallatin struct { 360aa8b2011SKonstantin Belousov l_long _band; /* POLL_IN,POLL_OUT,POLL_MSG */ 3615002a60fSMarcel Moolenaar l_int _fd; 36279363394SAndrew Gallatin } _sigpoll; 36379363394SAndrew Gallatin } _sifields; 3645002a60fSMarcel Moolenaar } l_siginfo_t; 36579363394SAndrew Gallatin 36679363394SAndrew Gallatin #define lsi_pid _sifields._kill._pid 36779363394SAndrew Gallatin #define lsi_uid _sifields._kill._uid 368aa8b2011SKonstantin Belousov #define lsi_tid _sifields._timer._tid 369aa8b2011SKonstantin Belousov #define lsi_overrun _sifields._timer._overrun 370aa8b2011SKonstantin Belousov #define lsi_sys_private _sifields._timer._sys_private 37179363394SAndrew Gallatin #define lsi_status _sifields._sigchld._status 37279363394SAndrew Gallatin #define lsi_utime _sifields._sigchld._utime 37379363394SAndrew Gallatin #define lsi_stime _sifields._sigchld._stime 37479363394SAndrew Gallatin #define lsi_value _sifields._rt._sigval 37579363394SAndrew Gallatin #define lsi_int _sifields._rt._sigval.sival_int 37679363394SAndrew Gallatin #define lsi_ptr _sifields._rt._sigval.sival_ptr 37779363394SAndrew Gallatin #define lsi_addr _sifields._sigfault._addr 37879363394SAndrew Gallatin #define lsi_band _sifields._sigpoll._band 37979363394SAndrew Gallatin #define lsi_fd _sifields._sigpoll._fd 38079363394SAndrew Gallatin 3815002a60fSMarcel Moolenaar struct l_fpreg { 3822c4ab9ddSAndrew Gallatin u_int16_t significand[4]; 3832c4ab9ddSAndrew Gallatin u_int16_t exponent; 3842c4ab9ddSAndrew Gallatin }; 3852c4ab9ddSAndrew Gallatin 3865002a60fSMarcel Moolenaar struct l_fpxreg { 3872c4ab9ddSAndrew Gallatin u_int16_t significand[4]; 3882c4ab9ddSAndrew Gallatin u_int16_t exponent; 3892c4ab9ddSAndrew Gallatin u_int16_t padding[3]; 3902c4ab9ddSAndrew Gallatin }; 3912c4ab9ddSAndrew Gallatin 3925002a60fSMarcel Moolenaar struct l_xmmreg { 3932c4ab9ddSAndrew Gallatin u_int32_t element[4]; 3942c4ab9ddSAndrew Gallatin }; 3952c4ab9ddSAndrew Gallatin 3965002a60fSMarcel Moolenaar struct l_fpstate { 3972c4ab9ddSAndrew Gallatin /* Regular FPU environment */ 3982c4ab9ddSAndrew Gallatin u_int32_t cw; 3992c4ab9ddSAndrew Gallatin u_int32_t sw; 4002c4ab9ddSAndrew Gallatin u_int32_t tag; 4012c4ab9ddSAndrew Gallatin u_int32_t ipoff; 4022c4ab9ddSAndrew Gallatin u_int32_t cssel; 4032c4ab9ddSAndrew Gallatin u_int32_t dataoff; 4042c4ab9ddSAndrew Gallatin u_int32_t datasel; 4055002a60fSMarcel Moolenaar struct l_fpreg _st[8]; 4062c4ab9ddSAndrew Gallatin u_int16_t status; 4072c4ab9ddSAndrew Gallatin u_int16_t magic; /* 0xffff = regular FPU data */ 4082c4ab9ddSAndrew Gallatin 4092c4ab9ddSAndrew Gallatin /* FXSR FPU environment */ 410a4e3bad7SJung-uk Kim u_int32_t _fxsr_env[6]; /* env is ignored. */ 4112c4ab9ddSAndrew Gallatin u_int32_t mxcsr; 4122c4ab9ddSAndrew Gallatin u_int32_t reserved; 413a4e3bad7SJung-uk Kim struct l_fpxreg _fxsr_st[8]; /* reg data is ignored. */ 4145002a60fSMarcel Moolenaar struct l_xmmreg _xmm[8]; 4152c4ab9ddSAndrew Gallatin u_int32_t padding[56]; 4162c4ab9ddSAndrew Gallatin }; 41779363394SAndrew Gallatin 418d66a5066SPeter Wemm /* 419d66a5066SPeter Wemm * We make the stack look like Linux expects it when calling a signal 420d66a5066SPeter Wemm * handler, but use the BSD way of calling the handler and sigreturn(). 421d66a5066SPeter Wemm * This means that we need to pass the pointer to the handler too. 422d66a5066SPeter Wemm * It is appended to the frame to not interfere with the rest of it. 423d66a5066SPeter Wemm */ 4245002a60fSMarcel Moolenaar struct l_sigframe { 4255002a60fSMarcel Moolenaar l_int sf_sig; 4265002a60fSMarcel Moolenaar struct l_sigcontext sf_sc; 4275002a60fSMarcel Moolenaar struct l_fpstate sf_fpstate; 4285002a60fSMarcel Moolenaar l_uint sf_extramask[LINUX_NSIG_WORDS-1]; 4295002a60fSMarcel Moolenaar l_handler_t sf_handler; 430d66a5066SPeter Wemm }; 431d66a5066SPeter Wemm 4325002a60fSMarcel Moolenaar struct l_rt_sigframe { 4335002a60fSMarcel Moolenaar l_int sf_sig; 4345002a60fSMarcel Moolenaar l_siginfo_t *sf_siginfo; 4355002a60fSMarcel Moolenaar struct l_ucontext *sf_ucontext; 4365002a60fSMarcel Moolenaar l_siginfo_t sf_si; 4375002a60fSMarcel Moolenaar struct l_ucontext sf_sc; 4385002a60fSMarcel Moolenaar l_handler_t sf_handler; 43979363394SAndrew Gallatin }; 44079363394SAndrew Gallatin 441d323ddf3SMatthew Dillon extern struct sysentvec linux_sysvec; 442c21dee17SSøren Schmidt 44343bef515SMarcel Moolenaar /* 4444d0f380dSDmitry Chagin * arch specific open/fcntl flags 44543bef515SMarcel Moolenaar */ 446aaaefc6bSRobert Drehmel #define LINUX_F_GETLK64 12 447aaaefc6bSRobert Drehmel #define LINUX_F_SETLK64 13 448aaaefc6bSRobert Drehmel #define LINUX_F_SETLKW64 14 449aaaefc6bSRobert Drehmel 4505002a60fSMarcel Moolenaar union l_semun { 4515002a60fSMarcel Moolenaar l_int val; 4525002a60fSMarcel Moolenaar struct l_semid_ds *buf; 4535002a60fSMarcel Moolenaar l_ushort *array; 4545002a60fSMarcel Moolenaar struct l_seminfo *__buf; 4555002a60fSMarcel Moolenaar void *__pad; 4565002a60fSMarcel Moolenaar }; 4575002a60fSMarcel Moolenaar 4585002a60fSMarcel Moolenaar struct l_sockaddr { 4595002a60fSMarcel Moolenaar l_ushort sa_family; 4603713cbffSMike Smith char sa_data[14]; 4613713cbffSMike Smith }; 4623713cbffSMike Smith 4635002a60fSMarcel Moolenaar struct l_ifmap { 4645002a60fSMarcel Moolenaar l_ulong mem_start; 4655002a60fSMarcel Moolenaar l_ulong mem_end; 4665002a60fSMarcel Moolenaar l_ushort base_addr; 46743bef515SMarcel Moolenaar u_char irq; 46843bef515SMarcel Moolenaar u_char dma; 46943bef515SMarcel Moolenaar u_char port; 4703713cbffSMike Smith }; 4713713cbffSMike Smith 4723713cbffSMike Smith #define LINUX_IFHWADDRLEN 6 4733713cbffSMike Smith #define LINUX_IFNAMSIZ 16 47443bef515SMarcel Moolenaar 4755002a60fSMarcel Moolenaar struct l_ifreq { 47643bef515SMarcel Moolenaar union { 47743bef515SMarcel Moolenaar char ifrn_name[LINUX_IFNAMSIZ]; 4783713cbffSMike Smith } ifr_ifrn; 4793713cbffSMike Smith 4803713cbffSMike Smith union { 4815002a60fSMarcel Moolenaar struct l_sockaddr ifru_addr; 4825002a60fSMarcel Moolenaar struct l_sockaddr ifru_dstaddr; 4835002a60fSMarcel Moolenaar struct l_sockaddr ifru_broadaddr; 4845002a60fSMarcel Moolenaar struct l_sockaddr ifru_netmask; 4855002a60fSMarcel Moolenaar struct l_sockaddr ifru_hwaddr; 486268aeb1eSDag-Erling Smørgrav l_short ifru_flags[1]; 4877ece126eSTai-hwa Liang l_int ifru_ivalue; 4885002a60fSMarcel Moolenaar l_int ifru_mtu; 4895002a60fSMarcel Moolenaar struct l_ifmap ifru_map; 4905002a60fSMarcel Moolenaar char ifru_slave[LINUX_IFNAMSIZ]; 4915002a60fSMarcel Moolenaar l_caddr_t ifru_data; 4923713cbffSMike Smith } ifr_ifru; 4933713cbffSMike Smith }; 4943713cbffSMike Smith 495a4e3bad7SJung-uk Kim #define ifr_name ifr_ifrn.ifrn_name /* Interface name */ 4963713cbffSMike Smith #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ 4977ece126eSTai-hwa Liang #define ifr_ifindex ifr_ifru.ifru_ivalue /* Interface index */ 4983713cbffSMike Smith 4995002a60fSMarcel Moolenaar /* 5005002a60fSMarcel Moolenaar * poll() 5015002a60fSMarcel Moolenaar */ 5025002a60fSMarcel Moolenaar #define LINUX_POLLIN 0x0001 5035002a60fSMarcel Moolenaar #define LINUX_POLLPRI 0x0002 5045002a60fSMarcel Moolenaar #define LINUX_POLLOUT 0x0004 5055002a60fSMarcel Moolenaar #define LINUX_POLLERR 0x0008 5065002a60fSMarcel Moolenaar #define LINUX_POLLHUP 0x0010 5075002a60fSMarcel Moolenaar #define LINUX_POLLNVAL 0x0020 5085002a60fSMarcel Moolenaar #define LINUX_POLLRDNORM 0x0040 5095002a60fSMarcel Moolenaar #define LINUX_POLLRDBAND 0x0080 5105002a60fSMarcel Moolenaar #define LINUX_POLLWRNORM 0x0100 5115002a60fSMarcel Moolenaar #define LINUX_POLLWRBAND 0x0200 5125002a60fSMarcel Moolenaar #define LINUX_POLLMSG 0x0400 5135002a60fSMarcel Moolenaar 5145002a60fSMarcel Moolenaar struct l_pollfd { 5155002a60fSMarcel Moolenaar l_int fd; 5165002a60fSMarcel Moolenaar l_short events; 5175002a60fSMarcel Moolenaar l_short revents; 5185002a60fSMarcel Moolenaar }; 5195002a60fSMarcel Moolenaar 5209b44bfc5SAlexander Leidinger struct l_user_desc { 5219b44bfc5SAlexander Leidinger l_uint entry_number; 5229b44bfc5SAlexander Leidinger l_uint base_addr; 5239b44bfc5SAlexander Leidinger l_uint limit; 5249b44bfc5SAlexander Leidinger l_uint seg_32bit:1; 5259b44bfc5SAlexander Leidinger l_uint contents:2; 5269b44bfc5SAlexander Leidinger l_uint read_exec_only:1; 5279b44bfc5SAlexander Leidinger l_uint limit_in_pages:1; 5289b44bfc5SAlexander Leidinger l_uint seg_not_present:1; 5299b44bfc5SAlexander Leidinger l_uint useable:1; 5309b44bfc5SAlexander Leidinger }; 5319b44bfc5SAlexander Leidinger 5329b44bfc5SAlexander Leidinger struct l_desc_struct { 5339b44bfc5SAlexander Leidinger unsigned long a, b; 5349b44bfc5SAlexander Leidinger }; 5359b44bfc5SAlexander Leidinger 5369b44bfc5SAlexander Leidinger 5379b44bfc5SAlexander Leidinger #define LINUX_LOWERWORD 0x0000ffff 5389b44bfc5SAlexander Leidinger 5390eef2f8aSAlexander Leidinger /* 540a4e3bad7SJung-uk Kim * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h. 541a4e3bad7SJung-uk Kim * These convert Linux user space descriptor to machine one. 5429b44bfc5SAlexander Leidinger */ 543a4e3bad7SJung-uk Kim #define LINUX_LDT_entry_a(info) \ 544a4e3bad7SJung-uk Kim ((((info)->base_addr & LINUX_LOWERWORD) << 16) | \ 545a4e3bad7SJung-uk Kim ((info)->limit & LINUX_LOWERWORD)) 5469b44bfc5SAlexander Leidinger 547a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_READ_EXEC_ONLY 9 548a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_CONTENTS 10 549a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_SEG_NOT_PRESENT 15 550a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_BASE_ADDR 16 551a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_USEABLE 20 552a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_SEG32BIT 22 553a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_LIMIT 23 5549b44bfc5SAlexander Leidinger 555a4e3bad7SJung-uk Kim #define LINUX_LDT_entry_b(info) \ 5569b44bfc5SAlexander Leidinger (((info)->base_addr & 0xff000000) | \ 5579b44bfc5SAlexander Leidinger ((info)->limit & 0xf0000) | \ 558a4e3bad7SJung-uk Kim ((info)->contents << LINUX_ENTRY_B_CONTENTS) | \ 559a4e3bad7SJung-uk Kim (((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) | \ 560a4e3bad7SJung-uk Kim (((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) | \ 561a4e3bad7SJung-uk Kim (((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) | \ 562a4e3bad7SJung-uk Kim ((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) | \ 563a4e3bad7SJung-uk Kim ((info)->useable << LINUX_ENTRY_B_USEABLE) | \ 564a4e3bad7SJung-uk Kim ((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000) 5659b44bfc5SAlexander Leidinger 566a4e3bad7SJung-uk Kim #define LINUX_LDT_empty(info) \ 567a4e3bad7SJung-uk Kim ((info)->base_addr == 0 && \ 5689b44bfc5SAlexander Leidinger (info)->limit == 0 && \ 5699b44bfc5SAlexander Leidinger (info)->contents == 0 && \ 5709b44bfc5SAlexander Leidinger (info)->seg_not_present == 1 && \ 5719b44bfc5SAlexander Leidinger (info)->read_exec_only == 1 && \ 5729b44bfc5SAlexander Leidinger (info)->seg_32bit == 0 && \ 5739b44bfc5SAlexander Leidinger (info)->limit_in_pages == 0 && \ 5749b44bfc5SAlexander Leidinger (info)->useable == 0) 5759b44bfc5SAlexander Leidinger 576a4e3bad7SJung-uk Kim /* 577a4e3bad7SJung-uk Kim * Macros for converting segments. 578a4e3bad7SJung-uk Kim * They do the same as those in arch/i386/kernel/process.c in Linux. 579a4e3bad7SJung-uk Kim */ 580a4e3bad7SJung-uk Kim #define LINUX_GET_BASE(desc) \ 581a4e3bad7SJung-uk Kim ((((desc)->a >> 16) & LINUX_LOWERWORD) | \ 5829b44bfc5SAlexander Leidinger (((desc)->b << 16) & 0x00ff0000) | \ 5839b44bfc5SAlexander Leidinger ((desc)->b & 0xff000000)) 5849b44bfc5SAlexander Leidinger 585a4e3bad7SJung-uk Kim #define LINUX_GET_LIMIT(desc) \ 586a4e3bad7SJung-uk Kim (((desc)->a & LINUX_LOWERWORD) | \ 5879b44bfc5SAlexander Leidinger ((desc)->b & 0xf0000)) 5889b44bfc5SAlexander Leidinger 589a4e3bad7SJung-uk Kim #define LINUX_GET_32BIT(desc) \ 590a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1) 591a4e3bad7SJung-uk Kim #define LINUX_GET_CONTENTS(desc) \ 592a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3) 593a4e3bad7SJung-uk Kim #define LINUX_GET_WRITABLE(desc) \ 594a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1) 595a4e3bad7SJung-uk Kim #define LINUX_GET_LIMIT_PAGES(desc) \ 596a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1) 597a4e3bad7SJung-uk Kim #define LINUX_GET_PRESENT(desc) \ 598a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1) 599a4e3bad7SJung-uk Kim #define LINUX_GET_USEABLE(desc) \ 600a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1) 6019b44bfc5SAlexander Leidinger 602001398c4SDmitry Chagin #define linux_copyout_rusage(r, u) copyout(r, u, sizeof(*r)) 603001398c4SDmitry Chagin 604175c6c31SKonstantin Belousov /* robust futexes */ 605175c6c31SKonstantin Belousov struct linux_robust_list { 606175c6c31SKonstantin Belousov struct linux_robust_list *next; 607175c6c31SKonstantin Belousov }; 608175c6c31SKonstantin Belousov 609175c6c31SKonstantin Belousov struct linux_robust_list_head { 610175c6c31SKonstantin Belousov struct linux_robust_list list; 61162162dfcSKonstantin Belousov l_long futex_offset; 612175c6c31SKonstantin Belousov struct linux_robust_list *pending_list; 613175c6c31SKonstantin Belousov }; 614175c6c31SKonstantin Belousov 615a4e3bad7SJung-uk Kim #endif /* !_I386_LINUX_H_ */ 616