xref: /netbsd-src/sys/compat/netbsd32/netbsd32.h (revision 001c68bd94f75ce9270b69227c4199fbf34ee396)
1 /*	$NetBSD: netbsd32.h,v 1.24 2003/01/18 08:28:25 thorpej 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/sa.h>
45 #include <sys/syscallargs.h>
46 #include <sys/ipc.h>
47 #include <sys/shm.h>
48 
49 /*
50  * first, define the basic types we need.
51  */
52 
53 typedef int32_t netbsd32_long;
54 typedef u_int32_t netbsd32_u_long;
55 
56 typedef u_int32_t netbsd32_clock_t;
57 typedef u_int32_t netbsd32_size_t;
58 typedef int32_t netbsd32_ssize_t;
59 typedef int32_t netbsd32_clockid_t;
60 typedef u_int32_t netbsd32_caddr_t;
61 typedef int32_t netbsd32_key_t;
62 typedef int32_t netbsd32_intptr_t;
63 typedef u_int32_t netbsd32_uintptr_t;
64 
65 /*
66  * machine depedant section; must define:
67  *	netbsd32_pointer_t
68  *		- 32-bit pointer type, normally u_int32_t but can be int32_t
69  *		  for platforms which rely on sign-extension of pointers
70  *		  such as SH-5.
71  *	NETBSD32PTR64(p32)
72  *		- Translate a 32-bit pointer into something valid in a
73  *		  64-bit context.
74  *	struct netbsd32_sigcontext
75  *		- 32bit compatibility sigcontext structure for this arch.
76  *	netbsd32_sigcontextp_t
77  *		- type of pointer to above, normally u_int32_t
78  *	void netbsd32_setregs(struct proc *p, struct exec_package *pack,
79  *	    u_long stack);
80  *	int netbsd32_sigreturn(struct proc *p, void *v,
81  *	    register_t *retval);
82  *	void netbsd32_sendsig(sig_t catcher, int sig, int mask, u_long code);
83  *	char netbsd32_esigcode[], netbsd32_sigcode[]
84  *		- the above are abvious
85  *
86  * pull in the netbsd32 machine dependant header, that may help with the
87  * above, or it may be provided via the MD layer itself.
88  */
89 #include <machine/netbsd32_machdep.h>
90 
91 /*
92  * all pointers are netbsd32_pointer_t (defined in <machine/netbsd32_machdep.h>)
93  */
94 
95 typedef netbsd32_pointer_t netbsd32_voidp;
96 typedef netbsd32_pointer_t netbsd32_u_shortp;
97 typedef netbsd32_pointer_t netbsd32_charp;
98 typedef netbsd32_pointer_t netbsd32_u_charp;
99 typedef netbsd32_pointer_t netbsd32_charpp;
100 typedef netbsd32_pointer_t netbsd32_size_tp;
101 typedef netbsd32_pointer_t netbsd32_intp;
102 typedef netbsd32_pointer_t netbsd32_longp;
103 typedef netbsd32_pointer_t netbsd32_caddrp;
104 typedef netbsd32_pointer_t netbsd32_caddr;
105 typedef netbsd32_pointer_t netbsd32_gid_tp;
106 typedef netbsd32_pointer_t netbsd32_fsid_tp_t;
107 
108 /*
109  * now, the compatibility structures and their fake pointer types.
110  */
111 
112 /* from <sys/types.h> */
113 typedef netbsd32_pointer_t netbsd32_fd_setp_t;
114 
115 /* from <sys/uio.h> */
116 typedef netbsd32_pointer_t netbsd32_iovecp_t;
117 struct netbsd32_iovec {
118 	netbsd32_voidp	iov_base;	/* Base address. */
119 	netbsd32_size_t	 iov_len;	/* Length. */
120 };
121 
122 /* from <sys/time.h> */
123 typedef int32_t netbsd32_timer_t;
124 typedef	int32_t netbsd32_time_t;
125 
126 typedef netbsd32_pointer_t netbsd32_timespecp_t;
127 struct netbsd32_timespec {
128 	netbsd32_time_t	tv_sec;			/* seconds */
129 	netbsd32_long	tv_nsec;	/* and nanoseconds */
130 };
131 
132 typedef netbsd32_pointer_t netbsd32_timevalp_t;
133 struct netbsd32_timeval {
134 	netbsd32_long	tv_sec;		/* seconds */
135 	netbsd32_long	tv_usec;	/* and microseconds */
136 };
137 
138 typedef netbsd32_pointer_t netbsd32_timezonep_t;
139 struct netbsd32_timezone {
140 	int	tz_minuteswest;	/* minutes west of Greenwich */
141 	int	tz_dsttime;	/* type of dst correction */
142 };
143 
144 typedef netbsd32_pointer_t netbsd32_itimervalp_t;
145 struct	netbsd32_itimerval {
146 	struct	netbsd32_timeval it_interval;	/* timer interval */
147 	struct	netbsd32_timeval it_value;	/* current value */
148 };
149 
150 /* from <sys/mount.h> */
151 typedef netbsd32_pointer_t netbsd32_fidp_t;
152 
153 typedef netbsd32_pointer_t netbsd32_fhandlep_t;
154 
155 typedef netbsd32_pointer_t netbsd32_statfsp_t;
156 struct netbsd32_statfs {
157 	short	f_type;			/* type of file system */
158 	u_short	f_flags;		/* copy of mount flags */
159 	netbsd32_long	f_bsize;	/* fundamental file system block size */
160 	netbsd32_long	f_iosize;	/* optimal transfer block size */
161 	netbsd32_long	f_blocks;	/* total data blocks in file system */
162 	netbsd32_long	f_bfree;	/* free blocks in fs */
163 	netbsd32_long	f_bavail;	/* free blocks avail to non-superuser */
164 	netbsd32_long	f_files;	/* total file nodes in file system */
165 	netbsd32_long	f_ffree;	/* free file nodes in fs */
166 	fsid_t	f_fsid;			/* file system id */
167 	uid_t	f_owner;		/* user that mounted the file system */
168 	netbsd32_long	f_spare[4];	/* spare for later */
169 	char	f_fstypename[MFSNAMELEN]; /* fs type name */
170 	char	f_mntonname[MNAMELEN];	  /* directory on which mounted */
171 	char	f_mntfromname[MNAMELEN];  /* mounted file system */
172 };
173 
174 /* from <sys/poll.h> */
175 typedef netbsd32_pointer_t netbsd32_pollfdp_t;
176 
177 /* from <sys/resource.h> */
178 typedef netbsd32_pointer_t netbsd32_rusagep_t;
179 struct	netbsd32_rusage {
180 	struct netbsd32_timeval ru_utime;/* user time used */
181 	struct netbsd32_timeval ru_stime;/* system time used */
182 	netbsd32_long	ru_maxrss;	/* max resident set size */
183 	netbsd32_long	ru_ixrss;	/* integral shared memory size */
184 	netbsd32_long	ru_idrss;	/* integral unshared data " */
185 	netbsd32_long	ru_isrss;	/* integral unshared stack " */
186 	netbsd32_long	ru_minflt;	/* page reclaims */
187 	netbsd32_long	ru_majflt;	/* page faults */
188 	netbsd32_long	ru_nswap;	/* swaps */
189 	netbsd32_long	ru_inblock;	/* block input operations */
190 	netbsd32_long	ru_oublock;	/* block output operations */
191 	netbsd32_long	ru_msgsnd;	/* messages sent */
192 	netbsd32_long	ru_msgrcv;	/* messages received */
193 	netbsd32_long	ru_nsignals;	/* signals received */
194 	netbsd32_long	ru_nvcsw;	/* voluntary context switches */
195 	netbsd32_long	ru_nivcsw;	/* involuntary " */
196 };
197 
198 typedef netbsd32_pointer_t netbsd32_orlimitp_t;
199 
200 typedef netbsd32_pointer_t netbsd32_rlimitp_t;
201 
202 struct netbsd32_loadavg {
203 	fixpt_t	ldavg[3];
204 	netbsd32_long	fscale;
205 };
206 
207 /* from <sys/ipc.h> */
208 typedef netbsd32_pointer_t netbsd32_ipc_permp_t;
209 struct netbsd32_ipc_perm {
210 	ushort	cuid;		/* creator user id */
211 	ushort	cgid;		/* creator group id */
212 	ushort	uid;		/* user id */
213 	ushort	gid;		/* group id */
214 	ushort	mode;		/* r/w permission */
215 	ushort	_seq;		/* sequence # (to generate unique msg/sem/shm id) */
216 	netbsd32_key_t	_key;	/* user specified msg/sem/shm key */
217 };
218 struct netbsd32_ipc_perm14 {
219 	ushort	cuid;		/* creator user id */
220 	ushort	cgid;		/* creator group id */
221 	ushort	uid;		/* user id */
222 	ushort	gid;		/* group id */
223 	ushort	mode;		/* r/w permission */
224 	ushort	seq;		/* sequence # (to generate unique msg/sem/shm id) */
225 	netbsd32_key_t	key;	/* user specified msg/sem/shm key */
226 };
227 
228 /* from <sys/msg.h> */
229 typedef netbsd32_pointer_t netbsd32_msgp_t;
230 struct netbsd32_msg {
231 	netbsd32_msgp_t msg_next;	/* next msg in the chain */
232 	netbsd32_long	msg_type;	/* type of this message */
233     				/* >0 -> type of this message */
234     				/* 0 -> free header */
235 	u_short	msg_ts;		/* size of this message */
236 	short	msg_spot;	/* location of start of msg in buffer */
237 };
238 
239 typedef u_int32_t netbsd32_msqid_dsp_t;
240 typedef u_int32_t netbsd32_msgqnum_t;
241 typedef netbsd32_size_t netbsd32_msglen_t;
242 
243 struct netbsd32_msqid_ds {
244 	struct netbsd32_ipc_perm	msg_perm;	/* operation permission strucure */
245 	netbsd32_msgqnum_t	msg_qnum;	/* number of messages in the queue */
246 	netbsd32_msglen_t	msg_qbytes;	/* max # of bytes in the queue */
247 	pid_t		msg_lspid;	/* process ID of last msgsend() */
248 	pid_t		msg_lrpid;	/* process ID of last msgrcv() */
249 	netbsd32_time_t		msg_stime;	/* time of last msgsend() */
250 	netbsd32_time_t		msg_rtime;	/* time of last msgrcv() */
251 	netbsd32_time_t		msg_ctime;	/* time of last change */
252 
253 	/*
254 	 * These members are private and used only in the internal
255 	 * implementation of this interface.
256 	 */
257 	netbsd32_msgp_t _msg_first;	/* first message in the queue */
258 	netbsd32_msgp_t	_msg_last;	/* last message in the queue */
259 	netbsd32_msglen_t	_msg_cbytes;	/* # of bytes currently in queue */
260 };
261 struct netbsd32_msqid_ds14 {
262 	struct	netbsd32_ipc_perm14 msg_perm;	/* msg queue permission bits */
263 	netbsd32_msgp_t	msg_first;	/* first message in the queue */
264 	netbsd32_msgp_t	msg_last;	/* last message in the queue */
265 	netbsd32_u_long	msg_cbytes;	/* number of bytes in use on the queue */
266 	netbsd32_u_long	msg_qnum;	/* number of msgs in the queue */
267 	netbsd32_u_long	msg_qbytes;	/* max # of bytes on the queue */
268 	pid_t msg_lspid;		/* pid of last msgsnd() */
269 	pid_t msg_lrpid;		/* pid of last msgrcv() */
270 	netbsd32_time_t	msg_stime;		/* time of last msgsnd() */
271 	netbsd32_long	msg_pad1;
272 	netbsd32_time_t	msg_rtime;		/* time of last msgrcv() */
273 	netbsd32_long	msg_pad2;
274 	netbsd32_time_t	msg_ctime;		/* time of last msgctl() */
275 	netbsd32_long	msg_pad3;
276 	netbsd32_long	msg_pad4[4];
277 };
278 
279 /* from <sys/sem.h> */
280 typedef netbsd32_pointer_t netbsd32_semp_t;
281 
282 typedef u_int32_t netbsd32_semid_dsp_t;
283 struct netbsd32_semid_ds {
284 	struct netbsd32_ipc_perm	sem_perm;/* operation permission struct */
285 	unsigned short	sem_nsems;	/* number of sems in set */
286 	netbsd32_time_t		sem_otime;	/* last operation time */
287 	netbsd32_time_t		sem_ctime;	/* last change time */
288 
289 	/*
290 	 * These members are private and used only in the internal
291 	 * implementation of this interface.
292 	 */
293 	netbsd32_semp_t	_sem_base;	/* pointer to first semaphore in set */
294 };
295 
296 struct netbsd32_semid_ds14 {
297 	struct netbsd32_ipc_perm14	sem_perm;/* operation permission struct */
298 	netbsd32_semp_t	sem_base;	/* pointer to first semaphore in set */
299 	unsigned short	sem_nsems;	/* number of sems in set */
300 	netbsd32_time_t	sem_otime;		/* last operation time */
301 	netbsd32_long	sem_pad1;	/* SVABI/386 says I need this here */
302 	netbsd32_time_t	sem_ctime;		/* last change time */
303 					/* Times measured in secs since */
304 					/* 00:00:00 GMT, Jan. 1, 1970 */
305 	netbsd32_long	sem_pad2;	/* SVABI/386 says I need this here */
306 	netbsd32_long	sem_pad3[4];	/* SVABI/386 says I need this here */
307 };
308 
309 typedef u_int32_t netbsd32_semunu_t;
310 union netbsd32_semun {
311 	int	val;		/* value for SETVAL */
312 	netbsd32_semid_dsp_t buf; /* buffer for IPC_STAT & IPC_SET */
313 	netbsd32_u_shortp array;	/* array for GETALL & SETALL */
314 };
315 
316 typedef netbsd32_pointer_t netbsd32_sembufp_t;
317 struct netbsd32_sembuf {
318 	unsigned short	sem_num;	/* semaphore # */
319 	short		sem_op;		/* semaphore operation */
320 	short		sem_flg;	/* operation flags */
321 };
322 
323 /* from <sys/shm.h> */
324 typedef u_int32_t netbsd32_shmid_dsp_t;
325 struct netbsd32_shmid_ds {
326 	struct netbsd32_ipc_perm	shm_perm; /* operation permission structure */
327 	size_t		shm_segsz;	/* size of segment in bytes */
328 	pid_t		shm_lpid;	/* process ID of last shm op */
329 	pid_t		shm_cpid;	/* process ID of creator */
330 	shmatt_t	shm_nattch;	/* number of current attaches */
331 	netbsd32_time_t	shm_atime;	/* time of last shmat() */
332 	netbsd32_time_t	shm_dtime;	/* time of last shmdt() */
333 	netbsd32_time_t	shm_ctime;	/* time of last change by shmctl() */
334 	netbsd32_voidp	_shm_internal;	/* sysv stupidity */
335 };
336 
337 struct netbsd32_shmid_ds14 {
338 	struct netbsd32_ipc_perm14	shm_perm; /* operation permission structure */
339 	int		shm_segsz;	/* size of segment in bytes */
340 	pid_t		shm_lpid;	/* process ID of last shm op */
341 	pid_t		shm_cpid;	/* process ID of creator */
342 	short		shm_nattch;	/* number of current attaches */
343 	netbsd32_time_t		shm_atime;	/* time of last shmat() */
344 	netbsd32_time_t		shm_dtime;	/* time of last shmdt() */
345 	netbsd32_time_t		shm_ctime;	/* time of last change by shmctl() */
346 	netbsd32_voidp	_shm_internal;	/* sysv stupidity */
347 };
348 
349 /* from <sys/signal.h> */
350 typedef netbsd32_pointer_t netbsd32_sigsetp_t;
351 typedef netbsd32_pointer_t netbsd32_sigactionp_t;
352 struct	netbsd32_sigaction {
353 	netbsd32_voidp netbsd32_sa_handler;	/* signal handler */
354 	sigset_t netbsd32_sa_mask;		/* signal mask to apply */
355 	int	netbsd32_sa_flags;		/* see signal options below */
356 };
357 
358 typedef netbsd32_pointer_t netbsd32_sigaltstack13p_t;
359 struct netbsd32_sigaltstack13 {
360 	netbsd32_charp	ss_sp;			/* signal stack base */
361 	int	ss_size;		/* signal stack length */
362 	int	ss_flags;		/* SS_DISABLE and/or SS_ONSTACK */
363 };
364 
365 typedef netbsd32_pointer_t netbsd32_sigaltstackp_t;
366 struct netbsd32_sigaltstack {
367 	netbsd32_voidp	ss_sp;			/* signal stack base */
368 	netbsd32_size_t	ss_size;		/* signal stack length */
369 	int	ss_flags;		/* SS_DISABLE and/or SS_ONSTACK */
370 };
371 
372 typedef netbsd32_pointer_t netbsd32_sigstackp_t;
373 struct	netbsd32_sigstack {
374 	netbsd32_voidp	ss_sp;			/* signal stack pointer */
375 	int	ss_onstack;		/* current status */
376 };
377 
378 typedef netbsd32_pointer_t netbsd32_sigvecp_t;
379 struct	netbsd32_sigvec {
380 	netbsd32_voidp sv_handler;	/* signal handler */
381 	int	sv_mask;		/* signal mask to apply */
382 	int	sv_flags;		/* see signal options below */
383 };
384 
385 /* from <sys/socket.h> */
386 typedef netbsd32_pointer_t netbsd32_sockaddrp_t;
387 typedef netbsd32_pointer_t netbsd32_osockaddrp_t;
388 
389 typedef netbsd32_pointer_t netbsd32_msghdrp_t;
390 struct netbsd32_msghdr {
391 	netbsd32_caddr_t	msg_name;		/* optional address */
392 	u_int	msg_namelen;		/* size of address */
393 	netbsd32_iovecp_t msg_iov;		/* scatter/gather array */
394 	u_int	msg_iovlen;		/* # elements in msg_iov */
395 	netbsd32_caddr_t	msg_control;		/* ancillary data, see below */
396 	u_int	msg_controllen;		/* ancillary data buffer len */
397 	int	msg_flags;		/* flags on received message */
398 };
399 
400 typedef netbsd32_pointer_t netbsd32_omsghdrp_t;
401 struct netbsd32_omsghdr {
402 	netbsd32_caddr_t	msg_name;		/* optional address */
403 	int	msg_namelen;		/* size of address */
404 	netbsd32_iovecp_t msg_iov;		/* scatter/gather array */
405 	int	msg_iovlen;		/* # elements in msg_iov */
406 	netbsd32_caddr_t	msg_accrights;		/* access rights sent/received */
407 	int	msg_accrightslen;
408 };
409 
410 /* from <sys/stat.h> */
411 typedef netbsd32_pointer_t netbsd32_stat12p_t;
412 struct netbsd32_stat12 {			/* NetBSD-1.2 stat struct */
413 	dev_t	  st_dev;		/* inode's device */
414 	ino_t	  st_ino;		/* inode's number */
415 	u_int16_t st_mode;		/* inode protection mode */
416 	u_int16_t st_nlink;		/* number of hard links */
417 	uid_t	  st_uid;		/* user ID of the file's owner */
418 	gid_t	  st_gid;		/* group ID of the file's group */
419 	dev_t	  st_rdev;		/* device type */
420 	struct	  netbsd32_timespec st_atimespec;/* time of last access */
421 	struct	  netbsd32_timespec st_mtimespec;/* time of last data modification */
422 	struct	  netbsd32_timespec st_ctimespec;/* time of last file status change */
423 	off_t	  st_size;		/* file size, in bytes */
424 	int64_t	  st_blocks;		/* blocks allocated for file */
425 	u_int32_t st_blksize;		/* optimal blocksize for I/O */
426 	u_int32_t st_flags;		/* user defined flags for file */
427 	u_int32_t st_gen;		/* file generation number */
428 	int32_t	  st_lspare;
429 	int64_t	  st_qspare[2];
430 };
431 
432 typedef netbsd32_pointer_t netbsd32_stat43p_t;
433 struct netbsd32_stat43 {			/* BSD-4.3 stat struct */
434 	u_int16_t st_dev;		/* inode's device */
435 	ino_t	  st_ino;		/* inode's number */
436 	u_int16_t st_mode;		/* inode protection mode */
437 	u_int16_t st_nlink;		/* number of hard links */
438 	u_int16_t st_uid;		/* user ID of the file's owner */
439 	u_int16_t st_gid;		/* group ID of the file's group */
440 	u_int16_t st_rdev;		/* device type */
441 	int32_t	  st_size;		/* file size, in bytes */
442 	struct	  netbsd32_timespec st_atimespec;/* time of last access */
443 	struct	  netbsd32_timespec st_mtimespec;/* time of last data modification */
444 	struct	  netbsd32_timespec st_ctimespec;/* time of last file status change */
445 	int32_t	  st_blksize;		/* optimal blocksize for I/O */
446 	int32_t	  st_blocks;		/* blocks allocated for file */
447 	u_int32_t st_flags;		/* user defined flags for file */
448 	u_int32_t st_gen;		/* file generation number */
449 };
450 typedef netbsd32_pointer_t netbsd32_statp_t;
451 struct netbsd32_stat {
452 	dev_t	  st_dev;		/* inode's device */
453 	ino_t	  st_ino;		/* inode's number */
454 	mode_t	  st_mode;		/* inode protection mode */
455 	nlink_t	  st_nlink;		/* number of hard links */
456 	uid_t	  st_uid;		/* user ID of the file's owner */
457 	gid_t	  st_gid;		/* group ID of the file's group */
458 	dev_t	  st_rdev;		/* device type */
459 	struct	  netbsd32_timespec st_atimespec;/* time of last access */
460 	struct	  netbsd32_timespec st_mtimespec;/* time of last data modification */
461 	struct	  netbsd32_timespec st_ctimespec;/* time of last file status change */
462 	off_t	  st_size;		/* file size, in bytes */
463 	blkcnt_t  st_blocks;		/* blocks allocated for file */
464 	blksize_t st_blksize;		/* optimal blocksize for I/O */
465 	u_int32_t st_flags;		/* user defined flags for file */
466 	u_int32_t st_gen;		/* file generation number */
467 	int64_t	  st_qspare[2];
468 }
469 #ifdef __x86_64__
470 __attribute__((packed))
471 #endif
472 ;
473 
474 /* from <sys/timex.h> */
475 typedef netbsd32_pointer_t netbsd32_ntptimevalp_t;
476 struct netbsd32_ntptimeval {
477 	struct netbsd32_timeval time;	/* current time (ro) */
478 	netbsd32_long maxerror;	/* maximum error (us) (ro) */
479 	netbsd32_long esterror;	/* estimated error (us) (ro) */
480 };
481 
482 typedef netbsd32_pointer_t netbsd32_timexp_t;
483 struct netbsd32_timex {
484 	unsigned int modes;	/* clock mode bits (wo) */
485 	netbsd32_long offset;	/* time offset (us) (rw) */
486 	netbsd32_long freq;	/* frequency offset (scaled ppm) (rw) */
487 	netbsd32_long maxerror;	/* maximum error (us) (rw) */
488 	netbsd32_long esterror;	/* estimated error (us) (rw) */
489 	int status;		/* clock status bits (rw) */
490 	netbsd32_long constant;	/* pll time constant (rw) */
491 	netbsd32_long precision;	/* clock precision (us) (ro) */
492 	netbsd32_long tolerance;	/* clock frequency tolerance (scaled
493 				 * ppm) (ro) */
494 	/*
495 	 * The following read-only structure members are implemented
496 	 * only if the PPS signal discipline is configured in the
497 	 * kernel.
498 	 */
499 	netbsd32_long ppsfreq;	/* pps frequency (scaled ppm) (ro) */
500 	netbsd32_long jitter;	/* pps jitter (us) (ro) */
501 	int shift;		/* interval duration (s) (shift) (ro) */
502 	netbsd32_long stabil;	/* pps stability (scaled ppm) (ro) */
503 	netbsd32_long jitcnt;	/* jitter limit exceeded (ro) */
504 	netbsd32_long calcnt;	/* calibration intervals (ro) */
505 	netbsd32_long errcnt;	/* calibration errors (ro) */
506 	netbsd32_long stbcnt;	/* stability limit exceeded (ro) */
507 };
508 
509 /* from <ufs/lfs/lfs.h> */
510 typedef netbsd32_pointer_t netbsd32_block_infop_t;  /* XXX broken */
511 
512 /* from <sys/utsname.h> */
513 typedef netbsd32_pointer_t netbsd32_utsnamep_t;
514 
515 /* from <compat/common/kern_info_09.c> */
516 typedef netbsd32_pointer_t netbsd32_outsnamep_t;
517 
518 /* from <arch/sparc{,64}/include/vuid_event.h> */
519 typedef struct firm_event32 {
520 	u_short	id;		/* key or MS_* or LOC_[XY]_DELTA */
521 	u_short	pad;		/* unused, at least by X11 */
522 	int	value;		/* VKEY_{UP,DOWN} or locator delta */
523 	struct netbsd32_timeval time;
524 } Firm_event32;
525 
526 /*
527  * here are some macros to convert between netbsd32 and sparc64 types.
528  * note that they do *NOT* act like good macros and put ()'s around all
529  * arguments cuz this _breaks_ SCARG().
530  */
531 #define NETBSD32TO64(s32uap, uap, name) \
532 	    SCARG(uap, name) = SCARG(s32uap, name)
533 #define NETBSD32TOP(s32uap, uap, name, type) \
534 	    SCARG(uap, name) = (type *)NETBSD32PTR64(SCARG(s32uap, name))
535 #define NETBSD32TOX(s32uap, uap, name, type) \
536 	    SCARG(uap, name) = (type)SCARG(s32uap, name)
537 #define NETBSD32TOX64(s32uap, uap, name, type) \
538 	    SCARG(uap, name) = (type)(long)SCARG(s32uap, name)
539 
540 /* and some standard versions */
541 #define	NETBSD32TO64_UAP(name)		NETBSD32TO64(uap, &ua, name);
542 #define	NETBSD32TOP_UAP(name, type)	NETBSD32TOP(uap, &ua, name, type);
543 #define	NETBSD32TOX_UAP(name, type)	NETBSD32TOX(uap, &ua, name, type);
544 #define	NETBSD32TOX64_UAP(name, type)	NETBSD32TOX64(uap, &ua, name, type);
545 
546 int	coredump_netbsd32(struct lwp *, struct vnode *, struct ucred *);
547 
548 /*
549  * random other stuff
550  */
551 #include <compat/common/compat_util.h>
552 
553 void netbsd32_from_stat43 __P((struct stat43 *, struct netbsd32_stat43 *));
554 int netbsd32_execve2(struct lwp *, struct sys_execve_args *, register_t *);
555 
556 #endif /* _COMPAT_NETBSD32_NETBSD32_H_ */
557