netbsd32.h revision 1.83 1 /* $NetBSD: netbsd32.h,v 1.83 2009/12/12 10:32:26 njoly Exp $ */
2
3 /*
4 * Copyright (c) 1998, 2001, 2008 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/systm.h>
40 #include <sys/mount.h>
41 #include <sys/stat.h>
42 #include <sys/statvfs.h>
43 #include <sys/syscallargs.h>
44 #include <sys/ipc.h>
45 #include <sys/shm.h>
46 #include <sys/ucontext.h>
47 #include <compat/sys/ucontext.h>
48 #include <compat/sys/mount.h>
49
50 /*
51 * first, define the basic types we need.
52 */
53
54 typedef int32_t netbsd32_long;
55 typedef uint32_t netbsd32_u_long;
56 typedef int64_t netbsd32_quad;
57
58 typedef uint32_t netbsd32_clock_t;
59 typedef uint32_t netbsd32_size_t;
60 typedef int32_t netbsd32_ssize_t;
61 typedef int32_t netbsd32_clockid_t;
62 typedef int32_t netbsd32_key_t;
63 typedef int32_t netbsd32_intptr_t;
64 typedef uint32_t netbsd32_uintptr_t;
65
66 /* netbsd32_[u]int64 are machine dependant and defined below */
67
68 /*
69 * machine depedant section; must define:
70 * netbsd32_pointer_t
71 * - 32-bit pointer type, normally uint32_t but can be int32_t
72 * for platforms which rely on sign-extension of pointers
73 * such as SH-5.
74 * NETBSD32PTR64(p32)
75 * - Translate a 32-bit pointer into something valid in a
76 * 64-bit context.
77 * struct netbsd32_sigcontext
78 * - 32bit compatibility sigcontext structure for this arch.
79 * netbsd32_sigcontextp_t
80 * - type of pointer to above, normally uint32_t
81 * void netbsd32_setregs(struct proc *p, struct exec_package *pack,
82 * unsigned long stack);
83 * int netbsd32_sigreturn(struct proc *p, void *v,
84 * register_t *retval);
85 * void netbsd32_sendsig(sig_t catcher, int sig, int mask, u_long code);
86 * char netbsd32_esigcode[], netbsd32_sigcode[]
87 * - the above are abvious
88 *
89 * pull in the netbsd32 machine dependant header, that may help with the
90 * above, or it may be provided via the MD layer itself.
91 */
92 #include <machine/netbsd32_machdep.h>
93
94 /* netbsd32_machdep.h will have (typically) defined:
95 #define NETBSD32_POINTER_TYPE uint32_t
96 typedef struct { NETBSD32_POINTER_TYPE i32; } netbsd32_pointer_t;
97 */
98
99 /*
100 * Conversion functions for the rest of the compat32 code:
101 *
102 * NETBSD32PTR64() Convert user-supplied 32bit pointer to 'void *'
103 * NETBSD32PTR32() Assign a 'void *' to a 32bit pointer variable
104 * NETBSD32PTR32PLUS() Add an integer to a 32bit pointer
105 *
106 * Under rare circumstances the following get used:
107 *
108 * NETBSD32PTR32I() Convert 'void *' to the 32bit pointer base type.
109 * NETBSD32IPTR64() Convert 32bit pointer base type to 'void *'
110 */
111 #define NETBSD32PTR64(p32) NETBSD32IPTR64((p32).i32)
112 #define NETBSD32PTR32(p32, p64) ((p32).i32 = NETBSD32PTR32I(p64))
113 #define NETBSD32PTR32PLUS(p32, incr) ((p32).i32 += incr)
114
115 static __inline NETBSD32_POINTER_TYPE
116 NETBSD32PTR32I(const void *p64) { return (uintptr_t)p64; }
117 static __inline void *
118 NETBSD32IPTR64(NETBSD32_POINTER_TYPE p32) { return (void *)(intptr_t)p32; }
119
120 /* Nothing should be using the raw type, so kill it */
121 #undef NETBSD32_POINTER_TYPE
122
123 /*
124 * 64 bit integers only have 4-byte alignment on some 32 bit ports,
125 * but always have 8-byte alignment on 64 bit systems.
126 * NETBSD32_INT64_ALIGN may be __attribute__((__aligned__(4)))
127 */
128 typedef int64_t netbsd32_int64 NETBSD32_INT64_ALIGN;
129 typedef uint64_t netbsd32_uint64 NETBSD32_INT64_ALIGN;
130 #undef NETBSD32_INT64_ALIGN
131
132 /*
133 * all pointers are netbsd32_pointer_t (defined in <machine/netbsd32_machdep.h>)
134 */
135
136 typedef netbsd32_pointer_t netbsd32_voidp;
137 typedef netbsd32_pointer_t netbsd32_u_shortp;
138 typedef netbsd32_pointer_t netbsd32_charp;
139 typedef netbsd32_pointer_t netbsd32_u_charp;
140 typedef netbsd32_pointer_t netbsd32_charpp;
141 typedef netbsd32_pointer_t netbsd32_size_tp;
142 typedef netbsd32_pointer_t netbsd32_intp;
143 typedef netbsd32_pointer_t netbsd32_longp;
144 typedef netbsd32_pointer_t netbsd32_caddrp;
145 typedef netbsd32_pointer_t netbsd32_caddr;
146 typedef netbsd32_pointer_t netbsd32_gid_tp;
147 typedef netbsd32_pointer_t netbsd32_fsid_tp_t;
148 typedef netbsd32_pointer_t netbsd32_lwpidp;
149 typedef netbsd32_pointer_t netbsd32_ucontextp;
150 typedef netbsd32_pointer_t netbsd32_caddr_t;
151 typedef netbsd32_pointer_t netbsd32_lwpctlp;
152
153 /*
154 * now, the compatibility structures and their fake pointer types.
155 */
156
157 /* from <sys/types.h> */
158 typedef netbsd32_pointer_t netbsd32_fd_setp_t;
159 typedef netbsd32_intptr_t netbsd32_semid_t;
160 typedef netbsd32_pointer_t netbsd32_semidp_t;
161 typedef netbsd32_uint64 netbsd32_dev_t;
162
163 /* from <sys/uio.h> */
164 typedef netbsd32_pointer_t netbsd32_iovecp_t;
165 struct netbsd32_iovec {
166 netbsd32_voidp iov_base; /* Base address. */
167 netbsd32_size_t iov_len; /* Length. */
168 };
169
170 /* from <sys/time.h> */
171 typedef int32_t netbsd32_timer_t;
172 typedef int32_t netbsd32_time50_t;
173 typedef netbsd32_int64 netbsd32_time_t;
174 typedef netbsd32_pointer_t netbsd32_timerp_t;
175
176 typedef netbsd32_pointer_t netbsd32_timespec50p_t;
177 struct netbsd32_timespec50 {
178 netbsd32_time50_t tv_sec; /* seconds */
179 netbsd32_long tv_nsec; /* and nanoseconds */
180 };
181
182 typedef netbsd32_pointer_t netbsd32_timespecp_t;
183 struct netbsd32_timespec {
184 netbsd32_time_t tv_sec; /* seconds */
185 netbsd32_long tv_nsec; /* and nanoseconds */
186 };
187
188 typedef netbsd32_pointer_t netbsd32_timeval50p_t;
189 struct netbsd32_timeval50 {
190 netbsd32_time50_t tv_sec; /* seconds */
191 netbsd32_long tv_usec; /* and microseconds */
192 };
193
194 typedef netbsd32_pointer_t netbsd32_timevalp_t;
195 struct netbsd32_timeval {
196 netbsd32_time_t tv_sec; /* seconds */
197 netbsd32_long tv_usec; /* and microseconds */
198 };
199
200 typedef netbsd32_pointer_t netbsd32_timezonep_t;
201 struct netbsd32_timezone {
202 int tz_minuteswest; /* minutes west of Greenwich */
203 int tz_dsttime; /* type of dst correction */
204 };
205
206 typedef netbsd32_pointer_t netbsd32_itimerval50p_t;
207 struct netbsd32_itimerval50 {
208 struct netbsd32_timeval50 it_interval; /* timer interval */
209 struct netbsd32_timeval50 it_value; /* current value */
210 };
211
212 typedef netbsd32_pointer_t netbsd32_itimervalp_t;
213 struct netbsd32_itimerval {
214 struct netbsd32_timeval it_interval; /* timer interval */
215 struct netbsd32_timeval it_value; /* current value */
216 };
217
218 typedef netbsd32_pointer_t netbsd32_itimerspec50p_t;
219 struct netbsd32_itimerspec50 {
220 struct netbsd32_timespec50 it_interval;
221 struct netbsd32_timespec50 it_value;
222 };
223
224 typedef netbsd32_pointer_t netbsd32_itimerspecp_t;
225 struct netbsd32_itimerspec {
226 struct netbsd32_timespec it_interval;
227 struct netbsd32_timespec it_value;
228 };
229
230 /* from <sys/mount.h> */
231 typedef netbsd32_pointer_t netbsd32_fidp_t;
232
233 typedef netbsd32_pointer_t netbsd32_fhandlep_t;
234 typedef netbsd32_pointer_t netbsd32_compat_30_fhandlep_t;
235
236 typedef netbsd32_pointer_t netbsd32_statfsp_t;
237 struct netbsd32_statfs {
238 short f_type; /* type of file system */
239 unsigned short f_flags; /* copy of mount flags */
240 netbsd32_long f_bsize; /* fundamental file system block size */
241 netbsd32_long f_iosize; /* optimal transfer block size */
242 netbsd32_long f_blocks; /* total data blocks in file system */
243 netbsd32_long f_bfree; /* free blocks in fs */
244 netbsd32_long f_bavail; /* free blocks avail to non-superuser */
245 netbsd32_long f_files; /* total file nodes in file system */
246 netbsd32_long f_ffree; /* free file nodes in fs */
247 fsid_t f_fsid; /* file system id */
248 uid_t f_owner; /* user that mounted the file system */
249 netbsd32_long f_spare[4]; /* spare for later */
250 char f_fstypename[MFSNAMELEN]; /* fs type name */
251 char f_mntonname[MNAMELEN]; /* directory on which mounted */
252 char f_mntfromname[MNAMELEN]; /* mounted file system */
253 };
254
255 /* from <sys/poll.h> */
256 typedef netbsd32_pointer_t netbsd32_pollfdp_t;
257
258 /* from <sys/resource.h> */
259 typedef netbsd32_pointer_t netbsd32_rusage50p_t;
260 struct netbsd32_rusage50 {
261 struct netbsd32_timeval50 ru_utime;/* user time used */
262 struct netbsd32_timeval50 ru_stime;/* system time used */
263 netbsd32_long ru_maxrss; /* max resident set size */
264 netbsd32_long ru_ixrss; /* integral shared memory size */
265 netbsd32_long ru_idrss; /* integral unshared data " */
266 netbsd32_long ru_isrss; /* integral unshared stack " */
267 netbsd32_long ru_minflt; /* page reclaims */
268 netbsd32_long ru_majflt; /* page faults */
269 netbsd32_long ru_nswap; /* swaps */
270 netbsd32_long ru_inblock; /* block input operations */
271 netbsd32_long ru_oublock; /* block output operations */
272 netbsd32_long ru_msgsnd; /* messages sent */
273 netbsd32_long ru_msgrcv; /* messages received */
274 netbsd32_long ru_nsignals; /* signals received */
275 netbsd32_long ru_nvcsw; /* voluntary context switches */
276 netbsd32_long ru_nivcsw; /* involuntary " */
277 };
278
279 typedef netbsd32_pointer_t netbsd32_rusagep_t;
280 struct netbsd32_rusage {
281 struct netbsd32_timeval ru_utime;/* user time used */
282 struct netbsd32_timeval ru_stime;/* system time used */
283 netbsd32_long ru_maxrss; /* max resident set size */
284 netbsd32_long ru_ixrss; /* integral shared memory size */
285 netbsd32_long ru_idrss; /* integral unshared data " */
286 netbsd32_long ru_isrss; /* integral unshared stack " */
287 netbsd32_long ru_minflt; /* page reclaims */
288 netbsd32_long ru_majflt; /* page faults */
289 netbsd32_long ru_nswap; /* swaps */
290 netbsd32_long ru_inblock; /* block input operations */
291 netbsd32_long ru_oublock; /* block output operations */
292 netbsd32_long ru_msgsnd; /* messages sent */
293 netbsd32_long ru_msgrcv; /* messages received */
294 netbsd32_long ru_nsignals; /* signals received */
295 netbsd32_long ru_nvcsw; /* voluntary context switches */
296 netbsd32_long ru_nivcsw; /* involuntary " */
297 };
298
299 typedef netbsd32_pointer_t netbsd32_orlimitp_t;
300
301 typedef netbsd32_pointer_t netbsd32_rlimitp_t;
302
303 struct netbsd32_loadavg {
304 fixpt_t ldavg[3];
305 netbsd32_long fscale;
306 };
307
308 /* from <sys/ipc.h> */
309 typedef netbsd32_pointer_t netbsd32_ipc_permp_t;
310 struct netbsd32_ipc_perm {
311 uid_t cuid; /* creator user id */
312 gid_t cgid; /* creator group id */
313 uid_t uid; /* user id */
314 gid_t gid; /* group id */
315 mode_t mode; /* r/w permission */
316 unsigned short _seq; /* sequence # (to generate unique msg/sem/shm id) */
317 netbsd32_key_t _key; /* user specified msg/sem/shm key */
318 };
319 struct netbsd32_ipc_perm14 {
320 unsigned short cuid; /* creator user id */
321 unsigned short cgid; /* creator group id */
322 unsigned short uid; /* user id */
323 unsigned short gid; /* group id */
324 unsigned short mode; /* r/w permission */
325 unsigned short seq; /* sequence # (to generate unique msg/sem/shm id) */
326 netbsd32_key_t key; /* user specified msg/sem/shm key */
327 };
328
329 /* from <sys/msg.h> */
330 typedef netbsd32_pointer_t netbsd32_msgp_t;
331 struct netbsd32_msg {
332 netbsd32_msgp_t msg_next; /* next msg in the chain */
333 netbsd32_long msg_type; /* type of this message */
334 /* >0 -> type of this message */
335 /* 0 -> free header */
336 unsigned short msg_ts; /* size of this message */
337 short msg_spot; /* location of start of msg in buffer */
338 };
339
340 typedef uint32_t netbsd32_msgqnum_t;
341 typedef netbsd32_size_t netbsd32_msglen_t;
342
343 typedef netbsd32_pointer_t netbsd32_msqid_dsp_t;
344 struct netbsd32_msqid_ds {
345 struct netbsd32_ipc_perm msg_perm; /* operation permission strucure */
346 netbsd32_msgqnum_t msg_qnum; /* number of messages in the queue */
347 netbsd32_msglen_t msg_qbytes; /* max # of bytes in the queue */
348 pid_t msg_lspid; /* process ID of last msgsend() */
349 pid_t msg_lrpid; /* process ID of last msgrcv() */
350 netbsd32_time_t msg_stime; /* time of last msgsend() */
351 netbsd32_time_t msg_rtime; /* time of last msgrcv() */
352 netbsd32_time_t msg_ctime; /* time of last change */
353
354 /*
355 * These members are private and used only in the internal
356 * implementation of this interface.
357 */
358 netbsd32_msgp_t _msg_first; /* first message in the queue */
359 netbsd32_msgp_t _msg_last; /* last message in the queue */
360 netbsd32_msglen_t _msg_cbytes; /* # of bytes currently in queue */
361 };
362 typedef netbsd32_pointer_t netbsd32_msqid_ds50p_t;
363 struct netbsd32_msqid_ds50 {
364 struct netbsd32_ipc_perm msg_perm; /* operation permission strucure */
365 netbsd32_msgqnum_t msg_qnum; /* number of messages in the queue */
366 netbsd32_msglen_t msg_qbytes; /* max # of bytes in the queue */
367 pid_t msg_lspid; /* process ID of last msgsend() */
368 pid_t msg_lrpid; /* process ID of last msgrcv() */
369 int32_t msg_stime; /* time of last msgsend() */
370 int32_t msg_rtime; /* time of last msgrcv() */
371 int32_t msg_ctime; /* time of last change */
372
373 /*
374 * These members are private and used only in the internal
375 * implementation of this interface.
376 */
377 netbsd32_msgp_t _msg_first; /* first message in the queue */
378 netbsd32_msgp_t _msg_last; /* last message in the queue */
379 netbsd32_msglen_t _msg_cbytes; /* # of bytes currently in queue */
380 };
381
382 typedef netbsd32_pointer_t netbsd32_msqid_ds14p_t;
383 struct netbsd32_msqid_ds14 {
384 struct netbsd32_ipc_perm14 msg_perm; /* msg queue permission bits */
385 netbsd32_msgp_t msg_first; /* first message in the queue */
386 netbsd32_msgp_t msg_last; /* last message in the queue */
387 netbsd32_u_long msg_cbytes; /* number of bytes in use on the queue */
388 netbsd32_u_long msg_qnum; /* number of msgs in the queue */
389 netbsd32_u_long msg_qbytes; /* max # of bytes on the queue */
390 pid_t msg_lspid; /* pid of last msgsnd() */
391 pid_t msg_lrpid; /* pid of last msgrcv() */
392 int32_t msg_stime; /* time of last msgsnd() */
393 netbsd32_long msg_pad1;
394 int32_t msg_rtime; /* time of last msgrcv() */
395 netbsd32_long msg_pad2;
396 int32_t msg_ctime; /* time of last msgctl() */
397 netbsd32_long msg_pad3;
398 netbsd32_long msg_pad4[4];
399 };
400
401 /* from <sys/sa.h> */
402 typedef netbsd32_pointer_t netbsd32_sa_upcall_t;
403 typedef netbsd32_pointer_t netbsd32_sa_upcallp_t;
404
405 void netbsd32_cpu_upcall(struct lwp *, int, int, int, void *, void *,
406 void *, sa_upcall_t);
407
408 /* from <sys/sem.h> */
409 typedef netbsd32_pointer_t netbsd32_semp_t;
410
411 typedef netbsd32_pointer_t netbsd32_semid_dsp_t;
412 struct netbsd32_semid_ds {
413 struct netbsd32_ipc_perm sem_perm;/* operation permission struct */
414 unsigned short sem_nsems; /* number of sems in set */
415 netbsd32_time_t sem_otime; /* last operation time */
416 netbsd32_time_t sem_ctime; /* last change time */
417
418 /*
419 * These members are private and used only in the internal
420 * implementation of this interface.
421 */
422 netbsd32_semp_t _sem_base; /* pointer to first semaphore in set */
423 };
424
425 typedef netbsd32_pointer_t netbsd32_semid_ds50p_t;
426 struct netbsd32_semid_ds50 {
427 struct netbsd32_ipc_perm sem_perm;/* operation permission struct */
428 unsigned short sem_nsems; /* number of sems in set */
429 int32_t sem_otime; /* last operation time */
430 int32_t sem_ctime; /* last change time */
431
432 /*
433 * These members are private and used only in the internal
434 * implementation of this interface.
435 */
436 netbsd32_semp_t _sem_base; /* pointer to first semaphore in set */
437 };
438
439 typedef netbsd32_pointer_t netbsd32_semid_ds14p_t;
440 struct netbsd32_semid_ds14 {
441 struct netbsd32_ipc_perm14 sem_perm;/* operation permission struct */
442 netbsd32_semp_t sem_base; /* pointer to first semaphore in set */
443 unsigned short sem_nsems; /* number of sems in set */
444 netbsd32_time_t sem_otime; /* last operation time */
445 netbsd32_long sem_pad1; /* SVABI/386 says I need this here */
446 netbsd32_time_t sem_ctime; /* last change time */
447 /* Times measured in secs since */
448 /* 00:00:00 GMT, Jan. 1, 1970 */
449 int32_t sem_pad2; /* SVABI/386 says I need this here */
450 int32_t sem_pad3[4]; /* SVABI/386 says I need this here */
451 };
452
453 typedef uint32_t netbsd32_semunu_t;
454 typedef netbsd32_pointer_t netbsd32_semunp_t;
455 union netbsd32_semun {
456 int val; /* value for SETVAL */
457 netbsd32_semid_dsp_t buf; /* buffer for IPC_STAT & IPC_SET */
458 netbsd32_u_shortp array; /* array for GETALL & SETALL */
459 };
460
461 typedef netbsd32_pointer_t netbsd32_semun50p_t;
462 union netbsd32_semun50 {
463 int val; /* value for SETVAL */
464 netbsd32_semid_ds50p_t buf; /* buffer for IPC_STAT & IPC_SET */
465 netbsd32_u_shortp array; /* array for GETALL & SETALL */
466 };
467
468 typedef netbsd32_pointer_t netbsd32_sembufp_t;
469 struct netbsd32_sembuf {
470 unsigned short sem_num; /* semaphore # */
471 short sem_op; /* semaphore operation */
472 short sem_flg; /* operation flags */
473 };
474
475 /* from <sys/shm.h> */
476 typedef netbsd32_pointer_t netbsd32_shmid_dsp_t;
477 struct netbsd32_shmid_ds {
478 struct netbsd32_ipc_perm shm_perm; /* operation permission structure */
479 netbsd32_size_t shm_segsz; /* size of segment in bytes */
480 pid_t shm_lpid; /* process ID of last shm op */
481 pid_t shm_cpid; /* process ID of creator */
482 shmatt_t shm_nattch; /* number of current attaches */
483 netbsd32_time_t shm_atime; /* time of last shmat() */
484 netbsd32_time_t shm_dtime; /* time of last shmdt() */
485 netbsd32_time_t shm_ctime; /* time of last change by shmctl() */
486 netbsd32_voidp _shm_internal; /* sysv stupidity */
487 };
488
489 typedef netbsd32_pointer_t netbsd32_shmid_ds50p_t;
490 struct netbsd32_shmid_ds50 {
491 struct netbsd32_ipc_perm shm_perm; /* operation permission structure */
492 netbsd32_size_t shm_segsz; /* size of segment in bytes */
493 pid_t shm_lpid; /* process ID of last shm op */
494 pid_t shm_cpid; /* process ID of creator */
495 shmatt_t shm_nattch; /* number of current attaches */
496 int32_t shm_atime; /* time of last shmat() */
497 int32_t shm_dtime; /* time of last shmdt() */
498 int32_t shm_ctime; /* time of last change by shmctl() */
499 netbsd32_voidp _shm_internal; /* sysv stupidity */
500 };
501
502 typedef netbsd32_pointer_t netbsd32_shmid_ds14p_t;
503 struct netbsd32_shmid_ds14 {
504 struct netbsd32_ipc_perm14 shm_perm; /* operation permission structure */
505 int shm_segsz; /* size of segment in bytes */
506 pid_t shm_lpid; /* process ID of last shm op */
507 pid_t shm_cpid; /* process ID of creator */
508 short shm_nattch; /* number of current attaches */
509 int32_t shm_atime; /* time of last shmat() */
510 int32_t shm_dtime; /* time of last shmdt() */
511 int32_t shm_ctime; /* time of last change by shmctl() */
512 netbsd32_voidp _shm_internal; /* sysv stupidity */
513 };
514
515 /* from <sys/signal.h> */
516 typedef netbsd32_pointer_t netbsd32_sigsetp_t;
517 typedef netbsd32_pointer_t netbsd32_sigactionp_t;
518 struct netbsd32_sigaction {
519 netbsd32_voidp netbsd32_sa_handler; /* signal handler */
520 sigset_t netbsd32_sa_mask; /* signal mask to apply */
521 int netbsd32_sa_flags; /* see signal options below */
522 };
523
524 typedef netbsd32_pointer_t netbsd32_sigaltstack13p_t;
525 struct netbsd32_sigaltstack13 {
526 netbsd32_charp ss_sp; /* signal stack base */
527 int ss_size; /* signal stack length */
528 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
529 };
530
531 typedef netbsd32_pointer_t netbsd32_sigaltstackp_t;
532 struct netbsd32_sigaltstack {
533 netbsd32_voidp ss_sp; /* signal stack base */
534 netbsd32_size_t ss_size; /* signal stack length */
535 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
536 };
537
538 typedef netbsd32_pointer_t netbsd32_sigstackp_t;
539 struct netbsd32_sigstack {
540 netbsd32_voidp ss_sp; /* signal stack pointer */
541 int ss_onstack; /* current status */
542 };
543
544 typedef netbsd32_pointer_t netbsd32_sigvecp_t;
545 struct netbsd32_sigvec {
546 netbsd32_voidp sv_handler; /* signal handler */
547 int sv_mask; /* signal mask to apply */
548 int sv_flags; /* see signal options below */
549 };
550
551 typedef netbsd32_pointer_t netbsd32_siginfop_t;
552
553 union netbsd32_sigval {
554 int sival_int;
555 netbsd32_voidp sival_ptr;
556 };
557
558 typedef netbsd32_pointer_t netbsd32_sigeventp_t;
559 struct netbsd32_sigevent {
560 int sigev_notify;
561 int sigev_signo;
562 union netbsd32_sigval sigev_value;
563 netbsd32_voidp sigev_notify_function;
564 netbsd32_voidp sigev_notify_attributes;
565 };
566
567 /* from <sys/sigtypes.h> */
568 typedef netbsd32_pointer_t netbsd32_stackp_t;
569
570 /* from <sys/socket.h> */
571 typedef netbsd32_pointer_t netbsd32_sockaddrp_t;
572 typedef netbsd32_pointer_t netbsd32_osockaddrp_t;
573
574 typedef netbsd32_pointer_t netbsd32_msghdrp_t;
575 struct netbsd32_msghdr {
576 netbsd32_caddr_t msg_name; /* optional address */
577 unsigned int msg_namelen; /* size of address */
578 netbsd32_iovecp_t msg_iov; /* scatter/gather array */
579 unsigned int msg_iovlen; /* # elements in msg_iov */
580 netbsd32_caddr_t msg_control; /* ancillary data, see below */
581 unsigned int msg_controllen; /* ancillary data buffer len */
582 int msg_flags; /* flags on received message */
583 };
584
585 typedef netbsd32_pointer_t netbsd32_omsghdrp_t;
586 struct netbsd32_omsghdr {
587 netbsd32_caddr_t msg_name; /* optional address */
588 int msg_namelen; /* size of address */
589 netbsd32_iovecp_t msg_iov; /* scatter/gather array */
590 int msg_iovlen; /* # elements in msg_iov */
591 netbsd32_caddr_t msg_accrights; /* access rights sent/recvd */
592 int msg_accrightslen;
593 };
594
595 /* from <sys/stat.h> */
596 typedef netbsd32_pointer_t netbsd32_stat12p_t;
597 struct netbsd32_stat12 { /* NetBSD-1.2 stat struct */
598 uint32_t st_dev; /* inode's device */
599 uint32_t st_ino; /* inode's number */
600 uint16_t st_mode; /* inode protection mode */
601 uint16_t st_nlink; /* number of hard links */
602 uid_t st_uid; /* user ID of the file's owner */
603 gid_t st_gid; /* group ID of the file's group */
604 uint32_t st_rdev; /* device type */
605 struct netbsd32_timespec st_atimespec;/* time of last access */
606 struct netbsd32_timespec st_mtimespec;/* time of last data modification */
607 struct netbsd32_timespec st_ctimespec;/* time of last file status change */
608 netbsd32_int64 st_size; /* file size, in bytes */
609 netbsd32_int64 st_blocks; /* blocks allocated for file */
610 uint32_t st_blksize; /* optimal blocksize for I/O */
611 uint32_t st_flags; /* user defined flags for file */
612 uint32_t st_gen; /* file generation number */
613 int32_t st_lspare;
614 netbsd32_int64 st_qspare[2];
615 };
616
617 typedef netbsd32_pointer_t netbsd32_stat43p_t;
618 struct netbsd32_stat43 { /* BSD-4.3 stat struct */
619 uint16_t st_dev; /* inode's device */
620 uint32_t st_ino; /* inode's number */
621 uint16_t st_mode; /* inode protection mode */
622 uint16_t st_nlink; /* number of hard links */
623 uint16_t st_uid; /* user ID of the file's owner */
624 uint16_t st_gid; /* group ID of the file's group */
625 uint16_t st_rdev; /* device type */
626 int32_t st_size; /* file size, in bytes */
627 struct netbsd32_timespec st_atimespec;/* time of last access */
628 struct netbsd32_timespec st_mtimespec;/* time of last data modification */
629 struct netbsd32_timespec st_ctimespec;/* time of last file status change */
630 int32_t st_blksize; /* optimal blocksize for I/O */
631 int32_t st_blocks; /* blocks allocated for file */
632 uint32_t st_flags; /* user defined flags for file */
633 uint32_t st_gen; /* file generation number */
634 };
635 typedef netbsd32_pointer_t netbsd32_stat13p_t;
636 struct netbsd32_stat13 {
637 uint32_t st_dev; /* inode's device */
638 uint32_t st_ino; /* inode's number */
639 mode_t st_mode; /* inode protection mode */
640 nlink_t st_nlink; /* number of hard links */
641 uid_t st_uid; /* user ID of the file's owner */
642 gid_t st_gid; /* group ID of the file's group */
643 uint32_t st_rdev; /* device type */
644 struct netbsd32_timespec st_atimespec;/* time of last access */
645 struct netbsd32_timespec st_mtimespec;/* time of last data modification */
646 struct netbsd32_timespec st_ctimespec;/* time of last file status change */
647 netbsd32_int64 st_size; /* file size, in bytes */
648 netbsd32_uint64 st_blocks; /* blocks allocated for file */
649 blksize_t st_blksize; /* optimal blocksize for I/O */
650 uint32_t st_flags; /* user defined flags for file */
651 uint32_t st_gen; /* file generation number */
652 uint32_t st_spare; /* file generation number */
653 struct netbsd32_timespec st_birthtimespec;
654 uint32_t st_spare2;
655 };
656
657 typedef netbsd32_pointer_t netbsd32_stat50p_t;
658 struct netbsd32_stat50 {
659 uint32_t st_dev; /* inode's device */
660 mode_t st_mode; /* inode protection mode */
661 netbsd32_uint64 st_ino; /* inode's number */
662 nlink_t st_nlink; /* number of hard links */
663 uid_t st_uid; /* user ID of the file's owner */
664 gid_t st_gid; /* group ID of the file's group */
665 uint32_t st_rdev; /* device type */
666 struct netbsd32_timespec50 st_atimespec;/* time of last access */
667 struct netbsd32_timespec50 st_mtimespec;/* time of last data modification */
668 struct netbsd32_timespec50 st_ctimespec;/* time of last file status change */
669 struct netbsd32_timespec50 st_birthtimespec; /* time of creation */
670 netbsd32_int64 st_size; /* file size, in bytes */
671 netbsd32_uint64 st_blocks; /* blocks allocated for file */
672 blksize_t st_blksize; /* optimal blocksize for I/O */
673 uint32_t st_flags; /* user defined flags for file */
674 uint32_t st_gen; /* file generation number */
675 uint32_t st_spare[2];
676 };
677
678 typedef netbsd32_pointer_t netbsd32_statp_t;
679 struct netbsd32_stat {
680 netbsd32_dev_t st_dev; /* inode's device */
681 mode_t st_mode; /* inode protection mode */
682 netbsd32_uint64 st_ino; /* inode's number */
683 nlink_t st_nlink; /* number of hard links */
684 uid_t st_uid; /* user ID of the file's owner */
685 gid_t st_gid; /* group ID of the file's group */
686 netbsd32_dev_t st_rdev; /* device type */
687 struct netbsd32_timespec st_atimespec;/* time of last access */
688 struct netbsd32_timespec st_mtimespec;/* time of last data modification */
689 struct netbsd32_timespec st_ctimespec;/* time of last file status change */
690 struct netbsd32_timespec st_birthtimespec; /* time of creation */
691 netbsd32_int64 st_size; /* file size, in bytes */
692 netbsd32_uint64 st_blocks; /* blocks allocated for file */
693 blksize_t st_blksize; /* optimal blocksize for I/O */
694 uint32_t st_flags; /* user defined flags for file */
695 uint32_t st_gen; /* file generation number */
696 uint32_t st_spare[2];
697 };
698
699 /* from <sys/statvfs.h> */
700 typedef netbsd32_pointer_t netbsd32_statvfsp_t;
701 struct netbsd32_statvfs {
702 netbsd32_u_long f_flag; /* copy of mount exported flags */
703 netbsd32_u_long f_bsize; /* system block size */
704 netbsd32_u_long f_frsize; /* system fragment size */
705 netbsd32_u_long f_iosize; /* optimal file system block size */
706 netbsd32_uint64 f_blocks; /* number of blocks in file system */
707 netbsd32_uint64 f_bfree; /* free blocks avail in file system */
708 netbsd32_uint64 f_bavail; /* free blocks avail to non-root */
709 netbsd32_uint64 f_bresvd; /* blocks reserved for root */
710 netbsd32_uint64 f_files; /* total file nodes in file system */
711 netbsd32_uint64 f_ffree; /* free file nodes in file system */
712 netbsd32_uint64 f_favail; /* free file nodes avail to non-root */
713 netbsd32_uint64 f_fresvd; /* file nodes reserved for root */
714 netbsd32_uint64 f_syncreads; /* count of sync reads since mount */
715 netbsd32_uint64 f_syncwrites; /* count of sync writes since mount */
716 netbsd32_uint64 f_asyncreads; /* count of async reads since mount */
717 netbsd32_uint64 f_asyncwrites; /* count of async writes since mount */
718 fsid_t f_fsidx; /* NetBSD compatible fsid */
719 netbsd32_u_long f_fsid; /* Posix compatible fsid */
720 netbsd32_u_long f_namemax; /* maximum filename length */
721 uid_t f_owner; /* user that mounted the file system */
722 uint32_t f_spare[4]; /* spare space */
723 char f_fstypename[_VFS_NAMELEN]; /* fs type name */
724 char f_mntonname[_VFS_MNAMELEN]; /* directory on which mounted */
725 char f_mntfromname[_VFS_MNAMELEN]; /* mounted file system */
726 };
727
728 /* from <sys/timex.h> */
729 typedef netbsd32_pointer_t netbsd32_ntptimevalp_t;
730 typedef netbsd32_pointer_t netbsd32_ntptimeval30p_t;
731 typedef netbsd32_pointer_t netbsd32_ntptimeval50p_t;
732
733 struct netbsd32_ntptimeval30 {
734 struct netbsd32_timeval50 time; /* current time (ro) */
735 netbsd32_long maxerror; /* maximum error (us) (ro) */
736 netbsd32_long esterror; /* estimated error (us) (ro) */
737 };
738 struct netbsd32_ntptimeval50 {
739 struct netbsd32_timespec50 time; /* current time (ro) */
740 netbsd32_long maxerror; /* maximum error (us) (ro) */
741 netbsd32_long esterror; /* estimated error (us) (ro) */
742 netbsd32_long tai; /* TAI offset */
743 int time_state; /* time status */
744 };
745
746 struct netbsd32_ntptimeval {
747 struct netbsd32_timespec time; /* current time (ro) */
748 netbsd32_long maxerror; /* maximum error (us) (ro) */
749 netbsd32_long esterror; /* estimated error (us) (ro) */
750 netbsd32_long tai; /* TAI offset */
751 int time_state; /* time status */
752 };
753 typedef netbsd32_pointer_t netbsd32_timexp_t;
754 struct netbsd32_timex {
755 unsigned int modes; /* clock mode bits (wo) */
756 netbsd32_long offset; /* time offset (us) (rw) */
757 netbsd32_long freq; /* frequency offset (scaled ppm) (rw) */
758 netbsd32_long maxerror; /* maximum error (us) (rw) */
759 netbsd32_long esterror; /* estimated error (us) (rw) */
760 int status; /* clock status bits (rw) */
761 netbsd32_long constant; /* pll time constant (rw) */
762 netbsd32_long precision; /* clock precision (us) (ro) */
763 netbsd32_long tolerance; /* clock frequency tolerance (scaled
764 * ppm) (ro) */
765 /*
766 * The following read-only structure members are implemented
767 * only if the PPS signal discipline is configured in the
768 * kernel.
769 */
770 netbsd32_long ppsfreq; /* pps frequency (scaled ppm) (ro) */
771 netbsd32_long jitter; /* pps jitter (us) (ro) */
772 int shift; /* interval duration (s) (shift) (ro) */
773 netbsd32_long stabil; /* pps stability (scaled ppm) (ro) */
774 netbsd32_long jitcnt; /* jitter limit exceeded (ro) */
775 netbsd32_long calcnt; /* calibration intervals (ro) */
776 netbsd32_long errcnt; /* calibration errors (ro) */
777 netbsd32_long stbcnt; /* stability limit exceeded (ro) */
778 };
779
780 /* from <ufs/lfs/lfs.h> */
781 typedef netbsd32_pointer_t netbsd32_block_infop_t; /* XXX broken */
782
783 /* from <sys/utsname.h> */
784 typedef netbsd32_pointer_t netbsd32_utsnamep_t;
785
786 /* from <compat/common/kern_info_09.c> */
787 typedef netbsd32_pointer_t netbsd32_outsnamep_t;
788
789 /* from <arch/sparc{,64}/include/vuid_event.h> */
790 typedef struct firm_event32 {
791 unsigned short id; /* key or MS_* or LOC_[XY]_DELTA */
792 unsigned short pad; /* unused, at least by X11 */
793 int value; /* VKEY_{UP,DOWN} or locator delta */
794 struct netbsd32_timeval time;
795 } Firm_event32;
796
797 /* from <sys/uuid.h> */
798 typedef netbsd32_pointer_t netbsd32_uuidp_t;
799
800 /* from <sys/event.h> */
801 typedef netbsd32_pointer_t netbsd32_keventp_t;
802
803 struct netbsd32_kevent {
804 netbsd32_uintptr_t ident;
805 uint32_t filter;
806 uint32_t flags;
807 uint32_t fflags;
808 netbsd32_int64 data;
809 netbsd32_intptr_t udata;
810 };
811
812 /* from <sys/sched.h> */
813 typedef netbsd32_pointer_t netbsd32_sched_paramp_t;
814 typedef netbsd32_pointer_t netbsd32_cpusetp_t;
815
816 #if 0
817 int netbsd32_kevent(struct lwp *, void *, register_t *);
818 #endif
819
820 /*
821 * here are some macros to convert between netbsd32 and sparc64 types.
822 * note that they do *NOT* act like good macros and put ()'s around all
823 * arguments cuz this _breaks_ SCARG().
824 */
825 #define NETBSD32TO64(s32uap, uap, name) \
826 SCARG(uap, name) = SCARG(s32uap, name)
827 #define NETBSD32TOP(s32uap, uap, name, type) \
828 SCARG(uap, name) = SCARG_P32(s32uap, name)
829 #define NETBSD32TOX(s32uap, uap, name, type) \
830 SCARG(uap, name) = (type)SCARG(s32uap, name)
831 #define NETBSD32TOX64(s32uap, uap, name, type) \
832 SCARG(uap, name) = (type)(long)SCARG(s32uap, name)
833
834 /* and some standard versions */
835 #define NETBSD32TO64_UAP(name) NETBSD32TO64(uap, &ua, name)
836 #define NETBSD32TOP_UAP(name, type) NETBSD32TOP(uap, &ua, name, type)
837 #define NETBSD32TOX_UAP(name, type) NETBSD32TOX(uap, &ua, name, type)
838 #define NETBSD32TOX64_UAP(name, type) NETBSD32TOX64(uap, &ua, name, type)
839
840 #define SCARG_P32(uap, name) NETBSD32PTR64(SCARG(uap, name))
841
842 int coredump_netbsd32(struct lwp *, void *);
843
844 /*
845 * random other stuff
846 */
847 #include <compat/common/compat_util.h>
848 #include <compat/sys/siginfo.h>
849
850 vaddr_t netbsd32_vm_default_addr(struct proc *, vaddr_t, vsize_t);
851 void netbsd32_adjust_limits(struct proc *);
852
853 void netbsd32_si_to_si32(siginfo32_t *, const siginfo_t *);
854 void netbsd32_si32_to_si(siginfo_t *, const siginfo32_t *);
855
856 void startlwp32(void *);
857 struct compat_50_netbsd32___semctl14_args;
858 int do_netbsd32___semctl14(struct lwp *, const struct compat_50_netbsd32___semctl14_args *, register_t *, void *);
859
860 struct iovec *netbsd32_get_iov(struct netbsd32_iovec *, int, struct iovec *,
861 int);
862
863 #ifdef SYSCTL_SETUP_PROTO
864 SYSCTL_SETUP_PROTO(netbsd32_sysctl_emul_setup);
865 #endif /* SYSCTL_SETUP_PROTO */
866 #endif /* _COMPAT_NETBSD32_NETBSD32_H_ */
867