1 /* $NetBSD: netbsd32.h,v 1.3 1998/10/01 14:27:56 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 /* 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 sparc32_long; 48 typedef u_int32_t sparc32_u_long; 49 50 typedef u_int32_t sparc32_clock_t; 51 typedef u_int32_t sparc32_size_t; 52 typedef int32_t sparc32_ssize_t; 53 typedef int32_t sparc32_clockid_t; 54 typedef u_int32_t sparc32_caddr_t; 55 typedef int32_t sparc32_key_t; 56 57 /* all pointers are u_int32_t */ 58 59 typedef u_int32_t sparc32_voidp; 60 typedef u_int32_t sparc32_u_shortp; 61 typedef u_int32_t sparc32_charp; 62 typedef u_int32_t sparc32_u_charp; 63 typedef u_int32_t sparc32_charpp; 64 typedef u_int32_t sparc32_size_tp; 65 typedef u_int32_t sparc32_intp; 66 typedef u_int32_t sparc32_longp; 67 typedef u_int32_t sparc32_caddrp; 68 typedef u_int32_t sparc32_caddr; 69 typedef u_int32_t sparc32_gid_tp; 70 typedef u_int32_t sparc32_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 sparc32_fd_setp_t; 78 79 /* from <sys/uio.h> */ 80 typedef u_int32_t sparc32_iovecp_t; 81 struct sparc32_iovec { 82 sparc32_voidp iov_base; /* Base address. */ 83 sparc32_size_t iov_len; /* Length. */ 84 }; 85 86 /* from <sys/time.h> */ 87 typedef int32_t sparc32_timer_t; 88 89 typedef u_int32_t sparc32_timespecp_t; 90 struct sparc32_timespec { 91 time_t tv_sec; /* seconds */ 92 sparc32_long tv_nsec; /* and nanoseconds */ 93 }; 94 95 typedef u_int32_t sparc32_timevalp_t; 96 struct sparc32_timeval { 97 sparc32_long tv_sec; /* seconds */ 98 sparc32_long tv_usec; /* and microseconds */ 99 }; 100 101 typedef u_int32_t sparc32_timezonep_t; 102 struct sparc32_timezone { 103 int tz_minuteswest; /* minutes west of Greenwich */ 104 int tz_dsttime; /* type of dst correction */ 105 }; 106 107 typedef u_int32_t sparc32_itimervalp_t; 108 struct sparc32_itimerval { 109 struct sparc32_timeval it_interval; /* timer interval */ 110 struct sparc32_timeval it_value; /* current value */ 111 }; 112 113 /* from <sys/mount.h> */ 114 typedef u_int32_t sparc32_fidp_t; 115 116 typedef u_int32_t sparc32_fhandlep_t; 117 118 typedef u_int32_t sparc32_statfsp_t; 119 struct sparc32_statfs { 120 short f_type; /* type of file system */ 121 u_short f_flags; /* copy of mount flags */ 122 sparc32_long f_bsize; /* fundamental file system block size */ 123 sparc32_long f_iosize; /* optimal transfer block size */ 124 sparc32_long f_blocks; /* total data blocks in file system */ 125 sparc32_long f_bfree; /* free blocks in fs */ 126 sparc32_long f_bavail; /* free blocks avail to non-superuser */ 127 sparc32_long f_files; /* total file nodes in file system */ 128 sparc32_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 sparc32_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 sparc32_pollfdp_t; 139 140 /* from <sys/resource.h> */ 141 typedef u_int32_t sparc32_rusagep_t; 142 struct sparc32_rusage { 143 struct sparc32_timeval ru_utime;/* user time used */ 144 struct sparc32_timeval ru_stime;/* system time used */ 145 sparc32_long ru_maxrss; /* max resident set size */ 146 sparc32_long ru_ixrss; /* integral shared memory size */ 147 sparc32_long ru_idrss; /* integral unshared data " */ 148 sparc32_long ru_isrss; /* integral unshared stack " */ 149 sparc32_long ru_minflt; /* page reclaims */ 150 sparc32_long ru_majflt; /* page faults */ 151 sparc32_long ru_nswap; /* swaps */ 152 sparc32_long ru_inblock; /* block input operations */ 153 sparc32_long ru_oublock; /* block output operations */ 154 sparc32_long ru_msgsnd; /* messages sent */ 155 sparc32_long ru_msgrcv; /* messages received */ 156 sparc32_long ru_nsignals; /* signals received */ 157 sparc32_long ru_nvcsw; /* voluntary context switches */ 158 sparc32_long ru_nivcsw; /* involuntary " */ 159 }; 160 161 typedef u_int32_t sparc32_orlimitp_t; 162 163 typedef u_int32_t sparc32_rlimitp_t; 164 165 /* from <sys/ipc.h> */ 166 typedef u_int32_t sparc32_ipc_permp_t; 167 struct sparc32_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 sparc32_key_t key; /* user specified msg/sem/shm key */ 175 }; 176 177 /* from <sys/msg.h> */ 178 typedef u_int32_t sparc32_msgp_t; 179 struct sparc32_msg { 180 sparc32_msgp_t msg_next; /* next msg in the chain */ 181 sparc32_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 sparc32_msqid_dsp_t; 189 struct sparc32_msqid_ds { 190 struct sparc32_ipc_perm msg_perm; /* msg queue permission bits */ 191 sparc32_msgp_t msg_first; /* first message in the queue */ 192 sparc32_msgp_t msg_last; /* last message in the queue */ 193 sparc32_u_long msg_cbytes; /* number of bytes in use on the queue */ 194 sparc32_u_long msg_qnum; /* number of msgs in the queue */ 195 sparc32_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 sparc32_long msg_pad1; 200 time_t msg_rtime; /* time of last msgrcv() */ 201 sparc32_long msg_pad2; 202 time_t msg_ctime; /* time of last msgctl() */ 203 sparc32_long msg_pad3; 204 sparc32_long msg_pad4[4]; 205 }; 206 207 /* from <sys/sem.h> */ 208 typedef u_int32_t sparc32_semp_t; 209 210 typedef u_int32_t sparc32_semid_dsp_t; 211 struct sparc32_semid_ds { 212 struct sparc32_ipc_perm sem_perm;/* operation permission struct */ 213 sparc32_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 sparc32_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 sparc32_long sem_pad2; /* SVABI/386 says I need this here */ 221 sparc32_long sem_pad3[4]; /* SVABI/386 says I need this here */ 222 }; 223 224 typedef u_int32_t sparc32_semunu_t; 225 union sparc32_semun { 226 int val; /* value for SETVAL */ 227 sparc32_semid_dsp_t buf; /* buffer for IPC_STAT & IPC_SET */ 228 sparc32_u_shortp array; /* array for GETALL & SETALL */ 229 }; 230 231 typedef u_int32_t sparc32_sembufp_t; 232 struct sparc32_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 sparc32_shmid_dsp_t; 240 struct sparc32_shmid_ds { 241 struct sparc32_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 sparc32_voidp shm_internal; /* sysv stupidity */ 250 }; 251 252 /* from <sys/signal.h> */ 253 typedef u_int32_t sparc32_sigactionp_t; 254 struct sparc32_sigaction { 255 sparc32_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 sparc32_sigaltstack13p_t; 261 struct sparc32_sigaltstack13 { 262 sparc32_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 sparc32_sigaltstackp_t; 268 struct sparc32_sigaltstack { 269 sparc32_voidp ss_sp; /* signal stack base */ 270 sparc32_size_t ss_size; /* signal stack length */ 271 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ 272 }; 273 274 typedef u_int32_t sparc32_sigstackp_t; 275 struct sparc32_sigstack { 276 sparc32_voidp ss_sp; /* signal stack pointer */ 277 int ss_onstack; /* current status */ 278 }; 279 280 typedef u_int32_t sparc32_sigvecp_t; 281 struct sparc32_sigvec { 282 sparc32_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 sparc32_sockaddrp_t; 289 typedef u_int32_t sparc32_osockaddrp_t; 290 291 typedef u_int32_t sparc32_msghdrp_t; 292 struct sparc32_msghdr { 293 sparc32_caddr_t msg_name; /* optional address */ 294 u_int msg_namelen; /* size of address */ 295 sparc32_iovecp_t msg_iov; /* scatter/gather array */ 296 u_int msg_iovlen; /* # elements in msg_iov */ 297 sparc32_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 sparc32_omsghdrp_t; 303 struct sparc32_omsghdr { 304 sparc32_caddr_t msg_name; /* optional address */ 305 int msg_namelen; /* size of address */ 306 sparc32_iovecp_t msg_iov; /* scatter/gather array */ 307 int msg_iovlen; /* # elements in msg_iov */ 308 sparc32_caddr_t msg_accrights; /* access rights sent/received */ 309 int msg_accrightslen; 310 }; 311 312 /* from <sys/stat.h> */ 313 typedef u_int32_t sparc32_stat12p_t; 314 struct sparc32_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 sparc32_timespec st_atimespec;/* time of last access */ 323 struct sparc32_timespec st_mtimespec;/* time of last data modification */ 324 struct sparc32_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 sparc32_stat43p_t; 335 struct sparc32_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 sparc32_timespec st_atimespec;/* time of last access */ 345 struct sparc32_timespec st_mtimespec;/* time of last data modification */ 346 struct sparc32_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 sparc32_statp_t; 353 struct sparc32_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 sparc32_ntptimevalp_t; 374 struct sparc32_ntptimeval { 375 struct sparc32_timeval time; /* current time (ro) */ 376 sparc32_long maxerror; /* maximum error (us) (ro) */ 377 sparc32_long esterror; /* estimated error (us) (ro) */ 378 }; 379 380 typedef u_int32_t sparc32_timexp_t; 381 struct sparc32_timex { 382 unsigned int modes; /* clock mode bits (wo) */ 383 sparc32_long offset; /* time offset (us) (rw) */ 384 sparc32_long freq; /* frequency offset (scaled ppm) (rw) */ 385 sparc32_long maxerror; /* maximum error (us) (rw) */ 386 sparc32_long esterror; /* estimated error (us) (rw) */ 387 int status; /* clock status bits (rw) */ 388 sparc32_long constant; /* pll time constant (rw) */ 389 sparc32_long precision; /* clock precision (us) (ro) */ 390 sparc32_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 sparc32_long ppsfreq; /* pps frequency (scaled ppm) (ro) */ 398 sparc32_long jitter; /* pps jitter (us) (ro) */ 399 int shift; /* interval duration (s) (shift) (ro) */ 400 sparc32_long stabil; /* pps stability (scaled ppm) (ro) */ 401 sparc32_long jitcnt; /* jitter limit exceeded (ro) */ 402 sparc32_long calcnt; /* calibration intervals (ro) */ 403 sparc32_long errcnt; /* calibration errors (ro) */ 404 sparc32_long stbcnt; /* stability limit exceeded (ro) */ 405 }; 406 407 /* from <ufs/lfs/lfs.h> */ 408 typedef u_int32_t sparc32_block_infop_t; /* XXX broken */ 409 410 /* from <sys/utsname.h> */ 411 typedef u_int32_t sparc32_utsnamep_t; 412 413 /* from <compat/common/kern_info_09.c> */ 414 typedef u_int32_t sparc32_outsnamep_t; 415 416 /* from <arch/sparc/include/signal.h> */ 417 typedef u_int32_t sparc32_sigcontextp_t; 418 /* XXX how can this work? */ 419 struct sparc32_sigcontext { 420 int sc_onstack; /* sigstack state to restore */ 421 int sc_mask; /* signal mask to restore */ 422 /* begin machine dependent portion */ 423 int sc_sp; /* %sp to restore */ 424 int sc_pc; /* pc to restore */ 425 int sc_npc; /* npc to restore */ 426 int sc_psr; /* psr to restore */ 427 int sc_g1; /* %g1 to restore */ 428 int sc_o0; /* %o0 to restore */ 429 }; 430 431 /* 432 * here are some macros to convert between sparc32 and sparc64 types. 433 * note that they do *NOT* act like good macros and put ()'s around all 434 * arguments cuz this _breaks_ SCARG(). 435 */ 436 #define SPARC32TO64(s32uap, uap, name) \ 437 SCARG(uap, name) = SCARG(s32uap, name) 438 #define SPARC32TOP(s32uap, uap, name, type) \ 439 SCARG(uap, name) = (type *)(u_long)(u_int)SCARG(s32uap, name) 440 #define SPARC32TOX(s32uap, uap, name, type) \ 441 SCARG(uap, name) = (type)SCARG(s32uap, name) 442 #define SPARC32TOX64(s32uap, uap, name, type) \ 443 SCARG(uap, name) = (type)(u_long)SCARG(s32uap, name) 444 445 /* and some standard versions */ 446 #define SPARC32TO64_UAP(name) SPARC32TO64(uap, &ua, name); 447 #define SPARC32TOP_UAP(name, type) SPARC32TOP(uap, &ua, name, type); 448 #define SPARC32TOX_UAP(name, type) SPARC32TOX(uap, &ua, name, type); 449 #define SPARC32TOX64_UAP(name, type) SPARC32TOX64(uap, &ua, name, type); 450 451 /* 452 * random other stuff 453 */ 454 #include <compat/common/compat_util.h> 455 456 extern const char sparc32_emul_path[]; 457 458 #define SPARC32_CHECK_ALT_EXIST(p, sgp, path) \ 459 emul_find(p, sgp, sparc32_emul_path, (char *)path, (char **)&path, 0) 460 461 #endif /* _COMPAT_SPARC32_SPARC32_H_ */ 462