1 /* $NetBSD: netbsd32.h,v 1.143 2023/07/30 06:52:20 rin Exp $ */
2
3 /*
4 * Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #ifndef _COMPAT_NETBSD32_NETBSD32_H_
30 #define _COMPAT_NETBSD32_NETBSD32_H_
31 /* We need to change the size of register_t */
32 #ifdef syscallargs
33 #undef syscallargs
34 #endif
35 /*
36 * NetBSD 32-bit compatibility module.
37 */
38
39 #include <sys/param.h> /* precautionary upon removal from ucred.h */
40 #include <sys/systm.h>
41 #include <sys/mount.h>
42 #include <sys/ptrace.h>
43 #include <sys/stat.h>
44 #include <sys/statvfs.h>
45 #include <sys/syscallargs.h>
46 #include <sys/ipc.h>
47 #include <sys/shm.h>
48 #include <sys/ucontext.h>
49 #include <sys/ucred.h>
50 #include <sys/module_hook.h>
51
52 #include <compat/sys/ucontext.h>
53 #include <compat/sys/mount.h>
54 #include <compat/sys/signal.h>
55 #include <compat/sys/siginfo.h>
56 #include <compat/common/compat_util.h>
57
58 #include <nfs/rpcv2.h>
59
60 /*
61 * first define the basic types we need, and any applicable limits.
62 */
63
64 typedef int32_t netbsd32_long;
65 typedef uint32_t netbsd32_u_long;
66 typedef int64_t netbsd32_quad;
67
68 typedef uint32_t netbsd32_clock_t;
69 typedef uint32_t netbsd32_size_t;
70 typedef int32_t netbsd32_ssize_t;
71 typedef int32_t netbsd32_clockid_t;
72 typedef int32_t netbsd32_key_t;
73 typedef int32_t netbsd32_intptr_t;
74 typedef uint32_t netbsd32_uintptr_t;
75
76 /* Note: 32-bit sparc defines ssize_t as long but still has same size as int. */
77 #define NETBSD32_SSIZE_MAX INT32_MAX
78
79 /* netbsd32_[u]int64 are machine dependent and defined below */
80
81 /*
82 * machine dependant section; must define:
83 * NETBSD32_POINTER_TYPE
84 * - 32-bit pointer type, normally uint32_t but can be int32_t
85 * for platforms which rely on sign-extension of pointers
86 * such as SH-5.
87 * eg: #define NETBSD32_POINTER_TYPE uint32_t
88 * netbsd32_pointer_t
89 * - a typedef'd struct with the above as an "i32" member.
90 * eg: typedef struct {
91 * NETBSD32_POINTER_TYPE i32;
92 * } netbsd32_pointer_t;
93 * NETBSD32PTR64(p32)
94 * - Translate a 32-bit pointer into something valid in a
95 * 64-bit context.
96 * struct netbsd32_sigcontext
97 * - 32bit compatibility sigcontext structure for this arch.
98 * netbsd32_sigcontextp_t
99 * - type of pointer to above, normally uint32_t
100 * void netbsd32_setregs(struct proc *p, struct exec_package *pack,
101 * unsigned long stack);
102 * int netbsd32_sigreturn(struct proc *p, void *v,
103 * register_t *retval);
104 * void netbsd32_sendsig(sig_t catcher, int sig, int mask, u_long code);
105 * char netbsd32_esigcode[], netbsd32_sigcode[]
106 * - the above are abvious
107 *
108 * pull in the netbsd32 machine dependent header, that may help with the
109 * above, or it may be provided via the MD layer itself.
110 */
111 #include <machine/netbsd32_machdep.h>
112
113 /*
114 * Conversion functions for the rest of the compat32 code:
115 *
116 * NETBSD32PTR64() Convert user-supplied 32bit pointer to 'void *'
117 * NETBSD32PTR32() Assign a 'void *' to a 32bit pointer variable
118 * NETBSD32PTR32PLUS() Add an integer to a 32bit pointer
119 *
120 * Under rare circumstances the following get used:
121 *
122 * NETBSD32PTR32I() Convert 'void *' to the 32bit pointer base type.
123 * NETBSD32IPTR64() Convert 32bit pointer base type to 'void *'
124 */
125 #define NETBSD32PTR64(p32) NETBSD32IPTR64((p32).i32)
126 #define NETBSD32PTR32(p32, p64) ((p32).i32 = NETBSD32PTR32I(p64))
127 #define NETBSD32PTR32PLUS(p32, incr) netbsd32_ptr32_incr(&p32, incr)
128 #define NETBSD32PTR32I(p32) netbsd32_ptr32i(p32)
129 #define NETBSD32IPTR64(p32) netbsd32_iptr64(p32)
130
131 static __inline NETBSD32_POINTER_TYPE
netbsd32_ptr32i(const void * p64)132 netbsd32_ptr32i(const void *p64)
133 {
134 uintptr_t u64 = (uintptr_t)p64;
135 KASSERTMSG(u64 == (uintptr_t)(NETBSD32_POINTER_TYPE)u64,
136 "u64 %jx != %jx", (uintmax_t)u64,
137 (uintmax_t)(NETBSD32_POINTER_TYPE)u64);
138 return u64;
139 }
140
141 static __inline void *
netbsd32_iptr64(NETBSD32_POINTER_TYPE p32)142 netbsd32_iptr64(NETBSD32_POINTER_TYPE p32)
143 {
144 return (void *)(intptr_t)p32;
145 }
146
147 static __inline netbsd32_pointer_t
netbsd32_ptr32_incr(netbsd32_pointer_t * p32,uint32_t incr)148 netbsd32_ptr32_incr(netbsd32_pointer_t *p32, uint32_t incr)
149 {
150 netbsd32_pointer_t n32 = *p32;
151
152 n32.i32 += incr;
153 KASSERT(NETBSD32PTR64(n32) > NETBSD32PTR64(*p32));
154 return *p32 = n32;
155 }
156
157 /* Nothing should be using the raw type, so kill it */
158 #undef NETBSD32_POINTER_TYPE
159
160 /*
161 * 64 bit integers only have 4-byte alignment on some 32 bit ports,
162 * but always have 8-byte alignment on 64 bit systems.
163 * NETBSD32_INT64_ALIGN may be __attribute__((__aligned__(4)))
164 */
165 typedef int64_t netbsd32_int64 NETBSD32_INT64_ALIGN;
166 typedef uint64_t netbsd32_uint64 NETBSD32_INT64_ALIGN;
167 #undef NETBSD32_INT64_ALIGN
168
169 /* Type used in siginfo, avoids circular dependencies between headers. */
170 CTASSERT(sizeof(netbsd32_uint64) == sizeof(netbsd32_siginfo_uint64));
171 CTASSERT(__alignof__(netbsd32_uint64) == __alignof__(netbsd32_siginfo_uint64));
172
173 /*
174 * all pointers are netbsd32_pointer_t (defined in <machine/netbsd32_machdep.h>)
175 */
176
177 typedef netbsd32_pointer_t netbsd32_voidp;
178 typedef netbsd32_pointer_t netbsd32_u_shortp;
179 typedef netbsd32_pointer_t netbsd32_charp;
180 typedef netbsd32_pointer_t netbsd32_u_charp;
181 typedef netbsd32_pointer_t netbsd32_charpp;
182 typedef netbsd32_pointer_t netbsd32_size_tp;
183 typedef netbsd32_pointer_t netbsd32_intp;
184 typedef netbsd32_pointer_t netbsd32_uintp;
185 typedef netbsd32_pointer_t netbsd32_longp;
186 typedef netbsd32_pointer_t netbsd32_caddrp;
187 typedef netbsd32_pointer_t netbsd32_caddr;
188 typedef netbsd32_pointer_t netbsd32_gid_tp;
189 typedef netbsd32_pointer_t netbsd32_fsid_tp_t;
190 typedef netbsd32_pointer_t netbsd32_lwpidp;
191 typedef netbsd32_pointer_t netbsd32_ucontextp;
192 typedef netbsd32_pointer_t netbsd32_caddr_t;
193 typedef netbsd32_pointer_t netbsd32_lwpctlp;
194 typedef netbsd32_pointer_t netbsd32_pid_tp;
195 typedef netbsd32_pointer_t netbsd32_psetidp_t;
196 typedef netbsd32_pointer_t netbsd32_aclp_t;
197
198 /*
199 * now, the compatibility structures and their fake pointer types.
200 */
201
202 /* from <sys/types.h> */
203 typedef netbsd32_pointer_t netbsd32_fd_setp_t;
204 typedef netbsd32_intptr_t netbsd32_semid_t;
205 typedef netbsd32_pointer_t netbsd32_semidp_t;
206 typedef netbsd32_uint64 netbsd32_dev_t;
207 typedef netbsd32_int64 netbsd32_off_t;
208 typedef netbsd32_uint64 netbsd32_ino_t;
209 typedef netbsd32_int64 netbsd32_blkcnt_t;
210
211 /* from <sys/epoll.h> */
212 typedef netbsd32_uint64 netbsd32_epoll_data_t;
213
214 typedef netbsd32_pointer_t netbsd32_epoll_eventp_t;
215 struct netbsd32_epoll_event {
216 uint32_t events;
217 netbsd32_epoll_data_t data;
218 };
219
220 /* from <sys/spawn.h> */
221 typedef netbsd32_pointer_t netbsd32_posix_spawn_file_actionsp;
222 typedef netbsd32_pointer_t netbsd32_posix_spawnattrp;
223 typedef netbsd32_pointer_t netbsd32_posix_spawn_file_actions_entryp;
224
225 /* from <sys/uio.h> */
226 typedef netbsd32_pointer_t netbsd32_iovecp_t;
227 struct netbsd32_iovec {
228 netbsd32_voidp iov_base; /* Base address. */
229 netbsd32_size_t iov_len; /* Length. */
230 };
231
232 /* from <sys/time.h> */
233 typedef int32_t netbsd32_timer_t;
234 typedef int32_t netbsd32_time50_t;
235 typedef netbsd32_int64 netbsd32_time_t;
236 typedef netbsd32_pointer_t netbsd32_timerp_t;
237 typedef netbsd32_pointer_t netbsd32_clockidp_t;
238
239 typedef netbsd32_pointer_t netbsd32_timespec50p_t;
240 struct netbsd32_timespec50 {
241 netbsd32_time50_t tv_sec; /* seconds */
242 netbsd32_long tv_nsec; /* and nanoseconds */
243 };
244
245 typedef netbsd32_pointer_t netbsd32_timespecp_t;
246 struct netbsd32_timespec {
247 netbsd32_time_t tv_sec; /* seconds */
248 netbsd32_long tv_nsec; /* and nanoseconds */
249 };
250
251 typedef netbsd32_pointer_t netbsd32_timeval50p_t;
252 struct netbsd32_timeval50 {
253 netbsd32_time50_t tv_sec; /* seconds */
254 netbsd32_long tv_usec; /* and microseconds */
255 };
256
257 typedef netbsd32_pointer_t netbsd32_timevalp_t;
258 struct netbsd32_timeval {
259 netbsd32_time_t tv_sec; /* seconds */
260 suseconds_t tv_usec; /* and microseconds */
261 };
262
263 typedef netbsd32_pointer_t netbsd32_timezonep_t;
264 struct netbsd32_timezone {
265 int tz_minuteswest; /* minutes west of Greenwich */
266 int tz_dsttime; /* type of dst correction */
267 };
268
269 typedef netbsd32_pointer_t netbsd32_itimerval50p_t;
270 struct netbsd32_itimerval50 {
271 struct netbsd32_timeval50 it_interval; /* timer interval */
272 struct netbsd32_timeval50 it_value; /* current value */
273 };
274
275 typedef netbsd32_pointer_t netbsd32_itimervalp_t;
276 struct netbsd32_itimerval {
277 struct netbsd32_timeval it_interval; /* timer interval */
278 struct netbsd32_timeval it_value; /* current value */
279 };
280
281 typedef netbsd32_pointer_t netbsd32_itimerspec50p_t;
282 struct netbsd32_itimerspec50 {
283 struct netbsd32_timespec50 it_interval;
284 struct netbsd32_timespec50 it_value;
285 };
286
287 typedef netbsd32_pointer_t netbsd32_itimerspecp_t;
288 struct netbsd32_itimerspec {
289 struct netbsd32_timespec it_interval;
290 struct netbsd32_timespec it_value;
291 };
292
293 /* from <sys/mount.h> */
294 typedef netbsd32_pointer_t netbsd32_fidp_t;
295
296 typedef netbsd32_pointer_t netbsd32_fhandlep_t;
297 typedef netbsd32_pointer_t netbsd32_compat_30_fhandlep_t;
298
299 typedef netbsd32_pointer_t netbsd32_statfsp_t;
300 struct netbsd32_statfs {
301 short f_type; /* type of file system */
302 unsigned short f_flags; /* copy of mount flags */
303 netbsd32_long f_bsize; /* fundamental file system block size */
304 netbsd32_long f_iosize; /* optimal transfer block size */
305 netbsd32_long f_blocks; /* total data blocks in file system */
306 netbsd32_long f_bfree; /* free blocks in fs */
307 netbsd32_long f_bavail; /* free blocks avail to non-superuser */
308 netbsd32_long f_files; /* total file nodes in file system */
309 netbsd32_long f_ffree; /* free file nodes in fs */
310 fsid_t f_fsid; /* file system id */
311 uid_t f_owner; /* user that mounted the file system */
312 netbsd32_long f_spare[4]; /* spare for later */
313 char f_fstypename[MFSNAMELEN]; /* fs type name */
314 char f_mntonname[MNAMELEN]; /* directory on which mounted */
315 char f_mntfromname[MNAMELEN]; /* mounted file system */
316 };
317
318 struct netbsd32_export_args30 {
319 int ex_flags; /* export related flags */
320 uid_t ex_root; /* mapping for root uid */
321 struct uucred ex_anon; /* mapping for anonymous user */
322 netbsd32_pointer_t ex_addr; /* net address to which exported */
323 int ex_addrlen; /* and the net address length */
324 netbsd32_pointer_t ex_mask; /* mask of valid bits in saddr */
325 int ex_masklen; /* and the smask length */
326 netbsd32_charp ex_indexfile; /* index file for WebNFS URLs */
327 };
328
329 /* from <sys/poll.h> */
330 typedef netbsd32_pointer_t netbsd32_pollfdp_t;
331
332 /* from <sys/ptrace.h> */
333 typedef netbsd32_pointer_t netbsd32_ptrace_io_descp_t;
334 struct netbsd32_ptrace_io_desc {
335 int piod_op; /* I/O operation */
336 netbsd32_voidp piod_offs; /* child offset */
337 netbsd32_voidp piod_addr; /* parent offset */
338 netbsd32_size_t piod_len; /* request length (in) /
339 actual count (out) */
340 };
341
342 struct netbsd32_ptrace_siginfo {
343 siginfo32_t psi_siginfo; /* signal information structure */
344 lwpid_t psi_lwpid; /* destination LWP of the signal
345 * value 0 means the whole process
346 * (route signal to all LWPs) */
347 };
348
349 #define PL32_LNAMELEN 20
350
351 struct netbsd32_ptrace_lwpstatus {
352 lwpid_t pl_lwpid;
353 sigset_t pl_sigpend;
354 sigset_t pl_sigmask;
355 char pl_name[PL32_LNAMELEN];
356 netbsd32_voidp pl_private;
357 };
358
359 /* from <sys/quotactl.h> */
360 typedef netbsd32_pointer_t netbsd32_quotactlargsp_t;
361 struct netbsd32_quotactlargs {
362 unsigned qc_op;
363 union {
364 struct {
365 netbsd32_pointer_t qc_info;
366 } stat;
367 struct {
368 int qc_idtype;
369 netbsd32_pointer_t qc_info;
370 } idtypestat;
371 struct {
372 int qc_objtype;
373 netbsd32_pointer_t qc_info;
374 } objtypestat;
375 struct {
376 netbsd32_pointer_t qc_key;
377 netbsd32_pointer_t qc_val;
378 } get;
379 struct {
380 netbsd32_pointer_t qc_key;
381 netbsd32_pointer_t qc_val;
382 } put;
383 struct {
384 netbsd32_pointer_t qc_key;
385 } del;
386 struct {
387 netbsd32_pointer_t qc_cursor;
388 } cursoropen;
389 struct {
390 netbsd32_pointer_t qc_cursor;
391 } cursorclose;
392 struct {
393 netbsd32_pointer_t qc_cursor;
394 int qc_idtype;
395 } cursorskipidtype;
396 struct {
397 netbsd32_pointer_t qc_cursor;
398 netbsd32_pointer_t qc_keys;
399 netbsd32_pointer_t qc_vals;
400 unsigned qc_maxnum;
401 netbsd32_pointer_t qc_ret;
402 } cursorget;
403 struct {
404 netbsd32_pointer_t qc_cursor;
405 netbsd32_pointer_t qc_ret;
406 } cursoratend;
407 struct {
408 netbsd32_pointer_t qc_cursor;
409 } cursorrewind;
410 struct {
411 int qc_idtype;
412 netbsd32_pointer_t qc_quotafile;
413 } quotaon;
414 struct {
415 int qc_idtype;
416 } quotaoff;
417 } u;
418 };
419
420 /* from <sys/resource.h> */
421 typedef netbsd32_pointer_t netbsd32_rusage50p_t;
422 struct netbsd32_rusage50 {
423 struct netbsd32_timeval50 ru_utime;/* user time used */
424 struct netbsd32_timeval50 ru_stime;/* system time used */
425 netbsd32_long ru_maxrss; /* max resident set size */
426 netbsd32_long ru_ixrss; /* integral shared memory size */
427 netbsd32_long ru_idrss; /* integral unshared data " */
428 netbsd32_long ru_isrss; /* integral unshared stack " */
429 netbsd32_long ru_minflt; /* page reclaims */
430 netbsd32_long ru_majflt; /* page faults */
431 netbsd32_long ru_nswap; /* swaps */
432 netbsd32_long ru_inblock; /* block input operations */
433 netbsd32_long ru_oublock; /* block output operations */
434 netbsd32_long ru_msgsnd; /* messages sent */
435 netbsd32_long ru_msgrcv; /* messages received */
436 netbsd32_long ru_nsignals; /* signals received */
437 netbsd32_long ru_nvcsw; /* voluntary context switches */
438 netbsd32_long ru_nivcsw; /* involuntary " */
439 };
440
441 typedef netbsd32_pointer_t netbsd32_rusagep_t;
442 struct netbsd32_rusage {
443 struct netbsd32_timeval ru_utime;/* user time used */
444 struct netbsd32_timeval ru_stime;/* system time used */
445 netbsd32_long ru_maxrss; /* max resident set size */
446 netbsd32_long ru_ixrss; /* integral shared memory size */
447 netbsd32_long ru_idrss; /* integral unshared data " */
448 netbsd32_long ru_isrss; /* integral unshared stack " */
449 netbsd32_long ru_minflt; /* page reclaims */
450 netbsd32_long ru_majflt; /* page faults */
451 netbsd32_long ru_nswap; /* swaps */
452 netbsd32_long ru_inblock; /* block input operations */
453 netbsd32_long ru_oublock; /* block output operations */
454 netbsd32_long ru_msgsnd; /* messages sent */
455 netbsd32_long ru_msgrcv; /* messages received */
456 netbsd32_long ru_nsignals; /* signals received */
457 netbsd32_long ru_nvcsw; /* voluntary context switches */
458 netbsd32_long ru_nivcsw; /* involuntary " */
459 };
460
461 typedef netbsd32_pointer_t netbsd32_wrusagep_t;
462 struct netbsd32_wrusage {
463 struct netbsd32_rusage wru_self;
464 struct netbsd32_rusage wru_children;
465 };
466
467 typedef netbsd32_pointer_t netbsd32_orlimitp_t;
468
469 typedef netbsd32_pointer_t netbsd32_rlimitp_t;
470
471 struct netbsd32_loadavg {
472 fixpt_t ldavg[3];
473 netbsd32_long fscale;
474 };
475
476 /* from <sys/swap.h> */
477 struct netbsd32_swapent {
478 netbsd32_dev_t se_dev; /* device id */
479 int se_flags; /* flags */
480 int se_nblks; /* total blocks */
481 int se_inuse; /* blocks in use */
482 int se_priority; /* priority of this device */
483 char se_path[PATH_MAX+1]; /* path name */
484 };
485
486 /* from <sys/ipc.h> */
487 typedef netbsd32_pointer_t netbsd32_ipc_permp_t;
488 struct netbsd32_ipc_perm {
489 uid_t cuid; /* creator user id */
490 gid_t cgid; /* creator group id */
491 uid_t uid; /* user id */
492 gid_t gid; /* group id */
493 mode_t mode; /* r/w permission */
494 unsigned short _seq; /* sequence # (to generate unique msg/sem/shm id) */
495 netbsd32_key_t _key; /* user specified msg/sem/shm key */
496 };
497 struct netbsd32_ipc_perm14 {
498 unsigned short cuid; /* creator user id */
499 unsigned short cgid; /* creator group id */
500 unsigned short uid; /* user id */
501 unsigned short gid; /* group id */
502 unsigned short mode; /* r/w permission */
503 unsigned short seq; /* sequence # (to generate unique msg/sem/shm id) */
504 netbsd32_key_t key; /* user specified msg/sem/shm key */
505 };
506
507 /* from <sys/msg.h> */
508 typedef netbsd32_pointer_t netbsd32_msgp_t;
509 struct netbsd32_msg {
510 netbsd32_msgp_t msg_next; /* next msg in the chain */
511 netbsd32_long msg_type; /* type of this message */
512 /* >0 -> type of this message */
513 /* 0 -> free header */
514 unsigned short msg_ts; /* size of this message */
515 short msg_spot; /* location of start of msg in buffer */
516 };
517
518 typedef uint32_t netbsd32_msgqnum_t;
519 typedef netbsd32_size_t netbsd32_msglen_t;
520
521 typedef netbsd32_pointer_t netbsd32_msqid_dsp_t;
522 struct netbsd32_msqid_ds {
523 struct netbsd32_ipc_perm msg_perm; /* operation permission structure */
524 netbsd32_msgqnum_t msg_qnum; /* number of messages in the queue */
525 netbsd32_msglen_t msg_qbytes; /* max # of bytes in the queue */
526 pid_t msg_lspid; /* process ID of last msgsend() */
527 pid_t msg_lrpid; /* process ID of last msgrcv() */
528 netbsd32_time_t msg_stime; /* time of last msgsend() */
529 netbsd32_time_t msg_rtime; /* time of last msgrcv() */
530 netbsd32_time_t msg_ctime; /* time of last change */
531
532 /*
533 * These members are private and used only in the internal
534 * implementation of this interface.
535 */
536 netbsd32_msgp_t _msg_first; /* first message in the queue */
537 netbsd32_msgp_t _msg_last; /* last message in the queue */
538 netbsd32_msglen_t _msg_cbytes; /* # of bytes currently in queue */
539 };
540 typedef netbsd32_pointer_t netbsd32_msqid_ds50p_t;
541 struct netbsd32_msqid_ds50 {
542 struct netbsd32_ipc_perm msg_perm; /* operation permission structure */
543 netbsd32_msgqnum_t msg_qnum; /* number of messages in the queue */
544 netbsd32_msglen_t msg_qbytes; /* max # of bytes in the queue */
545 pid_t msg_lspid; /* process ID of last msgsend() */
546 pid_t msg_lrpid; /* process ID of last msgrcv() */
547 int32_t msg_stime; /* time of last msgsend() */
548 int32_t msg_rtime; /* time of last msgrcv() */
549 int32_t msg_ctime; /* time of last change */
550
551 /*
552 * These members are private and used only in the internal
553 * implementation of this interface.
554 */
555 netbsd32_msgp_t _msg_first; /* first message in the queue */
556 netbsd32_msgp_t _msg_last; /* last message in the queue */
557 netbsd32_msglen_t _msg_cbytes; /* # of bytes currently in queue */
558 };
559
560 typedef netbsd32_pointer_t netbsd32_msqid_ds14p_t;
561 struct netbsd32_msqid_ds14 {
562 struct netbsd32_ipc_perm14 msg_perm; /* msg queue permission bits */
563 netbsd32_msgp_t msg_first; /* first message in the queue */
564 netbsd32_msgp_t msg_last; /* last message in the queue */
565 netbsd32_u_long msg_cbytes; /* number of bytes in use on the queue */
566 netbsd32_u_long msg_qnum; /* number of msgs in the queue */
567 netbsd32_u_long msg_qbytes; /* max # of bytes on the queue */
568 pid_t msg_lspid; /* pid of last msgsnd() */
569 pid_t msg_lrpid; /* pid of last msgrcv() */
570 int32_t msg_stime; /* time of last msgsnd() */
571 netbsd32_long msg_pad1;
572 int32_t msg_rtime; /* time of last msgrcv() */
573 netbsd32_long msg_pad2;
574 int32_t msg_ctime; /* time of last msgctl() */
575 netbsd32_long msg_pad3;
576 netbsd32_long msg_pad4[4];
577 };
578
579 /* from <sys/sem.h> */
580 typedef netbsd32_pointer_t netbsd32_semp_t;
581
582 typedef netbsd32_pointer_t netbsd32_semid_dsp_t;
583 struct netbsd32_semid_ds {
584 struct netbsd32_ipc_perm sem_perm;/* operation permission struct */
585 unsigned short sem_nsems; /* number of sems in set */
586 netbsd32_time_t sem_otime; /* last operation time */
587 netbsd32_time_t sem_ctime; /* last change time */
588
589 /*
590 * These members are private and used only in the internal
591 * implementation of this interface.
592 */
593 netbsd32_semp_t _sem_base; /* pointer to first semaphore in set */
594 };
595
596 typedef netbsd32_pointer_t netbsd32_semid_ds50p_t;
597 struct netbsd32_semid_ds50 {
598 struct netbsd32_ipc_perm sem_perm;/* operation permission struct */
599 unsigned short sem_nsems; /* number of sems in set */
600 int32_t sem_otime; /* last operation time */
601 int32_t sem_ctime; /* last change time */
602
603 /*
604 * These members are private and used only in the internal
605 * implementation of this interface.
606 */
607 netbsd32_semp_t _sem_base; /* pointer to first semaphore in set */
608 };
609
610 typedef netbsd32_pointer_t netbsd32_semid_ds14p_t;
611 struct netbsd32_semid_ds14 {
612 struct netbsd32_ipc_perm14 sem_perm;/* operation permission struct */
613 netbsd32_semp_t sem_base; /* pointer to first semaphore in set */
614 unsigned short sem_nsems; /* number of sems in set */
615 netbsd32_time_t sem_otime; /* last operation time */
616 netbsd32_long sem_pad1; /* SVABI/386 says I need this here */
617 netbsd32_time_t sem_ctime; /* last change time */
618 /* Times measured in secs since */
619 /* 00:00:00 GMT, Jan. 1, 1970 */
620 int32_t sem_pad2; /* SVABI/386 says I need this here */
621 int32_t sem_pad3[4]; /* SVABI/386 says I need this here */
622 };
623
624 typedef uint32_t netbsd32_semunu_t;
625 typedef netbsd32_pointer_t netbsd32_semunp_t;
626 union netbsd32_semun {
627 int val; /* value for SETVAL */
628 netbsd32_semid_dsp_t buf; /* buffer for IPC_STAT & IPC_SET */
629 netbsd32_u_shortp array; /* array for GETALL & SETALL */
630 };
631
632 typedef netbsd32_pointer_t netbsd32_semun50p_t;
633 union netbsd32_semun50 {
634 int val; /* value for SETVAL */
635 netbsd32_semid_ds50p_t buf; /* buffer for IPC_STAT & IPC_SET */
636 netbsd32_u_shortp array; /* array for GETALL & SETALL */
637 };
638
639 typedef netbsd32_pointer_t netbsd32_sembufp_t;
640 struct netbsd32_sembuf {
641 unsigned short sem_num; /* semaphore # */
642 short sem_op; /* semaphore operation */
643 short sem_flg; /* operation flags */
644 };
645
646 /* from <sys/shm.h> */
647 typedef netbsd32_pointer_t netbsd32_shmid_dsp_t;
648 struct netbsd32_shmid_ds {
649 struct netbsd32_ipc_perm shm_perm; /* operation permission structure */
650 netbsd32_size_t shm_segsz; /* size of segment in bytes */
651 pid_t shm_lpid; /* process ID of last shm op */
652 pid_t shm_cpid; /* process ID of creator */
653 shmatt_t shm_nattch; /* number of current attaches */
654 netbsd32_time_t shm_atime; /* time of last shmat() */
655 netbsd32_time_t shm_dtime; /* time of last shmdt() */
656 netbsd32_time_t shm_ctime; /* time of last change by shmctl() */
657 netbsd32_voidp _shm_internal; /* sysv stupidity */
658 };
659
660 typedef netbsd32_pointer_t netbsd32_shmid_ds50p_t;
661 struct netbsd32_shmid_ds50 {
662 struct netbsd32_ipc_perm shm_perm; /* operation permission structure */
663 netbsd32_size_t shm_segsz; /* size of segment in bytes */
664 pid_t shm_lpid; /* process ID of last shm op */
665 pid_t shm_cpid; /* process ID of creator */
666 shmatt_t shm_nattch; /* number of current attaches */
667 int32_t shm_atime; /* time of last shmat() */
668 int32_t shm_dtime; /* time of last shmdt() */
669 int32_t shm_ctime; /* time of last change by shmctl() */
670 netbsd32_voidp _shm_internal; /* sysv stupidity */
671 };
672
673 typedef netbsd32_pointer_t netbsd32_shmid_ds14p_t;
674 struct netbsd32_shmid_ds14 {
675 struct netbsd32_ipc_perm14 shm_perm; /* operation permission structure */
676 int shm_segsz; /* size of segment in bytes */
677 pid_t shm_lpid; /* process ID of last shm op */
678 pid_t shm_cpid; /* process ID of creator */
679 short shm_nattch; /* number of current attaches */
680 int32_t shm_atime; /* time of last shmat() */
681 int32_t shm_dtime; /* time of last shmdt() */
682 int32_t shm_ctime; /* time of last change by shmctl() */
683 netbsd32_voidp _shm_internal; /* sysv stupidity */
684 };
685
686 /* from <sys/signal.h> */
687 typedef netbsd32_pointer_t netbsd32_sigsetp_t;
688 typedef netbsd32_pointer_t netbsd32_sigactionp_t;
689 struct netbsd32_sigaction13 {
690 netbsd32_voidp netbsd32_sa_handler; /* signal handler */
691 sigset13_t netbsd32_sa_mask; /* signal mask to apply */
692 int netbsd32_sa_flags; /* see signal options below */
693 };
694
695 struct netbsd32_sigaction {
696 netbsd32_voidp netbsd32_sa_handler; /* signal handler */
697 sigset_t netbsd32_sa_mask; /* signal mask to apply */
698 int netbsd32_sa_flags; /* see signal options below */
699 };
700
701 typedef netbsd32_pointer_t netbsd32_sigaltstack13p_t;
702 struct netbsd32_sigaltstack13 {
703 netbsd32_charp ss_sp; /* signal stack base */
704 int ss_size; /* signal stack length */
705 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
706 };
707
708 typedef netbsd32_pointer_t netbsd32_sigaltstackp_t;
709 struct netbsd32_sigaltstack {
710 netbsd32_voidp ss_sp; /* signal stack base */
711 netbsd32_size_t ss_size; /* signal stack length */
712 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
713 };
714
715 typedef netbsd32_pointer_t netbsd32_sigstackp_t;
716 struct netbsd32_sigstack {
717 netbsd32_voidp ss_sp; /* signal stack pointer */
718 int ss_onstack; /* current status */
719 };
720
721 typedef netbsd32_pointer_t netbsd32_sigvecp_t;
722 struct netbsd32_sigvec {
723 netbsd32_voidp sv_handler; /* signal handler */
724 int sv_mask; /* signal mask to apply */
725 int sv_flags; /* see signal options below */
726 };
727
728 typedef netbsd32_pointer_t netbsd32_siginfop_t;
729
730 union netbsd32_sigval {
731 int sival_int;
732 netbsd32_voidp sival_ptr;
733 };
734
735 typedef netbsd32_pointer_t netbsd32_sigeventp_t;
736 struct netbsd32_sigevent {
737 int sigev_notify;
738 int sigev_signo;
739 union netbsd32_sigval sigev_value;
740 netbsd32_voidp sigev_notify_function;
741 netbsd32_voidp sigev_notify_attributes;
742 };
743
744 /* from <sys/sigtypes.h> */
745 typedef netbsd32_pointer_t netbsd32_stackp_t;
746
747 /* from <sys/socket.h> */
748 typedef netbsd32_pointer_t netbsd32_sockaddrp_t;
749 typedef netbsd32_pointer_t netbsd32_osockaddrp_t;
750 typedef netbsd32_pointer_t netbsd32_socklenp_t;
751
752 typedef netbsd32_pointer_t netbsd32_msghdrp_t;
753 struct netbsd32_msghdr {
754 netbsd32_caddr_t msg_name; /* optional address */
755 unsigned int msg_namelen; /* size of address */
756 netbsd32_iovecp_t msg_iov; /* scatter/gather array */
757 unsigned int msg_iovlen; /* # elements in msg_iov */
758 netbsd32_caddr_t msg_control; /* ancillary data, see below */
759 unsigned int msg_controllen; /* ancillary data buffer len */
760 int msg_flags; /* flags on received message */
761 };
762
763 typedef netbsd32_pointer_t netbsd32_omsghdrp_t;
764 struct netbsd32_omsghdr {
765 netbsd32_caddr_t msg_name; /* optional address */
766 int msg_namelen; /* size of address */
767 netbsd32_iovecp_t msg_iov; /* scatter/gather array */
768 int msg_iovlen; /* # elements in msg_iov */
769 netbsd32_caddr_t msg_accrights; /* access rights sent/recvd */
770 u_int msg_accrightslen;
771 };
772
773 typedef netbsd32_pointer_t netbsd32_mmsghdrp_t;
774 struct netbsd32_mmsghdr {
775 struct netbsd32_msghdr msg_hdr;
776 unsigned int msg_len;
777 };
778
779 /* from <sys/stat.h> */
780 typedef netbsd32_pointer_t netbsd32_stat12p_t;
781 struct netbsd32_stat12 { /* NetBSD-1.2 stat struct */
782 uint32_t st_dev; /* inode's device */
783 uint32_t st_ino; /* inode's number */
784 uint16_t st_mode; /* inode protection mode */
785 uint16_t st_nlink; /* number of hard links */
786 uid_t st_uid; /* user ID of the file's owner */
787 gid_t st_gid; /* group ID of the file's group */
788 uint32_t st_rdev; /* device type */
789 struct netbsd32_timespec50 st_atimespec;/* time of last access */
790 struct netbsd32_timespec50 st_mtimespec;/* time of last data modification */
791 struct netbsd32_timespec50 st_ctimespec;/* time of last file status change */
792 netbsd32_int64 st_size; /* file size, in bytes */
793 netbsd32_int64 st_blocks; /* blocks allocated for file */
794 uint32_t st_blksize; /* optimal blocksize for I/O */
795 uint32_t st_flags; /* user defined flags for file */
796 uint32_t st_gen; /* file generation number */
797 int32_t st_lspare;
798 netbsd32_int64 st_qspare[2];
799 };
800
801 typedef netbsd32_pointer_t netbsd32_stat43p_t;
802 struct netbsd32_stat43 { /* BSD-4.3 stat struct */
803 uint16_t st_dev; /* inode's device */
804 uint32_t st_ino; /* inode's number */
805 uint16_t st_mode; /* inode protection mode */
806 uint16_t st_nlink; /* number of hard links */
807 uint16_t st_uid; /* user ID of the file's owner */
808 uint16_t st_gid; /* group ID of the file's group */
809 uint16_t st_rdev; /* device type */
810 int32_t st_size; /* file size, in bytes */
811 struct netbsd32_timespec50 st_atimespec;/* time of last access */
812 struct netbsd32_timespec50 st_mtimespec;/* time of last data modification */
813 struct netbsd32_timespec50 st_ctimespec;/* time of last file status change */
814 int32_t st_blksize; /* optimal blocksize for I/O */
815 int32_t st_blocks; /* blocks allocated for file */
816 uint32_t st_flags; /* user defined flags for file */
817 uint32_t st_gen; /* file generation number */
818 };
819 typedef netbsd32_pointer_t netbsd32_stat13p_t;
820 struct netbsd32_stat13 {
821 uint32_t st_dev; /* inode's device */
822 uint32_t st_ino; /* inode's number */
823 mode_t st_mode; /* inode protection mode */
824 nlink_t st_nlink; /* number of hard links */
825 uid_t st_uid; /* user ID of the file's owner */
826 gid_t st_gid; /* group ID of the file's group */
827 uint32_t st_rdev; /* device type */
828 struct netbsd32_timespec50 st_atimespec;/* time of last access */
829 struct netbsd32_timespec50 st_mtimespec;/* time of last data modification */
830 struct netbsd32_timespec50 st_ctimespec;/* time of last file status change */
831 netbsd32_int64 st_size; /* file size, in bytes */
832 netbsd32_uint64 st_blocks; /* blocks allocated for file */
833 blksize_t st_blksize; /* optimal blocksize for I/O */
834 uint32_t st_flags; /* user defined flags for file */
835 uint32_t st_gen; /* file generation number */
836 uint32_t st_spare; /* file generation number */
837 struct netbsd32_timespec50 st_birthtimespec;
838 uint32_t st_spare2;
839 };
840
841 typedef netbsd32_pointer_t netbsd32_stat50p_t;
842 struct netbsd32_stat50 {
843 uint32_t st_dev; /* inode's device */
844 mode_t st_mode; /* inode protection mode */
845 netbsd32_uint64 st_ino; /* inode's number */
846 nlink_t st_nlink; /* number of hard links */
847 uid_t st_uid; /* user ID of the file's owner */
848 gid_t st_gid; /* group ID of the file's group */
849 uint32_t st_rdev; /* device type */
850 struct netbsd32_timespec50 st_atimespec;/* time of last access */
851 struct netbsd32_timespec50 st_mtimespec;/* time of last data modification */
852 struct netbsd32_timespec50 st_ctimespec;/* time of last file status change */
853 struct netbsd32_timespec50 st_birthtimespec; /* time of creation */
854 netbsd32_int64 st_size; /* file size, in bytes */
855 netbsd32_uint64 st_blocks; /* blocks allocated for file */
856 blksize_t st_blksize; /* optimal blocksize for I/O */
857 uint32_t st_flags; /* user defined flags for file */
858 uint32_t st_gen; /* file generation number */
859 uint32_t st_spare[2];
860 };
861
862 typedef netbsd32_pointer_t netbsd32_statp_t;
863 struct netbsd32_stat {
864 netbsd32_dev_t st_dev; /* inode's device */
865 mode_t st_mode; /* inode protection mode */
866 netbsd32_uint64 st_ino; /* inode's number */
867 nlink_t st_nlink; /* number of hard links */
868 uid_t st_uid; /* user ID of the file's owner */
869 gid_t st_gid; /* group ID of the file's group */
870 netbsd32_dev_t st_rdev; /* device type */
871 struct netbsd32_timespec st_atimespec;/* time of last access */
872 struct netbsd32_timespec st_mtimespec;/* time of last data modification */
873 struct netbsd32_timespec st_ctimespec;/* time of last file status change */
874 struct netbsd32_timespec st_birthtimespec; /* time of creation */
875 netbsd32_int64 st_size; /* file size, in bytes */
876 netbsd32_uint64 st_blocks; /* blocks allocated for file */
877 blksize_t st_blksize; /* optimal blocksize for I/O */
878 uint32_t st_flags; /* user defined flags for file */
879 uint32_t st_gen; /* file generation number */
880 uint32_t st_spare[2];
881 };
882
883 /* from <sys/statvfs.h> */
884 typedef netbsd32_pointer_t netbsd32_statvfs90p_t;
885 struct netbsd32_statvfs90 {
886 netbsd32_u_long f_flag; /* copy of mount exported flags */
887 netbsd32_u_long f_bsize; /* system block size */
888 netbsd32_u_long f_frsize; /* system fragment size */
889 netbsd32_u_long f_iosize; /* optimal file system block size */
890 netbsd32_uint64 f_blocks; /* number of blocks in file system */
891 netbsd32_uint64 f_bfree; /* free blocks avail in file system */
892 netbsd32_uint64 f_bavail; /* free blocks avail to non-root */
893 netbsd32_uint64 f_bresvd; /* blocks reserved for root */
894 netbsd32_uint64 f_files; /* total file nodes in file system */
895 netbsd32_uint64 f_ffree; /* free file nodes in file system */
896 netbsd32_uint64 f_favail; /* free file nodes avail to non-root */
897 netbsd32_uint64 f_fresvd; /* file nodes reserved for root */
898 netbsd32_uint64 f_syncreads; /* count of sync reads since mount */
899 netbsd32_uint64 f_syncwrites; /* count of sync writes since mount */
900 netbsd32_uint64 f_asyncreads; /* count of async reads since mount */
901 netbsd32_uint64 f_asyncwrites; /* count of async writes since mount */
902 fsid_t f_fsidx; /* NetBSD compatible fsid */
903 netbsd32_u_long f_fsid; /* Posix compatible fsid */
904 netbsd32_u_long f_namemax; /* maximum filename length */
905 uid_t f_owner; /* user that mounted the file system */
906 uint32_t f_spare[4]; /* spare space */
907 char f_fstypename[_VFS_NAMELEN]; /* fs type name */
908 char f_mntonname[_VFS_MNAMELEN]; /* directory on which mounted */
909 char f_mntfromname[_VFS_MNAMELEN]; /* mounted file system */
910 };
911
912 typedef netbsd32_pointer_t netbsd32_statvfsp_t;
913 struct netbsd32_statvfs {
914 netbsd32_u_long f_flag; /* copy of mount exported flags */
915 netbsd32_u_long f_bsize; /* system block size */
916 netbsd32_u_long f_frsize; /* system fragment size */
917 netbsd32_u_long f_iosize; /* optimal file system block size */
918 netbsd32_uint64 f_blocks; /* number of blocks in file system */
919 netbsd32_uint64 f_bfree; /* free blocks avail in file system */
920 netbsd32_uint64 f_bavail; /* free blocks avail to non-root */
921 netbsd32_uint64 f_bresvd; /* blocks reserved for root */
922 netbsd32_uint64 f_files; /* total file nodes in file system */
923 netbsd32_uint64 f_ffree; /* free file nodes in file system */
924 netbsd32_uint64 f_favail; /* free file nodes avail to non-root */
925 netbsd32_uint64 f_fresvd; /* file nodes reserved for root */
926 netbsd32_uint64 f_syncreads; /* count of sync reads since mount */
927 netbsd32_uint64 f_syncwrites; /* count of sync writes since mount */
928 netbsd32_uint64 f_asyncreads; /* count of async reads since mount */
929 netbsd32_uint64 f_asyncwrites; /* count of async writes since mount */
930 fsid_t f_fsidx; /* NetBSD compatible fsid */
931 netbsd32_u_long f_fsid; /* Posix compatible fsid */
932 netbsd32_u_long f_namemax; /* maximum filename length */
933 uid_t f_owner; /* user that mounted the file system */
934 netbsd32_uint64 f_spare[4]; /* spare space */
935 char f_fstypename[_VFS_NAMELEN]; /* fs type name */
936 char f_mntonname[_VFS_MNAMELEN]; /* directory on which mounted */
937 char f_mntfromname[_VFS_MNAMELEN]; /* mounted file system */
938 char f_mntfromlabel[_VFS_MNAMELEN]; /* disk label name if available */
939 };
940
941 /* from <sys/timex.h> */
942 typedef netbsd32_pointer_t netbsd32_ntptimevalp_t;
943 typedef netbsd32_pointer_t netbsd32_ntptimeval30p_t;
944 typedef netbsd32_pointer_t netbsd32_ntptimeval50p_t;
945
946 struct netbsd32_ntptimeval30 {
947 struct netbsd32_timeval50 time; /* current time (ro) */
948 netbsd32_long maxerror; /* maximum error (us) (ro) */
949 netbsd32_long esterror; /* estimated error (us) (ro) */
950 };
951 struct netbsd32_ntptimeval50 {
952 struct netbsd32_timespec50 time; /* current time (ro) */
953 netbsd32_long maxerror; /* maximum error (us) (ro) */
954 netbsd32_long esterror; /* estimated error (us) (ro) */
955 netbsd32_long tai; /* TAI offset */
956 int time_state; /* time status */
957 };
958
959 struct netbsd32_ntptimeval {
960 struct netbsd32_timespec time; /* current time (ro) */
961 netbsd32_long maxerror; /* maximum error (us) (ro) */
962 netbsd32_long esterror; /* estimated error (us) (ro) */
963 netbsd32_long tai; /* TAI offset */
964 int time_state; /* time status */
965 };
966 typedef netbsd32_pointer_t netbsd32_timexp_t;
967 struct netbsd32_timex {
968 unsigned int modes; /* clock mode bits (wo) */
969 netbsd32_long offset; /* time offset (us) (rw) */
970 netbsd32_long freq; /* frequency offset (scaled ppm) (rw) */
971 netbsd32_long maxerror; /* maximum error (us) (rw) */
972 netbsd32_long esterror; /* estimated error (us) (rw) */
973 int status; /* clock status bits (rw) */
974 netbsd32_long constant; /* pll time constant (rw) */
975 netbsd32_long precision; /* clock precision (us) (ro) */
976 netbsd32_long tolerance; /* clock frequency tolerance (scaled
977 * ppm) (ro) */
978 /*
979 * The following read-only structure members are implemented
980 * only if the PPS signal discipline is configured in the
981 * kernel.
982 */
983 netbsd32_long ppsfreq; /* pps frequency (scaled ppm) (ro) */
984 netbsd32_long jitter; /* pps jitter (us) (ro) */
985 int shift; /* interval duration (s) (shift) (ro) */
986 netbsd32_long stabil; /* pps stability (scaled ppm) (ro) */
987 netbsd32_long jitcnt; /* jitter limit exceeded (ro) */
988 netbsd32_long calcnt; /* calibration intervals (ro) */
989 netbsd32_long errcnt; /* calibration errors (ro) */
990 netbsd32_long stbcnt; /* stability limit exceeded (ro) */
991 };
992
993 /* <prop/plistref.h> */
994 struct netbsd32_plistref {
995 netbsd32_pointer_t pref_plist;
996 netbsd32_size_t pref_len;
997 };
998
999 /* <nv.h> */
1000 typedef struct {
1001 netbsd32_pointer_t buf;
1002 netbsd32_size_t len;
1003 int flags;
1004 } netbsd32_nvlist_ref_t;
1005
1006 /* from <ufs/lfs/lfs.h> */
1007 typedef netbsd32_pointer_t netbsd32_block_infop_t; /* XXX broken */
1008
1009 /* from <sys/utsname.h> */
1010 typedef netbsd32_pointer_t netbsd32_utsnamep_t;
1011
1012 /* from <compat/common/kern_info_09.c> */
1013 typedef netbsd32_pointer_t netbsd32_outsnamep_t;
1014
1015 /* from <arch/sparc{,64}/include/vuid_event.h> */
1016 typedef struct firm_event32 {
1017 unsigned short id; /* key or MS_* or LOC_[XY]_DELTA */
1018 unsigned short pad; /* unused, at least by X11 */
1019 int value; /* VKEY_{UP,DOWN} or locator delta */
1020 struct netbsd32_timeval time;
1021 } Firm_event32;
1022
1023 /* from <sys/uuid.h> */
1024 typedef netbsd32_pointer_t netbsd32_uuidp_t;
1025
1026 /* from <sys/event.h> */
1027 typedef netbsd32_pointer_t netbsd32_keventp_t;
1028
1029 struct netbsd32_kevent {
1030 netbsd32_uintptr_t ident;
1031 uint32_t filter;
1032 uint32_t flags;
1033 uint32_t fflags;
1034 netbsd32_int64 data;
1035 netbsd32_pointer_t udata;
1036 netbsd32_uint64 ext[4];
1037 };
1038
1039 /* from <compat/sys/event.h> */
1040 typedef netbsd32_pointer_t netbsd32_kevent100p_t;
1041
1042 struct netbsd32_kevent100 {
1043 netbsd32_uintptr_t ident;
1044 uint32_t filter;
1045 uint32_t flags;
1046 uint32_t fflags;
1047 netbsd32_int64 data;
1048 netbsd32_pointer_t udata;
1049 };
1050
1051 /* from <sys/sched.h> */
1052 typedef netbsd32_pointer_t netbsd32_sched_paramp_t;
1053 typedef netbsd32_pointer_t netbsd32_cpusetp_t;
1054
1055 /* from <fs/tmpfs/tmpfs_args.h> */
1056 struct netbsd32_tmpfs_args {
1057 int ta_version;
1058
1059 /* Size counters. */
1060 netbsd32_ino_t ta_nodes_max;
1061 netbsd32_off_t ta_size_max;
1062
1063 /* Root node attributes. */
1064 uid_t ta_root_uid;
1065 gid_t ta_root_gid;
1066 mode_t ta_root_mode;
1067 };
1068
1069 /* from <fs/cd9660/cd9660_mount.h> */
1070 struct netbsd32_iso_args {
1071 netbsd32_charp fspec;
1072 struct netbsd32_export_args30 _pad1;
1073 int flags;
1074 };
1075
1076 /* from <ufs/ufs/ufs_mount.h> */
1077 struct netbsd32_ufs_args {
1078 netbsd32_charp fspec;
1079 };
1080
1081 struct netbsd32_mfs_args {
1082 netbsd32_charp fspec;
1083 struct netbsd32_export_args30 _pad1;
1084 netbsd32_voidp base;
1085 netbsd32_u_long size;
1086 };
1087
1088 /* from <nfs/nfs.h> */
1089 struct netbsd32_nfsd_args {
1090 int sock;
1091 netbsd32_voidp name;
1092 int namelen;
1093 };
1094
1095 typedef netbsd32_pointer_t netbsd32_nfsdp;
1096 struct netbsd32_nfsd_srvargs {
1097 netbsd32_nfsdp nsd_nfsd;
1098 uid_t nsd_uid;
1099 uint32_t nsd_haddr;
1100 struct uucred nsd_cr;
1101 int nsd_authlen;
1102 netbsd32_u_charp nsd_authstr;
1103 int nsd_verflen;
1104 netbsd32_u_charp nsd_verfstr;
1105 struct netbsd32_timeval nsd_timestamp;
1106 uint32_t nsd_ttl;
1107 NFSKERBKEY_T nsd_key;
1108 };
1109
1110 typedef netbsd32_pointer_t netbsd32_export_argsp;
1111 struct netbsd32_export_args {
1112 int ex_flags;
1113 uid_t ex_root;
1114 struct uucred ex_anon;
1115 netbsd32_sockaddrp_t ex_addr;
1116 int ex_addrlen;
1117 netbsd32_sockaddrp_t ex_mask;
1118 int ex_masklen;
1119 netbsd32_charp ex_indexfile;
1120 };
1121
1122 struct netbsd32_mountd_exports_list {
1123 const netbsd32_charp mel_path;
1124 netbsd32_size_t mel_nexports;
1125 netbsd32_export_argsp mel_exports;
1126 };
1127
1128 /* from <nfs/nfsmount,h> */
1129 struct netbsd32_nfs_args {
1130 int32_t version; /* args structure version number */
1131 netbsd32_sockaddrp_t addr; /* file server address */
1132 int32_t addrlen; /* length of address */
1133 int32_t sotype; /* Socket type */
1134 int32_t proto; /* and Protocol */
1135 netbsd32_u_charp fh; /* File handle to be mounted */
1136 int32_t fhsize; /* Size, in bytes, of fh */
1137 int32_t flags; /* flags */
1138 int32_t wsize; /* write size in bytes */
1139 int32_t rsize; /* read size in bytes */
1140 int32_t readdirsize; /* readdir size in bytes */
1141 int32_t timeo; /* initial timeout in .1 secs */
1142 int32_t retrans; /* times to retry send */
1143 int32_t maxgrouplist; /* Max. size of group list */
1144 int32_t readahead; /* # of blocks to readahead */
1145 int32_t leaseterm; /* Ignored; Term (sec) of lease */
1146 int32_t deadthresh; /* Retrans threshold */
1147 netbsd32_charp hostname; /* server's name */
1148 };
1149
1150 /* from <msdosfs/msdosfsmount.h> */
1151 struct netbsd32_msdosfs_args {
1152 netbsd32_charp fspec; /* blocks special holding the fs to mount */
1153 struct netbsd32_export_args30 _pad1; /* compat with old userland tools */
1154 uid_t uid; /* uid that owns msdosfs files */
1155 gid_t gid; /* gid that owns msdosfs files */
1156 mode_t mask; /* mask to be applied for msdosfs perms */
1157 int flags; /* see below */
1158
1159 /* Following items added after versioning support */
1160 int version; /* version of the struct */
1161 mode_t dirmask; /* v2: mask to be applied for msdosfs perms */
1162 int gmtoff; /* v3: offset from UTC in seconds */
1163 };
1164
1165 /* from <udf/udf_mount.h> */
1166 struct netbsd32_udf_args {
1167 uint32_t version; /* version of this structure */
1168 netbsd32_charp fspec; /* mount specifier */
1169 int32_t sessionnr; /* session specifier, rel of abs */
1170 uint32_t udfmflags; /* mount options */
1171 int32_t gmtoff; /* offset from UTC in seconds */
1172
1173 uid_t anon_uid; /* mapping of anonymous files uid */
1174 gid_t anon_gid; /* mapping of anonymous files gid */
1175 uid_t nobody_uid; /* nobody:nobody will map to -1:-1 */
1176 gid_t nobody_gid; /* nobody:nobody will map to -1:-1 */
1177
1178 uint32_t sector_size; /* for mounting dumps/files */
1179
1180 /* extendable */
1181 uint8_t reserved[32];
1182 };
1183
1184 /* from <miscfs/genfs/layer.h> */
1185 struct netbsd32_layer_args {
1186 netbsd32_charp target; /* Target of loopback */
1187 struct netbsd32_export_args30 _pad1; /* compat with old userland tools */
1188 };
1189
1190 /* from <miscfs/nullfs/null.h> */
1191 struct netbsd32_null_args {
1192 struct netbsd32_layer_args la; /* generic layerfs args */
1193 };
1194
1195 struct netbsd32_posix_spawn_file_actions_entry {
1196 enum { FAE32_OPEN, FAE32_DUP2, FAE32_CLOSE,
1197 FAE32_CHDIR, FAE32_FCHDIR } fae_action;
1198
1199 int fae_fildes;
1200 union {
1201 struct {
1202 netbsd32_charp path;
1203 int oflag;
1204 mode_t mode;
1205 } open;
1206 struct {
1207 int newfildes;
1208 } dup2;
1209 struct {
1210 netbsd32_charp path;
1211 } chdir;
1212 } fae_data;
1213 };
1214
1215 struct netbsd32_posix_spawn_file_actions {
1216 unsigned int size; /* size of fae array */
1217 unsigned int len; /* how many slots are used */
1218 netbsd32_posix_spawn_file_actions_entryp fae;
1219 };
1220
1221 struct netbsd32_modctl_load {
1222 netbsd32_charp ml_filename;
1223 int ml_flags;
1224 netbsd32_charp ml_props;
1225 netbsd32_size_t ml_propslen;
1226 };
1227
1228 struct netbsd32_mq_attr {
1229 netbsd32_long mq_flags;
1230 netbsd32_long mq_maxmsg;
1231 netbsd32_long mq_msgsize;
1232 netbsd32_long mq_curmsgs;
1233 };
1234 typedef netbsd32_pointer_t netbsd32_mq_attrp_t;
1235
1236 #if 0
1237 int netbsd32_kevent(struct lwp *, void *, register_t *);
1238 #endif
1239
1240 /*
1241 * here are some macros to convert between netbsd32 and native 64 bit types.
1242 * note that they do *NOT* act like good macros and put ()'s around all
1243 * arguments cuz this _breaks_ SCARG().
1244 */
1245 #define NETBSD32TO64(s32uap, uap, name) \
1246 SCARG(uap, name) = SCARG(s32uap, name)
1247 #define NETBSD32TOP(s32uap, uap, name, type) \
1248 SCARG(uap, name) = SCARG_P32(s32uap, name)
1249 #define NETBSD32TOX(s32uap, uap, name, type) \
1250 SCARG(uap, name) = (type)SCARG(s32uap, name)
1251 #define NETBSD32TOX64(s32uap, uap, name, type) \
1252 SCARG(uap, name) = (type)(long)SCARG(s32uap, name)
1253
1254 /* and some standard versions */
1255 #define NETBSD32TO64_UAP(name) NETBSD32TO64(uap, &ua, name)
1256 #define NETBSD32TOP_UAP(name, type) NETBSD32TOP(uap, &ua, name, type)
1257 #define NETBSD32TOX_UAP(name, type) NETBSD32TOX(uap, &ua, name, type)
1258 #define NETBSD32TOX64_UAP(name, type) NETBSD32TOX64(uap, &ua, name, type)
1259
1260 #define SCARG_P32(uap, name) NETBSD32PTR64(SCARG(uap, name))
1261
1262 struct coredump_iostate;
1263 int coredump_netbsd32(struct lwp *, struct coredump_iostate *);
1264 int real_coredump_netbsd32(struct lwp *, struct coredump_iostate *);
1265
1266 /*
1267 * random other stuff
1268 */
1269
1270 vaddr_t netbsd32_vm_default_addr(struct proc *, vaddr_t, vsize_t, int);
1271 void netbsd32_adjust_limits(struct proc *);
1272
1273 void netbsd32_si_to_si32(siginfo32_t *, const siginfo_t *);
1274 void netbsd32_si32_to_si(siginfo_t *, const siginfo32_t *);
1275
1276 void netbsd32_ksi32_to_ksi(struct _ksiginfo *si, const struct __ksiginfo32 *si32);
1277
1278 void netbsd32_read_lwpstatus(struct lwp *, struct netbsd32_ptrace_lwpstatus *);
1279
1280 #ifdef KTRACE
1281 void netbsd32_ktrpsig(int, sig_t, const sigset_t *, const ksiginfo_t *);
1282 #else
1283 #define netbsd32_ktrpsig NULL
1284 #endif
1285
1286
1287 void startlwp32(void *);
1288 struct compat_50_netbsd32___semctl14_args;
1289 int do_netbsd32___semctl14(struct lwp *, const struct compat_50_netbsd32___semctl14_args *, register_t *, void *);
1290
1291 struct iovec *netbsd32_get_iov(struct netbsd32_iovec *, int, struct iovec *,
1292 int);
1293
1294 #ifdef SYSCTL_SETUP_PROTO
1295 SYSCTL_SETUP_PROTO(netbsd32_sysctl_emul_setup);
1296 #endif /* SYSCTL_SETUP_PROTO */
1297
1298 #ifdef __HAVE_STRUCT_SIGCONTEXT
1299 MODULE_HOOK(netbsd32_sendsig_sigcontext_16_hook, void,
1300 (const struct ksiginfo *, const sigset_t *));
1301 #endif
1302
1303 extern struct sysent netbsd32_sysent[];
1304 extern const uint32_t netbsd32_sysent_nomodbits[];
1305 #ifdef SYSCALL_DEBUG
1306 extern const char * const netbsd32_syscallnames[];
1307 #endif
1308
1309 extern struct sysctlnode netbsd32_sysctl_root;
1310
1311 struct netbsd32_modctl_args;
1312 MODULE_HOOK(compat32_80_modctl_hook, int,
1313 (struct lwp *, const struct netbsd32_modctl_args *, register_t *));
1314
1315 /*
1316 * Finally, declare emul_netbsd32 as this is needed in lots of
1317 * places when calling syscall_{,dis}establish()
1318 */
1319
1320 extern struct emul emul_netbsd32;
1321 extern char netbsd32_sigcode[], netbsd32_esigcode[];
1322
1323 /*
1324 * Prototypes for MD initialization routines
1325 */
1326 void netbsd32_machdep_md_init(void);
1327 void netbsd32_machdep_md_fini(void);
1328 void netbsd32_machdep_md_13_init(void);
1329 void netbsd32_machdep_md_13_fini(void);
1330 void netbsd32_machdep_md_16_init(void);
1331 void netbsd32_machdep_md_16_fini(void);
1332
1333 #endif /* _COMPAT_NETBSD32_NETBSD32_H_ */
1334