1 /*- 2 * Copyright (c) 1994-1996 Søren Schmidt 3 * Copyright (c) 2013 Dmitry Chagin <dchagin@FreeBSD.org> 4 * Copyright (c) 2018 Turing Robotic Industries Inc. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28 /* 29 */ 30 #ifndef _ARM64_LINUX_H_ 31 #define _ARM64_LINUX_H_ 32 33 #include <sys/abi_compat.h> 34 35 #include <compat/linux/linux.h> 36 #include <arm64/linux/linux_syscall.h> 37 38 #define LINUX_DTRACE linuxulator 39 40 /* Provide a separate set of types for the Linux types */ 41 typedef int32_t l_int; 42 typedef int64_t l_long; 43 typedef int16_t l_short; 44 typedef uint32_t l_uint; 45 typedef uint64_t l_ulong; 46 typedef uint16_t l_ushort; 47 48 typedef l_ulong l_uintptr_t; 49 typedef l_long l_clock_t; 50 typedef l_int l_daddr_t; 51 typedef l_uint l_gid_t; 52 typedef l_ushort l_gid16_t; /* XXX */ 53 typedef l_uint l_uid_t; 54 typedef l_ushort l_uid16_t; /* XXX */ 55 typedef l_ulong l_ino_t; 56 typedef l_int l_key_t; 57 typedef l_long l_loff_t; 58 typedef l_uint l_mode_t; 59 typedef l_long l_off_t; 60 typedef l_int l_pid_t; 61 typedef l_ulong l_size_t; 62 typedef l_long l_suseconds_t; 63 typedef l_long l_time_t; 64 typedef l_int l_timer_t; /* XXX */ 65 typedef l_int l_mqd_t; 66 typedef l_ulong l_fd_mask; 67 68 #include <compat/linux/linux_siginfo.h> 69 70 typedef struct { 71 l_int val[2]; 72 } l_fsid_t; 73 74 typedef struct { 75 l_time_t tv_sec; 76 l_suseconds_t tv_usec; 77 } l_timeval; 78 79 #define l_fd_set fd_set 80 81 /* Miscellaneous */ 82 #define LINUX_AT_COUNT 21 /* Count of used aux entry types. 83 * Keep this synchronized with 84 * linux_copyout_auxargs() code. 85 */ 86 87 struct l___sysctl_args 88 { 89 l_uintptr_t name; 90 l_int nlen; 91 l_uintptr_t oldval; 92 l_uintptr_t oldlenp; 93 l_uintptr_t newval; 94 l_uintptr_t newlen; 95 l_ulong __spare[4]; 96 }; 97 98 /* Resource limits */ 99 #define LINUX_RLIMIT_CPU 0 100 #define LINUX_RLIMIT_FSIZE 1 101 #define LINUX_RLIMIT_DATA 2 102 #define LINUX_RLIMIT_STACK 3 103 #define LINUX_RLIMIT_CORE 4 104 #define LINUX_RLIMIT_RSS 5 105 #define LINUX_RLIMIT_NPROC 6 106 #define LINUX_RLIMIT_NOFILE 7 107 #define LINUX_RLIMIT_MEMLOCK 8 108 #define LINUX_RLIMIT_AS 9 /* Address space limit */ 109 110 #define LINUX_RLIM_NLIMITS 10 111 112 struct l_rlimit { 113 l_ulong rlim_cur; 114 l_ulong rlim_max; 115 }; 116 117 /* stat family of syscalls */ 118 struct l_timespec { 119 l_time_t tv_sec; 120 l_long tv_nsec; 121 }; 122 123 #define LINUX_O_DIRECTORY 000040000 /* Must be a directory */ 124 #define LINUX_O_NOFOLLOW 000100000 /* Do not follow links */ 125 #define LINUX_O_DIRECT 000200000 /* Direct disk access hint */ 126 #define LINUX_O_LARGEFILE 000400000 127 128 struct l_newstat { 129 l_ulong st_dev; 130 l_ino_t st_ino; 131 l_uint st_mode; 132 l_uint st_nlink; 133 134 l_uid_t st_uid; 135 l_gid_t st_gid; 136 137 l_ulong st_rdev; 138 l_ulong __st_pad1; 139 l_off_t st_size; 140 l_int st_blksize; 141 l_int __st_pad2; 142 l_long st_blocks; 143 144 struct l_timespec st_atim; 145 struct l_timespec st_mtim; 146 struct l_timespec st_ctim; 147 l_uint __unused1; 148 l_uint __unused2; 149 }; 150 151 /* sigaction flags */ 152 #define LINUX_SA_NOCLDSTOP 0x00000001 153 #define LINUX_SA_NOCLDWAIT 0x00000002 154 #define LINUX_SA_SIGINFO 0x00000004 155 #define LINUX_SA_RESTORER 0x04000000 156 #define LINUX_SA_ONSTACK 0x08000000 157 #define LINUX_SA_RESTART 0x10000000 158 #define LINUX_SA_INTERRUPT 0x20000000 /* XXX */ 159 #define LINUX_SA_NOMASK 0x40000000 /* SA_NODEFER */ 160 #define LINUX_SA_ONESHOT 0x80000000 /* SA_RESETHAND */ 161 162 typedef void (*l_handler_t)(l_int); 163 164 typedef struct { 165 l_handler_t lsa_handler; 166 l_ulong lsa_flags; 167 l_uintptr_t lsa_restorer; 168 l_sigset_t lsa_mask; 169 } l_sigaction_t; /* XXX */ 170 171 typedef struct { 172 l_uintptr_t ss_sp; 173 l_int ss_flags; 174 l_size_t ss_size; 175 } l_stack_t; 176 177 union l_semun { 178 l_int val; 179 l_uintptr_t buf; 180 l_uintptr_t array; 181 l_uintptr_t __buf; 182 l_uintptr_t __pad; 183 }; 184 185 #define linux_copyout_rusage(r, u) copyout(r, u, sizeof(*r)) 186 187 struct linux_pt_regset { 188 l_ulong x[31]; 189 l_ulong sp; 190 l_ulong pc; 191 l_ulong cpsr; 192 }; 193 194 #ifdef _KERNEL 195 struct reg; 196 struct syscall_info; 197 198 void bsd_to_linux_regset(const struct reg *b_reg, 199 struct linux_pt_regset *l_regset); 200 void linux_to_bsd_regset(struct reg *b_reg, 201 const struct linux_pt_regset *l_regset); 202 void linux_ptrace_get_syscall_info_machdep(const struct reg *reg, 203 struct syscall_info *si); 204 int linux_ptrace_getregs_machdep(struct thread *td, pid_t pid, 205 struct linux_pt_regset *l_regset); 206 int linux_ptrace_peekuser(struct thread *td, pid_t pid, 207 void *addr, void *data); 208 int linux_ptrace_pokeuser(struct thread *td, pid_t pid, 209 void *addr, void *data); 210 #endif /* _KERNEL */ 211 212 #endif /* _ARM64_LINUX_H_ */ 213