netbsd32.h revision 1.2 1 /* $NetBSD: netbsd32.h,v 1.2 1998/09/07 01:38:03 eeh 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
34 /*
35 * SPARC 32-bit compatibility module.
36 */
37
38 #include <sys/mount.h>
39
40 /*
41 * first, define all the types we need.
42 */
43
44 typedef int32_t sparc32_long;
45 typedef u_int32_t sparc32_u_long;
46
47 typedef u_int32_t sparc32_clock_t;
48 typedef u_int32_t sparc32_size_t;
49 typedef int32_t sparc32_ssize_t;
50 typedef int32_t sparc32_clockid_t;
51 typedef int32_t sparc32_caddr_t;
52 typedef int32_t sparc32_key_t;
53
54 /* all pointers are int32_t */
55
56 typedef int32_t sparc32_voidp;
57 typedef int32_t sparc32_u_shortp;
58 typedef int32_t sparc32_charp;
59 typedef int32_t sparc32_u_charp;
60 typedef int32_t sparc32_charpp;
61 typedef int32_t sparc32_size_tp;
62 typedef int32_t sparc32_intp;
63 typedef int32_t sparc32_longp;
64 typedef int32_t sparc32_caddrp;
65 typedef int32_t sparc32_caddr;
66 typedef int32_t sparc32_gid_tp;
67 typedef int32_t sparc32_fsid_tp_t;
68
69 /*
70 * now, the compatibility structures and their fake pointer types.
71 */
72
73 /* from <sys/types.h> */
74 typedef int32_t sparc32_fd_setp_t;
75
76 /* from <sys/uio.h> */
77 typedef int32_t sparc32_iovecp_t;
78 struct sparc32_iovec {
79 sparc32_voidp iov_base; /* Base address. */
80 size_t iov_len; /* Length. */
81 };
82
83 /* from <sys/time.h> */
84 typedef int32_t sparc32_timer_t;
85
86 typedef int32_t sparc32_timespecp_t;
87 struct sparc32_timespec {
88 time_t tv_sec; /* seconds */
89 sparc32_long tv_nsec; /* and nanoseconds */
90 };
91
92 typedef int32_t sparc32_timevalp_t;
93 struct sparc32_timeval {
94 sparc32_long tv_sec; /* seconds */
95 sparc32_long tv_usec; /* and microseconds */
96 };
97
98 typedef int32_t sparc32_timezonep_t;
99 struct sparc32_timezone {
100 int tz_minuteswest; /* minutes west of Greenwich */
101 int tz_dsttime; /* type of dst correction */
102 };
103
104 typedef int32_t sparc32_itimervalp_t;
105 struct sparc32_itimerval {
106 struct sparc32_timeval it_interval; /* timer interval */
107 struct sparc32_timeval it_value; /* current value */
108 };
109
110 /* from <sys/mount.h> */
111 typedef int32_t sparc32_fidp_t;
112
113 typedef int32_t sparc32_fhandlep_t;
114
115 typedef int32_t sparc32_statfsp_t;
116 struct sparc32_statfs {
117 short f_type; /* type of file system */
118 u_short f_flags; /* copy of mount flags */
119 sparc32_long f_bsize; /* fundamental file system block size */
120 sparc32_long f_iosize; /* optimal transfer block size */
121 sparc32_long f_blocks; /* total data blocks in file system */
122 sparc32_long f_bfree; /* free blocks in fs */
123 sparc32_long f_bavail; /* free blocks avail to non-superuser */
124 sparc32_long f_files; /* total file nodes in file system */
125 sparc32_long f_ffree; /* free file nodes in fs */
126 fsid_t f_fsid; /* file system id */
127 uid_t f_owner; /* user that mounted the file system */
128 sparc32_long f_spare[4]; /* spare for later */
129 char f_fstypename[MFSNAMELEN]; /* fs type name */
130 char f_mntonname[MNAMELEN]; /* directory on which mounted */
131 char f_mntfromname[MNAMELEN]; /* mounted file system */
132 };
133
134 /* from <sys/poll.h> */
135 typedef int32_t sparc32_pollfdp_t;
136
137 /* from <sys/resource.h> */
138 typedef int32_t sparc32_rusagep_t;
139 struct sparc32_rusage {
140 struct sparc32_timeval ru_utime;/* user time used */
141 struct sparc32_timeval ru_stime;/* system time used */
142 sparc32_long ru_maxrss; /* max resident set size */
143 sparc32_long ru_ixrss; /* integral shared memory size */
144 sparc32_long ru_idrss; /* integral unshared data " */
145 sparc32_long ru_isrss; /* integral unshared stack " */
146 sparc32_long ru_minflt; /* page reclaims */
147 sparc32_long ru_majflt; /* page faults */
148 sparc32_long ru_nswap; /* swaps */
149 sparc32_long ru_inblock; /* block input operations */
150 sparc32_long ru_oublock; /* block output operations */
151 sparc32_long ru_msgsnd; /* messages sent */
152 sparc32_long ru_msgrcv; /* messages received */
153 sparc32_long ru_nsignals; /* signals received */
154 sparc32_long ru_nvcsw; /* voluntary context switches */
155 sparc32_long ru_nivcsw; /* involuntary " */
156 };
157
158 typedef int32_t sparc32_orlimitp_t;
159
160 typedef int32_t sparc32_rlimitp_t;
161
162 /* from <sys/ipc.h> */
163 typedef int32_t sparc32_ipc_permp_t;
164 struct sparc32_ipc_perm {
165 ushort cuid; /* creator user id */
166 ushort cgid; /* creator group id */
167 ushort uid; /* user id */
168 ushort gid; /* group id */
169 ushort mode; /* r/w permission */
170 ushort seq; /* sequence # (to generate unique msg/sem/shm id) */
171 sparc32_key_t key; /* user specified msg/sem/shm key */
172 };
173
174 /* from <sys/msg.h> */
175 typedef int32_t sparc32_msgp_t;
176 struct sparc32_msg {
177 sparc32_msgp_t msg_next; /* next msg in the chain */
178 sparc32_long msg_type; /* type of this message */
179 /* >0 -> type of this message */
180 /* 0 -> free header */
181 u_short msg_ts; /* size of this message */
182 short msg_spot; /* location of start of msg in buffer */
183 };
184
185 typedef int32_t sparc32_msqid_dsp_t;
186 struct sparc32_msqid_ds {
187 struct sparc32_ipc_perm msg_perm; /* msg queue permission bits */
188 sparc32_msgp_t msg_first; /* first message in the queue */
189 sparc32_msgp_t msg_last; /* last message in the queue */
190 sparc32_u_long msg_cbytes; /* number of bytes in use on the queue */
191 sparc32_u_long msg_qnum; /* number of msgs in the queue */
192 sparc32_u_long msg_qbytes; /* max # of bytes on the queue */
193 pid_t msg_lspid; /* pid of last msgsnd() */
194 pid_t msg_lrpid; /* pid of last msgrcv() */
195 time_t msg_stime; /* time of last msgsnd() */
196 sparc32_long msg_pad1;
197 time_t msg_rtime; /* time of last msgrcv() */
198 sparc32_long msg_pad2;
199 time_t msg_ctime; /* time of last msgctl() */
200 sparc32_long msg_pad3;
201 sparc32_long msg_pad4[4];
202 };
203
204 /* from <sys/sem.h> */
205 typedef int32_t sparc32_semp_t;
206
207 typedef int32_t sparc32_semid_dsp_t;
208 struct sparc32_semid_ds {
209 struct sparc32_ipc_perm sem_perm;/* operation permission struct */
210 sparc32_semp_t sem_base; /* pointer to first semaphore in set */
211 unsigned short sem_nsems; /* number of sems in set */
212 time_t sem_otime; /* last operation time */
213 sparc32_long sem_pad1; /* SVABI/386 says I need this here */
214 time_t sem_ctime; /* last change time */
215 /* Times measured in secs since */
216 /* 00:00:00 GMT, Jan. 1, 1970 */
217 sparc32_long sem_pad2; /* SVABI/386 says I need this here */
218 sparc32_long sem_pad3[4]; /* SVABI/386 says I need this here */
219 };
220
221 typedef int32_t sparc32_semunu_t;
222 union sparc32_semun {
223 int val; /* value for SETVAL */
224 sparc32_semid_dsp_t buf; /* buffer for IPC_STAT & IPC_SET */
225 sparc32_u_shortp array; /* array for GETALL & SETALL */
226 };
227
228 typedef int32_t sparc32_sembufp_t;
229 struct sparc32_sembuf {
230 unsigned short sem_num; /* semaphore # */
231 short sem_op; /* semaphore operation */
232 short sem_flg; /* operation flags */
233 };
234
235 /* from <sys/shm.h> */
236 typedef int32_t sparc32_shmid_dsp_t;
237 struct sparc32_shmid_ds {
238 struct sparc32_ipc_perm shm_perm; /* operation permission structure */
239 int shm_segsz; /* size of segment in bytes */
240 pid_t shm_lpid; /* process ID of last shm op */
241 pid_t shm_cpid; /* process ID of creator */
242 short shm_nattch; /* number of current attaches */
243 time_t shm_atime; /* time of last shmat() */
244 time_t shm_dtime; /* time of last shmdt() */
245 time_t shm_ctime; /* time of last change by shmctl() */
246 sparc32_voidp shm_internal; /* sysv stupidity */
247 };
248
249 /* from <sys/signal.h> */
250 typedef int32_t sparc32_sigactionp_t;
251 struct sparc32_sigaction {
252 sparc32_voidp sa_handler; /* signal handler */
253 sigset_t sa_mask; /* signal mask to apply */
254 int sa_flags; /* see signal options below */
255 };
256
257 typedef int32_t sparc32_sigaltstack13p_t;
258 struct sparc32_sigaltstack13 {
259 sparc32_charp ss_sp; /* signal stack base */
260 int ss_size; /* signal stack length */
261 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
262 };
263
264 typedef int32_t sparc32_sigaltstackp_t;
265 struct sparc32_sigaltstack {
266 sparc32_voidp ss_sp; /* signal stack base */
267 sparc32_size_t ss_size; /* signal stack length */
268 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
269 };
270
271 typedef int32_t sparc32_sigstackp_t;
272 struct sparc32_sigstack {
273 sparc32_voidp ss_sp; /* signal stack pointer */
274 int ss_onstack; /* current status */
275 };
276
277 typedef int32_t sparc32_sigvecp_t;
278 struct sparc32_sigvec {
279 sparc32_voidp sv_handler; /* signal handler */
280 int sv_mask; /* signal mask to apply */
281 int sv_flags; /* see signal options below */
282 };
283
284 /* from <sys/socket.h> */
285 typedef int32_t sparc32_sockaddrp_t;
286 typedef int32_t sparc32_osockaddrp_t;
287
288 typedef int32_t sparc32_msghdrp_t;
289 struct sparc32_msghdr {
290 sparc32_caddr_t msg_name; /* optional address */
291 u_int msg_namelen; /* size of address */
292 sparc32_iovecp_t msg_iov; /* scatter/gather array */
293 u_int msg_iovlen; /* # elements in msg_iov */
294 sparc32_caddr_t msg_control; /* ancillary data, see below */
295 u_int msg_controllen; /* ancillary data buffer len */
296 int msg_flags; /* flags on received message */
297 };
298
299 typedef int32_t sparc32_omsghdrp_t;
300 struct sparc32_omsghdr {
301 sparc32_caddr_t msg_name; /* optional address */
302 int msg_namelen; /* size of address */
303 sparc32_iovecp_t msg_iov; /* scatter/gather array */
304 int msg_iovlen; /* # elements in msg_iov */
305 sparc32_caddr_t msg_accrights; /* access rights sent/received */
306 int msg_accrightslen;
307 };
308
309 /* from <sys/stat.h> */
310 typedef int32_t sparc32_stat12p_t;
311 struct sparc32_stat12 { /* NetBSD-1.2 stat struct */
312 dev_t st_dev; /* inode's device */
313 ino_t st_ino; /* inode's number */
314 u_int16_t st_mode; /* inode protection mode */
315 u_int16_t st_nlink; /* number of hard links */
316 uid_t st_uid; /* user ID of the file's owner */
317 gid_t st_gid; /* group ID of the file's group */
318 dev_t st_rdev; /* device type */
319 struct sparc32_timespec st_atimespec;/* time of last access */
320 struct sparc32_timespec st_mtimespec;/* time of last data modification */
321 struct sparc32_timespec st_ctimespec;/* time of last file status change */
322 off_t st_size; /* file size, in bytes */
323 int64_t st_blocks; /* blocks allocated for file */
324 u_int32_t st_blksize; /* optimal blocksize for I/O */
325 u_int32_t st_flags; /* user defined flags for file */
326 u_int32_t st_gen; /* file generation number */
327 int32_t st_lspare;
328 int64_t st_qspare[2];
329 };
330
331 typedef int32_t sparc32_stat43p_t;
332 struct sparc32_stat43 { /* BSD-4.3 stat struct */
333 u_int16_t st_dev; /* inode's device */
334 ino_t st_ino; /* inode's number */
335 u_int16_t st_mode; /* inode protection mode */
336 u_int16_t st_nlink; /* number of hard links */
337 u_int16_t st_uid; /* user ID of the file's owner */
338 u_int16_t st_gid; /* group ID of the file's group */
339 u_int16_t st_rdev; /* device type */
340 int32_t st_size; /* file size, in bytes */
341 struct sparc32_timespec st_atimespec;/* time of last access */
342 struct sparc32_timespec st_mtimespec;/* time of last data modification */
343 struct sparc32_timespec st_ctimespec;/* time of last file status change */
344 int32_t st_blksize; /* optimal blocksize for I/O */
345 int32_t st_blocks; /* blocks allocated for file */
346 u_int32_t st_flags; /* user defined flags for file */
347 u_int32_t st_gen; /* file generation number */
348 };
349 typedef int32_t sparc32_statp_t;
350 struct sparc32_stat {
351 dev_t st_dev; /* inode's device */
352 ino_t st_ino; /* inode's number */
353 mode_t st_mode; /* inode protection mode */
354 nlink_t st_nlink; /* number of hard links */
355 uid_t st_uid; /* user ID of the file's owner */
356 gid_t st_gid; /* group ID of the file's group */
357 dev_t st_rdev; /* device type */
358 struct timespec st_atimespec;/* time of last access */
359 struct timespec st_mtimespec;/* time of last data modification */
360 struct timespec st_ctimespec;/* time of last file status change */
361 off_t st_size; /* file size, in bytes */
362 blkcnt_t st_blocks; /* blocks allocated for file */
363 blksize_t st_blksize; /* optimal blocksize for I/O */
364 u_int32_t st_flags; /* user defined flags for file */
365 u_int32_t st_gen; /* file generation number */
366 int64_t st_qspare[2];
367 };
368
369 /* from <sys/timex.h> */
370 typedef int32_t sparc32_ntptimevalp_t;
371 struct sparc32_ntptimeval {
372 struct sparc32_timeval time; /* current time (ro) */
373 sparc32_long maxerror; /* maximum error (us) (ro) */
374 sparc32_long esterror; /* estimated error (us) (ro) */
375 };
376
377 typedef int32_t sparc32_timexp_t;
378 struct sparc32_timex {
379 unsigned int modes; /* clock mode bits (wo) */
380 sparc32_long offset; /* time offset (us) (rw) */
381 sparc32_long freq; /* frequency offset (scaled ppm) (rw) */
382 sparc32_long maxerror; /* maximum error (us) (rw) */
383 sparc32_long esterror; /* estimated error (us) (rw) */
384 int status; /* clock status bits (rw) */
385 sparc32_long constant; /* pll time constant (rw) */
386 sparc32_long precision; /* clock precision (us) (ro) */
387 sparc32_long tolerance; /* clock frequency tolerance (scaled
388 * ppm) (ro) */
389 /*
390 * The following read-only structure members are implemented
391 * only if the PPS signal discipline is configured in the
392 * kernel.
393 */
394 sparc32_long ppsfreq; /* pps frequency (scaled ppm) (ro) */
395 sparc32_long jitter; /* pps jitter (us) (ro) */
396 int shift; /* interval duration (s) (shift) (ro) */
397 sparc32_long stabil; /* pps stability (scaled ppm) (ro) */
398 sparc32_long jitcnt; /* jitter limit exceeded (ro) */
399 sparc32_long calcnt; /* calibration intervals (ro) */
400 sparc32_long errcnt; /* calibration errors (ro) */
401 sparc32_long stbcnt; /* stability limit exceeded (ro) */
402 };
403
404 /* from <ufs/lfs/lfs.h> */
405 typedef int32_t sparc32_block_infop_t; /* XXX broken */
406
407 /* from <sys/utsname.h> */
408 typedef int32_t sparc32_utsnamep_t;
409
410 /* from <compat/common/kern_info_09.c> */
411 typedef int32_t sparc32_outsnamep_t;
412
413 /* from <arch/sparc/include/signal.h> */
414 typedef int32_t sparc32_sigcontextp_t;
415 /* XXX how can this work? */
416 struct sparc32_sigcontext {
417 int sc_onstack; /* sigstack state to restore */
418 int sc_mask; /* signal mask to restore */
419 /* begin machine dependent portion */
420 int sc_sp; /* %sp to restore */
421 int sc_pc; /* pc to restore */
422 int sc_npc; /* npc to restore */
423 int sc_psr; /* psr to restore */
424 int sc_g1; /* %g1 to restore */
425 int sc_o0; /* %o0 to restore */
426 };
427
428 /*
429 * here are some macros to convert between sparc32 and sparc64 types.
430 * note that they do *NOT* act like good macros and put ()'s around all
431 * arguments cuz this _breaks_ SCARG().
432 */
433 #define SPARC32TO64(s32uap, uap, name) \
434 SCARG(uap, name) = SCARG(s32uap, name)
435 #define SPARC32TOP(s32uap, uap, name, type) \
436 SCARG(uap, name) = (type *)(u_long)(u_int)SCARG(s32uap, name)
437 #define SPARC32TOX(s32uap, uap, name, type) \
438 SCARG(uap, name) = (type)SCARG(s32uap, name)
439 #define SPARC32TOX64(s32uap, uap, name, type) \
440 SCARG(uap, name) = (type)(u_long)SCARG(s32uap, name)
441
442 /* and some standard versions */
443 #define SPARC32TO64_UAP(name) SPARC32TO64(uap, &ua, name);
444 #define SPARC32TOP_UAP(name, type) SPARC32TOP(uap, &ua, name, type);
445 #define SPARC32TOX_UAP(name, type) SPARC32TOX(uap, &ua, name, type);
446 #define SPARC32TOX64_UAP(name, type) SPARC32TOX64(uap, &ua, name, type);
447
448 /*
449 * random other stuff
450 */
451 #include <compat/common/compat_util.h>
452
453 extern const char sparc32_emul_path[];
454
455 #define SPARC32_CHECK_ALT_EXIST(p, sgp, path) \
456 emul_find(p, sgp, sparc32_emul_path, (char *)path, (char **)&path, 0)
457
458 #endif /* _COMPAT_SPARC32_SPARC32_H_ */
459