1ea0fabbcSTim J. Robbins /*- 2c49761ddSPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 3c49761ddSPedro F. Giffuni * 4ea0fabbcSTim J. Robbins * Copyright (c) 2004 Tim J. Robbins 5ea0fabbcSTim J. Robbins * Copyright (c) 2001 Doug Rabson 69a14aa01SUlrich Spörlein * Copyright (c) 1994-1996 Søren Schmidt 7ea0fabbcSTim J. Robbins * All rights reserved. 8ea0fabbcSTim J. Robbins * 9ea0fabbcSTim J. Robbins * Redistribution and use in source and binary forms, with or without 10ea0fabbcSTim J. Robbins * modification, are permitted provided that the following conditions 11ea0fabbcSTim J. Robbins * are met: 12ea0fabbcSTim J. Robbins * 1. Redistributions of source code must retain the above copyright 13ea0fabbcSTim J. Robbins * notice, this list of conditions and the following disclaimer 14ea0fabbcSTim J. Robbins * in this position and unchanged. 15ea0fabbcSTim J. Robbins * 2. Redistributions in binary form must reproduce the above copyright 16ea0fabbcSTim J. Robbins * notice, this list of conditions and the following disclaimer in the 17ea0fabbcSTim J. Robbins * documentation and/or other materials provided with the distribution. 18ea0fabbcSTim J. Robbins * 3. The name of the author may not be used to endorse or promote products 19ea0fabbcSTim J. Robbins * derived from this software without specific prior written permission 20ea0fabbcSTim J. Robbins * 21ea0fabbcSTim J. Robbins * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22ea0fabbcSTim J. Robbins * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23ea0fabbcSTim J. Robbins * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24ea0fabbcSTim J. Robbins * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25ea0fabbcSTim J. Robbins * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26ea0fabbcSTim J. Robbins * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27ea0fabbcSTim J. Robbins * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28ea0fabbcSTim J. Robbins * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29ea0fabbcSTim J. Robbins * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30ea0fabbcSTim J. Robbins * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31ea0fabbcSTim J. Robbins * 32ea0fabbcSTim J. Robbins * $FreeBSD$ 33ea0fabbcSTim J. Robbins */ 34ea0fabbcSTim J. Robbins 35a4e3bad7SJung-uk Kim #ifndef _AMD64_LINUX_H_ 36a4e3bad7SJung-uk Kim #define _AMD64_LINUX_H_ 37ea0fabbcSTim J. Robbins 38562894f0SBrooks Davis #include <sys/abi_compat.h> 39562894f0SBrooks Davis 404ab7403bSDmitry Chagin #include <compat/linux/linux.h> 41ea0fabbcSTim J. Robbins #include <amd64/linux32/linux32_syscall.h> 42ea0fabbcSTim J. Robbins 43931e2a1aSEd Maste #define LINUX_LEGACY_SYSCALLS 44931e2a1aSEd Maste 4519e252baSAlexander Leidinger #define LINUX_DTRACE linuxulator32 46ea0fabbcSTim J. Robbins 478f1e49a6SDmitry Chagin #define LINUX32_MAXUSER ((1ul << 32) - PAGE_SIZE) 488f1e49a6SDmitry Chagin #define LINUX32_SHAREDPAGE (LINUX32_MAXUSER - PAGE_SIZE) 498f1e49a6SDmitry Chagin #define LINUX32_USRSTACK LINUX32_SHAREDPAGE 508f1e49a6SDmitry Chagin 51ea0fabbcSTim J. Robbins /* XXX 16 = sizeof(linux32_ps_strings) */ 52ea0fabbcSTim J. Robbins #define LINUX32_PS_STRINGS (LINUX32_USRSTACK - 16) 53ea0fabbcSTim J. Robbins #define LINUX32_MAXDSIZ (512 * 1024 * 1024) /* 512MB */ 54ea0fabbcSTim J. Robbins #define LINUX32_MAXSSIZ (64 * 1024 * 1024) /* 64MB */ 55ea0fabbcSTim J. Robbins #define LINUX32_MAXVMEM 0 /* Unlimited */ 56ea0fabbcSTim J. Robbins 57ea0fabbcSTim J. Robbins /* 58ea0fabbcSTim J. Robbins * Provide a separate set of types for the Linux types. 59ea0fabbcSTim J. Robbins */ 60ea0fabbcSTim J. Robbins typedef int l_int; 61ea0fabbcSTim J. Robbins typedef int32_t l_long; 62ea0fabbcSTim J. Robbins typedef int64_t l_longlong; 63ea0fabbcSTim J. Robbins typedef short l_short; 64ea0fabbcSTim J. Robbins typedef unsigned int l_uint; 65ea0fabbcSTim J. Robbins typedef uint32_t l_ulong; 66ea0fabbcSTim J. Robbins typedef uint64_t l_ulonglong; 67ea0fabbcSTim J. Robbins typedef unsigned short l_ushort; 68ea0fabbcSTim J. Robbins 69ea0fabbcSTim J. Robbins typedef l_ulong l_uintptr_t; 70ea0fabbcSTim J. Robbins typedef l_long l_clock_t; 71ea0fabbcSTim J. Robbins typedef l_int l_daddr_t; 72ea0fabbcSTim J. Robbins typedef l_ushort l_dev_t; 73ea0fabbcSTim J. Robbins typedef l_uint l_gid_t; 74ea0fabbcSTim J. Robbins typedef l_ushort l_gid16_t; 75ea0fabbcSTim J. Robbins typedef l_ulong l_ino_t; 76ea0fabbcSTim J. Robbins typedef l_int l_key_t; 77ea0fabbcSTim J. Robbins typedef l_longlong l_loff_t; 78ea0fabbcSTim J. Robbins typedef l_ushort l_mode_t; 790af71035SDoug Ambrisko typedef l_long l_off_t; 80ea0fabbcSTim J. Robbins typedef l_int l_pid_t; 81ea0fabbcSTim J. Robbins typedef l_uint l_size_t; 82ea0fabbcSTim J. Robbins typedef l_long l_suseconds_t; 83ea0fabbcSTim J. Robbins typedef l_long l_time_t; 84*bfcce1a9SDmitry Chagin typedef l_longlong l_time64_t; 85ea0fabbcSTim J. Robbins typedef l_uint l_uid_t; 86ea0fabbcSTim J. Robbins typedef l_ushort l_uid16_t; 87aa8b2011SKonstantin Belousov typedef l_int l_timer_t; 88aa8b2011SKonstantin Belousov typedef l_int l_mqd_t; 893e89b641SDmitry Chagin typedef l_ulong l_fd_mask; 90ea0fabbcSTim J. Robbins 91ea0fabbcSTim J. Robbins typedef struct { 92ea0fabbcSTim J. Robbins l_int val[2]; 9319593f77SDmitry Chagin } l_fsid_t; 94ea0fabbcSTim J. Robbins 95ea0fabbcSTim J. Robbins typedef struct { 96ea0fabbcSTim J. Robbins l_time_t tv_sec; 97ea0fabbcSTim J. Robbins l_suseconds_t tv_usec; 9803cc95d2SDmitry Chagin } l_timeval; 99ea0fabbcSTim J. Robbins 100ea0fabbcSTim J. Robbins #define l_fd_set fd_set 101ea0fabbcSTim J. Robbins 102ea0fabbcSTim J. Robbins /* 103ea0fabbcSTim J. Robbins * Miscellaneous 104ea0fabbcSTim J. Robbins */ 105ca6e1fa3SEdward Tomasz Napierala #define LINUX_AT_COUNT 21 /* Count of used aux entry types. 1064d7c2e8aSDmitry Chagin * Keep this synchronized with 107dc858467SEd Maste * linux_fixup_elf() code. 1084d7c2e8aSDmitry Chagin */ 109ea0fabbcSTim J. Robbins struct l___sysctl_args 110ea0fabbcSTim J. Robbins { 111ea0fabbcSTim J. Robbins l_uintptr_t name; 112ea0fabbcSTim J. Robbins l_int nlen; 113ea0fabbcSTim J. Robbins l_uintptr_t oldval; 114ea0fabbcSTim J. Robbins l_uintptr_t oldlenp; 115ea0fabbcSTim J. Robbins l_uintptr_t newval; 116ea0fabbcSTim J. Robbins l_size_t newlen; 117ea0fabbcSTim J. Robbins l_ulong __spare[4]; 11819593f77SDmitry Chagin }; 119ea0fabbcSTim J. Robbins 120ea0fabbcSTim J. Robbins /* Resource limits */ 121ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_CPU 0 122ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_FSIZE 1 123ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_DATA 2 124ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_STACK 3 125ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_CORE 4 126ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_RSS 5 127ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_NPROC 6 128ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_NOFILE 7 129ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_MEMLOCK 8 130a4e3bad7SJung-uk Kim #define LINUX_RLIMIT_AS 9 /* Address space limit */ 131ea0fabbcSTim J. Robbins 132ea0fabbcSTim J. Robbins #define LINUX_RLIM_NLIMITS 10 133ea0fabbcSTim J. Robbins 134ea0fabbcSTim J. Robbins struct l_rlimit { 135ea0fabbcSTim J. Robbins l_ulong rlim_cur; 136ea0fabbcSTim J. Robbins l_ulong rlim_max; 13719593f77SDmitry Chagin }; 138ea0fabbcSTim J. Robbins 139ea0fabbcSTim J. Robbins struct l_rusage { 140ea0fabbcSTim J. Robbins l_timeval ru_utime; 141ea0fabbcSTim J. Robbins l_timeval ru_stime; 142ea0fabbcSTim J. Robbins l_long ru_maxrss; 143ea0fabbcSTim J. Robbins l_long ru_ixrss; 144ea0fabbcSTim J. Robbins l_long ru_idrss; 145ea0fabbcSTim J. Robbins l_long ru_isrss; 146ea0fabbcSTim J. Robbins l_long ru_minflt; 147ea0fabbcSTim J. Robbins l_long ru_majflt; 148ea0fabbcSTim J. Robbins l_long ru_nswap; 149ea0fabbcSTim J. Robbins l_long ru_inblock; 150ea0fabbcSTim J. Robbins l_long ru_oublock; 151ea0fabbcSTim J. Robbins l_long ru_msgsnd; 152ea0fabbcSTim J. Robbins l_long ru_msgrcv; 153ea0fabbcSTim J. Robbins l_long ru_nsignals; 154ea0fabbcSTim J. Robbins l_long ru_nvcsw; 155ea0fabbcSTim J. Robbins l_long ru_nivcsw; 15619593f77SDmitry Chagin }; 157ea0fabbcSTim J. Robbins 15810931a46SJung-uk Kim struct l_mmap_argv { 15910931a46SJung-uk Kim l_uintptr_t addr; 16010931a46SJung-uk Kim l_size_t len; 16110931a46SJung-uk Kim l_int prot; 16210931a46SJung-uk Kim l_int flags; 16310931a46SJung-uk Kim l_int fd; 1640af71035SDoug Ambrisko l_ulong pgoff; 1650af71035SDoug Ambrisko }; 16610931a46SJung-uk Kim 167ea0fabbcSTim J. Robbins /* 168ea0fabbcSTim J. Robbins * stat family of syscalls 169ea0fabbcSTim J. Robbins */ 170ea0fabbcSTim J. Robbins struct l_timespec { 17177424f41SJung-uk Kim l_time_t tv_sec; 17277424f41SJung-uk Kim l_long tv_nsec; 17319593f77SDmitry Chagin }; 174ea0fabbcSTim J. Robbins 175*bfcce1a9SDmitry Chagin /* __kernel_timespec */ 176*bfcce1a9SDmitry Chagin struct l_timespec64 { 177*bfcce1a9SDmitry Chagin l_time64_t tv_sec; 178*bfcce1a9SDmitry Chagin l_longlong tv_nsec; 179*bfcce1a9SDmitry Chagin }; 180*bfcce1a9SDmitry Chagin 181ea0fabbcSTim J. Robbins struct l_newstat { 182ea0fabbcSTim J. Robbins l_ushort st_dev; 183ea0fabbcSTim J. Robbins l_ushort __pad1; 184ea0fabbcSTim J. Robbins l_ulong st_ino; 185ea0fabbcSTim J. Robbins l_ushort st_mode; 186ea0fabbcSTim J. Robbins l_ushort st_nlink; 187ea0fabbcSTim J. Robbins l_ushort st_uid; 188ea0fabbcSTim J. Robbins l_ushort st_gid; 189ea0fabbcSTim J. Robbins l_ushort st_rdev; 190ea0fabbcSTim J. Robbins l_ushort __pad2; 191ea0fabbcSTim J. Robbins l_ulong st_size; 192ea0fabbcSTim J. Robbins l_ulong st_blksize; 193ea0fabbcSTim J. Robbins l_ulong st_blocks; 194510ea843SEd Schouten struct l_timespec st_atim; 195510ea843SEd Schouten struct l_timespec st_mtim; 196510ea843SEd Schouten struct l_timespec st_ctim; 197ea0fabbcSTim J. Robbins l_ulong __unused4; 198ea0fabbcSTim J. Robbins l_ulong __unused5; 19919593f77SDmitry Chagin }; 200ea0fabbcSTim J. Robbins 2011f7642e0SAlexander Leidinger struct l_stat { 2021f7642e0SAlexander Leidinger l_ushort st_dev; 2031f7642e0SAlexander Leidinger l_ulong st_ino; 2041f7642e0SAlexander Leidinger l_ushort st_mode; 2051f7642e0SAlexander Leidinger l_ushort st_nlink; 2061f7642e0SAlexander Leidinger l_ushort st_uid; 2071f7642e0SAlexander Leidinger l_ushort st_gid; 2081f7642e0SAlexander Leidinger l_ushort st_rdev; 2091f7642e0SAlexander Leidinger l_long st_size; 210510ea843SEd Schouten struct l_timespec st_atim; 211510ea843SEd Schouten struct l_timespec st_mtim; 212510ea843SEd Schouten struct l_timespec st_ctim; 2131f7642e0SAlexander Leidinger l_long st_blksize; 2141f7642e0SAlexander Leidinger l_long st_blocks; 2151f7642e0SAlexander Leidinger l_ulong st_flags; 2161f7642e0SAlexander Leidinger l_ulong st_gen; 2171f7642e0SAlexander Leidinger }; 2181f7642e0SAlexander Leidinger 219ea0fabbcSTim J. Robbins struct l_stat64 { 220ea0fabbcSTim J. Robbins l_ushort st_dev; 221ea0fabbcSTim J. Robbins u_char __pad0[10]; 222ea0fabbcSTim J. Robbins l_ulong __st_ino; 223ea0fabbcSTim J. Robbins l_uint st_mode; 224ea0fabbcSTim J. Robbins l_uint st_nlink; 225ea0fabbcSTim J. Robbins l_ulong st_uid; 226ea0fabbcSTim J. Robbins l_ulong st_gid; 227ea0fabbcSTim J. Robbins l_ushort st_rdev; 228ea0fabbcSTim J. Robbins u_char __pad3[10]; 229ea0fabbcSTim J. Robbins l_longlong st_size; 230ea0fabbcSTim J. Robbins l_ulong st_blksize; 231ea0fabbcSTim J. Robbins l_ulong st_blocks; 232ea0fabbcSTim J. Robbins l_ulong __pad4; 233510ea843SEd Schouten struct l_timespec st_atim; 234510ea843SEd Schouten struct l_timespec st_mtim; 235510ea843SEd Schouten struct l_timespec st_ctim; 236ea0fabbcSTim J. Robbins l_ulonglong st_ino; 237ea0fabbcSTim J. Robbins } __packed; 238ea0fabbcSTim J. Robbins 2393ab85269SDavid Malone struct l_statfs64 { 2403ab85269SDavid Malone l_int f_type; 2413ab85269SDavid Malone l_int f_bsize; 2423ab85269SDavid Malone uint64_t f_blocks; 2433ab85269SDavid Malone uint64_t f_bfree; 2443ab85269SDavid Malone uint64_t f_bavail; 2453ab85269SDavid Malone uint64_t f_files; 2463ab85269SDavid Malone uint64_t f_ffree; 2473ab85269SDavid Malone l_fsid_t f_fsid; 2483ab85269SDavid Malone l_int f_namelen; 249e801ac78SEdward Tomasz Napierala l_int f_frsize; 250e801ac78SEdward Tomasz Napierala l_int f_flags; 251e801ac78SEdward Tomasz Napierala l_int f_spare[4]; 2523ab85269SDavid Malone } __packed; 2533ab85269SDavid Malone 254ea0fabbcSTim J. Robbins /* sigaction flags */ 255ea0fabbcSTim J. Robbins #define LINUX_SA_NOCLDSTOP 0x00000001 256ea0fabbcSTim J. Robbins #define LINUX_SA_NOCLDWAIT 0x00000002 257ea0fabbcSTim J. Robbins #define LINUX_SA_SIGINFO 0x00000004 258ea0fabbcSTim J. Robbins #define LINUX_SA_RESTORER 0x04000000 259ea0fabbcSTim J. Robbins #define LINUX_SA_ONSTACK 0x08000000 260ea0fabbcSTim J. Robbins #define LINUX_SA_RESTART 0x10000000 261ea0fabbcSTim J. Robbins #define LINUX_SA_INTERRUPT 0x20000000 262ea0fabbcSTim J. Robbins #define LINUX_SA_NOMASK 0x40000000 263ea0fabbcSTim J. Robbins #define LINUX_SA_ONESHOT 0x80000000 264ea0fabbcSTim J. Robbins 265ea0fabbcSTim J. Robbins /* sigprocmask actions */ 266ea0fabbcSTim J. Robbins #define LINUX_SIG_BLOCK 0 267ea0fabbcSTim J. Robbins #define LINUX_SIG_UNBLOCK 1 268ea0fabbcSTim J. Robbins #define LINUX_SIG_SETMASK 2 269ea0fabbcSTim J. Robbins 270ea0fabbcSTim J. Robbins /* sigaltstack */ 271ea0fabbcSTim J. Robbins #define LINUX_MINSIGSTKSZ 2048 272ea0fabbcSTim J. Robbins 273ea0fabbcSTim J. Robbins typedef l_uintptr_t l_handler_t; 274ea0fabbcSTim J. Robbins typedef l_ulong l_osigset_t; 275ea0fabbcSTim J. Robbins 276ea0fabbcSTim J. Robbins typedef struct { 277ea0fabbcSTim J. Robbins l_handler_t lsa_handler; 278ea0fabbcSTim J. Robbins l_osigset_t lsa_mask; 279ea0fabbcSTim J. Robbins l_ulong lsa_flags; 280ea0fabbcSTim J. Robbins l_uintptr_t lsa_restorer; 28119593f77SDmitry Chagin } l_osigaction_t; 282ea0fabbcSTim J. Robbins 283ea0fabbcSTim J. Robbins typedef struct { 284ea0fabbcSTim J. Robbins l_handler_t lsa_handler; 285ea0fabbcSTim J. Robbins l_ulong lsa_flags; 286ea0fabbcSTim J. Robbins l_uintptr_t lsa_restorer; 287ea0fabbcSTim J. Robbins l_sigset_t lsa_mask; 288ea0fabbcSTim J. Robbins } __packed l_sigaction_t; 289ea0fabbcSTim J. Robbins 290ea0fabbcSTim J. Robbins typedef struct { 291ea0fabbcSTim J. Robbins l_uintptr_t ss_sp; 292ea0fabbcSTim J. Robbins l_int ss_flags; 293ea0fabbcSTim J. Robbins l_size_t ss_size; 29419593f77SDmitry Chagin } l_stack_t; 295ea0fabbcSTim J. Robbins 296ea0fabbcSTim J. Robbins /* The Linux sigcontext, pretty much a standard 386 trapframe. */ 297ea0fabbcSTim J. Robbins struct l_sigcontext { 29877185f47SKonstantin Belousov l_uint sc_gs; 29977185f47SKonstantin Belousov l_uint sc_fs; 30077185f47SKonstantin Belousov l_uint sc_es; 30177185f47SKonstantin Belousov l_uint sc_ds; 30277185f47SKonstantin Belousov l_uint sc_edi; 30377185f47SKonstantin Belousov l_uint sc_esi; 30477185f47SKonstantin Belousov l_uint sc_ebp; 30577185f47SKonstantin Belousov l_uint sc_esp; 30677185f47SKonstantin Belousov l_uint sc_ebx; 30777185f47SKonstantin Belousov l_uint sc_edx; 30877185f47SKonstantin Belousov l_uint sc_ecx; 30977185f47SKonstantin Belousov l_uint sc_eax; 31077185f47SKonstantin Belousov l_uint sc_trapno; 31177185f47SKonstantin Belousov l_uint sc_err; 31277185f47SKonstantin Belousov l_uint sc_eip; 31377185f47SKonstantin Belousov l_uint sc_cs; 31477185f47SKonstantin Belousov l_uint sc_eflags; 31577185f47SKonstantin Belousov l_uint sc_esp_at_signal; 31677185f47SKonstantin Belousov l_uint sc_ss; 31777185f47SKonstantin Belousov l_uint sc_387; 31877185f47SKonstantin Belousov l_uint sc_mask; 31977185f47SKonstantin Belousov l_uint sc_cr2; 32019593f77SDmitry Chagin }; 321ea0fabbcSTim J. Robbins 322ea0fabbcSTim J. Robbins struct l_ucontext { 323ea0fabbcSTim J. Robbins l_ulong uc_flags; 324ea0fabbcSTim J. Robbins l_uintptr_t uc_link; 325ea0fabbcSTim J. Robbins l_stack_t uc_stack; 326ea0fabbcSTim J. Robbins struct l_sigcontext uc_mcontext; 327ea0fabbcSTim J. Robbins l_sigset_t uc_sigmask; 328ea0fabbcSTim J. Robbins } __packed; 329ea0fabbcSTim J. Robbins 330ea0fabbcSTim J. Robbins #define LINUX_SI_MAX_SIZE 128 331ea0fabbcSTim J. Robbins #define LINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3) 332ea0fabbcSTim J. Robbins 333aa8b2011SKonstantin Belousov typedef union l_sigval { 3346ddd7e6aSJohn Baldwin l_int sival_int; 3356ddd7e6aSJohn Baldwin l_uintptr_t sival_ptr; 336aa8b2011SKonstantin Belousov } l_sigval_t; 3376ddd7e6aSJohn Baldwin 338ea0fabbcSTim J. Robbins typedef struct l_siginfo { 339ea0fabbcSTim J. Robbins l_int lsi_signo; 340ea0fabbcSTim J. Robbins l_int lsi_errno; 341ea0fabbcSTim J. Robbins l_int lsi_code; 342ea0fabbcSTim J. Robbins union { 343ea0fabbcSTim J. Robbins l_int _pad[LINUX_SI_PAD_SIZE]; 344ea0fabbcSTim J. Robbins 345ea0fabbcSTim J. Robbins struct { 346ea0fabbcSTim J. Robbins l_pid_t _pid; 347aa8b2011SKonstantin Belousov l_uid_t _uid; 34819593f77SDmitry Chagin } _kill; 349ea0fabbcSTim J. Robbins 350ea0fabbcSTim J. Robbins struct { 351aa8b2011SKonstantin Belousov l_timer_t _tid; 352aa8b2011SKonstantin Belousov l_int _overrun; 353aa8b2011SKonstantin Belousov char _pad[sizeof(l_uid_t) - sizeof(l_int)]; 354aa8b2011SKonstantin Belousov l_sigval_t _sigval; 355aa8b2011SKonstantin Belousov l_int _sys_private; 35619593f77SDmitry Chagin } _timer; 357ea0fabbcSTim J. Robbins 358ea0fabbcSTim J. Robbins struct { 359ea0fabbcSTim J. Robbins l_pid_t _pid; /* sender's pid */ 360aa8b2011SKonstantin Belousov l_uid_t _uid; /* sender's uid */ 361aa8b2011SKonstantin Belousov l_sigval_t _sigval; 36219593f77SDmitry Chagin } _rt; 363ea0fabbcSTim J. Robbins 364ea0fabbcSTim J. Robbins struct { 365ea0fabbcSTim J. Robbins l_pid_t _pid; /* which child */ 366aa8b2011SKonstantin Belousov l_uid_t _uid; /* sender's uid */ 367ea0fabbcSTim J. Robbins l_int _status; /* exit code */ 368ea0fabbcSTim J. Robbins l_clock_t _utime; 369ea0fabbcSTim J. Robbins l_clock_t _stime; 37019593f77SDmitry Chagin } _sigchld; 371ea0fabbcSTim J. Robbins 372ea0fabbcSTim J. Robbins struct { 373a4e3bad7SJung-uk Kim l_uintptr_t _addr; /* Faulting insn/memory ref. */ 37419593f77SDmitry Chagin } _sigfault; 375ea0fabbcSTim J. Robbins 376ea0fabbcSTim J. Robbins struct { 377aa8b2011SKonstantin Belousov l_long _band; /* POLL_IN,POLL_OUT,POLL_MSG */ 378ea0fabbcSTim J. Robbins l_int _fd; 37919593f77SDmitry Chagin } _sigpoll; 380ea0fabbcSTim J. Robbins } _sifields; 38119593f77SDmitry Chagin } l_siginfo_t; 382ea0fabbcSTim J. Robbins 383ea0fabbcSTim J. Robbins #define lsi_pid _sifields._kill._pid 384ea0fabbcSTim J. Robbins #define lsi_uid _sifields._kill._uid 385aa8b2011SKonstantin Belousov #define lsi_tid _sifields._timer._tid 386aa8b2011SKonstantin Belousov #define lsi_overrun _sifields._timer._overrun 387aa8b2011SKonstantin Belousov #define lsi_sys_private _sifields._timer._sys_private 388ea0fabbcSTim J. Robbins #define lsi_status _sifields._sigchld._status 389ea0fabbcSTim J. Robbins #define lsi_utime _sifields._sigchld._utime 390ea0fabbcSTim J. Robbins #define lsi_stime _sifields._sigchld._stime 391ea0fabbcSTim J. Robbins #define lsi_value _sifields._rt._sigval 392ea0fabbcSTim J. Robbins #define lsi_int _sifields._rt._sigval.sival_int 393ea0fabbcSTim J. Robbins #define lsi_ptr _sifields._rt._sigval.sival_ptr 394ea0fabbcSTim J. Robbins #define lsi_addr _sifields._sigfault._addr 395ea0fabbcSTim J. Robbins #define lsi_band _sifields._sigpoll._band 396ea0fabbcSTim J. Robbins #define lsi_fd _sifields._sigpoll._fd 397ea0fabbcSTim J. Robbins 398ea0fabbcSTim J. Robbins struct l_fpreg { 399ea0fabbcSTim J. Robbins u_int16_t significand[4]; 400ea0fabbcSTim J. Robbins u_int16_t exponent; 40119593f77SDmitry Chagin }; 402ea0fabbcSTim J. Robbins 403ea0fabbcSTim J. Robbins struct l_fpxreg { 404ea0fabbcSTim J. Robbins u_int16_t significand[4]; 405ea0fabbcSTim J. Robbins u_int16_t exponent; 406ea0fabbcSTim J. Robbins u_int16_t padding[3]; 40719593f77SDmitry Chagin }; 408ea0fabbcSTim J. Robbins 409ea0fabbcSTim J. Robbins struct l_xmmreg { 410ea0fabbcSTim J. Robbins u_int32_t element[4]; 41119593f77SDmitry Chagin }; 412ea0fabbcSTim J. Robbins 413ea0fabbcSTim J. Robbins struct l_fpstate { 414ea0fabbcSTim J. Robbins /* Regular FPU environment */ 415ea0fabbcSTim J. Robbins u_int32_t cw; 416ea0fabbcSTim J. Robbins u_int32_t sw; 417ea0fabbcSTim J. Robbins u_int32_t tag; 418ea0fabbcSTim J. Robbins u_int32_t ipoff; 419ea0fabbcSTim J. Robbins u_int32_t cssel; 420ea0fabbcSTim J. Robbins u_int32_t dataoff; 421ea0fabbcSTim J. Robbins u_int32_t datasel; 422ea0fabbcSTim J. Robbins struct l_fpreg _st[8]; 423ea0fabbcSTim J. Robbins u_int16_t status; 424ea0fabbcSTim J. Robbins u_int16_t magic; /* 0xffff = regular FPU data */ 425ea0fabbcSTim J. Robbins 426ea0fabbcSTim J. Robbins /* FXSR FPU environment */ 427a4e3bad7SJung-uk Kim u_int32_t _fxsr_env[6]; /* env is ignored. */ 428ea0fabbcSTim J. Robbins u_int32_t mxcsr; 429ea0fabbcSTim J. Robbins u_int32_t reserved; 430a4e3bad7SJung-uk Kim struct l_fpxreg _fxsr_st[8]; /* reg data is ignored. */ 431ea0fabbcSTim J. Robbins struct l_xmmreg _xmm[8]; 432ea0fabbcSTim J. Robbins u_int32_t padding[56]; 43319593f77SDmitry Chagin }; 434ea0fabbcSTim J. Robbins 435ea0fabbcSTim J. Robbins /* 436ea0fabbcSTim J. Robbins * We make the stack look like Linux expects it when calling a signal 437ea0fabbcSTim J. Robbins * handler, but use the BSD way of calling the handler and sigreturn(). 438ea0fabbcSTim J. Robbins * This means that we need to pass the pointer to the handler too. 439ea0fabbcSTim J. Robbins * It is appended to the frame to not interfere with the rest of it. 440ea0fabbcSTim J. Robbins */ 441ea0fabbcSTim J. Robbins struct l_sigframe { 442ea0fabbcSTim J. Robbins l_int sf_sig; 443ea0fabbcSTim J. Robbins struct l_sigcontext sf_sc; 444ea0fabbcSTim J. Robbins struct l_fpstate sf_fpstate; 4454ab7403bSDmitry Chagin l_uint sf_extramask[1]; 446ea0fabbcSTim J. Robbins l_handler_t sf_handler; 44719593f77SDmitry Chagin }; 448ea0fabbcSTim J. Robbins 449ea0fabbcSTim J. Robbins struct l_rt_sigframe { 450ea0fabbcSTim J. Robbins l_int sf_sig; 451ea0fabbcSTim J. Robbins l_uintptr_t sf_siginfo; 452ea0fabbcSTim J. Robbins l_uintptr_t sf_ucontext; 453ea0fabbcSTim J. Robbins l_siginfo_t sf_si; 454ea0fabbcSTim J. Robbins struct l_ucontext sf_sc; 455ea0fabbcSTim J. Robbins l_handler_t sf_handler; 456ea0fabbcSTim J. Robbins } __packed; 457ea0fabbcSTim J. Robbins 458ea0fabbcSTim J. Robbins /* 4594d0f380dSDmitry Chagin * arch specific open/fcntl flags 460ea0fabbcSTim J. Robbins */ 461ea0fabbcSTim J. Robbins #define LINUX_F_GETLK64 12 462ea0fabbcSTim J. Robbins #define LINUX_F_SETLK64 13 463ea0fabbcSTim J. Robbins #define LINUX_F_SETLKW64 14 464ea0fabbcSTim J. Robbins 465ea0fabbcSTim J. Robbins union l_semun { 466ea0fabbcSTim J. Robbins l_int val; 467ea0fabbcSTim J. Robbins l_uintptr_t buf; 468ea0fabbcSTim J. Robbins l_uintptr_t array; 469ea0fabbcSTim J. Robbins l_uintptr_t __buf; 470ea0fabbcSTim J. Robbins l_uintptr_t __pad; 47119593f77SDmitry Chagin }; 472ea0fabbcSTim J. Robbins 473ea0fabbcSTim J. Robbins struct l_ifmap { 474ea0fabbcSTim J. Robbins l_ulong mem_start; 475ea0fabbcSTim J. Robbins l_ulong mem_end; 476ea0fabbcSTim J. Robbins l_ushort base_addr; 477ea0fabbcSTim J. Robbins u_char irq; 478ea0fabbcSTim J. Robbins u_char dma; 479ea0fabbcSTim J. Robbins u_char port; 48019593f77SDmitry Chagin /* 3 bytes spare */ 48119593f77SDmitry Chagin }; 482ea0fabbcSTim J. Robbins 483ea0fabbcSTim J. Robbins struct l_ifreq { 484ea0fabbcSTim J. Robbins union { 485ea0fabbcSTim J. Robbins char ifrn_name[LINUX_IFNAMSIZ]; 486ea0fabbcSTim J. Robbins } ifr_ifrn; 487ea0fabbcSTim J. Robbins 488ea0fabbcSTim J. Robbins union { 489ea0fabbcSTim J. Robbins struct l_sockaddr ifru_addr; 490ea0fabbcSTim J. Robbins struct l_sockaddr ifru_dstaddr; 491ea0fabbcSTim J. Robbins struct l_sockaddr ifru_broadaddr; 492ea0fabbcSTim J. Robbins struct l_sockaddr ifru_netmask; 493ea0fabbcSTim J. Robbins struct l_sockaddr ifru_hwaddr; 494ea0fabbcSTim J. Robbins l_short ifru_flags[1]; 4957ece126eSTai-hwa Liang l_int ifru_ivalue; 496ea0fabbcSTim J. Robbins l_int ifru_mtu; 497ea0fabbcSTim J. Robbins struct l_ifmap ifru_map; 498ea0fabbcSTim J. Robbins char ifru_slave[LINUX_IFNAMSIZ]; 499ea0fabbcSTim J. Robbins l_uintptr_t ifru_data; 500ea0fabbcSTim J. Robbins } ifr_ifru; 50119593f77SDmitry Chagin }; 502ea0fabbcSTim J. Robbins 503a4e3bad7SJung-uk Kim #define ifr_name ifr_ifrn.ifrn_name /* Interface name */ 504ea0fabbcSTim J. Robbins #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ 5057ece126eSTai-hwa Liang #define ifr_ifindex ifr_ifru.ifru_ivalue /* Interface index */ 506ea0fabbcSTim J. Robbins 507ea0fabbcSTim J. Robbins struct l_ifconf { 508ea0fabbcSTim J. Robbins int ifc_len; 509ea0fabbcSTim J. Robbins union { 510ea0fabbcSTim J. Robbins l_uintptr_t ifcu_buf; 511ea0fabbcSTim J. Robbins l_uintptr_t ifcu_req; 512ea0fabbcSTim J. Robbins } ifc_ifcu; 51319593f77SDmitry Chagin }; 514ea0fabbcSTim J. Robbins 515ea0fabbcSTim J. Robbins #define ifc_buf ifc_ifcu.ifcu_buf 516ea0fabbcSTim J. Robbins #define ifc_req ifc_ifcu.ifcu_req 517ea0fabbcSTim J. Robbins 518ea0fabbcSTim J. Robbins /* 519ea0fabbcSTim J. Robbins * poll() 520ea0fabbcSTim J. Robbins */ 521ea0fabbcSTim J. Robbins #define LINUX_POLLIN 0x0001 522ea0fabbcSTim J. Robbins #define LINUX_POLLPRI 0x0002 523ea0fabbcSTim J. Robbins #define LINUX_POLLOUT 0x0004 524ea0fabbcSTim J. Robbins #define LINUX_POLLERR 0x0008 525ea0fabbcSTim J. Robbins #define LINUX_POLLHUP 0x0010 526ea0fabbcSTim J. Robbins #define LINUX_POLLNVAL 0x0020 527ea0fabbcSTim J. Robbins #define LINUX_POLLRDNORM 0x0040 528ea0fabbcSTim J. Robbins #define LINUX_POLLRDBAND 0x0080 529ea0fabbcSTim J. Robbins #define LINUX_POLLWRNORM 0x0100 530ea0fabbcSTim J. Robbins #define LINUX_POLLWRBAND 0x0200 531ea0fabbcSTim J. Robbins #define LINUX_POLLMSG 0x0400 532ea0fabbcSTim J. Robbins 533ea0fabbcSTim J. Robbins struct l_pollfd { 534ea0fabbcSTim J. Robbins l_int fd; 535ea0fabbcSTim J. Robbins l_short events; 536ea0fabbcSTim J. Robbins l_short revents; 53719593f77SDmitry Chagin }; 538ea0fabbcSTim J. Robbins 5399b44bfc5SAlexander Leidinger struct l_user_desc { 5409b44bfc5SAlexander Leidinger l_uint entry_number; 5419b44bfc5SAlexander Leidinger l_uint base_addr; 5429b44bfc5SAlexander Leidinger l_uint limit; 5439b44bfc5SAlexander Leidinger l_uint seg_32bit:1; 5449b44bfc5SAlexander Leidinger l_uint contents:2; 5459b44bfc5SAlexander Leidinger l_uint read_exec_only:1; 5469b44bfc5SAlexander Leidinger l_uint limit_in_pages:1; 5479b44bfc5SAlexander Leidinger l_uint seg_not_present:1; 5489b44bfc5SAlexander Leidinger l_uint useable:1; 5499b44bfc5SAlexander Leidinger }; 5509b44bfc5SAlexander Leidinger 5519b44bfc5SAlexander Leidinger #define LINUX_LOWERWORD 0x0000ffff 5529b44bfc5SAlexander Leidinger 5530eef2f8aSAlexander Leidinger /* 554a4e3bad7SJung-uk Kim * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h. 555a4e3bad7SJung-uk Kim * These convert Linux user space descriptor to machine one. 5569b44bfc5SAlexander Leidinger */ 557a4e3bad7SJung-uk Kim #define LINUX_LDT_entry_a(info) \ 558a4e3bad7SJung-uk Kim ((((info)->base_addr & LINUX_LOWERWORD) << 16) | \ 559a4e3bad7SJung-uk Kim ((info)->limit & LINUX_LOWERWORD)) 5609b44bfc5SAlexander Leidinger 561a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_READ_EXEC_ONLY 9 562a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_CONTENTS 10 563a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_SEG_NOT_PRESENT 15 564a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_BASE_ADDR 16 565a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_USEABLE 20 566a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_SEG32BIT 22 567a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_LIMIT 23 5689b44bfc5SAlexander Leidinger 569a4e3bad7SJung-uk Kim #define LINUX_LDT_entry_b(info) \ 5709b44bfc5SAlexander Leidinger (((info)->base_addr & 0xff000000) | \ 5719b44bfc5SAlexander Leidinger ((info)->limit & 0xf0000) | \ 572a4e3bad7SJung-uk Kim ((info)->contents << LINUX_ENTRY_B_CONTENTS) | \ 573a4e3bad7SJung-uk Kim (((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) | \ 574a4e3bad7SJung-uk Kim (((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) | \ 575a4e3bad7SJung-uk Kim (((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) | \ 576a4e3bad7SJung-uk Kim ((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) | \ 577a4e3bad7SJung-uk Kim ((info)->useable << LINUX_ENTRY_B_USEABLE) | \ 578a4e3bad7SJung-uk Kim ((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000) 5799b44bfc5SAlexander Leidinger 580a4e3bad7SJung-uk Kim #define LINUX_LDT_empty(info) \ 581a4e3bad7SJung-uk Kim ((info)->base_addr == 0 && \ 5829b44bfc5SAlexander Leidinger (info)->limit == 0 && \ 5839b44bfc5SAlexander Leidinger (info)->contents == 0 && \ 5849b44bfc5SAlexander Leidinger (info)->seg_not_present == 1 && \ 5859b44bfc5SAlexander Leidinger (info)->read_exec_only == 1 && \ 5869b44bfc5SAlexander Leidinger (info)->seg_32bit == 0 && \ 5879b44bfc5SAlexander Leidinger (info)->limit_in_pages == 0 && \ 5889b44bfc5SAlexander Leidinger (info)->useable == 0) 5899b44bfc5SAlexander Leidinger 590a4e3bad7SJung-uk Kim /* 591a4e3bad7SJung-uk Kim * Macros for converting segments. 592a4e3bad7SJung-uk Kim * They do the same as those in arch/i386/kernel/process.c in Linux. 593a4e3bad7SJung-uk Kim */ 594a4e3bad7SJung-uk Kim #define LINUX_GET_BASE(desc) \ 595a4e3bad7SJung-uk Kim ((((desc)->a >> 16) & LINUX_LOWERWORD) | \ 5969b44bfc5SAlexander Leidinger (((desc)->b << 16) & 0x00ff0000) | \ 5979b44bfc5SAlexander Leidinger ((desc)->b & 0xff000000)) 5989b44bfc5SAlexander Leidinger 599a4e3bad7SJung-uk Kim #define LINUX_GET_LIMIT(desc) \ 600a4e3bad7SJung-uk Kim (((desc)->a & LINUX_LOWERWORD) | \ 6019b44bfc5SAlexander Leidinger ((desc)->b & 0xf0000)) 6029b44bfc5SAlexander Leidinger 603a4e3bad7SJung-uk Kim #define LINUX_GET_32BIT(desc) \ 604a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1) 605a4e3bad7SJung-uk Kim #define LINUX_GET_CONTENTS(desc) \ 606a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3) 607a4e3bad7SJung-uk Kim #define LINUX_GET_WRITABLE(desc) \ 608a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1) 609a4e3bad7SJung-uk Kim #define LINUX_GET_LIMIT_PAGES(desc) \ 610a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1) 611a4e3bad7SJung-uk Kim #define LINUX_GET_PRESENT(desc) \ 612a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1) 613a4e3bad7SJung-uk Kim #define LINUX_GET_USEABLE(desc) \ 614a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1) 6159b44bfc5SAlexander Leidinger 61641f53a36SKonstantin Belousov struct iovec; 617bd911530SMahdi Mokhtari struct uio; 61841f53a36SKonstantin Belousov 61941f53a36SKonstantin Belousov struct l_iovec32 { 62041f53a36SKonstantin Belousov uint32_t iov_base; 62141f53a36SKonstantin Belousov l_size_t iov_len; 62241f53a36SKonstantin Belousov }; 62341f53a36SKonstantin Belousov 62441f53a36SKonstantin Belousov int linux32_copyiniov(struct l_iovec32 *iovp32, l_ulong iovcnt, 62541f53a36SKonstantin Belousov struct iovec **iovp, int error); 626bd911530SMahdi Mokhtari int linux32_copyinuio(struct l_iovec32 *iovp, l_ulong iovcnt, 627bd911530SMahdi Mokhtari struct uio **uiop); 628001398c4SDmitry Chagin int linux_copyout_rusage(struct rusage *ru, void *uaddr); 62941f53a36SKonstantin Belousov 630175c6c31SKonstantin Belousov /* robust futexes */ 631175c6c31SKonstantin Belousov struct linux_robust_list { 632175c6c31SKonstantin Belousov l_uintptr_t next; 633175c6c31SKonstantin Belousov }; 634175c6c31SKonstantin Belousov 635175c6c31SKonstantin Belousov struct linux_robust_list_head { 636175c6c31SKonstantin Belousov struct linux_robust_list list; 63762162dfcSKonstantin Belousov l_long futex_offset; 638175c6c31SKonstantin Belousov l_uintptr_t pending_list; 639175c6c31SKonstantin Belousov }; 640175c6c31SKonstantin Belousov 64195c19e1dSEdward Tomasz Napierala /* This corresponds to 'struct user_regs_struct32' in Linux. */ 64295c19e1dSEdward Tomasz Napierala struct linux_pt_regset32 { 64395c19e1dSEdward Tomasz Napierala l_uint ebx; 64495c19e1dSEdward Tomasz Napierala l_uint ecx; 64595c19e1dSEdward Tomasz Napierala l_uint edx; 64695c19e1dSEdward Tomasz Napierala l_uint esi; 64795c19e1dSEdward Tomasz Napierala l_uint edi; 64895c19e1dSEdward Tomasz Napierala l_uint ebp; 64995c19e1dSEdward Tomasz Napierala l_uint eax; 65095c19e1dSEdward Tomasz Napierala l_uint ds; 65195c19e1dSEdward Tomasz Napierala l_uint es; 65295c19e1dSEdward Tomasz Napierala l_uint fs; 65395c19e1dSEdward Tomasz Napierala l_uint gs; 65495c19e1dSEdward Tomasz Napierala l_uint orig_eax; 65595c19e1dSEdward Tomasz Napierala l_uint eip; 65695c19e1dSEdward Tomasz Napierala l_uint cs; 65795c19e1dSEdward Tomasz Napierala l_uint eflags; 65895c19e1dSEdward Tomasz Napierala l_uint esp; 65995c19e1dSEdward Tomasz Napierala l_uint ss; 66095c19e1dSEdward Tomasz Napierala }; 66195c19e1dSEdward Tomasz Napierala 66295c19e1dSEdward Tomasz Napierala struct reg32; 66395c19e1dSEdward Tomasz Napierala 66495c19e1dSEdward Tomasz Napierala void bsd_to_linux_regset32(struct reg32 *b_reg, 66595c19e1dSEdward Tomasz Napierala struct linux_pt_regset32 *l_regset); 66695c19e1dSEdward Tomasz Napierala 667a4e3bad7SJung-uk Kim #endif /* !_AMD64_LINUX_H_ */ 668