1c21dee17SSøren Schmidt /*- 29a14aa01SUlrich Spörlein * Copyright (c) 1994-1996 Søren Schmidt 3c21dee17SSøren Schmidt * All rights reserved. 4c21dee17SSøren Schmidt * 5c21dee17SSøren Schmidt * Redistribution and use in source and binary forms, with or without 6c21dee17SSøren Schmidt * modification, are permitted provided that the following conditions 7c21dee17SSøren Schmidt * are met: 8c21dee17SSøren Schmidt * 1. Redistributions of source code must retain the above copyright 9c21dee17SSøren Schmidt * notice, this list of conditions and the following disclaimer 10c21dee17SSøren Schmidt * in this position and unchanged. 11c21dee17SSøren Schmidt * 2. Redistributions in binary form must reproduce the above copyright 12c21dee17SSøren Schmidt * notice, this list of conditions and the following disclaimer in the 13c21dee17SSøren Schmidt * documentation and/or other materials provided with the distribution. 14c21dee17SSøren Schmidt * 3. The name of the author may not be used to endorse or promote products 156c5e9bbdSMike Pritchard * derived from this software without specific prior written permission 16c21dee17SSøren Schmidt * 17c21dee17SSøren Schmidt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18c21dee17SSøren Schmidt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19c21dee17SSøren Schmidt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20c21dee17SSøren Schmidt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21c21dee17SSøren Schmidt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22c21dee17SSøren Schmidt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23c21dee17SSøren Schmidt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24c21dee17SSøren Schmidt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25c21dee17SSøren Schmidt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26c21dee17SSøren Schmidt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27c21dee17SSøren Schmidt * 28c3aac50fSPeter Wemm * $FreeBSD$ 29c21dee17SSøren Schmidt */ 30c21dee17SSøren Schmidt 31a4e3bad7SJung-uk Kim #ifndef _I386_LINUX_H_ 32a4e3bad7SJung-uk Kim #define _I386_LINUX_H_ 3362c3734cSBruce Evans 3479363394SAndrew Gallatin #include <sys/signal.h> /* for sigval union */ 3579363394SAndrew Gallatin 36*4ab7403bSDmitry Chagin #include <compat/linux/linux.h> 37ebea8660SMarcel Moolenaar #include <i386/linux/linux_syscall.h> 38c21dee17SSøren Schmidt 3924593369SJonathan Lemon /* 4024593369SJonathan Lemon * debugging support 4124593369SJonathan Lemon */ 4224593369SJonathan Lemon extern u_char linux_debug_map[]; 4324593369SJonathan Lemon #define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name) 441d80c8a8SDmitry Chagin #define ARGS(nm, fmt) "linux(%ld/%ld): "#nm"("fmt")\n", \ 451d80c8a8SDmitry Chagin (long)td->td_proc->p_pid, (long)td->td_tid 461d80c8a8SDmitry Chagin #define LMSG(fmt) "linux(%ld/%ld): "fmt"\n", \ 471d80c8a8SDmitry Chagin (long)td->td_proc->p_pid, (long)td->td_tid 4819e252baSAlexander Leidinger #define LINUX_DTRACE linuxulator 4924593369SJonathan Lemon 508f1e49a6SDmitry Chagin #define LINUX_SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) 518f1e49a6SDmitry Chagin #define LINUX_USRSTACK LINUX_SHAREDPAGE 528f1e49a6SDmitry Chagin 530e73a962STim J. Robbins #define PTRIN(v) (void *)(v) 540e73a962STim J. Robbins #define PTROUT(v) (l_uintptr_t)(v) 550e73a962STim J. Robbins 560a041f3bSBjoern A. Zeeb #define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0) 570a041f3bSBjoern A. Zeeb #define CP2(src,dst,sfld,dfld) do { (dst).dfld = (src).sfld; } while (0) 580a041f3bSBjoern A. Zeeb #define PTRIN_CP(src,dst,fld) \ 590a041f3bSBjoern A. Zeeb do { (dst).fld = PTRIN((src).fld); } while (0) 600a041f3bSBjoern A. Zeeb 6143bef515SMarcel Moolenaar /* 621b20ff34SEric Melville * Provide a separate set of types for the Linux types. 635002a60fSMarcel Moolenaar */ 645002a60fSMarcel Moolenaar typedef int l_int; 655002a60fSMarcel Moolenaar typedef int32_t l_long; 665002a60fSMarcel Moolenaar typedef int64_t l_longlong; 675002a60fSMarcel Moolenaar typedef short l_short; 685002a60fSMarcel Moolenaar typedef unsigned int l_uint; 695002a60fSMarcel Moolenaar typedef uint32_t l_ulong; 705002a60fSMarcel Moolenaar typedef uint64_t l_ulonglong; 715002a60fSMarcel Moolenaar typedef unsigned short l_ushort; 725002a60fSMarcel Moolenaar 735002a60fSMarcel Moolenaar typedef char *l_caddr_t; 740e73a962STim J. Robbins typedef l_ulong l_uintptr_t; 755002a60fSMarcel Moolenaar typedef l_long l_clock_t; 765002a60fSMarcel Moolenaar typedef l_int l_daddr_t; 775002a60fSMarcel Moolenaar typedef l_ushort l_dev_t; 785002a60fSMarcel Moolenaar typedef l_uint l_gid_t; 795002a60fSMarcel Moolenaar typedef l_ushort l_gid16_t; 805002a60fSMarcel Moolenaar typedef l_ulong l_ino_t; 815002a60fSMarcel Moolenaar typedef l_int l_key_t; 825002a60fSMarcel Moolenaar typedef l_longlong l_loff_t; 835002a60fSMarcel Moolenaar typedef l_ushort l_mode_t; 845002a60fSMarcel Moolenaar typedef l_long l_off_t; 855002a60fSMarcel Moolenaar typedef l_int l_pid_t; 865002a60fSMarcel Moolenaar typedef l_uint l_size_t; 875002a60fSMarcel Moolenaar typedef l_long l_suseconds_t; 885002a60fSMarcel Moolenaar typedef l_long l_time_t; 895002a60fSMarcel Moolenaar typedef l_uint l_uid_t; 905002a60fSMarcel Moolenaar typedef l_ushort l_uid16_t; 91aa8b2011SKonstantin Belousov typedef l_int l_timer_t; 92aa8b2011SKonstantin Belousov typedef l_int l_mqd_t; 933e89b641SDmitry Chagin typedef l_ulong l_fd_mask; 945002a60fSMarcel Moolenaar 955002a60fSMarcel Moolenaar typedef struct { 965002a60fSMarcel Moolenaar l_int val[2]; 975002a60fSMarcel Moolenaar } l_fsid_t; 985002a60fSMarcel Moolenaar 995002a60fSMarcel Moolenaar typedef struct { 1005002a60fSMarcel Moolenaar l_time_t tv_sec; 1015002a60fSMarcel Moolenaar l_suseconds_t tv_usec; 1025002a60fSMarcel Moolenaar } l_timeval; 1035002a60fSMarcel Moolenaar 1045002a60fSMarcel Moolenaar #define l_fd_set fd_set 1055002a60fSMarcel Moolenaar 1065002a60fSMarcel Moolenaar /* 10743bef515SMarcel Moolenaar * Miscellaneous 10843bef515SMarcel Moolenaar */ 1094048f59cSDmitry Chagin #define LINUX_AT_COUNT 20 /* Count of used aux entry types. 1104d7c2e8aSDmitry Chagin * Keep this synchronized with 1114d7c2e8aSDmitry Chagin * elf_linux_fixup() code. 1124d7c2e8aSDmitry Chagin */ 1135002a60fSMarcel Moolenaar struct l___sysctl_args 1145002a60fSMarcel Moolenaar { 1155002a60fSMarcel Moolenaar l_int *name; 1165002a60fSMarcel Moolenaar l_int nlen; 1175002a60fSMarcel Moolenaar void *oldval; 1185002a60fSMarcel Moolenaar l_size_t *oldlenp; 1195002a60fSMarcel Moolenaar void *newval; 1205002a60fSMarcel Moolenaar l_size_t newlen; 1215002a60fSMarcel Moolenaar l_ulong __spare[4]; 1225002a60fSMarcel Moolenaar }; 1235002a60fSMarcel Moolenaar 12443bef515SMarcel Moolenaar /* Resource limits */ 12543bef515SMarcel Moolenaar #define LINUX_RLIMIT_CPU 0 12643bef515SMarcel Moolenaar #define LINUX_RLIMIT_FSIZE 1 12743bef515SMarcel Moolenaar #define LINUX_RLIMIT_DATA 2 12843bef515SMarcel Moolenaar #define LINUX_RLIMIT_STACK 3 12943bef515SMarcel Moolenaar #define LINUX_RLIMIT_CORE 4 13043bef515SMarcel Moolenaar #define LINUX_RLIMIT_RSS 5 13143bef515SMarcel Moolenaar #define LINUX_RLIMIT_NPROC 6 13243bef515SMarcel Moolenaar #define LINUX_RLIMIT_NOFILE 7 13343bef515SMarcel Moolenaar #define LINUX_RLIMIT_MEMLOCK 8 134a4e3bad7SJung-uk Kim #define LINUX_RLIMIT_AS 9 /* Address space limit */ 13543bef515SMarcel Moolenaar 13643bef515SMarcel Moolenaar #define LINUX_RLIM_NLIMITS 10 13743bef515SMarcel Moolenaar 1385002a60fSMarcel Moolenaar struct l_rlimit { 1395002a60fSMarcel Moolenaar l_ulong rlim_cur; 1405002a60fSMarcel Moolenaar l_ulong rlim_max; 1415002a60fSMarcel Moolenaar }; 1425002a60fSMarcel Moolenaar 14343bef515SMarcel Moolenaar /* mmap options */ 14443bef515SMarcel Moolenaar #define LINUX_MAP_SHARED 0x0001 14543bef515SMarcel Moolenaar #define LINUX_MAP_PRIVATE 0x0002 14643bef515SMarcel Moolenaar #define LINUX_MAP_FIXED 0x0010 14743bef515SMarcel Moolenaar #define LINUX_MAP_ANON 0x0020 14843bef515SMarcel Moolenaar #define LINUX_MAP_GROWSDOWN 0x0100 14943bef515SMarcel Moolenaar 15010931a46SJung-uk Kim struct l_mmap_argv { 15110931a46SJung-uk Kim l_uintptr_t addr; 15210931a46SJung-uk Kim l_size_t len; 15310931a46SJung-uk Kim l_int prot; 15410931a46SJung-uk Kim l_int flags; 15510931a46SJung-uk Kim l_int fd; 15610931a46SJung-uk Kim l_off_t pgoff; 15710931a46SJung-uk Kim } __packed; 15810931a46SJung-uk Kim 1595002a60fSMarcel Moolenaar /* 1605002a60fSMarcel Moolenaar * stat family of syscalls 1615002a60fSMarcel Moolenaar */ 1625002a60fSMarcel Moolenaar struct l_timespec { 16377424f41SJung-uk Kim l_time_t tv_sec; 16477424f41SJung-uk Kim l_long tv_nsec; 1655002a60fSMarcel Moolenaar }; 16643bef515SMarcel Moolenaar 1675002a60fSMarcel Moolenaar struct l_newstat { 1685002a60fSMarcel Moolenaar l_ushort st_dev; 1695002a60fSMarcel Moolenaar l_ushort __pad1; 1705002a60fSMarcel Moolenaar l_ulong st_ino; 1715002a60fSMarcel Moolenaar l_ushort st_mode; 1725002a60fSMarcel Moolenaar l_ushort st_nlink; 1735002a60fSMarcel Moolenaar l_ushort st_uid; 1745002a60fSMarcel Moolenaar l_ushort st_gid; 1755002a60fSMarcel Moolenaar l_ushort st_rdev; 1765002a60fSMarcel Moolenaar l_ushort __pad2; 1775002a60fSMarcel Moolenaar l_ulong st_size; 1785002a60fSMarcel Moolenaar l_ulong st_blksize; 1795002a60fSMarcel Moolenaar l_ulong st_blocks; 180510ea843SEd Schouten struct l_timespec st_atim; 181510ea843SEd Schouten struct l_timespec st_mtim; 182510ea843SEd Schouten struct l_timespec st_ctim; 1835002a60fSMarcel Moolenaar l_ulong __unused4; 1845002a60fSMarcel Moolenaar l_ulong __unused5; 1855002a60fSMarcel Moolenaar }; 18643bef515SMarcel Moolenaar 1871f7642e0SAlexander Leidinger struct l_stat { 1881f7642e0SAlexander Leidinger l_ushort st_dev; 1891f7642e0SAlexander Leidinger l_ulong st_ino; 1901f7642e0SAlexander Leidinger l_ushort st_mode; 1911f7642e0SAlexander Leidinger l_ushort st_nlink; 1921f7642e0SAlexander Leidinger l_ushort st_uid; 1931f7642e0SAlexander Leidinger l_ushort st_gid; 1941f7642e0SAlexander Leidinger l_ushort st_rdev; 1951f7642e0SAlexander Leidinger l_long st_size; 196510ea843SEd Schouten struct l_timespec st_atim; 197510ea843SEd Schouten struct l_timespec st_mtim; 198510ea843SEd Schouten struct l_timespec st_ctim; 1991f7642e0SAlexander Leidinger l_long st_blksize; 2001f7642e0SAlexander Leidinger l_long st_blocks; 2011f7642e0SAlexander Leidinger l_ulong st_flags; 2021f7642e0SAlexander Leidinger l_ulong st_gen; 2031f7642e0SAlexander Leidinger }; 2041f7642e0SAlexander Leidinger 2055002a60fSMarcel Moolenaar struct l_stat64 { 2065002a60fSMarcel Moolenaar l_ushort st_dev; 2075002a60fSMarcel Moolenaar u_char __pad0[10]; 2085002a60fSMarcel Moolenaar l_ulong __st_ino; 2095002a60fSMarcel Moolenaar l_uint st_mode; 2105002a60fSMarcel Moolenaar l_uint st_nlink; 2115002a60fSMarcel Moolenaar l_ulong st_uid; 2125002a60fSMarcel Moolenaar l_ulong st_gid; 2135002a60fSMarcel Moolenaar l_ushort st_rdev; 2145002a60fSMarcel Moolenaar u_char __pad3[10]; 2155002a60fSMarcel Moolenaar l_longlong st_size; 2165002a60fSMarcel Moolenaar l_ulong st_blksize; 2175002a60fSMarcel Moolenaar l_ulong st_blocks; 2185002a60fSMarcel Moolenaar l_ulong __pad4; 219510ea843SEd Schouten struct l_timespec st_atim; 220510ea843SEd Schouten struct l_timespec st_mtim; 221510ea843SEd Schouten struct l_timespec st_ctim; 2225002a60fSMarcel Moolenaar l_ulonglong st_ino; 2235002a60fSMarcel Moolenaar }; 2245002a60fSMarcel Moolenaar 2253ab85269SDavid Malone struct l_statfs64 { 2263ab85269SDavid Malone l_int f_type; 2273ab85269SDavid Malone l_int f_bsize; 2283ab85269SDavid Malone uint64_t f_blocks; 2293ab85269SDavid Malone uint64_t f_bfree; 2303ab85269SDavid Malone uint64_t f_bavail; 2313ab85269SDavid Malone uint64_t f_files; 2323ab85269SDavid Malone uint64_t f_ffree; 2333ab85269SDavid Malone l_fsid_t f_fsid; 2343ab85269SDavid Malone l_int f_namelen; 2353ab85269SDavid Malone l_int f_spare[6]; 2363ab85269SDavid Malone }; 2373ab85269SDavid Malone 2382c4ab9ddSAndrew Gallatin #define LINUX_NSIG_WORDS 2 23943bef515SMarcel Moolenaar 24043bef515SMarcel Moolenaar /* sigaction flags */ 24143bef515SMarcel Moolenaar #define LINUX_SA_NOCLDSTOP 0x00000001 24243bef515SMarcel Moolenaar #define LINUX_SA_NOCLDWAIT 0x00000002 24343bef515SMarcel Moolenaar #define LINUX_SA_SIGINFO 0x00000004 24443bef515SMarcel Moolenaar #define LINUX_SA_RESTORER 0x04000000 24543bef515SMarcel Moolenaar #define LINUX_SA_ONSTACK 0x08000000 24643bef515SMarcel Moolenaar #define LINUX_SA_RESTART 0x10000000 24743bef515SMarcel Moolenaar #define LINUX_SA_INTERRUPT 0x20000000 24843bef515SMarcel Moolenaar #define LINUX_SA_NOMASK 0x40000000 24943bef515SMarcel Moolenaar #define LINUX_SA_ONESHOT 0x80000000 25043bef515SMarcel Moolenaar 25143bef515SMarcel Moolenaar /* sigprocmask actions */ 25243bef515SMarcel Moolenaar #define LINUX_SIG_BLOCK 0 25343bef515SMarcel Moolenaar #define LINUX_SIG_UNBLOCK 1 25443bef515SMarcel Moolenaar #define LINUX_SIG_SETMASK 2 25543bef515SMarcel Moolenaar 256dee4ec33SMarcel Moolenaar /* sigaltstack */ 257dee4ec33SMarcel Moolenaar #define LINUX_MINSIGSTKSZ 2048 258931a7258SAndrew Gallatin 2595002a60fSMarcel Moolenaar typedef void (*l_handler_t)(l_int); 2605002a60fSMarcel Moolenaar typedef l_ulong l_osigset_t; 261956d3333SMarcel Moolenaar 26206ebbe77SMarcel Moolenaar typedef struct { 2635002a60fSMarcel Moolenaar l_handler_t lsa_handler; 2645002a60fSMarcel Moolenaar l_osigset_t lsa_mask; 2655002a60fSMarcel Moolenaar l_ulong lsa_flags; 266956d3333SMarcel Moolenaar void (*lsa_restorer)(void); 2675002a60fSMarcel Moolenaar } l_osigaction_t; 268956d3333SMarcel Moolenaar 26906ebbe77SMarcel Moolenaar typedef struct { 2705002a60fSMarcel Moolenaar l_handler_t lsa_handler; 2715002a60fSMarcel Moolenaar l_ulong lsa_flags; 27206ebbe77SMarcel Moolenaar void (*lsa_restorer)(void); 2735002a60fSMarcel Moolenaar l_sigset_t lsa_mask; 2745002a60fSMarcel Moolenaar } l_sigaction_t; 27506ebbe77SMarcel Moolenaar 27643bef515SMarcel Moolenaar typedef struct { 277ec99e322SMarcel Moolenaar void *ss_sp; 2785002a60fSMarcel Moolenaar l_int ss_flags; 2795002a60fSMarcel Moolenaar l_size_t ss_size; 2805002a60fSMarcel Moolenaar } l_stack_t; 281ec99e322SMarcel Moolenaar 28243bef515SMarcel Moolenaar /* The Linux sigcontext, pretty much a standard 386 trapframe. */ 2835002a60fSMarcel Moolenaar struct l_sigcontext { 2845002a60fSMarcel Moolenaar l_int sc_gs; 2855002a60fSMarcel Moolenaar l_int sc_fs; 2865002a60fSMarcel Moolenaar l_int sc_es; 2875002a60fSMarcel Moolenaar l_int sc_ds; 2885002a60fSMarcel Moolenaar l_int sc_edi; 2895002a60fSMarcel Moolenaar l_int sc_esi; 2905002a60fSMarcel Moolenaar l_int sc_ebp; 2915002a60fSMarcel Moolenaar l_int sc_esp; 2925002a60fSMarcel Moolenaar l_int sc_ebx; 2935002a60fSMarcel Moolenaar l_int sc_edx; 2945002a60fSMarcel Moolenaar l_int sc_ecx; 2955002a60fSMarcel Moolenaar l_int sc_eax; 2965002a60fSMarcel Moolenaar l_int sc_trapno; 2975002a60fSMarcel Moolenaar l_int sc_err; 2985002a60fSMarcel Moolenaar l_int sc_eip; 2995002a60fSMarcel Moolenaar l_int sc_cs; 3005002a60fSMarcel Moolenaar l_int sc_eflags; 3015002a60fSMarcel Moolenaar l_int sc_esp_at_signal; 3025002a60fSMarcel Moolenaar l_int sc_ss; 3035002a60fSMarcel Moolenaar l_int sc_387; 3045002a60fSMarcel Moolenaar l_int sc_mask; 3055002a60fSMarcel Moolenaar l_int sc_cr2; 306d66a5066SPeter Wemm }; 307d66a5066SPeter Wemm 3085002a60fSMarcel Moolenaar struct l_ucontext { 3095002a60fSMarcel Moolenaar l_ulong uc_flags; 31079363394SAndrew Gallatin void *uc_link; 3115002a60fSMarcel Moolenaar l_stack_t uc_stack; 3125002a60fSMarcel Moolenaar struct l_sigcontext uc_mcontext; 3135002a60fSMarcel Moolenaar l_sigset_t uc_sigmask; 31479363394SAndrew Gallatin }; 31579363394SAndrew Gallatin 31679363394SAndrew Gallatin #define LINUX_SI_MAX_SIZE 128 3175002a60fSMarcel Moolenaar #define LINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3) 31879363394SAndrew Gallatin 319aa8b2011SKonstantin Belousov typedef union l_sigval { 320aa8b2011SKonstantin Belousov l_int sival_int; 321aa8b2011SKonstantin Belousov l_uintptr_t sival_ptr; 322aa8b2011SKonstantin Belousov } l_sigval_t; 323aa8b2011SKonstantin Belousov 3245002a60fSMarcel Moolenaar typedef struct l_siginfo { 3255002a60fSMarcel Moolenaar l_int lsi_signo; 3265002a60fSMarcel Moolenaar l_int lsi_errno; 3275002a60fSMarcel Moolenaar l_int lsi_code; 32879363394SAndrew Gallatin union { 3295002a60fSMarcel Moolenaar l_int _pad[LINUX_SI_PAD_SIZE]; 3305002a60fSMarcel Moolenaar 33179363394SAndrew Gallatin struct { 3325002a60fSMarcel Moolenaar l_pid_t _pid; 333aa8b2011SKonstantin Belousov l_uid_t _uid; 33479363394SAndrew Gallatin } _kill; 33579363394SAndrew Gallatin 33679363394SAndrew Gallatin struct { 337aa8b2011SKonstantin Belousov l_timer_t _tid; 338aa8b2011SKonstantin Belousov l_int _overrun; 339aa8b2011SKonstantin Belousov char _pad[sizeof(l_uid_t) - sizeof(l_int)]; 340aa8b2011SKonstantin Belousov l_sigval_t _sigval; 341aa8b2011SKonstantin Belousov l_int _sys_private; 34279363394SAndrew Gallatin } _timer; 34379363394SAndrew Gallatin 34479363394SAndrew Gallatin struct { 3455002a60fSMarcel Moolenaar l_pid_t _pid; /* sender's pid */ 346aa8b2011SKonstantin Belousov l_uid_t _uid; /* sender's uid */ 347aa8b2011SKonstantin Belousov l_sigval_t _sigval; 34879363394SAndrew Gallatin } _rt; 34979363394SAndrew Gallatin 35079363394SAndrew Gallatin struct { 3515002a60fSMarcel Moolenaar l_pid_t _pid; /* which child */ 352aa8b2011SKonstantin Belousov l_uid_t _uid; /* sender's uid */ 3535002a60fSMarcel Moolenaar l_int _status; /* exit code */ 3545002a60fSMarcel Moolenaar l_clock_t _utime; 3555002a60fSMarcel Moolenaar l_clock_t _stime; 35679363394SAndrew Gallatin } _sigchld; 35779363394SAndrew Gallatin 35879363394SAndrew Gallatin struct { 359aa8b2011SKonstantin Belousov l_uintptr_t _addr; /* Faulting insn/memory ref. */ 36079363394SAndrew Gallatin } _sigfault; 36179363394SAndrew Gallatin 36279363394SAndrew Gallatin struct { 363aa8b2011SKonstantin Belousov l_long _band; /* POLL_IN,POLL_OUT,POLL_MSG */ 3645002a60fSMarcel Moolenaar l_int _fd; 36579363394SAndrew Gallatin } _sigpoll; 36679363394SAndrew Gallatin } _sifields; 3675002a60fSMarcel Moolenaar } l_siginfo_t; 36879363394SAndrew Gallatin 36979363394SAndrew Gallatin #define lsi_pid _sifields._kill._pid 37079363394SAndrew Gallatin #define lsi_uid _sifields._kill._uid 371aa8b2011SKonstantin Belousov #define lsi_tid _sifields._timer._tid 372aa8b2011SKonstantin Belousov #define lsi_overrun _sifields._timer._overrun 373aa8b2011SKonstantin Belousov #define lsi_sys_private _sifields._timer._sys_private 37479363394SAndrew Gallatin #define lsi_status _sifields._sigchld._status 37579363394SAndrew Gallatin #define lsi_utime _sifields._sigchld._utime 37679363394SAndrew Gallatin #define lsi_stime _sifields._sigchld._stime 37779363394SAndrew Gallatin #define lsi_value _sifields._rt._sigval 37879363394SAndrew Gallatin #define lsi_int _sifields._rt._sigval.sival_int 37979363394SAndrew Gallatin #define lsi_ptr _sifields._rt._sigval.sival_ptr 38079363394SAndrew Gallatin #define lsi_addr _sifields._sigfault._addr 38179363394SAndrew Gallatin #define lsi_band _sifields._sigpoll._band 38279363394SAndrew Gallatin #define lsi_fd _sifields._sigpoll._fd 38379363394SAndrew Gallatin 3845002a60fSMarcel Moolenaar struct l_fpreg { 3852c4ab9ddSAndrew Gallatin u_int16_t significand[4]; 3862c4ab9ddSAndrew Gallatin u_int16_t exponent; 3872c4ab9ddSAndrew Gallatin }; 3882c4ab9ddSAndrew Gallatin 3895002a60fSMarcel Moolenaar struct l_fpxreg { 3902c4ab9ddSAndrew Gallatin u_int16_t significand[4]; 3912c4ab9ddSAndrew Gallatin u_int16_t exponent; 3922c4ab9ddSAndrew Gallatin u_int16_t padding[3]; 3932c4ab9ddSAndrew Gallatin }; 3942c4ab9ddSAndrew Gallatin 3955002a60fSMarcel Moolenaar struct l_xmmreg { 3962c4ab9ddSAndrew Gallatin u_int32_t element[4]; 3972c4ab9ddSAndrew Gallatin }; 3982c4ab9ddSAndrew Gallatin 3995002a60fSMarcel Moolenaar struct l_fpstate { 4002c4ab9ddSAndrew Gallatin /* Regular FPU environment */ 4012c4ab9ddSAndrew Gallatin u_int32_t cw; 4022c4ab9ddSAndrew Gallatin u_int32_t sw; 4032c4ab9ddSAndrew Gallatin u_int32_t tag; 4042c4ab9ddSAndrew Gallatin u_int32_t ipoff; 4052c4ab9ddSAndrew Gallatin u_int32_t cssel; 4062c4ab9ddSAndrew Gallatin u_int32_t dataoff; 4072c4ab9ddSAndrew Gallatin u_int32_t datasel; 4085002a60fSMarcel Moolenaar struct l_fpreg _st[8]; 4092c4ab9ddSAndrew Gallatin u_int16_t status; 4102c4ab9ddSAndrew Gallatin u_int16_t magic; /* 0xffff = regular FPU data */ 4112c4ab9ddSAndrew Gallatin 4122c4ab9ddSAndrew Gallatin /* FXSR FPU environment */ 413a4e3bad7SJung-uk Kim u_int32_t _fxsr_env[6]; /* env is ignored. */ 4142c4ab9ddSAndrew Gallatin u_int32_t mxcsr; 4152c4ab9ddSAndrew Gallatin u_int32_t reserved; 416a4e3bad7SJung-uk Kim struct l_fpxreg _fxsr_st[8]; /* reg data is ignored. */ 4175002a60fSMarcel Moolenaar struct l_xmmreg _xmm[8]; 4182c4ab9ddSAndrew Gallatin u_int32_t padding[56]; 4192c4ab9ddSAndrew Gallatin }; 42079363394SAndrew Gallatin 421d66a5066SPeter Wemm /* 422d66a5066SPeter Wemm * We make the stack look like Linux expects it when calling a signal 423d66a5066SPeter Wemm * handler, but use the BSD way of calling the handler and sigreturn(). 424d66a5066SPeter Wemm * This means that we need to pass the pointer to the handler too. 425d66a5066SPeter Wemm * It is appended to the frame to not interfere with the rest of it. 426d66a5066SPeter Wemm */ 4275002a60fSMarcel Moolenaar struct l_sigframe { 4285002a60fSMarcel Moolenaar l_int sf_sig; 4295002a60fSMarcel Moolenaar struct l_sigcontext sf_sc; 4305002a60fSMarcel Moolenaar struct l_fpstate sf_fpstate; 4315002a60fSMarcel Moolenaar l_uint sf_extramask[LINUX_NSIG_WORDS-1]; 4325002a60fSMarcel Moolenaar l_handler_t sf_handler; 433d66a5066SPeter Wemm }; 434d66a5066SPeter Wemm 4355002a60fSMarcel Moolenaar struct l_rt_sigframe { 4365002a60fSMarcel Moolenaar l_int sf_sig; 4375002a60fSMarcel Moolenaar l_siginfo_t *sf_siginfo; 4385002a60fSMarcel Moolenaar struct l_ucontext *sf_ucontext; 4395002a60fSMarcel Moolenaar l_siginfo_t sf_si; 4405002a60fSMarcel Moolenaar struct l_ucontext sf_sc; 4415002a60fSMarcel Moolenaar l_handler_t sf_handler; 44279363394SAndrew Gallatin }; 44379363394SAndrew Gallatin 444d323ddf3SMatthew Dillon extern struct sysentvec linux_sysvec; 445c21dee17SSøren Schmidt 44643bef515SMarcel Moolenaar /* 4474d0f380dSDmitry Chagin * arch specific open/fcntl flags 44843bef515SMarcel Moolenaar */ 449aaaefc6bSRobert Drehmel #define LINUX_F_GETLK64 12 450aaaefc6bSRobert Drehmel #define LINUX_F_SETLK64 13 451aaaefc6bSRobert Drehmel #define LINUX_F_SETLKW64 14 452aaaefc6bSRobert Drehmel 4535002a60fSMarcel Moolenaar union l_semun { 4545002a60fSMarcel Moolenaar l_int val; 4555002a60fSMarcel Moolenaar struct l_semid_ds *buf; 4565002a60fSMarcel Moolenaar l_ushort *array; 4575002a60fSMarcel Moolenaar struct l_seminfo *__buf; 4585002a60fSMarcel Moolenaar void *__pad; 4595002a60fSMarcel Moolenaar }; 4605002a60fSMarcel Moolenaar 46131eb4388SDmitry Chagin struct l_ipc_perm { 46231eb4388SDmitry Chagin l_key_t key; 46331eb4388SDmitry Chagin l_uid16_t uid; 46431eb4388SDmitry Chagin l_gid16_t gid; 46531eb4388SDmitry Chagin l_uid16_t cuid; 46631eb4388SDmitry Chagin l_gid16_t cgid; 46731eb4388SDmitry Chagin l_ushort mode; 46831eb4388SDmitry Chagin l_ushort seq; 46931eb4388SDmitry Chagin }; 47031eb4388SDmitry Chagin 47143bef515SMarcel Moolenaar /* 47243bef515SMarcel Moolenaar * Socket defines 47343bef515SMarcel Moolenaar */ 474c21dee17SSøren Schmidt #define LINUX_SOL_SOCKET 1 475c21dee17SSøren Schmidt #define LINUX_SOL_IP 0 476c21dee17SSøren Schmidt #define LINUX_SOL_IPX 256 477c21dee17SSøren Schmidt #define LINUX_SOL_AX25 257 478c21dee17SSøren Schmidt #define LINUX_SOL_TCP 6 479c21dee17SSøren Schmidt #define LINUX_SOL_UDP 17 480c21dee17SSøren Schmidt 481c21dee17SSøren Schmidt #define LINUX_SO_DEBUG 1 482c21dee17SSøren Schmidt #define LINUX_SO_REUSEADDR 2 483c21dee17SSøren Schmidt #define LINUX_SO_TYPE 3 484c21dee17SSøren Schmidt #define LINUX_SO_ERROR 4 485c21dee17SSøren Schmidt #define LINUX_SO_DONTROUTE 5 486c21dee17SSøren Schmidt #define LINUX_SO_BROADCAST 6 487c21dee17SSøren Schmidt #define LINUX_SO_SNDBUF 7 488c21dee17SSøren Schmidt #define LINUX_SO_RCVBUF 8 489c21dee17SSøren Schmidt #define LINUX_SO_KEEPALIVE 9 490c21dee17SSøren Schmidt #define LINUX_SO_OOBINLINE 10 491c21dee17SSøren Schmidt #define LINUX_SO_NO_CHECK 11 492c21dee17SSøren Schmidt #define LINUX_SO_PRIORITY 12 493c21dee17SSøren Schmidt #define LINUX_SO_LINGER 13 494d0b2365eSKonstantin Belousov #define LINUX_SO_PEERCRED 17 495d0b2365eSKonstantin Belousov #define LINUX_SO_RCVLOWAT 18 496d0b2365eSKonstantin Belousov #define LINUX_SO_SNDLOWAT 19 497d0b2365eSKonstantin Belousov #define LINUX_SO_RCVTIMEO 20 498d0b2365eSKonstantin Belousov #define LINUX_SO_SNDTIMEO 21 499d0b2365eSKonstantin Belousov #define LINUX_SO_TIMESTAMP 29 500d0b2365eSKonstantin Belousov #define LINUX_SO_ACCEPTCONN 30 501c21dee17SSøren Schmidt 5025002a60fSMarcel Moolenaar struct l_sockaddr { 5035002a60fSMarcel Moolenaar l_ushort sa_family; 5043713cbffSMike Smith char sa_data[14]; 5053713cbffSMike Smith }; 5063713cbffSMike Smith 50774f5d680SKonstantin Belousov struct l_msghdr { 50874f5d680SKonstantin Belousov l_uintptr_t msg_name; 50974f5d680SKonstantin Belousov l_int msg_namelen; 51074f5d680SKonstantin Belousov l_uintptr_t msg_iov; 51174f5d680SKonstantin Belousov l_size_t msg_iovlen; 51274f5d680SKonstantin Belousov l_uintptr_t msg_control; 51374f5d680SKonstantin Belousov l_size_t msg_controllen; 51474f5d680SKonstantin Belousov l_uint msg_flags; 51574f5d680SKonstantin Belousov }; 51674f5d680SKonstantin Belousov 51774f5d680SKonstantin Belousov struct l_cmsghdr { 51874f5d680SKonstantin Belousov l_size_t cmsg_len; 51974f5d680SKonstantin Belousov l_int cmsg_level; 52074f5d680SKonstantin Belousov l_int cmsg_type; 52174f5d680SKonstantin Belousov }; 52274f5d680SKonstantin Belousov 5235002a60fSMarcel Moolenaar struct l_ifmap { 5245002a60fSMarcel Moolenaar l_ulong mem_start; 5255002a60fSMarcel Moolenaar l_ulong mem_end; 5265002a60fSMarcel Moolenaar l_ushort base_addr; 52743bef515SMarcel Moolenaar u_char irq; 52843bef515SMarcel Moolenaar u_char dma; 52943bef515SMarcel Moolenaar u_char port; 5303713cbffSMike Smith }; 5313713cbffSMike Smith 5323713cbffSMike Smith #define LINUX_IFHWADDRLEN 6 5333713cbffSMike Smith #define LINUX_IFNAMSIZ 16 53443bef515SMarcel Moolenaar 5355002a60fSMarcel Moolenaar struct l_ifreq { 53643bef515SMarcel Moolenaar union { 53743bef515SMarcel Moolenaar char ifrn_name[LINUX_IFNAMSIZ]; 5383713cbffSMike Smith } ifr_ifrn; 5393713cbffSMike Smith 5403713cbffSMike Smith union { 5415002a60fSMarcel Moolenaar struct l_sockaddr ifru_addr; 5425002a60fSMarcel Moolenaar struct l_sockaddr ifru_dstaddr; 5435002a60fSMarcel Moolenaar struct l_sockaddr ifru_broadaddr; 5445002a60fSMarcel Moolenaar struct l_sockaddr ifru_netmask; 5455002a60fSMarcel Moolenaar struct l_sockaddr ifru_hwaddr; 546268aeb1eSDag-Erling Smørgrav l_short ifru_flags[1]; 5475002a60fSMarcel Moolenaar l_int ifru_metric; 5485002a60fSMarcel Moolenaar l_int ifru_mtu; 5495002a60fSMarcel Moolenaar struct l_ifmap ifru_map; 5505002a60fSMarcel Moolenaar char ifru_slave[LINUX_IFNAMSIZ]; 5515002a60fSMarcel Moolenaar l_caddr_t ifru_data; 5523713cbffSMike Smith } ifr_ifru; 5533713cbffSMike Smith }; 5543713cbffSMike Smith 555a4e3bad7SJung-uk Kim #define ifr_name ifr_ifrn.ifrn_name /* Interface name */ 5563713cbffSMike Smith #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ 5573713cbffSMike Smith 5585002a60fSMarcel Moolenaar /* 5595002a60fSMarcel Moolenaar * poll() 5605002a60fSMarcel Moolenaar */ 5615002a60fSMarcel Moolenaar #define LINUX_POLLIN 0x0001 5625002a60fSMarcel Moolenaar #define LINUX_POLLPRI 0x0002 5635002a60fSMarcel Moolenaar #define LINUX_POLLOUT 0x0004 5645002a60fSMarcel Moolenaar #define LINUX_POLLERR 0x0008 5655002a60fSMarcel Moolenaar #define LINUX_POLLHUP 0x0010 5665002a60fSMarcel Moolenaar #define LINUX_POLLNVAL 0x0020 5675002a60fSMarcel Moolenaar #define LINUX_POLLRDNORM 0x0040 5685002a60fSMarcel Moolenaar #define LINUX_POLLRDBAND 0x0080 5695002a60fSMarcel Moolenaar #define LINUX_POLLWRNORM 0x0100 5705002a60fSMarcel Moolenaar #define LINUX_POLLWRBAND 0x0200 5715002a60fSMarcel Moolenaar #define LINUX_POLLMSG 0x0400 5725002a60fSMarcel Moolenaar 5735002a60fSMarcel Moolenaar struct l_pollfd { 5745002a60fSMarcel Moolenaar l_int fd; 5755002a60fSMarcel Moolenaar l_short events; 5765002a60fSMarcel Moolenaar l_short revents; 5775002a60fSMarcel Moolenaar }; 5785002a60fSMarcel Moolenaar 5799b44bfc5SAlexander Leidinger struct l_user_desc { 5809b44bfc5SAlexander Leidinger l_uint entry_number; 5819b44bfc5SAlexander Leidinger l_uint base_addr; 5829b44bfc5SAlexander Leidinger l_uint limit; 5839b44bfc5SAlexander Leidinger l_uint seg_32bit:1; 5849b44bfc5SAlexander Leidinger l_uint contents:2; 5859b44bfc5SAlexander Leidinger l_uint read_exec_only:1; 5869b44bfc5SAlexander Leidinger l_uint limit_in_pages:1; 5879b44bfc5SAlexander Leidinger l_uint seg_not_present:1; 5889b44bfc5SAlexander Leidinger l_uint useable:1; 5899b44bfc5SAlexander Leidinger }; 5909b44bfc5SAlexander Leidinger 5919b44bfc5SAlexander Leidinger struct l_desc_struct { 5929b44bfc5SAlexander Leidinger unsigned long a, b; 5939b44bfc5SAlexander Leidinger }; 5949b44bfc5SAlexander Leidinger 5959b44bfc5SAlexander Leidinger 5969b44bfc5SAlexander Leidinger #define LINUX_LOWERWORD 0x0000ffff 5979b44bfc5SAlexander Leidinger 5980eef2f8aSAlexander Leidinger /* 599a4e3bad7SJung-uk Kim * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h. 600a4e3bad7SJung-uk Kim * These convert Linux user space descriptor to machine one. 6019b44bfc5SAlexander Leidinger */ 602a4e3bad7SJung-uk Kim #define LINUX_LDT_entry_a(info) \ 603a4e3bad7SJung-uk Kim ((((info)->base_addr & LINUX_LOWERWORD) << 16) | \ 604a4e3bad7SJung-uk Kim ((info)->limit & LINUX_LOWERWORD)) 6059b44bfc5SAlexander Leidinger 606a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_READ_EXEC_ONLY 9 607a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_CONTENTS 10 608a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_SEG_NOT_PRESENT 15 609a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_BASE_ADDR 16 610a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_USEABLE 20 611a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_SEG32BIT 22 612a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_LIMIT 23 6139b44bfc5SAlexander Leidinger 614a4e3bad7SJung-uk Kim #define LINUX_LDT_entry_b(info) \ 6159b44bfc5SAlexander Leidinger (((info)->base_addr & 0xff000000) | \ 6169b44bfc5SAlexander Leidinger ((info)->limit & 0xf0000) | \ 617a4e3bad7SJung-uk Kim ((info)->contents << LINUX_ENTRY_B_CONTENTS) | \ 618a4e3bad7SJung-uk Kim (((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) | \ 619a4e3bad7SJung-uk Kim (((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) | \ 620a4e3bad7SJung-uk Kim (((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) | \ 621a4e3bad7SJung-uk Kim ((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) | \ 622a4e3bad7SJung-uk Kim ((info)->useable << LINUX_ENTRY_B_USEABLE) | \ 623a4e3bad7SJung-uk Kim ((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000) 6249b44bfc5SAlexander Leidinger 625a4e3bad7SJung-uk Kim #define LINUX_LDT_empty(info) \ 626a4e3bad7SJung-uk Kim ((info)->base_addr == 0 && \ 6279b44bfc5SAlexander Leidinger (info)->limit == 0 && \ 6289b44bfc5SAlexander Leidinger (info)->contents == 0 && \ 6299b44bfc5SAlexander Leidinger (info)->seg_not_present == 1 && \ 6309b44bfc5SAlexander Leidinger (info)->read_exec_only == 1 && \ 6319b44bfc5SAlexander Leidinger (info)->seg_32bit == 0 && \ 6329b44bfc5SAlexander Leidinger (info)->limit_in_pages == 0 && \ 6339b44bfc5SAlexander Leidinger (info)->useable == 0) 6349b44bfc5SAlexander Leidinger 635a4e3bad7SJung-uk Kim /* 636a4e3bad7SJung-uk Kim * Macros for converting segments. 637a4e3bad7SJung-uk Kim * They do the same as those in arch/i386/kernel/process.c in Linux. 638a4e3bad7SJung-uk Kim */ 639a4e3bad7SJung-uk Kim #define LINUX_GET_BASE(desc) \ 640a4e3bad7SJung-uk Kim ((((desc)->a >> 16) & LINUX_LOWERWORD) | \ 6419b44bfc5SAlexander Leidinger (((desc)->b << 16) & 0x00ff0000) | \ 6429b44bfc5SAlexander Leidinger ((desc)->b & 0xff000000)) 6439b44bfc5SAlexander Leidinger 644a4e3bad7SJung-uk Kim #define LINUX_GET_LIMIT(desc) \ 645a4e3bad7SJung-uk Kim (((desc)->a & LINUX_LOWERWORD) | \ 6469b44bfc5SAlexander Leidinger ((desc)->b & 0xf0000)) 6479b44bfc5SAlexander Leidinger 648a4e3bad7SJung-uk Kim #define LINUX_GET_32BIT(desc) \ 649a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1) 650a4e3bad7SJung-uk Kim #define LINUX_GET_CONTENTS(desc) \ 651a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3) 652a4e3bad7SJung-uk Kim #define LINUX_GET_WRITABLE(desc) \ 653a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1) 654a4e3bad7SJung-uk Kim #define LINUX_GET_LIMIT_PAGES(desc) \ 655a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1) 656a4e3bad7SJung-uk Kim #define LINUX_GET_PRESENT(desc) \ 657a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1) 658a4e3bad7SJung-uk Kim #define LINUX_GET_USEABLE(desc) \ 659a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1) 6609b44bfc5SAlexander Leidinger 661001398c4SDmitry Chagin #define linux_copyout_rusage(r, u) copyout(r, u, sizeof(*r)) 662001398c4SDmitry Chagin 663175c6c31SKonstantin Belousov /* robust futexes */ 664175c6c31SKonstantin Belousov struct linux_robust_list { 665175c6c31SKonstantin Belousov struct linux_robust_list *next; 666175c6c31SKonstantin Belousov }; 667175c6c31SKonstantin Belousov 668175c6c31SKonstantin Belousov struct linux_robust_list_head { 669175c6c31SKonstantin Belousov struct linux_robust_list list; 67062162dfcSKonstantin Belousov l_long futex_offset; 671175c6c31SKonstantin Belousov struct linux_robust_list *pending_list; 672175c6c31SKonstantin Belousov }; 673175c6c31SKonstantin Belousov 674a4e3bad7SJung-uk Kim #endif /* !_I386_LINUX_H_ */ 675