]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm64/linux/linux.h
ktls: Inline ktls_cleanup() into ktls_destroy().
[FreeBSD/FreeBSD.git] / sys / arm64 / linux / linux.h
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  * $FreeBSD$
30  */
31 #ifndef _ARM64_LINUX_H_
32 #define _ARM64_LINUX_H_
33
34 #include <sys/abi_compat.h>
35
36 #include <compat/linux/linux.h>
37 #include <arm64/linux/linux_syscall.h>
38
39 #define LINUX_DTRACE    linuxulator
40
41 /* Provide a separate set of types for the Linux types */
42 typedef int32_t         l_int;
43 typedef int64_t         l_long;
44 typedef int16_t         l_short;
45 typedef uint32_t        l_uint;
46 typedef uint64_t        l_ulong;
47 typedef uint16_t        l_ushort;
48
49 typedef l_ulong         l_uintptr_t;
50 typedef l_long          l_clock_t;
51 typedef l_int           l_daddr_t;
52 typedef l_ulong         l_dev_t;
53 typedef l_uint          l_gid_t;
54 typedef l_ushort        l_gid16_t;      /* XXX */
55 typedef l_uint          l_uid_t;
56 typedef l_ushort        l_uid16_t;      /* XXX */
57 typedef l_ulong         l_ino_t;
58 typedef l_int           l_key_t;
59 typedef l_long          l_loff_t;
60 typedef l_uint          l_mode_t;
61 typedef l_long          l_off_t;
62 typedef l_int           l_pid_t;
63 typedef l_ulong         l_size_t;
64 typedef l_long          l_suseconds_t;
65 typedef l_long          l_time_t;
66 typedef l_int           l_timer_t;      /* XXX */
67 typedef l_int           l_mqd_t;
68 typedef l_ulong         l_fd_mask;
69
70 #include <compat/linux/linux_siginfo.h>
71
72 typedef struct {
73         l_int           val[2];
74 } l_fsid_t;
75
76 typedef struct {
77         l_time_t        tv_sec;
78         l_suseconds_t   tv_usec;
79 } l_timeval;
80
81 #define l_fd_set        fd_set
82
83 /* Miscellaneous */
84 #define LINUX_AT_COUNT          21
85
86 struct l___sysctl_args
87 {
88         l_uintptr_t     name;
89         l_int           nlen;
90         l_uintptr_t     oldval;
91         l_uintptr_t     oldlenp;
92         l_uintptr_t     newval;
93         l_uintptr_t     newlen;
94         l_ulong         __spare[4];
95 };
96
97 /* Resource limits */
98 #define LINUX_RLIMIT_CPU        0
99 #define LINUX_RLIMIT_FSIZE      1
100 #define LINUX_RLIMIT_DATA       2
101 #define LINUX_RLIMIT_STACK      3
102 #define LINUX_RLIMIT_CORE       4
103 #define LINUX_RLIMIT_RSS        5
104 #define LINUX_RLIMIT_NPROC      6
105 #define LINUX_RLIMIT_NOFILE     7
106 #define LINUX_RLIMIT_MEMLOCK    8
107 #define LINUX_RLIMIT_AS         9       /* Address space limit */
108
109 #define LINUX_RLIM_NLIMITS      10
110
111 struct l_rlimit {
112         l_ulong         rlim_cur;
113         l_ulong         rlim_max;
114 };
115
116 /* stat family of syscalls */
117 struct l_timespec {
118         l_time_t        tv_sec;
119         l_long          tv_nsec;
120 };
121
122 #define LINUX_O_DIRECTORY       000040000       /* Must be a directory */
123 #define LINUX_O_NOFOLLOW        000100000       /* Do not follow links */
124 #define LINUX_O_DIRECT          000200000       /* Direct disk access hint */
125 #define LINUX_O_LARGEFILE       000400000
126
127 struct l_newstat {
128         l_dev_t         st_dev;
129         l_ino_t         st_ino;
130         l_uint          st_mode;
131         l_uint          st_nlink;
132
133         l_uid_t         st_uid;
134         l_gid_t         st_gid;
135
136         l_dev_t         st_rdev;
137         l_ulong         __st_pad1;
138         l_off_t         st_size;
139         l_int           st_blksize;
140         l_int           __st_pad2;
141         l_long          st_blocks;
142
143         struct l_timespec       st_atim;
144         struct l_timespec       st_mtim;
145         struct l_timespec       st_ctim;
146         l_uint          __unused1;
147         l_uint          __unused2;
148 };
149
150 /* sigaction flags */
151 #define LINUX_SA_NOCLDSTOP      0x00000001
152 #define LINUX_SA_NOCLDWAIT      0x00000002
153 #define LINUX_SA_SIGINFO        0x00000004
154 #define LINUX_SA_RESTORER       0x04000000
155 #define LINUX_SA_ONSTACK        0x08000000
156 #define LINUX_SA_RESTART        0x10000000
157 #define LINUX_SA_INTERRUPT      0x20000000      /* XXX */
158 #define LINUX_SA_NOMASK         0x40000000      /* SA_NODEFER */
159 #define LINUX_SA_ONESHOT        0x80000000      /* SA_RESETHAND */
160
161 typedef void    (*l_handler_t)(l_int);
162
163 typedef struct {
164         l_handler_t     lsa_handler;
165         l_ulong         lsa_flags;
166         l_uintptr_t     lsa_restorer;
167         l_sigset_t      lsa_mask;
168 } l_sigaction_t;                                /* XXX */
169
170 typedef struct {
171         l_uintptr_t     ss_sp;
172         l_int           ss_flags;
173         l_size_t        ss_size;
174 } l_stack_t;
175
176 union l_semun {
177         l_int           val;
178         l_uintptr_t     buf;
179         l_uintptr_t     array;
180         l_uintptr_t     __buf;
181         l_uintptr_t     __pad;
182 };
183
184 struct l_ifmap {
185         l_ulong         mem_start;
186         l_ulong         mem_end;
187         l_ushort        base_addr;
188         u_char          irq;
189         u_char          dma;
190         u_char          port;
191         /* 3 bytes spare*/
192 };
193
194 struct l_ifreq {
195         union {
196                 char    ifrn_name[LINUX_IFNAMSIZ];
197         } ifr_ifrn;
198
199         union {
200                 struct l_sockaddr       ifru_addr;
201                 struct l_sockaddr       ifru_dstaddr;
202                 struct l_sockaddr       ifru_broadaddr;
203                 struct l_sockaddr       ifru_netmask;
204                 struct l_sockaddr       ifru_hwaddr;
205                 l_short         ifru_flags[1];
206                 l_int           ifru_ivalue;
207                 l_int           ifru_mtu;
208                 struct l_ifmap  ifru_map;
209                 char            ifru_slave[LINUX_IFNAMSIZ];
210                 l_uintptr_t     ifru_data;
211         } ifr_ifru;
212 };
213
214 #define ifr_name        ifr_ifrn.ifrn_name      /* Interface name */
215 #define ifr_hwaddr      ifr_ifru.ifru_hwaddr    /* MAC address */
216 #define ifr_ifindex     ifr_ifru.ifru_ivalue    /* Interface index */
217
218 #define linux_copyout_rusage(r, u)      copyout(r, u, sizeof(*r))
219
220 /* robust futexes */
221 struct linux_robust_list {
222         l_uintptr_t                     next;
223 };
224
225 struct linux_robust_list_head {
226         struct linux_robust_list        list;
227         l_long                          futex_offset;
228         l_uintptr_t                     pending_list;
229 };
230
231 struct linux_pt_regset {
232         l_ulong x[31];
233         l_ulong sp;
234         l_ulong pc;
235         l_ulong cpsr;
236 };
237
238 #ifdef _KERNEL
239 struct reg;
240 struct syscall_info;
241
242 void    bsd_to_linux_regset(const struct reg *b_reg,
243             struct linux_pt_regset *l_regset);
244 void    linux_to_bsd_regset(struct reg *b_reg,
245             const struct linux_pt_regset *l_regset);
246 void    linux_ptrace_get_syscall_info_machdep(const struct reg *reg,
247             struct syscall_info *si);
248 int     linux_ptrace_getregs_machdep(struct thread *td, pid_t pid,
249             struct linux_pt_regset *l_regset);
250 #endif /* _KERNEL */
251
252 #endif /* _ARM64_LINUX_H_ */