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 47ea0fabbcSTim J. Robbins #define LINUX32_MAXDSIZ (512 * 1024 * 1024) /* 512MB */ 48ea0fabbcSTim J. Robbins #define LINUX32_MAXSSIZ (64 * 1024 * 1024) /* 64MB */ 49ea0fabbcSTim J. Robbins #define LINUX32_MAXVMEM 0 /* Unlimited */ 50ea0fabbcSTim J. Robbins 51ea0fabbcSTim J. Robbins /* 52ea0fabbcSTim J. Robbins * Provide a separate set of types for the Linux types. 53ea0fabbcSTim J. Robbins */ 54ea0fabbcSTim J. Robbins typedef int l_int; 55ea0fabbcSTim J. Robbins typedef int32_t l_long; 56ea0fabbcSTim J. Robbins typedef int64_t l_longlong; 57ea0fabbcSTim J. Robbins typedef short l_short; 58ea0fabbcSTim J. Robbins typedef unsigned int l_uint; 59ea0fabbcSTim J. Robbins typedef uint32_t l_ulong; 60ea0fabbcSTim J. Robbins typedef uint64_t l_ulonglong; 61ea0fabbcSTim J. Robbins typedef unsigned short l_ushort; 62ea0fabbcSTim J. Robbins 63ea0fabbcSTim J. Robbins typedef l_ulong l_uintptr_t; 64ea0fabbcSTim J. Robbins typedef l_long l_clock_t; 65ea0fabbcSTim J. Robbins typedef l_int l_daddr_t; 66ea0fabbcSTim J. Robbins typedef l_ushort l_dev_t; 67ea0fabbcSTim J. Robbins typedef l_uint l_gid_t; 68ea0fabbcSTim J. Robbins typedef l_ushort l_gid16_t; 69ea0fabbcSTim J. Robbins typedef l_ulong l_ino_t; 70ea0fabbcSTim J. Robbins typedef l_int l_key_t; 71ea0fabbcSTim J. Robbins typedef l_longlong l_loff_t; 72ea0fabbcSTim J. Robbins typedef l_ushort l_mode_t; 730af71035SDoug Ambrisko typedef l_long l_off_t; 74ea0fabbcSTim J. Robbins typedef l_int l_pid_t; 75ea0fabbcSTim J. Robbins typedef l_uint l_size_t; 76ea0fabbcSTim J. Robbins typedef l_long l_suseconds_t; 77ea0fabbcSTim J. Robbins typedef l_long l_time_t; 78bfcce1a9SDmitry Chagin typedef l_longlong l_time64_t; 79ea0fabbcSTim J. Robbins typedef l_uint l_uid_t; 80ea0fabbcSTim J. Robbins typedef l_ushort l_uid16_t; 81aa8b2011SKonstantin Belousov typedef l_int l_timer_t; 82aa8b2011SKonstantin Belousov typedef l_int l_mqd_t; 833e89b641SDmitry Chagin typedef l_ulong l_fd_mask; 84ea0fabbcSTim J. Robbins 85*af557e64SDmitry Chagin #include <compat/linux/linux_siginfo.h> 86*af557e64SDmitry Chagin 87ea0fabbcSTim J. Robbins typedef struct { 88ea0fabbcSTim J. Robbins l_int val[2]; 8919593f77SDmitry Chagin } l_fsid_t; 90ea0fabbcSTim J. Robbins 91ea0fabbcSTim J. Robbins typedef struct { 92ea0fabbcSTim J. Robbins l_time_t tv_sec; 93ea0fabbcSTim J. Robbins l_suseconds_t tv_usec; 9403cc95d2SDmitry Chagin } l_timeval; 95ea0fabbcSTim J. Robbins 96ea0fabbcSTim J. Robbins #define l_fd_set fd_set 97ea0fabbcSTim J. Robbins 98ea0fabbcSTim J. Robbins /* 99ea0fabbcSTim J. Robbins * Miscellaneous 100ea0fabbcSTim J. Robbins */ 101ca6e1fa3SEdward Tomasz Napierala #define LINUX_AT_COUNT 21 /* Count of used aux entry types. 1024d7c2e8aSDmitry Chagin * Keep this synchronized with 103dc858467SEd Maste * linux_fixup_elf() code. 1044d7c2e8aSDmitry Chagin */ 105ea0fabbcSTim J. Robbins struct l___sysctl_args 106ea0fabbcSTim J. Robbins { 107ea0fabbcSTim J. Robbins l_uintptr_t name; 108ea0fabbcSTim J. Robbins l_int nlen; 109ea0fabbcSTim J. Robbins l_uintptr_t oldval; 110ea0fabbcSTim J. Robbins l_uintptr_t oldlenp; 111ea0fabbcSTim J. Robbins l_uintptr_t newval; 112ea0fabbcSTim J. Robbins l_size_t newlen; 113ea0fabbcSTim J. Robbins l_ulong __spare[4]; 11419593f77SDmitry Chagin }; 115ea0fabbcSTim J. Robbins 116ea0fabbcSTim J. Robbins /* Resource limits */ 117ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_CPU 0 118ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_FSIZE 1 119ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_DATA 2 120ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_STACK 3 121ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_CORE 4 122ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_RSS 5 123ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_NPROC 6 124ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_NOFILE 7 125ea0fabbcSTim J. Robbins #define LINUX_RLIMIT_MEMLOCK 8 126a4e3bad7SJung-uk Kim #define LINUX_RLIMIT_AS 9 /* Address space limit */ 127ea0fabbcSTim J. Robbins 128ea0fabbcSTim J. Robbins #define LINUX_RLIM_NLIMITS 10 129ea0fabbcSTim J. Robbins 130ea0fabbcSTim J. Robbins struct l_rlimit { 131ea0fabbcSTim J. Robbins l_ulong rlim_cur; 132ea0fabbcSTim J. Robbins l_ulong rlim_max; 13319593f77SDmitry Chagin }; 134ea0fabbcSTim J. Robbins 135ea0fabbcSTim J. Robbins struct l_rusage { 136ea0fabbcSTim J. Robbins l_timeval ru_utime; 137ea0fabbcSTim J. Robbins l_timeval ru_stime; 138ea0fabbcSTim J. Robbins l_long ru_maxrss; 139ea0fabbcSTim J. Robbins l_long ru_ixrss; 140ea0fabbcSTim J. Robbins l_long ru_idrss; 141ea0fabbcSTim J. Robbins l_long ru_isrss; 142ea0fabbcSTim J. Robbins l_long ru_minflt; 143ea0fabbcSTim J. Robbins l_long ru_majflt; 144ea0fabbcSTim J. Robbins l_long ru_nswap; 145ea0fabbcSTim J. Robbins l_long ru_inblock; 146ea0fabbcSTim J. Robbins l_long ru_oublock; 147ea0fabbcSTim J. Robbins l_long ru_msgsnd; 148ea0fabbcSTim J. Robbins l_long ru_msgrcv; 149ea0fabbcSTim J. Robbins l_long ru_nsignals; 150ea0fabbcSTim J. Robbins l_long ru_nvcsw; 151ea0fabbcSTim J. Robbins l_long ru_nivcsw; 15219593f77SDmitry Chagin }; 153ea0fabbcSTim J. Robbins 15410931a46SJung-uk Kim struct l_mmap_argv { 15510931a46SJung-uk Kim l_uintptr_t addr; 15610931a46SJung-uk Kim l_size_t len; 15710931a46SJung-uk Kim l_int prot; 15810931a46SJung-uk Kim l_int flags; 15910931a46SJung-uk Kim l_int fd; 1600af71035SDoug Ambrisko l_ulong pgoff; 1610af71035SDoug Ambrisko }; 16210931a46SJung-uk Kim 163ea0fabbcSTim J. Robbins /* 164ea0fabbcSTim J. Robbins * stat family of syscalls 165ea0fabbcSTim J. Robbins */ 166ea0fabbcSTim J. Robbins struct l_timespec { 16777424f41SJung-uk Kim l_time_t tv_sec; 16877424f41SJung-uk Kim l_long tv_nsec; 16919593f77SDmitry Chagin }; 170ea0fabbcSTim J. Robbins 171bfcce1a9SDmitry Chagin /* __kernel_timespec */ 172bfcce1a9SDmitry Chagin struct l_timespec64 { 173bfcce1a9SDmitry Chagin l_time64_t tv_sec; 174bfcce1a9SDmitry Chagin l_longlong tv_nsec; 175bfcce1a9SDmitry Chagin }; 176bfcce1a9SDmitry Chagin 177ea0fabbcSTim J. Robbins struct l_newstat { 178ea0fabbcSTim J. Robbins l_ushort st_dev; 179ea0fabbcSTim J. Robbins l_ushort __pad1; 180ea0fabbcSTim J. Robbins l_ulong st_ino; 181ea0fabbcSTim J. Robbins l_ushort st_mode; 182ea0fabbcSTim J. Robbins l_ushort st_nlink; 183ea0fabbcSTim J. Robbins l_ushort st_uid; 184ea0fabbcSTim J. Robbins l_ushort st_gid; 185ea0fabbcSTim J. Robbins l_ushort st_rdev; 186ea0fabbcSTim J. Robbins l_ushort __pad2; 187ea0fabbcSTim J. Robbins l_ulong st_size; 188ea0fabbcSTim J. Robbins l_ulong st_blksize; 189ea0fabbcSTim J. Robbins l_ulong st_blocks; 190510ea843SEd Schouten struct l_timespec st_atim; 191510ea843SEd Schouten struct l_timespec st_mtim; 192510ea843SEd Schouten struct l_timespec st_ctim; 193ea0fabbcSTim J. Robbins l_ulong __unused4; 194ea0fabbcSTim J. Robbins l_ulong __unused5; 19519593f77SDmitry Chagin }; 196ea0fabbcSTim J. Robbins 1971f7642e0SAlexander Leidinger struct l_stat { 1981f7642e0SAlexander Leidinger l_ushort st_dev; 1991f7642e0SAlexander Leidinger l_ulong st_ino; 2001f7642e0SAlexander Leidinger l_ushort st_mode; 2011f7642e0SAlexander Leidinger l_ushort st_nlink; 2021f7642e0SAlexander Leidinger l_ushort st_uid; 2031f7642e0SAlexander Leidinger l_ushort st_gid; 2041f7642e0SAlexander Leidinger l_ushort st_rdev; 2051f7642e0SAlexander Leidinger l_long st_size; 206510ea843SEd Schouten struct l_timespec st_atim; 207510ea843SEd Schouten struct l_timespec st_mtim; 208510ea843SEd Schouten struct l_timespec st_ctim; 2091f7642e0SAlexander Leidinger l_long st_blksize; 2101f7642e0SAlexander Leidinger l_long st_blocks; 2111f7642e0SAlexander Leidinger l_ulong st_flags; 2121f7642e0SAlexander Leidinger l_ulong st_gen; 2131f7642e0SAlexander Leidinger }; 2141f7642e0SAlexander Leidinger 215ea0fabbcSTim J. Robbins struct l_stat64 { 216ea0fabbcSTim J. Robbins l_ushort st_dev; 217ea0fabbcSTim J. Robbins u_char __pad0[10]; 218ea0fabbcSTim J. Robbins l_ulong __st_ino; 219ea0fabbcSTim J. Robbins l_uint st_mode; 220ea0fabbcSTim J. Robbins l_uint st_nlink; 221ea0fabbcSTim J. Robbins l_ulong st_uid; 222ea0fabbcSTim J. Robbins l_ulong st_gid; 223ea0fabbcSTim J. Robbins l_ushort st_rdev; 224ea0fabbcSTim J. Robbins u_char __pad3[10]; 225ea0fabbcSTim J. Robbins l_longlong st_size; 226ea0fabbcSTim J. Robbins l_ulong st_blksize; 227ea0fabbcSTim J. Robbins l_ulong st_blocks; 228ea0fabbcSTim J. Robbins l_ulong __pad4; 229510ea843SEd Schouten struct l_timespec st_atim; 230510ea843SEd Schouten struct l_timespec st_mtim; 231510ea843SEd Schouten struct l_timespec st_ctim; 232ea0fabbcSTim J. Robbins l_ulonglong st_ino; 233ea0fabbcSTim J. Robbins } __packed; 234ea0fabbcSTim J. Robbins 2353ab85269SDavid Malone struct l_statfs64 { 2363ab85269SDavid Malone l_int f_type; 2373ab85269SDavid Malone l_int f_bsize; 2383ab85269SDavid Malone uint64_t f_blocks; 2393ab85269SDavid Malone uint64_t f_bfree; 2403ab85269SDavid Malone uint64_t f_bavail; 2413ab85269SDavid Malone uint64_t f_files; 2423ab85269SDavid Malone uint64_t f_ffree; 2433ab85269SDavid Malone l_fsid_t f_fsid; 2443ab85269SDavid Malone l_int f_namelen; 245e801ac78SEdward Tomasz Napierala l_int f_frsize; 246e801ac78SEdward Tomasz Napierala l_int f_flags; 247e801ac78SEdward Tomasz Napierala l_int f_spare[4]; 2483ab85269SDavid Malone } __packed; 2493ab85269SDavid Malone 250ea0fabbcSTim J. Robbins /* sigaction flags */ 251ea0fabbcSTim J. Robbins #define LINUX_SA_NOCLDSTOP 0x00000001 252ea0fabbcSTim J. Robbins #define LINUX_SA_NOCLDWAIT 0x00000002 253ea0fabbcSTim J. Robbins #define LINUX_SA_SIGINFO 0x00000004 254ea0fabbcSTim J. Robbins #define LINUX_SA_RESTORER 0x04000000 255ea0fabbcSTim J. Robbins #define LINUX_SA_ONSTACK 0x08000000 256ea0fabbcSTim J. Robbins #define LINUX_SA_RESTART 0x10000000 257ea0fabbcSTim J. Robbins #define LINUX_SA_INTERRUPT 0x20000000 258ea0fabbcSTim J. Robbins #define LINUX_SA_NOMASK 0x40000000 259ea0fabbcSTim J. Robbins #define LINUX_SA_ONESHOT 0x80000000 260ea0fabbcSTim J. Robbins 261ea0fabbcSTim J. Robbins /* sigprocmask actions */ 262ea0fabbcSTim J. Robbins #define LINUX_SIG_BLOCK 0 263ea0fabbcSTim J. Robbins #define LINUX_SIG_UNBLOCK 1 264ea0fabbcSTim J. Robbins #define LINUX_SIG_SETMASK 2 265ea0fabbcSTim J. Robbins 266ea0fabbcSTim J. Robbins /* sigaltstack */ 267ea0fabbcSTim J. Robbins #define LINUX_MINSIGSTKSZ 2048 268ea0fabbcSTim J. Robbins 269ea0fabbcSTim J. Robbins typedef l_uintptr_t l_handler_t; 270ea0fabbcSTim J. Robbins typedef l_ulong l_osigset_t; 271ea0fabbcSTim J. Robbins 272ea0fabbcSTim J. Robbins typedef struct { 273ea0fabbcSTim J. Robbins l_handler_t lsa_handler; 274ea0fabbcSTim J. Robbins l_osigset_t lsa_mask; 275ea0fabbcSTim J. Robbins l_ulong lsa_flags; 276ea0fabbcSTim J. Robbins l_uintptr_t lsa_restorer; 27719593f77SDmitry Chagin } l_osigaction_t; 278ea0fabbcSTim J. Robbins 279ea0fabbcSTim J. Robbins typedef struct { 280ea0fabbcSTim J. Robbins l_handler_t lsa_handler; 281ea0fabbcSTim J. Robbins l_ulong lsa_flags; 282ea0fabbcSTim J. Robbins l_uintptr_t lsa_restorer; 283ea0fabbcSTim J. Robbins l_sigset_t lsa_mask; 284ea0fabbcSTim J. Robbins } __packed l_sigaction_t; 285ea0fabbcSTim J. Robbins 286ea0fabbcSTim J. Robbins typedef struct { 287ea0fabbcSTim J. Robbins l_uintptr_t ss_sp; 288ea0fabbcSTim J. Robbins l_int ss_flags; 289ea0fabbcSTim J. Robbins l_size_t ss_size; 29019593f77SDmitry Chagin } l_stack_t; 291ea0fabbcSTim J. Robbins 292ea0fabbcSTim J. Robbins /* 2934d0f380dSDmitry Chagin * arch specific open/fcntl flags 294ea0fabbcSTim J. Robbins */ 295ea0fabbcSTim J. Robbins #define LINUX_F_GETLK64 12 296ea0fabbcSTim J. Robbins #define LINUX_F_SETLK64 13 297ea0fabbcSTim J. Robbins #define LINUX_F_SETLKW64 14 298ea0fabbcSTim J. Robbins 299ea0fabbcSTim J. Robbins union l_semun { 300ea0fabbcSTim J. Robbins l_int val; 301ea0fabbcSTim J. Robbins l_uintptr_t buf; 302ea0fabbcSTim J. Robbins l_uintptr_t array; 303ea0fabbcSTim J. Robbins l_uintptr_t __buf; 304ea0fabbcSTim J. Robbins l_uintptr_t __pad; 30519593f77SDmitry Chagin }; 306ea0fabbcSTim J. Robbins 307ea0fabbcSTim J. Robbins struct l_ifmap { 308ea0fabbcSTim J. Robbins l_ulong mem_start; 309ea0fabbcSTim J. Robbins l_ulong mem_end; 310ea0fabbcSTim J. Robbins l_ushort base_addr; 311ea0fabbcSTim J. Robbins u_char irq; 312ea0fabbcSTim J. Robbins u_char dma; 313ea0fabbcSTim J. Robbins u_char port; 31419593f77SDmitry Chagin /* 3 bytes spare */ 31519593f77SDmitry Chagin }; 316ea0fabbcSTim J. Robbins 317ea0fabbcSTim J. Robbins struct l_ifreq { 318ea0fabbcSTim J. Robbins union { 319ea0fabbcSTim J. Robbins char ifrn_name[LINUX_IFNAMSIZ]; 320ea0fabbcSTim J. Robbins } ifr_ifrn; 321ea0fabbcSTim J. Robbins 322ea0fabbcSTim J. Robbins union { 323ea0fabbcSTim J. Robbins struct l_sockaddr ifru_addr; 324ea0fabbcSTim J. Robbins struct l_sockaddr ifru_dstaddr; 325ea0fabbcSTim J. Robbins struct l_sockaddr ifru_broadaddr; 326ea0fabbcSTim J. Robbins struct l_sockaddr ifru_netmask; 327ea0fabbcSTim J. Robbins struct l_sockaddr ifru_hwaddr; 328ea0fabbcSTim J. Robbins l_short ifru_flags[1]; 3297ece126eSTai-hwa Liang l_int ifru_ivalue; 330ea0fabbcSTim J. Robbins l_int ifru_mtu; 331ea0fabbcSTim J. Robbins struct l_ifmap ifru_map; 332ea0fabbcSTim J. Robbins char ifru_slave[LINUX_IFNAMSIZ]; 333ea0fabbcSTim J. Robbins l_uintptr_t ifru_data; 334ea0fabbcSTim J. Robbins } ifr_ifru; 33519593f77SDmitry Chagin }; 336ea0fabbcSTim J. Robbins 337a4e3bad7SJung-uk Kim #define ifr_name ifr_ifrn.ifrn_name /* Interface name */ 338ea0fabbcSTim J. Robbins #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ 3397ece126eSTai-hwa Liang #define ifr_ifindex ifr_ifru.ifru_ivalue /* Interface index */ 340ea0fabbcSTim J. Robbins 341ea0fabbcSTim J. Robbins struct l_ifconf { 342ea0fabbcSTim J. Robbins int ifc_len; 343ea0fabbcSTim J. Robbins union { 344ea0fabbcSTim J. Robbins l_uintptr_t ifcu_buf; 345ea0fabbcSTim J. Robbins l_uintptr_t ifcu_req; 346ea0fabbcSTim J. Robbins } ifc_ifcu; 34719593f77SDmitry Chagin }; 348ea0fabbcSTim J. Robbins 349ea0fabbcSTim J. Robbins #define ifc_buf ifc_ifcu.ifcu_buf 350ea0fabbcSTim J. Robbins #define ifc_req ifc_ifcu.ifcu_req 351ea0fabbcSTim J. Robbins 3529b44bfc5SAlexander Leidinger struct l_user_desc { 3539b44bfc5SAlexander Leidinger l_uint entry_number; 3549b44bfc5SAlexander Leidinger l_uint base_addr; 3559b44bfc5SAlexander Leidinger l_uint limit; 3569b44bfc5SAlexander Leidinger l_uint seg_32bit:1; 3579b44bfc5SAlexander Leidinger l_uint contents:2; 3589b44bfc5SAlexander Leidinger l_uint read_exec_only:1; 3599b44bfc5SAlexander Leidinger l_uint limit_in_pages:1; 3609b44bfc5SAlexander Leidinger l_uint seg_not_present:1; 3619b44bfc5SAlexander Leidinger l_uint useable:1; 3629b44bfc5SAlexander Leidinger }; 3639b44bfc5SAlexander Leidinger 3649b44bfc5SAlexander Leidinger #define LINUX_LOWERWORD 0x0000ffff 3659b44bfc5SAlexander Leidinger 3660eef2f8aSAlexander Leidinger /* 367a4e3bad7SJung-uk Kim * Macros which does the same thing as those in Linux include/asm-um/ldt-i386.h. 368a4e3bad7SJung-uk Kim * These convert Linux user space descriptor to machine one. 3699b44bfc5SAlexander Leidinger */ 370a4e3bad7SJung-uk Kim #define LINUX_LDT_entry_a(info) \ 371a4e3bad7SJung-uk Kim ((((info)->base_addr & LINUX_LOWERWORD) << 16) | \ 372a4e3bad7SJung-uk Kim ((info)->limit & LINUX_LOWERWORD)) 3739b44bfc5SAlexander Leidinger 374a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_READ_EXEC_ONLY 9 375a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_CONTENTS 10 376a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_SEG_NOT_PRESENT 15 377a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_BASE_ADDR 16 378a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_USEABLE 20 379a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_SEG32BIT 22 380a4e3bad7SJung-uk Kim #define LINUX_ENTRY_B_LIMIT 23 3819b44bfc5SAlexander Leidinger 382a4e3bad7SJung-uk Kim #define LINUX_LDT_entry_b(info) \ 3839b44bfc5SAlexander Leidinger (((info)->base_addr & 0xff000000) | \ 3849b44bfc5SAlexander Leidinger ((info)->limit & 0xf0000) | \ 385a4e3bad7SJung-uk Kim ((info)->contents << LINUX_ENTRY_B_CONTENTS) | \ 386a4e3bad7SJung-uk Kim (((info)->seg_not_present == 0) << LINUX_ENTRY_B_SEG_NOT_PRESENT) | \ 387a4e3bad7SJung-uk Kim (((info)->base_addr & 0x00ff0000) >> LINUX_ENTRY_B_BASE_ADDR) | \ 388a4e3bad7SJung-uk Kim (((info)->read_exec_only == 0) << LINUX_ENTRY_B_READ_EXEC_ONLY) | \ 389a4e3bad7SJung-uk Kim ((info)->seg_32bit << LINUX_ENTRY_B_SEG32BIT) | \ 390a4e3bad7SJung-uk Kim ((info)->useable << LINUX_ENTRY_B_USEABLE) | \ 391a4e3bad7SJung-uk Kim ((info)->limit_in_pages << LINUX_ENTRY_B_LIMIT) | 0x7000) 3929b44bfc5SAlexander Leidinger 393a4e3bad7SJung-uk Kim #define LINUX_LDT_empty(info) \ 394a4e3bad7SJung-uk Kim ((info)->base_addr == 0 && \ 3959b44bfc5SAlexander Leidinger (info)->limit == 0 && \ 3969b44bfc5SAlexander Leidinger (info)->contents == 0 && \ 3979b44bfc5SAlexander Leidinger (info)->seg_not_present == 1 && \ 3989b44bfc5SAlexander Leidinger (info)->read_exec_only == 1 && \ 3999b44bfc5SAlexander Leidinger (info)->seg_32bit == 0 && \ 4009b44bfc5SAlexander Leidinger (info)->limit_in_pages == 0 && \ 4019b44bfc5SAlexander Leidinger (info)->useable == 0) 4029b44bfc5SAlexander Leidinger 403a4e3bad7SJung-uk Kim /* 404a4e3bad7SJung-uk Kim * Macros for converting segments. 405a4e3bad7SJung-uk Kim * They do the same as those in arch/i386/kernel/process.c in Linux. 406a4e3bad7SJung-uk Kim */ 407a4e3bad7SJung-uk Kim #define LINUX_GET_BASE(desc) \ 408a4e3bad7SJung-uk Kim ((((desc)->a >> 16) & LINUX_LOWERWORD) | \ 4099b44bfc5SAlexander Leidinger (((desc)->b << 16) & 0x00ff0000) | \ 4109b44bfc5SAlexander Leidinger ((desc)->b & 0xff000000)) 4119b44bfc5SAlexander Leidinger 412a4e3bad7SJung-uk Kim #define LINUX_GET_LIMIT(desc) \ 413a4e3bad7SJung-uk Kim (((desc)->a & LINUX_LOWERWORD) | \ 4149b44bfc5SAlexander Leidinger ((desc)->b & 0xf0000)) 4159b44bfc5SAlexander Leidinger 416a4e3bad7SJung-uk Kim #define LINUX_GET_32BIT(desc) \ 417a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_SEG32BIT) & 1) 418a4e3bad7SJung-uk Kim #define LINUX_GET_CONTENTS(desc) \ 419a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_CONTENTS) & 3) 420a4e3bad7SJung-uk Kim #define LINUX_GET_WRITABLE(desc) \ 421a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_READ_EXEC_ONLY) & 1) 422a4e3bad7SJung-uk Kim #define LINUX_GET_LIMIT_PAGES(desc) \ 423a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_LIMIT) & 1) 424a4e3bad7SJung-uk Kim #define LINUX_GET_PRESENT(desc) \ 425a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_SEG_NOT_PRESENT) & 1) 426a4e3bad7SJung-uk Kim #define LINUX_GET_USEABLE(desc) \ 427a4e3bad7SJung-uk Kim (((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1) 4289b44bfc5SAlexander Leidinger 42941f53a36SKonstantin Belousov struct iovec; 430bd911530SMahdi Mokhtari struct uio; 43141f53a36SKonstantin Belousov 43241f53a36SKonstantin Belousov struct l_iovec32 { 43341f53a36SKonstantin Belousov uint32_t iov_base; 43441f53a36SKonstantin Belousov l_size_t iov_len; 43541f53a36SKonstantin Belousov }; 43641f53a36SKonstantin Belousov 43741f53a36SKonstantin Belousov int linux32_copyiniov(struct l_iovec32 *iovp32, l_ulong iovcnt, 43841f53a36SKonstantin Belousov struct iovec **iovp, int error); 439bd911530SMahdi Mokhtari int linux32_copyinuio(struct l_iovec32 *iovp, l_ulong iovcnt, 440bd911530SMahdi Mokhtari struct uio **uiop); 441001398c4SDmitry Chagin int linux_copyout_rusage(struct rusage *ru, void *uaddr); 44241f53a36SKonstantin Belousov 443175c6c31SKonstantin Belousov /* robust futexes */ 444175c6c31SKonstantin Belousov struct linux_robust_list { 445175c6c31SKonstantin Belousov l_uintptr_t next; 446175c6c31SKonstantin Belousov }; 447175c6c31SKonstantin Belousov 448175c6c31SKonstantin Belousov struct linux_robust_list_head { 449175c6c31SKonstantin Belousov struct linux_robust_list list; 45062162dfcSKonstantin Belousov l_long futex_offset; 451175c6c31SKonstantin Belousov l_uintptr_t pending_list; 452175c6c31SKonstantin Belousov }; 453175c6c31SKonstantin Belousov 45495c19e1dSEdward Tomasz Napierala /* This corresponds to 'struct user_regs_struct32' in Linux. */ 45595c19e1dSEdward Tomasz Napierala struct linux_pt_regset32 { 45695c19e1dSEdward Tomasz Napierala l_uint ebx; 45795c19e1dSEdward Tomasz Napierala l_uint ecx; 45895c19e1dSEdward Tomasz Napierala l_uint edx; 45995c19e1dSEdward Tomasz Napierala l_uint esi; 46095c19e1dSEdward Tomasz Napierala l_uint edi; 46195c19e1dSEdward Tomasz Napierala l_uint ebp; 46295c19e1dSEdward Tomasz Napierala l_uint eax; 46395c19e1dSEdward Tomasz Napierala l_uint ds; 46495c19e1dSEdward Tomasz Napierala l_uint es; 46595c19e1dSEdward Tomasz Napierala l_uint fs; 46695c19e1dSEdward Tomasz Napierala l_uint gs; 46795c19e1dSEdward Tomasz Napierala l_uint orig_eax; 46895c19e1dSEdward Tomasz Napierala l_uint eip; 46995c19e1dSEdward Tomasz Napierala l_uint cs; 47095c19e1dSEdward Tomasz Napierala l_uint eflags; 47195c19e1dSEdward Tomasz Napierala l_uint esp; 47295c19e1dSEdward Tomasz Napierala l_uint ss; 47395c19e1dSEdward Tomasz Napierala }; 47495c19e1dSEdward Tomasz Napierala 47595c19e1dSEdward Tomasz Napierala struct reg32; 47695c19e1dSEdward Tomasz Napierala 4773417c298SEdward Tomasz Napierala void bsd_to_linux_regset32(const struct reg32 *b_reg, 47895c19e1dSEdward Tomasz Napierala struct linux_pt_regset32 *l_regset); 47995c19e1dSEdward Tomasz Napierala 480d5dc757eSDmitry Chagin extern bool linux32_emulate_i386; 481d5dc757eSDmitry Chagin 482a4e3bad7SJung-uk Kim #endif /* !_AMD64_LINUX_H_ */ 483