1e248c237SEd Maste /*- 2e248c237SEd Maste * Copyright (c) 1994-1996 Søren Schmidt 31ca6b15bSDmitry Chagin * Copyright (c) 2013 Dmitry Chagin <dchagin@FreeBSD.org> 4e248c237SEd Maste * Copyright (c) 2018 Turing Robotic Industries Inc. 5e248c237SEd Maste * 6e248c237SEd Maste * Redistribution and use in source and binary forms, with or without 7e248c237SEd Maste * modification, are permitted provided that the following conditions 8e248c237SEd Maste * are met: 9e248c237SEd Maste * 1. Redistributions of source code must retain the above copyright 10e248c237SEd Maste * notice, this list of conditions and the following disclaimer. 11e248c237SEd Maste * 2. Redistributions in binary form must reproduce the above copyright 12e248c237SEd Maste * notice, this list of conditions and the following disclaimer in the 13e248c237SEd Maste * documentation and/or other materials provided with the distribution. 14e248c237SEd Maste * 15e248c237SEd Maste * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16e248c237SEd Maste * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17e248c237SEd Maste * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18e248c237SEd Maste * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19e248c237SEd Maste * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20e248c237SEd Maste * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21e248c237SEd Maste * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22e248c237SEd Maste * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23e248c237SEd Maste * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24e248c237SEd Maste * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25e248c237SEd Maste * SUCH DAMAGE. 26e248c237SEd Maste */ 27e248c237SEd Maste 28e248c237SEd Maste /* 29e248c237SEd Maste * $FreeBSD$ 30e248c237SEd Maste */ 31e248c237SEd Maste #ifndef _ARM64_LINUX_H_ 32e248c237SEd Maste #define _ARM64_LINUX_H_ 33e248c237SEd Maste 34562894f0SBrooks Davis #include <sys/abi_compat.h> 35562894f0SBrooks Davis 36e248c237SEd Maste #include <compat/linux/linux.h> 37e248c237SEd Maste #include <arm64/linux/linux_syscall.h> 38e248c237SEd Maste 39e248c237SEd Maste #define LINUX_DTRACE linuxulator 40e248c237SEd Maste 41e248c237SEd Maste /* Provide a separate set of types for the Linux types */ 42e248c237SEd Maste typedef int32_t l_int; 43e248c237SEd Maste typedef int64_t l_long; 44e248c237SEd Maste typedef int16_t l_short; 45e248c237SEd Maste typedef uint32_t l_uint; 46e248c237SEd Maste typedef uint64_t l_ulong; 47e248c237SEd Maste typedef uint16_t l_ushort; 48e248c237SEd Maste 49e248c237SEd Maste typedef l_ulong l_uintptr_t; 50e248c237SEd Maste typedef l_long l_clock_t; 51e248c237SEd Maste typedef l_int l_daddr_t; 52e248c237SEd Maste typedef l_ulong l_dev_t; 53e248c237SEd Maste typedef l_uint l_gid_t; 54e248c237SEd Maste typedef l_ushort l_gid16_t; /* XXX */ 55e248c237SEd Maste typedef l_uint l_uid_t; 56e248c237SEd Maste typedef l_ushort l_uid16_t; /* XXX */ 57e248c237SEd Maste typedef l_ulong l_ino_t; 58e248c237SEd Maste typedef l_int l_key_t; 59e248c237SEd Maste typedef l_long l_loff_t; 60e248c237SEd Maste typedef l_uint l_mode_t; 61e248c237SEd Maste typedef l_long l_off_t; 62e248c237SEd Maste typedef l_int l_pid_t; 63e248c237SEd Maste typedef l_ulong l_size_t; 64e248c237SEd Maste typedef l_long l_suseconds_t; 65e248c237SEd Maste typedef l_long l_time_t; 66e248c237SEd Maste typedef l_int l_timer_t; /* XXX */ 67308e194cSEdward Tomasz Napierala typedef l_int l_mqd_t; 68e248c237SEd Maste typedef l_ulong l_fd_mask; 69e248c237SEd Maste 70e248c237SEd Maste typedef struct { 71e248c237SEd Maste l_int val[2]; 72e248c237SEd Maste } l_fsid_t; 73e248c237SEd Maste 74e248c237SEd Maste typedef struct { 75e248c237SEd Maste l_time_t tv_sec; 76e248c237SEd Maste l_suseconds_t tv_usec; 77e248c237SEd Maste } l_timeval; 78e248c237SEd Maste 79e248c237SEd Maste #define l_fd_set fd_set 80e248c237SEd Maste 81e248c237SEd Maste /* Miscellaneous */ 82e248c237SEd Maste #define LINUX_AT_COUNT 20 83e248c237SEd Maste 84e248c237SEd Maste struct l___sysctl_args 85e248c237SEd Maste { 86e248c237SEd Maste l_uintptr_t name; 87e248c237SEd Maste l_int nlen; 88e248c237SEd Maste l_uintptr_t oldval; 89e248c237SEd Maste l_uintptr_t oldlenp; 90e248c237SEd Maste l_uintptr_t newval; 91e248c237SEd Maste l_uintptr_t newlen; 92e248c237SEd Maste l_ulong __spare[4]; 93e248c237SEd Maste }; 94e248c237SEd Maste 95e248c237SEd Maste /* Resource limits */ 96e248c237SEd Maste #define LINUX_RLIMIT_CPU 0 97e248c237SEd Maste #define LINUX_RLIMIT_FSIZE 1 98e248c237SEd Maste #define LINUX_RLIMIT_DATA 2 99e248c237SEd Maste #define LINUX_RLIMIT_STACK 3 100e248c237SEd Maste #define LINUX_RLIMIT_CORE 4 101e248c237SEd Maste #define LINUX_RLIMIT_RSS 5 102e248c237SEd Maste #define LINUX_RLIMIT_NPROC 6 103e248c237SEd Maste #define LINUX_RLIMIT_NOFILE 7 104e248c237SEd Maste #define LINUX_RLIMIT_MEMLOCK 8 105e248c237SEd Maste #define LINUX_RLIMIT_AS 9 /* Address space limit */ 106e248c237SEd Maste 107e248c237SEd Maste #define LINUX_RLIM_NLIMITS 10 108e248c237SEd Maste 109e248c237SEd Maste struct l_rlimit { 110e248c237SEd Maste l_ulong rlim_cur; 111e248c237SEd Maste l_ulong rlim_max; 112e248c237SEd Maste }; 113e248c237SEd Maste 114e248c237SEd Maste /* stat family of syscalls */ 115e248c237SEd Maste struct l_timespec { 116e248c237SEd Maste l_time_t tv_sec; 117e248c237SEd Maste l_long tv_nsec; 118e248c237SEd Maste }; 119e248c237SEd Maste 120e248c237SEd Maste struct l_newstat { 121e248c237SEd Maste l_dev_t st_dev; 122e248c237SEd Maste l_ino_t st_ino; 123e248c237SEd Maste l_uint st_mode; 124e248c237SEd Maste l_uint st_nlink; 125e248c237SEd Maste 126e248c237SEd Maste l_uid_t st_uid; 127e248c237SEd Maste l_gid_t st_gid; 128e248c237SEd Maste 129e248c237SEd Maste l_dev_t st_rdev; 130e248c237SEd Maste l_ulong __st_pad1; 131e248c237SEd Maste l_off_t st_size; 132e248c237SEd Maste l_int st_blksize; 133e248c237SEd Maste l_int __st_pad2; 134e248c237SEd Maste l_long st_blocks; 135e248c237SEd Maste 136e248c237SEd Maste struct l_timespec st_atim; 137e248c237SEd Maste struct l_timespec st_mtim; 138e248c237SEd Maste struct l_timespec st_ctim; 139e248c237SEd Maste l_uint __unused1; 140e248c237SEd Maste l_uint __unused2; 141e248c237SEd Maste }; 142e248c237SEd Maste 143e248c237SEd Maste /* sigaction flags */ 144e248c237SEd Maste #define LINUX_SA_NOCLDSTOP 0x00000001 145e248c237SEd Maste #define LINUX_SA_NOCLDWAIT 0x00000002 146e248c237SEd Maste #define LINUX_SA_SIGINFO 0x00000004 147e248c237SEd Maste #define LINUX_SA_RESTORER 0x04000000 148e248c237SEd Maste #define LINUX_SA_ONSTACK 0x08000000 149e248c237SEd Maste #define LINUX_SA_RESTART 0x10000000 150e248c237SEd Maste #define LINUX_SA_INTERRUPT 0x20000000 /* XXX */ 151e248c237SEd Maste #define LINUX_SA_NOMASK 0x40000000 /* SA_NODEFER */ 152e248c237SEd Maste #define LINUX_SA_ONESHOT 0x80000000 /* SA_RESETHAND */ 153e248c237SEd Maste 154e248c237SEd Maste /* sigprocmask actions */ 155e248c237SEd Maste #define LINUX_SIG_BLOCK 0 156e248c237SEd Maste #define LINUX_SIG_UNBLOCK 1 157e248c237SEd Maste #define LINUX_SIG_SETMASK 2 158e248c237SEd Maste 159e248c237SEd Maste /* sigaltstack */ 160e248c237SEd Maste #define LINUX_MINSIGSTKSZ 2048 /* XXX */ 161e248c237SEd Maste 162e248c237SEd Maste typedef void (*l_handler_t)(l_int); 163e248c237SEd Maste 164e248c237SEd Maste typedef struct { 165e248c237SEd Maste l_handler_t lsa_handler; 166e248c237SEd Maste l_ulong lsa_flags; 167e248c237SEd Maste l_uintptr_t lsa_restorer; 16895e1f42eSMitchell Horne l_sigset_t lsa_mask; 169e248c237SEd Maste } l_sigaction_t; /* XXX */ 170e248c237SEd Maste 171e248c237SEd Maste typedef struct { 172e248c237SEd Maste l_uintptr_t ss_sp; 173e248c237SEd Maste l_int ss_flags; 174e248c237SEd Maste l_size_t ss_size; 175e248c237SEd Maste } l_stack_t; 176e248c237SEd Maste 177e248c237SEd Maste #define LINUX_SI_PREAMBLE_SIZE (4 * sizeof(int)) 178e248c237SEd Maste #define LINUX_SI_MAX_SIZE 128 179e248c237SEd Maste #define LINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE - \ 180e248c237SEd Maste LINUX_SI_PREAMBLE_SIZE) / sizeof(l_int)) 181e248c237SEd Maste typedef union l_sigval { 182e248c237SEd Maste l_int sival_int; 183e248c237SEd Maste l_uintptr_t sival_ptr; 184e248c237SEd Maste } l_sigval_t; 185e248c237SEd Maste 186e248c237SEd Maste typedef struct l_siginfo { 187e248c237SEd Maste l_int lsi_signo; 188e248c237SEd Maste l_int lsi_errno; 189e248c237SEd Maste l_int lsi_code; 190e248c237SEd Maste union { 191e248c237SEd Maste l_int _pad[LINUX_SI_PAD_SIZE]; 192e248c237SEd Maste 193e248c237SEd Maste struct { 194e248c237SEd Maste l_pid_t _pid; 195e248c237SEd Maste l_uid_t _uid; 196e248c237SEd Maste } _kill; 197e248c237SEd Maste 198e248c237SEd Maste struct { 199e248c237SEd Maste l_timer_t _tid; 200e248c237SEd Maste l_int _overrun; 201e248c237SEd Maste char _pad[sizeof(l_uid_t) - sizeof(int)]; 202e248c237SEd Maste union l_sigval _sigval; 203e248c237SEd Maste l_uint _sys_private; 204e248c237SEd Maste } _timer; 205e248c237SEd Maste 206e248c237SEd Maste struct { 207e248c237SEd Maste l_pid_t _pid; /* sender's pid */ 208e248c237SEd Maste l_uid_t _uid; /* sender's uid */ 209e248c237SEd Maste union l_sigval _sigval; 210e248c237SEd Maste } _rt; 211e248c237SEd Maste 212e248c237SEd Maste struct { 213e248c237SEd Maste l_pid_t _pid; /* which child */ 214e248c237SEd Maste l_uid_t _uid; /* sender's uid */ 215e248c237SEd Maste l_int _status; /* exit code */ 216e248c237SEd Maste l_clock_t _utime; 217e248c237SEd Maste l_clock_t _stime; 218e248c237SEd Maste } _sigchld; 219e248c237SEd Maste 220e248c237SEd Maste struct { 221e248c237SEd Maste l_uintptr_t _addr; /* Faulting insn/memory ref. */ 222e248c237SEd Maste } _sigfault; 223e248c237SEd Maste 224e248c237SEd Maste struct { 225e248c237SEd Maste l_long _band; /* POLL_IN,POLL_OUT,POLL_MSG */ 226e248c237SEd Maste l_int _fd; 227e248c237SEd Maste } _sigpoll; 228e248c237SEd Maste } _sifields; 229e248c237SEd Maste } l_siginfo_t; 230e248c237SEd Maste 231e248c237SEd Maste #define lsi_pid _sifields._kill._pid 232e248c237SEd Maste #define lsi_uid _sifields._kill._uid 233e248c237SEd Maste #define lsi_tid _sifields._timer._tid 234e248c237SEd Maste #define lsi_overrun _sifields._timer._overrun 235e248c237SEd Maste #define lsi_sys_private _sifields._timer._sys_private 236e248c237SEd Maste #define lsi_status _sifields._sigchld._status 237e248c237SEd Maste #define lsi_utime _sifields._sigchld._utime 238e248c237SEd Maste #define lsi_stime _sifields._sigchld._stime 239e248c237SEd Maste #define lsi_value _sifields._rt._sigval 240e248c237SEd Maste #define lsi_int _sifields._rt._sigval.sival_int 241e248c237SEd Maste #define lsi_ptr _sifields._rt._sigval.sival_ptr 242e248c237SEd Maste #define lsi_addr _sifields._sigfault._addr 243e248c237SEd Maste #define lsi_band _sifields._sigpoll._band 244e248c237SEd Maste #define lsi_fd _sifields._sigpoll._fd 245e248c237SEd Maste 246e248c237SEd Maste union l_semun { 247e248c237SEd Maste l_int val; 248e248c237SEd Maste l_uintptr_t buf; 249e248c237SEd Maste l_uintptr_t array; 250e248c237SEd Maste l_uintptr_t __buf; 251e248c237SEd Maste l_uintptr_t __pad; 252e248c237SEd Maste }; 253e248c237SEd Maste 254e248c237SEd Maste struct l_ifmap { 255e248c237SEd Maste l_ulong mem_start; 256e248c237SEd Maste l_ulong mem_end; 257e248c237SEd Maste l_ushort base_addr; 258e248c237SEd Maste u_char irq; 259e248c237SEd Maste u_char dma; 260e248c237SEd Maste u_char port; 26119593f77SDmitry Chagin /* 3 bytes spare*/ 26219593f77SDmitry Chagin }; 263e248c237SEd Maste 264e248c237SEd Maste struct l_ifreq { 265e248c237SEd Maste union { 266e248c237SEd Maste char ifrn_name[LINUX_IFNAMSIZ]; 267e248c237SEd Maste } ifr_ifrn; 268e248c237SEd Maste 269e248c237SEd Maste union { 270e248c237SEd Maste struct l_sockaddr ifru_addr; 271e248c237SEd Maste struct l_sockaddr ifru_dstaddr; 272e248c237SEd Maste struct l_sockaddr ifru_broadaddr; 273e248c237SEd Maste struct l_sockaddr ifru_netmask; 274e248c237SEd Maste struct l_sockaddr ifru_hwaddr; 275e248c237SEd Maste l_short ifru_flags[1]; 276e248c237SEd Maste l_int ifru_ivalue; 277e248c237SEd Maste l_int ifru_mtu; 278e248c237SEd Maste struct l_ifmap ifru_map; 279e248c237SEd Maste char ifru_slave[LINUX_IFNAMSIZ]; 280e248c237SEd Maste l_uintptr_t ifru_data; 281e248c237SEd Maste } ifr_ifru; 28219593f77SDmitry Chagin }; 283e248c237SEd Maste 284e248c237SEd Maste #define ifr_name ifr_ifrn.ifrn_name /* Interface name */ 285e248c237SEd Maste #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ 286e248c237SEd Maste #define ifr_ifindex ifr_ifru.ifru_ivalue /* Interface index */ 287e248c237SEd Maste 288e248c237SEd Maste #define linux_copyout_rusage(r, u) copyout(r, u, sizeof(*r)) 289e248c237SEd Maste 290e248c237SEd Maste /* robust futexes */ 291e248c237SEd Maste struct linux_robust_list { 292e248c237SEd Maste l_uintptr_t next; 293e248c237SEd Maste }; 294e248c237SEd Maste 295e248c237SEd Maste struct linux_robust_list_head { 296e248c237SEd Maste struct linux_robust_list list; 297e248c237SEd Maste l_long futex_offset; 298e248c237SEd Maste l_uintptr_t pending_list; 299e248c237SEd Maste }; 300e248c237SEd Maste 30145d99014SEdward Tomasz Napierala struct linux_pt_regset { 30245d99014SEdward Tomasz Napierala l_ulong x[31]; 30345d99014SEdward Tomasz Napierala l_ulong sp; 30445d99014SEdward Tomasz Napierala l_ulong pc; 30545d99014SEdward Tomasz Napierala l_ulong cpsr; 30645d99014SEdward Tomasz Napierala }; 30745d99014SEdward Tomasz Napierala 30845d99014SEdward Tomasz Napierala struct reg; 30945d99014SEdward Tomasz Napierala 31045d99014SEdward Tomasz Napierala void bsd_to_linux_regset(struct reg *b_reg, 31145d99014SEdward Tomasz Napierala struct linux_pt_regset *l_regset); 31245d99014SEdward Tomasz Napierala 313e248c237SEd Maste #endif /* _ARM64_LINUX_H_ */ 314