netbsd32.h revision 1.4 1 /* $NetBSD: netbsd32.h,v 1.4 1999/03/25 16:22:49 mrg Exp $ */
2
3 /*
4 * Copyright (c) 1998 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_SPARC32_SPARC32_H_
32 #define _COMPAT_SPARC32_SPARC32_H_
33 /* We need to change the size of register_t */
34 #ifdef syscallargs
35 #undef syscallargs
36 #endif
37 /*
38 * SPARC 32-bit compatibility module.
39 */
40
41 #include <sys/mount.h>
42
43 /*
44 * first, define all the types we need.
45 */
46
47 typedef int32_t netbsd32_long;
48 typedef u_int32_t netbsd32_u_long;
49
50 typedef u_int32_t netbsd32_clock_t;
51 typedef u_int32_t netbsd32_size_t;
52 typedef int32_t netbsd32_ssize_t;
53 typedef int32_t netbsd32_clockid_t;
54 typedef u_int32_t netbsd32_caddr_t;
55 typedef int32_t netbsd32_key_t;
56
57 /* all pointers are u_int32_t */
58
59 typedef u_int32_t netbsd32_voidp;
60 typedef u_int32_t netbsd32_u_shortp;
61 typedef u_int32_t netbsd32_charp;
62 typedef u_int32_t netbsd32_u_charp;
63 typedef u_int32_t netbsd32_charpp;
64 typedef u_int32_t netbsd32_size_tp;
65 typedef u_int32_t netbsd32_intp;
66 typedef u_int32_t netbsd32_longp;
67 typedef u_int32_t netbsd32_caddrp;
68 typedef u_int32_t netbsd32_caddr;
69 typedef u_int32_t netbsd32_gid_tp;
70 typedef u_int32_t netbsd32_fsid_tp_t;
71
72 /*
73 * now, the compatibility structures and their fake pointer types.
74 */
75
76 /* from <sys/types.h> */
77 typedef u_int32_t netbsd32_fd_setp_t;
78
79 /* from <sys/uio.h> */
80 typedef u_int32_t netbsd32_iovecp_t;
81 struct netbsd32_iovec {
82 netbsd32_voidp iov_base; /* Base address. */
83 netbsd32_size_t iov_len; /* Length. */
84 };
85
86 /* from <sys/time.h> */
87 typedef int32_t netbsd32_timer_t;
88
89 typedef u_int32_t netbsd32_timespecp_t;
90 struct netbsd32_timespec {
91 time_t tv_sec; /* seconds */
92 netbsd32_long tv_nsec; /* and nanoseconds */
93 };
94
95 typedef u_int32_t netbsd32_timevalp_t;
96 struct netbsd32_timeval {
97 netbsd32_long tv_sec; /* seconds */
98 netbsd32_long tv_usec; /* and microseconds */
99 };
100
101 typedef u_int32_t netbsd32_timezonep_t;
102 struct netbsd32_timezone {
103 int tz_minuteswest; /* minutes west of Greenwich */
104 int tz_dsttime; /* type of dst correction */
105 };
106
107 typedef u_int32_t netbsd32_itimervalp_t;
108 struct netbsd32_itimerval {
109 struct netbsd32_timeval it_interval; /* timer interval */
110 struct netbsd32_timeval it_value; /* current value */
111 };
112
113 /* from <sys/mount.h> */
114 typedef u_int32_t netbsd32_fidp_t;
115
116 typedef u_int32_t netbsd32_fhandlep_t;
117
118 typedef u_int32_t netbsd32_statfsp_t;
119 struct netbsd32_statfs {
120 short f_type; /* type of file system */
121 u_short f_flags; /* copy of mount flags */
122 netbsd32_long f_bsize; /* fundamental file system block size */
123 netbsd32_long f_iosize; /* optimal transfer block size */
124 netbsd32_long f_blocks; /* total data blocks in file system */
125 netbsd32_long f_bfree; /* free blocks in fs */
126 netbsd32_long f_bavail; /* free blocks avail to non-superuser */
127 netbsd32_long f_files; /* total file nodes in file system */
128 netbsd32_long f_ffree; /* free file nodes in fs */
129 fsid_t f_fsid; /* file system id */
130 uid_t f_owner; /* user that mounted the file system */
131 netbsd32_long f_spare[4]; /* spare for later */
132 char f_fstypename[MFSNAMELEN]; /* fs type name */
133 char f_mntonname[MNAMELEN]; /* directory on which mounted */
134 char f_mntfromname[MNAMELEN]; /* mounted file system */
135 };
136
137 /* from <sys/poll.h> */
138 typedef u_int32_t netbsd32_pollfdp_t;
139
140 /* from <sys/resource.h> */
141 typedef u_int32_t netbsd32_rusagep_t;
142 struct netbsd32_rusage {
143 struct netbsd32_timeval ru_utime;/* user time used */
144 struct netbsd32_timeval ru_stime;/* system time used */
145 netbsd32_long ru_maxrss; /* max resident set size */
146 netbsd32_long ru_ixrss; /* integral shared memory size */
147 netbsd32_long ru_idrss; /* integral unshared data " */
148 netbsd32_long ru_isrss; /* integral unshared stack " */
149 netbsd32_long ru_minflt; /* page reclaims */
150 netbsd32_long ru_majflt; /* page faults */
151 netbsd32_long ru_nswap; /* swaps */
152 netbsd32_long ru_inblock; /* block input operations */
153 netbsd32_long ru_oublock; /* block output operations */
154 netbsd32_long ru_msgsnd; /* messages sent */
155 netbsd32_long ru_msgrcv; /* messages received */
156 netbsd32_long ru_nsignals; /* signals received */
157 netbsd32_long ru_nvcsw; /* voluntary context switches */
158 netbsd32_long ru_nivcsw; /* involuntary " */
159 };
160
161 typedef u_int32_t netbsd32_orlimitp_t;
162
163 typedef u_int32_t netbsd32_rlimitp_t;
164
165 /* from <sys/ipc.h> */
166 typedef u_int32_t netbsd32_ipc_permp_t;
167 struct netbsd32_ipc_perm {
168 ushort cuid; /* creator user id */
169 ushort cgid; /* creator group id */
170 ushort uid; /* user id */
171 ushort gid; /* group id */
172 ushort mode; /* r/w permission */
173 ushort seq; /* sequence # (to generate unique msg/sem/shm id) */
174 netbsd32_key_t key; /* user specified msg/sem/shm key */
175 };
176
177 /* from <sys/msg.h> */
178 typedef u_int32_t netbsd32_msgp_t;
179 struct netbsd32_msg {
180 netbsd32_msgp_t msg_next; /* next msg in the chain */
181 netbsd32_long msg_type; /* type of this message */
182 /* >0 -> type of this message */
183 /* 0 -> free header */
184 u_short msg_ts; /* size of this message */
185 short msg_spot; /* location of start of msg in buffer */
186 };
187
188 typedef u_int32_t netbsd32_msqid_dsp_t;
189 struct netbsd32_msqid_ds {
190 struct netbsd32_ipc_perm msg_perm; /* msg queue permission bits */
191 netbsd32_msgp_t msg_first; /* first message in the queue */
192 netbsd32_msgp_t msg_last; /* last message in the queue */
193 netbsd32_u_long msg_cbytes; /* number of bytes in use on the queue */
194 netbsd32_u_long msg_qnum; /* number of msgs in the queue */
195 netbsd32_u_long msg_qbytes; /* max # of bytes on the queue */
196 pid_t msg_lspid; /* pid of last msgsnd() */
197 pid_t msg_lrpid; /* pid of last msgrcv() */
198 time_t msg_stime; /* time of last msgsnd() */
199 netbsd32_long msg_pad1;
200 time_t msg_rtime; /* time of last msgrcv() */
201 netbsd32_long msg_pad2;
202 time_t msg_ctime; /* time of last msgctl() */
203 netbsd32_long msg_pad3;
204 netbsd32_long msg_pad4[4];
205 };
206
207 /* from <sys/sem.h> */
208 typedef u_int32_t netbsd32_semp_t;
209
210 typedef u_int32_t netbsd32_semid_dsp_t;
211 struct netbsd32_semid_ds {
212 struct netbsd32_ipc_perm sem_perm;/* operation permission struct */
213 netbsd32_semp_t sem_base; /* pointer to first semaphore in set */
214 unsigned short sem_nsems; /* number of sems in set */
215 time_t sem_otime; /* last operation time */
216 netbsd32_long sem_pad1; /* SVABI/386 says I need this here */
217 time_t sem_ctime; /* last change time */
218 /* Times measured in secs since */
219 /* 00:00:00 GMT, Jan. 1, 1970 */
220 netbsd32_long sem_pad2; /* SVABI/386 says I need this here */
221 netbsd32_long sem_pad3[4]; /* SVABI/386 says I need this here */
222 };
223
224 typedef u_int32_t netbsd32_semunu_t;
225 union netbsd32_semun {
226 int val; /* value for SETVAL */
227 netbsd32_semid_dsp_t buf; /* buffer for IPC_STAT & IPC_SET */
228 netbsd32_u_shortp array; /* array for GETALL & SETALL */
229 };
230
231 typedef u_int32_t netbsd32_sembufp_t;
232 struct netbsd32_sembuf {
233 unsigned short sem_num; /* semaphore # */
234 short sem_op; /* semaphore operation */
235 short sem_flg; /* operation flags */
236 };
237
238 /* from <sys/shm.h> */
239 typedef u_int32_t netbsd32_shmid_dsp_t;
240 struct netbsd32_shmid_ds {
241 struct netbsd32_ipc_perm shm_perm; /* operation permission structure */
242 int shm_segsz; /* size of segment in bytes */
243 pid_t shm_lpid; /* process ID of last shm op */
244 pid_t shm_cpid; /* process ID of creator */
245 short shm_nattch; /* number of current attaches */
246 time_t shm_atime; /* time of last shmat() */
247 time_t shm_dtime; /* time of last shmdt() */
248 time_t shm_ctime; /* time of last change by shmctl() */
249 netbsd32_voidp shm_internal; /* sysv stupidity */
250 };
251
252 /* from <sys/signal.h> */
253 typedef u_int32_t netbsd32_sigactionp_t;
254 struct netbsd32_sigaction {
255 netbsd32_voidp sa_handler; /* signal handler */
256 sigset_t sa_mask; /* signal mask to apply */
257 int sa_flags; /* see signal options below */
258 };
259
260 typedef u_int32_t netbsd32_sigaltstack13p_t;
261 struct netbsd32_sigaltstack13 {
262 netbsd32_charp ss_sp; /* signal stack base */
263 int ss_size; /* signal stack length */
264 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
265 };
266
267 typedef u_int32_t netbsd32_sigaltstackp_t;
268 struct netbsd32_sigaltstack {
269 netbsd32_voidp ss_sp; /* signal stack base */
270 netbsd32_size_t ss_size; /* signal stack length */
271 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
272 };
273
274 typedef u_int32_t netbsd32_sigstackp_t;
275 struct netbsd32_sigstack {
276 netbsd32_voidp ss_sp; /* signal stack pointer */
277 int ss_onstack; /* current status */
278 };
279
280 typedef u_int32_t netbsd32_sigvecp_t;
281 struct netbsd32_sigvec {
282 netbsd32_voidp sv_handler; /* signal handler */
283 int sv_mask; /* signal mask to apply */
284 int sv_flags; /* see signal options below */
285 };
286
287 /* from <sys/socket.h> */
288 typedef u_int32_t netbsd32_sockaddrp_t;
289 typedef u_int32_t netbsd32_osockaddrp_t;
290
291 typedef u_int32_t netbsd32_msghdrp_t;
292 struct netbsd32_msghdr {
293 netbsd32_caddr_t msg_name; /* optional address */
294 u_int msg_namelen; /* size of address */
295 netbsd32_iovecp_t msg_iov; /* scatter/gather array */
296 u_int msg_iovlen; /* # elements in msg_iov */
297 netbsd32_caddr_t msg_control; /* ancillary data, see below */
298 u_int msg_controllen; /* ancillary data buffer len */
299 int msg_flags; /* flags on received message */
300 };
301
302 typedef u_int32_t netbsd32_omsghdrp_t;
303 struct netbsd32_omsghdr {
304 netbsd32_caddr_t msg_name; /* optional address */
305 int msg_namelen; /* size of address */
306 netbsd32_iovecp_t msg_iov; /* scatter/gather array */
307 int msg_iovlen; /* # elements in msg_iov */
308 netbsd32_caddr_t msg_accrights; /* access rights sent/received */
309 int msg_accrightslen;
310 };
311
312 /* from <sys/stat.h> */
313 typedef u_int32_t netbsd32_stat12p_t;
314 struct netbsd32_stat12 { /* NetBSD-1.2 stat struct */
315 dev_t st_dev; /* inode's device */
316 ino_t st_ino; /* inode's number */
317 u_int16_t st_mode; /* inode protection mode */
318 u_int16_t st_nlink; /* number of hard links */
319 uid_t st_uid; /* user ID of the file's owner */
320 gid_t st_gid; /* group ID of the file's group */
321 dev_t st_rdev; /* device type */
322 struct netbsd32_timespec st_atimespec;/* time of last access */
323 struct netbsd32_timespec st_mtimespec;/* time of last data modification */
324 struct netbsd32_timespec st_ctimespec;/* time of last file status change */
325 off_t st_size; /* file size, in bytes */
326 int64_t st_blocks; /* blocks allocated for file */
327 u_int32_t st_blksize; /* optimal blocksize for I/O */
328 u_int32_t st_flags; /* user defined flags for file */
329 u_int32_t st_gen; /* file generation number */
330 int32_t st_lspare;
331 int64_t st_qspare[2];
332 };
333
334 typedef u_int32_t netbsd32_stat43p_t;
335 struct netbsd32_stat43 { /* BSD-4.3 stat struct */
336 u_int16_t st_dev; /* inode's device */
337 ino_t st_ino; /* inode's number */
338 u_int16_t st_mode; /* inode protection mode */
339 u_int16_t st_nlink; /* number of hard links */
340 u_int16_t st_uid; /* user ID of the file's owner */
341 u_int16_t st_gid; /* group ID of the file's group */
342 u_int16_t st_rdev; /* device type */
343 int32_t st_size; /* file size, in bytes */
344 struct netbsd32_timespec st_atimespec;/* time of last access */
345 struct netbsd32_timespec st_mtimespec;/* time of last data modification */
346 struct netbsd32_timespec st_ctimespec;/* time of last file status change */
347 int32_t st_blksize; /* optimal blocksize for I/O */
348 int32_t st_blocks; /* blocks allocated for file */
349 u_int32_t st_flags; /* user defined flags for file */
350 u_int32_t st_gen; /* file generation number */
351 };
352 typedef u_int32_t netbsd32_statp_t;
353 struct netbsd32_stat {
354 dev_t st_dev; /* inode's device */
355 ino_t st_ino; /* inode's number */
356 mode_t st_mode; /* inode protection mode */
357 nlink_t st_nlink; /* number of hard links */
358 uid_t st_uid; /* user ID of the file's owner */
359 gid_t st_gid; /* group ID of the file's group */
360 dev_t st_rdev; /* device type */
361 struct timespec st_atimespec;/* time of last access */
362 struct timespec st_mtimespec;/* time of last data modification */
363 struct timespec st_ctimespec;/* time of last file status change */
364 off_t st_size; /* file size, in bytes */
365 blkcnt_t st_blocks; /* blocks allocated for file */
366 blksize_t st_blksize; /* optimal blocksize for I/O */
367 u_int32_t st_flags; /* user defined flags for file */
368 u_int32_t st_gen; /* file generation number */
369 int64_t st_qspare[2];
370 };
371
372 /* from <sys/timex.h> */
373 typedef u_int32_t netbsd32_ntptimevalp_t;
374 struct netbsd32_ntptimeval {
375 struct netbsd32_timeval time; /* current time (ro) */
376 netbsd32_long maxerror; /* maximum error (us) (ro) */
377 netbsd32_long esterror; /* estimated error (us) (ro) */
378 };
379
380 typedef u_int32_t netbsd32_timexp_t;
381 struct netbsd32_timex {
382 unsigned int modes; /* clock mode bits (wo) */
383 netbsd32_long offset; /* time offset (us) (rw) */
384 netbsd32_long freq; /* frequency offset (scaled ppm) (rw) */
385 netbsd32_long maxerror; /* maximum error (us) (rw) */
386 netbsd32_long esterror; /* estimated error (us) (rw) */
387 int status; /* clock status bits (rw) */
388 netbsd32_long constant; /* pll time constant (rw) */
389 netbsd32_long precision; /* clock precision (us) (ro) */
390 netbsd32_long tolerance; /* clock frequency tolerance (scaled
391 * ppm) (ro) */
392 /*
393 * The following read-only structure members are implemented
394 * only if the PPS signal discipline is configured in the
395 * kernel.
396 */
397 netbsd32_long ppsfreq; /* pps frequency (scaled ppm) (ro) */
398 netbsd32_long jitter; /* pps jitter (us) (ro) */
399 int shift; /* interval duration (s) (shift) (ro) */
400 netbsd32_long stabil; /* pps stability (scaled ppm) (ro) */
401 netbsd32_long jitcnt; /* jitter limit exceeded (ro) */
402 netbsd32_long calcnt; /* calibration intervals (ro) */
403 netbsd32_long errcnt; /* calibration errors (ro) */
404 netbsd32_long stbcnt; /* stability limit exceeded (ro) */
405 };
406
407 /* from <ufs/lfs/lfs.h> */
408 typedef u_int32_t netbsd32_block_infop_t; /* XXX broken */
409
410 /* from <sys/utsname.h> */
411 typedef u_int32_t netbsd32_utsnamep_t;
412
413 /* from <compat/common/kern_info_09.c> */
414 typedef u_int32_t netbsd32_outsnamep_t;
415
416 /*
417 * machine depedant section; must define:
418 * netbsd32_sigcontextp_t - point to sigcontext
419 * <arch32>_sigcontext
420 */
421
422 #include <machine/netbsd32.h>
423
424 /*
425 * here are some macros to convert between netbsd32 and sparc64 types.
426 * note that they do *NOT* act like good macros and put ()'s around all
427 * arguments cuz this _breaks_ SCARG().
428 */
429 #define SPARC32TO64(s32uap, uap, name) \
430 SCARG(uap, name) = SCARG(s32uap, name)
431 #define SPARC32TOP(s32uap, uap, name, type) \
432 SCARG(uap, name) = (type *)(u_long)(u_int)SCARG(s32uap, name)
433 #define SPARC32TOX(s32uap, uap, name, type) \
434 SCARG(uap, name) = (type)SCARG(s32uap, name)
435 #define SPARC32TOX64(s32uap, uap, name, type) \
436 SCARG(uap, name) = (type)(u_long)SCARG(s32uap, name)
437
438 /* and some standard versions */
439 #define SPARC32TO64_UAP(name) SPARC32TO64(uap, &ua, name);
440 #define SPARC32TOP_UAP(name, type) SPARC32TOP(uap, &ua, name, type);
441 #define SPARC32TOX_UAP(name, type) SPARC32TOX(uap, &ua, name, type);
442 #define SPARC32TOX64_UAP(name, type) SPARC32TOX64(uap, &ua, name, type);
443
444 /*
445 * random other stuff
446 */
447 #include <compat/common/compat_util.h>
448
449 extern const char netbsd32_emul_path[];
450
451 #define SPARC32_CHECK_ALT_EXIST(p, sgp, path) \
452 emul_find(p, sgp, netbsd32_emul_path, (char *)path, (char **)&path, 0)
453
454 #endif /* _COMPAT_SPARC32_SPARC32_H_ */
455