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