Home | History | Annotate | Line # | Download | only in alpha
linux_osf1.c revision 1.3.4.2
      1  1.3.4.2  christos /*	$NetBSD: linux_osf1.c,v 1.3.4.2 2019/06/10 22:06:59 christos Exp $	*/
      2  1.3.4.2  christos 
      3  1.3.4.2  christos /*
      4  1.3.4.2  christos  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
      5  1.3.4.2  christos  *
      6  1.3.4.2  christos  * Redistribution and use in source and binary forms, with or without
      7  1.3.4.2  christos  * modification, are permitted provided that the following conditions
      8  1.3.4.2  christos  * are met:
      9  1.3.4.2  christos  * 1. Redistributions of source code must retain the above copyright
     10  1.3.4.2  christos  *    notice, this list of conditions and the following disclaimer.
     11  1.3.4.2  christos  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.3.4.2  christos  *    notice, this list of conditions and the following disclaimer in the
     13  1.3.4.2  christos  *    documentation and/or other materials provided with the distribution.
     14  1.3.4.2  christos  * 3. All advertising materials mentioning features or use of this software
     15  1.3.4.2  christos  *    must display the following acknowledgement:
     16  1.3.4.2  christos  *      This product includes software developed by Christopher G. Demetriou
     17  1.3.4.2  christos  *	for the NetBSD Project.
     18  1.3.4.2  christos  * 4. The name of the author may not be used to endorse or promote products
     19  1.3.4.2  christos  *    derived from this software without specific prior written permission
     20  1.3.4.2  christos  *
     21  1.3.4.2  christos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.3.4.2  christos  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.3.4.2  christos  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.3.4.2  christos  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.3.4.2  christos  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.3.4.2  christos  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.3.4.2  christos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.3.4.2  christos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.3.4.2  christos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.3.4.2  christos  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.3.4.2  christos  */
     32  1.3.4.2  christos 
     33  1.3.4.2  christos #include <sys/cdefs.h>
     34  1.3.4.2  christos __KERNEL_RCSID(0, "$NetBSD: linux_osf1.c,v 1.3.4.2 2019/06/10 22:06:59 christos Exp $");
     35  1.3.4.2  christos 
     36  1.3.4.2  christos #include <sys/param.h>
     37  1.3.4.2  christos #include <sys/systm.h>
     38  1.3.4.2  christos #include <sys/namei.h>
     39  1.3.4.2  christos #include <sys/proc.h>
     40  1.3.4.2  christos #include <sys/file.h>
     41  1.3.4.2  christos #include <sys/filedesc.h>
     42  1.3.4.2  christos #include <sys/kernel.h>
     43  1.3.4.2  christos #include <sys/mount.h>
     44  1.3.4.2  christos #include <sys/vnode.h>
     45  1.3.4.2  christos #include <sys/wait.h>
     46  1.3.4.2  christos #include <sys/select.h>
     47  1.3.4.2  christos #include <sys/syscallargs.h>
     48  1.3.4.2  christos #include <sys/vfs_syscalls.h>
     49  1.3.4.2  christos 
     50  1.3.4.2  christos #include <machine/alpha.h>
     51  1.3.4.2  christos #include <machine/cpuconf.h>
     52  1.3.4.2  christos #include <machine/rpb.h>
     53  1.3.4.2  christos #include <machine/fpu.h>
     54  1.3.4.2  christos 
     55  1.3.4.2  christos #include <compat/common/compat_util.h>
     56  1.3.4.2  christos #include <compat/linux/common/linux_types.h>
     57  1.3.4.2  christos #include <compat/linux/common/linux_signal.h>
     58  1.3.4.2  christos #include <compat/linux/arch/alpha/linux_signal.h>
     59  1.3.4.2  christos #include <compat/linux/arch/alpha/linux_osf1.h>
     60  1.3.4.2  christos #include <compat/linux/linux_syscallargs.h>
     61  1.3.4.2  christos 
     62  1.3.4.2  christos #include <net/if.h>
     63  1.3.4.2  christos #include <netinet/in.h>
     64  1.3.4.2  christos 
     65  1.3.4.2  christos #include <nfs/rpcv2.h>
     66  1.3.4.2  christos #include <nfs/nfsproto.h>
     67  1.3.4.2  christos #include <nfs/nfs.h>
     68  1.3.4.2  christos #include <nfs/nfsmount.h>
     69  1.3.4.2  christos 
     70  1.3.4.2  christos #include <ufs/ufs/quota.h>
     71  1.3.4.2  christos #include <ufs/ufs/ufsmount.h>
     72  1.3.4.2  christos 
     73  1.3.4.2  christos #include <machine/vmparam.h>
     74  1.3.4.2  christos 
     75  1.3.4.2  christos const struct emul_flags_xtab osf1_wait_options_xtab[] = {
     76  1.3.4.2  christos     {	OSF1_WNOHANG,		OSF1_WNOHANG,		WNOHANG		},
     77  1.3.4.2  christos     {	OSF1_WUNTRACED,		OSF1_WUNTRACED,		WUNTRACED	},
     78  1.3.4.2  christos     {	0								}
     79  1.3.4.2  christos };
     80  1.3.4.2  christos 
     81  1.3.4.2  christos const struct emul_flags_xtab osf1_nfs_mount_flags_xtab[] = {
     82  1.3.4.2  christos     {	OSF1_NFSMNT_SOFT,	OSF1_NFSMNT_SOFT,	NFSMNT_SOFT,	},
     83  1.3.4.2  christos     {	OSF1_NFSMNT_WSIZE,	OSF1_NFSMNT_WSIZE,	NFSMNT_WSIZE,	},
     84  1.3.4.2  christos     {	OSF1_NFSMNT_RSIZE,	OSF1_NFSMNT_RSIZE,	NFSMNT_RSIZE,	},
     85  1.3.4.2  christos     {	OSF1_NFSMNT_TIMEO,	OSF1_NFSMNT_TIMEO,	NFSMNT_TIMEO,	},
     86  1.3.4.2  christos     {	OSF1_NFSMNT_RETRANS,	OSF1_NFSMNT_RETRANS,	NFSMNT_RETRANS,	},
     87  1.3.4.2  christos #if 0 /* no equivalent; needs special handling, see below */
     88  1.3.4.2  christos     {	OSF1_NFSMNT_HOSTNAME,	OSF1_NFSMNT_HOSTNAME,	???,		},
     89  1.3.4.2  christos #endif
     90  1.3.4.2  christos     {	OSF1_NFSMNT_INT,	OSF1_NFSMNT_INT,	NFSMNT_INT,	},
     91  1.3.4.2  christos     {	OSF1_NFSMNT_NOCONN,	OSF1_NFSMNT_NOCONN,	NFSMNT_NOCONN,	},
     92  1.3.4.2  christos #if 0 /* no equivalents */
     93  1.3.4.2  christos     {	OSF1_NFSMNT_NOAC,	OSF1_NFSMNT_NOAC,	???,		},
     94  1.3.4.2  christos     {	OSF1_NFSMNT_ACREGMIN,	OSF1_NFSMNT_ACREGMIN,	???,		},
     95  1.3.4.2  christos     {	OSF1_NFSMNT_ACREGMAX,	OSF1_NFSMNT_ACREGMAX,	???,		},
     96  1.3.4.2  christos     {	OSF1_NFSMNT_ACDIRMIN,	OSF1_NFSMNT_ACDIRMIN,	???,		},
     97  1.3.4.2  christos     {	OSF1_NFSMNT_ACDIRMAX,	OSF1_NFSMNT_ACDIRMAX,	???,		},
     98  1.3.4.2  christos     {	OSF1_NFSMNT_NOCTO,	OSF1_NFSMNT_NOCTO,	???,		},
     99  1.3.4.2  christos     {	OSF1_NFSMNT_POSIX,	OSF1_NFSMNT_POSIX,	???,		},
    100  1.3.4.2  christos     {	OSF1_NFSMNT_AUTO,	OSF1_NFSMNT_AUTO,	???,		},
    101  1.3.4.2  christos     {	OSF1_NFSMNT_SEC,	OSF1_NFSMNT_SEC,	???,		},
    102  1.3.4.2  christos     {	OSF1_NFSMNT_TCP,	OSF1_NFSMNT_TCP,	???,		},
    103  1.3.4.2  christos     {	OSF1_NFSMNT_PROPLIST,	OSF1_NFSMNT_PROPLIST,	???,		},
    104  1.3.4.2  christos #endif
    105  1.3.4.2  christos     {	0								}
    106  1.3.4.2  christos };
    107  1.3.4.2  christos 
    108  1.3.4.2  christos static void
    109  1.3.4.2  christos osf1_cvt_rusage_from_native(const struct rusage *ru, struct osf1_rusage *oru)
    110  1.3.4.2  christos {
    111  1.3.4.2  christos 
    112  1.3.4.2  christos 	oru->ru_utime.tv_sec = ru->ru_utime.tv_sec;
    113  1.3.4.2  christos 	oru->ru_utime.tv_usec = ru->ru_utime.tv_usec;
    114  1.3.4.2  christos 
    115  1.3.4.2  christos 	oru->ru_stime.tv_sec = ru->ru_stime.tv_sec;
    116  1.3.4.2  christos 	oru->ru_stime.tv_usec = ru->ru_stime.tv_usec;
    117  1.3.4.2  christos 
    118  1.3.4.2  christos 	oru->ru_maxrss = ru->ru_maxrss;
    119  1.3.4.2  christos 	oru->ru_ixrss = ru->ru_ixrss;
    120  1.3.4.2  christos 	oru->ru_idrss = ru->ru_idrss;
    121  1.3.4.2  christos 	oru->ru_isrss = ru->ru_isrss;
    122  1.3.4.2  christos 	oru->ru_minflt = ru->ru_minflt;
    123  1.3.4.2  christos 	oru->ru_majflt = ru->ru_majflt;
    124  1.3.4.2  christos 	oru->ru_nswap = ru->ru_nswap;
    125  1.3.4.2  christos 	oru->ru_inblock = ru->ru_inblock;
    126  1.3.4.2  christos 	oru->ru_oublock = ru->ru_oublock;
    127  1.3.4.2  christos 	oru->ru_msgsnd = ru->ru_msgsnd;
    128  1.3.4.2  christos 	oru->ru_msgrcv = ru->ru_msgrcv;
    129  1.3.4.2  christos 	oru->ru_nsignals = ru->ru_nsignals;
    130  1.3.4.2  christos 	oru->ru_nvcsw = ru->ru_nvcsw;
    131  1.3.4.2  christos 	oru->ru_nivcsw = ru->ru_nivcsw;
    132  1.3.4.2  christos }
    133  1.3.4.2  christos 
    134  1.3.4.2  christos static void
    135  1.3.4.2  christos osf1_cvt_statfs_from_native(const struct statvfs *bsfs, struct osf1_statfs *osfs)
    136  1.3.4.2  christos {
    137  1.3.4.2  christos 
    138  1.3.4.2  christos 	memset(osfs, 0, sizeof (struct osf1_statfs));
    139  1.3.4.2  christos 	if (!strncmp(MOUNT_FFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename)))
    140  1.3.4.2  christos 		osfs->f_type = OSF1_MOUNT_UFS;
    141  1.3.4.2  christos 	else if (!strncmp(MOUNT_NFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename)))
    142  1.3.4.2  christos 		osfs->f_type = OSF1_MOUNT_NFS;
    143  1.3.4.2  christos 	else if (!strncmp(MOUNT_MFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename)))
    144  1.3.4.2  christos 		osfs->f_type = OSF1_MOUNT_MFS;
    145  1.3.4.2  christos 	else
    146  1.3.4.2  christos 		/* uh oh...  XXX = PC, CDFS, PROCFS, etc. */
    147  1.3.4.2  christos 		osfs->f_type = OSF1_MOUNT_ADDON;
    148  1.3.4.2  christos 	osfs->f_flags = bsfs->f_flag;		/* XXX translate */
    149  1.3.4.2  christos 	osfs->f_fsize = bsfs->f_frsize;
    150  1.3.4.2  christos 	osfs->f_bsize = bsfs->f_bsize;
    151  1.3.4.2  christos 	osfs->f_blocks = bsfs->f_blocks;
    152  1.3.4.2  christos 	osfs->f_bfree = bsfs->f_bfree;
    153  1.3.4.2  christos 	osfs->f_bavail = bsfs->f_bavail;
    154  1.3.4.2  christos 	osfs->f_files = bsfs->f_files;
    155  1.3.4.2  christos 	osfs->f_ffree = bsfs->f_ffree;
    156  1.3.4.2  christos 	memcpy(&osfs->f_fsid, &bsfs->f_fsidx, sizeof osfs->f_fsid);
    157  1.3.4.2  christos 	/* osfs->f_spare zeroed above */
    158  1.3.4.2  christos 	memcpy(osfs->f_mntonname, bsfs->f_mntonname, sizeof osfs->f_mntonname);
    159  1.3.4.2  christos 	memcpy(osfs->f_mntfromname, bsfs->f_mntfromname,
    160  1.3.4.2  christos 	    sizeof osfs->f_mntfromname);
    161  1.3.4.2  christos 	/* XXX osfs->f_xxx should be filled in... */
    162  1.3.4.2  christos }
    163  1.3.4.2  christos 
    164  1.3.4.2  christos /* --------------------------------------------------------------------- */
    165  1.3.4.2  christos 
    166  1.3.4.2  christos int
    167  1.3.4.2  christos linux_sys_osf1_wait4(struct lwp *l, const struct linux_sys_osf1_wait4_args *uap, register_t *retval)
    168  1.3.4.2  christos {
    169  1.3.4.2  christos 	struct osf1_rusage osf1_rusage;
    170  1.3.4.2  christos 	struct rusage netbsd_rusage;
    171  1.3.4.2  christos 	unsigned long leftovers;
    172  1.3.4.2  christos 	int error, status;
    173  1.3.4.2  christos 	int options = SCARG(uap, options);
    174  1.3.4.2  christos 	int pid = SCARG(uap, pid);
    175  1.3.4.2  christos 
    176  1.3.4.2  christos 	/* translate options */
    177  1.3.4.2  christos 	options = emul_flags_translate(osf1_wait_options_xtab,
    178  1.3.4.2  christos 	    options, &leftovers);
    179  1.3.4.2  christos 	if (leftovers != 0)
    180  1.3.4.2  christos 		return (EINVAL);
    181  1.3.4.2  christos 
    182  1.3.4.2  christos 	error = do_sys_wait(&pid, &status, options,
    183  1.3.4.2  christos 	    SCARG(uap, rusage) != NULL ? &netbsd_rusage : NULL);
    184  1.3.4.2  christos 
    185  1.3.4.2  christos 	retval[0] = pid;
    186  1.3.4.2  christos 	if (pid == 0)
    187  1.3.4.2  christos 		return error;
    188  1.3.4.2  christos 
    189  1.3.4.2  christos 	if (SCARG(uap, rusage)) {
    190  1.3.4.2  christos 		osf1_cvt_rusage_from_native(&netbsd_rusage, &osf1_rusage);
    191  1.3.4.2  christos 		error = copyout(&osf1_rusage, SCARG(uap, rusage),
    192  1.3.4.2  christos 		    sizeof osf1_rusage);
    193  1.3.4.2  christos 	}
    194  1.3.4.2  christos 
    195  1.3.4.2  christos 	if (error == 0 && SCARG(uap, status))
    196  1.3.4.2  christos 		error = copyout(&status, SCARG(uap, status), sizeof(status));
    197  1.3.4.2  christos 
    198  1.3.4.2  christos 	return error;
    199  1.3.4.2  christos }
    200  1.3.4.2  christos 
    201  1.3.4.2  christos #define	OSF1_MNT_WAIT		0x1
    202  1.3.4.2  christos #define	OSF1_MNT_NOWAIT		0x2
    203  1.3.4.2  christos 
    204  1.3.4.2  christos #define	OSF1_MNT_FORCE		0x1
    205  1.3.4.2  christos #define	OSF1_MNT_NOFORCE	0x2
    206  1.3.4.2  christos 
    207  1.3.4.2  christos /* acceptable flags for various calls */
    208  1.3.4.2  christos #define	OSF1_GETFSSTAT_FLAGS	(OSF1_MNT_WAIT|OSF1_MNT_NOWAIT)
    209  1.3.4.2  christos #define	OSF1_MOUNT_FLAGS	0xffffffff			/* XXX */
    210  1.3.4.2  christos #define	OSF1_UNMOUNT_FLAGS	(OSF1_MNT_FORCE|OSF1_MNT_NOFORCE)
    211  1.3.4.2  christos 
    212  1.3.4.2  christos static int
    213  1.3.4.2  christos osf1_mount_mfs(struct lwp *l, const struct linux_sys_osf1_mount_args *uap)
    214  1.3.4.2  christos {
    215  1.3.4.2  christos 	struct osf1_mfs_args osf_ma;
    216  1.3.4.2  christos 	struct mfs_args bsd_ma;
    217  1.3.4.2  christos 	int error;
    218  1.3.4.2  christos 	register_t dummy;
    219  1.3.4.2  christos 
    220  1.3.4.2  christos 	if ((error = copyin(SCARG(uap, data), &osf_ma, sizeof osf_ma)))
    221  1.3.4.2  christos 		return error;
    222  1.3.4.2  christos 
    223  1.3.4.2  christos 	memset(&bsd_ma, 0, sizeof bsd_ma);
    224  1.3.4.2  christos 	bsd_ma.fspec = osf_ma.name;
    225  1.3.4.2  christos 	/* XXX export args */
    226  1.3.4.2  christos 	bsd_ma.base = osf_ma.base;
    227  1.3.4.2  christos 	bsd_ma.size = osf_ma.size;
    228  1.3.4.2  christos 
    229  1.3.4.2  christos 	return do_sys_mount(l, "mfs", UIO_SYSSPACE, SCARG(uap, path),
    230  1.3.4.2  christos 	    SCARG(uap, flags), &bsd_ma, UIO_SYSSPACE, sizeof bsd_ma, &dummy);
    231  1.3.4.2  christos }
    232  1.3.4.2  christos 
    233  1.3.4.2  christos static int
    234  1.3.4.2  christos osf1_mount_nfs(struct lwp *l, const struct linux_sys_osf1_mount_args *uap)
    235  1.3.4.2  christos {
    236  1.3.4.2  christos 	struct osf1_nfs_args osf_na;
    237  1.3.4.2  christos 	struct nfs_args bsd_na;
    238  1.3.4.2  christos 	int error;
    239  1.3.4.2  christos 	unsigned long leftovers;
    240  1.3.4.2  christos 	register_t dummy;
    241  1.3.4.2  christos 
    242  1.3.4.2  christos 	if ((error = copyin(SCARG(uap, data), &osf_na, sizeof osf_na)))
    243  1.3.4.2  christos 		return error;
    244  1.3.4.2  christos 
    245  1.3.4.2  christos 	memset(&bsd_na, 0, sizeof bsd_na);
    246  1.3.4.2  christos 	bsd_na.addr = (struct sockaddr *)osf_na.addr;
    247  1.3.4.2  christos 	bsd_na.addrlen = sizeof (struct sockaddr_in);
    248  1.3.4.2  christos 	bsd_na.fh = osf_na.fh;
    249  1.3.4.2  christos 
    250  1.3.4.2  christos         /* translate flags */
    251  1.3.4.2  christos         bsd_na.flags = emul_flags_translate(osf1_nfs_mount_flags_xtab,
    252  1.3.4.2  christos             osf_na.flags, &leftovers);
    253  1.3.4.2  christos 	if (leftovers & OSF1_NFSMNT_HOSTNAME) {
    254  1.3.4.2  christos 		leftovers &= ~OSF1_NFSMNT_HOSTNAME;
    255  1.3.4.2  christos 		bsd_na.hostname = osf_na.hostname;
    256  1.3.4.2  christos 	} else {
    257  1.3.4.2  christos 		/* XXX FILL IN HOST NAME WITH IPADDR? */
    258  1.3.4.2  christos 	}
    259  1.3.4.2  christos 	if (leftovers & OSF1_NFSMNT_TCP) {
    260  1.3.4.2  christos 		leftovers &= ~OSF1_NFSMNT_TCP;
    261  1.3.4.2  christos 		bsd_na.sotype = SOCK_DGRAM;
    262  1.3.4.2  christos 		bsd_na.proto = 0;
    263  1.3.4.2  christos 	} else {
    264  1.3.4.2  christos 		bsd_na.sotype = SOCK_STREAM;
    265  1.3.4.2  christos 		bsd_na.proto = 0;
    266  1.3.4.2  christos 	}
    267  1.3.4.2  christos         if (leftovers != 0)
    268  1.3.4.2  christos                 return (EINVAL);
    269  1.3.4.2  christos 
    270  1.3.4.2  christos 	/* copy structure elements based on flags */
    271  1.3.4.2  christos 	if (bsd_na.flags & NFSMNT_WSIZE)
    272  1.3.4.2  christos 		bsd_na.wsize = osf_na.wsize;
    273  1.3.4.2  christos 	if (bsd_na.flags & NFSMNT_RSIZE)
    274  1.3.4.2  christos 		bsd_na.rsize = osf_na.rsize;
    275  1.3.4.2  christos 	if (bsd_na.flags & NFSMNT_TIMEO)
    276  1.3.4.2  christos 		bsd_na.timeo = osf_na.timeo;
    277  1.3.4.2  christos 	if (bsd_na.flags & NFSMNT_RETRANS)
    278  1.3.4.2  christos 		bsd_na.retrans = osf_na.retrans;
    279  1.3.4.2  christos 
    280  1.3.4.2  christos 	return do_sys_mount(l, "nfs", UIO_SYSSPACE, SCARG(uap, path),
    281  1.3.4.2  christos 	    SCARG(uap, flags), &bsd_na, UIO_SYSSPACE, sizeof bsd_na, &dummy);
    282  1.3.4.2  christos }
    283  1.3.4.2  christos 
    284  1.3.4.2  christos int
    285  1.3.4.2  christos linux_sys_osf1_mount(struct lwp *l, const struct linux_sys_osf1_mount_args *uap, register_t *retval)
    286  1.3.4.2  christos {
    287  1.3.4.2  christos 
    288  1.3.4.2  christos 	if (SCARG(uap, flags) & ~OSF1_MOUNT_FLAGS)
    289  1.3.4.2  christos 		return (EINVAL);
    290  1.3.4.2  christos 
    291  1.3.4.2  christos 	/* XXX - xlate flags */
    292  1.3.4.2  christos 
    293  1.3.4.2  christos 	switch (SCARG(uap, type)) {
    294  1.3.4.2  christos 	case OSF1_MOUNT_NFS:
    295  1.3.4.2  christos 		return osf1_mount_nfs(l, uap);
    296  1.3.4.2  christos 		break;
    297  1.3.4.2  christos 
    298  1.3.4.2  christos 	case OSF1_MOUNT_MFS:
    299  1.3.4.2  christos 		return osf1_mount_mfs(l, uap);
    300  1.3.4.2  christos 
    301  1.3.4.2  christos 	default:
    302  1.3.4.2  christos 		return (EINVAL);
    303  1.3.4.2  christos 	}
    304  1.3.4.2  christos }
    305  1.3.4.2  christos 
    306  1.3.4.2  christos int
    307  1.3.4.2  christos linux_sys_osf1_set_program_attributes(struct lwp *l, const struct linux_sys_osf1_set_program_attributes_args *uap, register_t *retval)
    308  1.3.4.2  christos {
    309  1.3.4.2  christos 	struct proc *p = l->l_proc;
    310  1.3.4.2  christos 	segsz_t tsize, dsize;
    311  1.3.4.2  christos 
    312  1.3.4.2  christos 	tsize = btoc(SCARG(uap, tsize));
    313  1.3.4.2  christos 	dsize = btoc(SCARG(uap, dsize));
    314  1.3.4.2  christos 
    315  1.3.4.2  christos 	if (dsize > p->p_rlimit[RLIMIT_DATA].rlim_cur)
    316  1.3.4.2  christos 		return (ENOMEM);
    317  1.3.4.2  christos 	if (tsize > MAXTSIZ)
    318  1.3.4.2  christos 		return (ENOMEM);
    319  1.3.4.2  christos 
    320  1.3.4.2  christos 	/* XXXSMP unlocked */
    321  1.3.4.2  christos 	p->p_vmspace->vm_taddr = SCARG(uap, taddr);
    322  1.3.4.2  christos 	p->p_vmspace->vm_tsize = tsize;
    323  1.3.4.2  christos 	p->p_vmspace->vm_daddr = SCARG(uap, daddr);
    324  1.3.4.2  christos 	p->p_vmspace->vm_dsize = dsize;
    325  1.3.4.2  christos 
    326  1.3.4.2  christos 	return (0);
    327  1.3.4.2  christos }
    328  1.3.4.2  christos 
    329  1.3.4.2  christos int
    330  1.3.4.2  christos linux_sys_osf1_setitimer(struct lwp *l, const struct linux_sys_osf1_setitimer_args *uap, register_t *retval)
    331  1.3.4.2  christos {
    332  1.3.4.2  christos 	struct osf1_itimerval o_itv, o_oitv;
    333  1.3.4.2  christos 	struct itimerval b_itv, b_oitv;
    334  1.3.4.2  christos 	int which;
    335  1.3.4.2  christos 	int error;
    336  1.3.4.2  christos 
    337  1.3.4.2  christos 	switch (SCARG(uap, which)) {
    338  1.3.4.2  christos 	case OSF1_ITIMER_REAL:
    339  1.3.4.2  christos 		which = ITIMER_REAL;
    340  1.3.4.2  christos 		break;
    341  1.3.4.2  christos 
    342  1.3.4.2  christos 	case OSF1_ITIMER_VIRTUAL:
    343  1.3.4.2  christos 		which = ITIMER_VIRTUAL;
    344  1.3.4.2  christos 		break;
    345  1.3.4.2  christos 
    346  1.3.4.2  christos 	case OSF1_ITIMER_PROF:
    347  1.3.4.2  christos 		which = ITIMER_PROF;
    348  1.3.4.2  christos 		break;
    349  1.3.4.2  christos 
    350  1.3.4.2  christos 	default:
    351  1.3.4.2  christos 		return (EINVAL);
    352  1.3.4.2  christos 	}
    353  1.3.4.2  christos 
    354  1.3.4.2  christos 	/* get the OSF/1 itimerval argument */
    355  1.3.4.2  christos 	error = copyin(SCARG(uap, itv), &o_itv, sizeof o_itv);
    356  1.3.4.2  christos 	if (error != 0)
    357  1.3.4.2  christos 		return error;
    358  1.3.4.2  christos 
    359  1.3.4.2  christos 	/* fill in and the NetBSD timeval */
    360  1.3.4.2  christos 	memset(&b_itv, 0, sizeof b_itv);
    361  1.3.4.2  christos 	b_itv.it_interval.tv_sec = o_itv.it_interval.tv_sec;
    362  1.3.4.2  christos 	b_itv.it_interval.tv_usec = o_itv.it_interval.tv_usec;
    363  1.3.4.2  christos 	b_itv.it_value.tv_sec = o_itv.it_value.tv_sec;
    364  1.3.4.2  christos 	b_itv.it_value.tv_usec = o_itv.it_value.tv_usec;
    365  1.3.4.2  christos 
    366  1.3.4.2  christos 	if (SCARG(uap, oitv) != NULL) {
    367  1.3.4.2  christos 		dogetitimer(l->l_proc, which, &b_oitv);
    368  1.3.4.2  christos 		if (error)
    369  1.3.4.2  christos 			return error;
    370  1.3.4.2  christos 	}
    371  1.3.4.2  christos 
    372  1.3.4.2  christos 	error = dosetitimer(l->l_proc, which, &b_itv);
    373  1.3.4.2  christos 
    374  1.3.4.2  christos 	if (error == 0 || SCARG(uap, oitv) == NULL)
    375  1.3.4.2  christos 		return error;
    376  1.3.4.2  christos 
    377  1.3.4.2  christos 	/* fill in and copy out the old timeval */
    378  1.3.4.2  christos 	memset(&o_oitv, 0, sizeof o_oitv);
    379  1.3.4.2  christos 	o_oitv.it_interval.tv_sec = b_oitv.it_interval.tv_sec;
    380  1.3.4.2  christos 	o_oitv.it_interval.tv_usec = b_oitv.it_interval.tv_usec;
    381  1.3.4.2  christos 	o_oitv.it_value.tv_sec = b_oitv.it_value.tv_sec;
    382  1.3.4.2  christos 	o_oitv.it_value.tv_usec = b_oitv.it_value.tv_usec;
    383  1.3.4.2  christos 
    384  1.3.4.2  christos 	return copyout(&o_oitv, SCARG(uap, oitv), sizeof o_oitv);
    385  1.3.4.2  christos }
    386  1.3.4.2  christos 
    387  1.3.4.2  christos int
    388  1.3.4.2  christos linux_sys_osf1_select(struct lwp *l, const struct linux_sys_osf1_select_args *uap,
    389  1.3.4.2  christos     register_t *retval)
    390  1.3.4.2  christos {
    391  1.3.4.2  christos 	struct osf1_timeval otv;
    392  1.3.4.2  christos 	struct timespec ats, *ts = NULL;
    393  1.3.4.2  christos 	int error;
    394  1.3.4.2  christos 
    395  1.3.4.2  christos 	if (SCARG(uap, tv)) {
    396  1.3.4.2  christos 		/* get the OSF/1 timeval argument */
    397  1.3.4.2  christos 		error = copyin(SCARG(uap, tv), &otv, sizeof otv);
    398  1.3.4.2  christos 		if (error != 0)
    399  1.3.4.2  christos 			return error;
    400  1.3.4.2  christos 
    401  1.3.4.2  christos 		ats.tv_sec = otv.tv_sec;
    402  1.3.4.2  christos 		ats.tv_nsec = otv.tv_usec * 1000;
    403  1.3.4.2  christos 		ts = &ats;
    404  1.3.4.2  christos 	}
    405  1.3.4.2  christos 
    406  1.3.4.2  christos 	return selcommon(retval, SCARG(uap, nd), SCARG(uap, in),
    407  1.3.4.2  christos 	    SCARG(uap, ou), SCARG(uap, ex), ts, NULL);
    408  1.3.4.2  christos }
    409  1.3.4.2  christos 
    410  1.3.4.2  christos int
    411  1.3.4.2  christos linux_sys_osf1_gettimeofday(struct lwp *l, const struct linux_sys_osf1_gettimeofday_args *uap, register_t *retval)
    412  1.3.4.2  christos {
    413  1.3.4.2  christos 	struct osf1_timeval otv;
    414  1.3.4.2  christos 	struct osf1_timezone otz;
    415  1.3.4.2  christos 	struct timeval tv;
    416  1.3.4.2  christos 	int error;
    417  1.3.4.2  christos 
    418  1.3.4.2  christos 	microtime(&tv);
    419  1.3.4.2  christos 	memset(&otv, 0, sizeof otv);
    420  1.3.4.2  christos 	otv.tv_sec = tv.tv_sec;
    421  1.3.4.2  christos 	otv.tv_usec = tv.tv_usec;
    422  1.3.4.2  christos 	error = copyout(&otv, SCARG(uap, tv), sizeof otv);
    423  1.3.4.2  christos 
    424  1.3.4.2  christos 	if (error == 0 && SCARG(uap, tzp) != NULL) {
    425  1.3.4.2  christos 		memset(&otz, 0, sizeof otz);
    426  1.3.4.2  christos 		error = copyout(&otz, SCARG(uap, tzp), sizeof otz);
    427  1.3.4.2  christos 	}
    428  1.3.4.2  christos 	return (error);
    429  1.3.4.2  christos }
    430  1.3.4.2  christos 
    431  1.3.4.2  christos int
    432  1.3.4.2  christos linux_sys_osf1_getrusage(struct lwp *l, const struct linux_sys_osf1_getrusage_args *uap, register_t *retval)
    433  1.3.4.2  christos {
    434  1.3.4.2  christos 	int error, who;
    435  1.3.4.2  christos 	struct osf1_rusage osf1_rusage;
    436  1.3.4.2  christos 	struct rusage ru;
    437  1.3.4.2  christos 	struct proc *p = l->l_proc;
    438  1.3.4.2  christos 
    439  1.3.4.2  christos 
    440  1.3.4.2  christos 	switch (SCARG(uap, who)) {
    441  1.3.4.2  christos 	case OSF1_RUSAGE_SELF:
    442  1.3.4.2  christos 		who = RUSAGE_SELF;
    443  1.3.4.2  christos 		break;
    444  1.3.4.2  christos 
    445  1.3.4.2  christos 	case OSF1_RUSAGE_CHILDREN:
    446  1.3.4.2  christos 		who = RUSAGE_CHILDREN;
    447  1.3.4.2  christos 		break;
    448  1.3.4.2  christos 
    449  1.3.4.2  christos 	case OSF1_RUSAGE_THREAD:		/* XXX not supported */
    450  1.3.4.2  christos 	default:
    451  1.3.4.2  christos 		return EINVAL;
    452  1.3.4.2  christos 	}
    453  1.3.4.2  christos 
    454  1.3.4.2  christos 	error = getrusage1(p, who, &ru);
    455  1.3.4.2  christos 	if (error != 0)
    456  1.3.4.2  christos 		return error;
    457  1.3.4.2  christos 
    458  1.3.4.2  christos 	osf1_cvt_rusage_from_native(&ru, &osf1_rusage);
    459  1.3.4.2  christos 
    460  1.3.4.2  christos 	return copyout(&osf1_rusage, SCARG(uap, rusage), sizeof osf1_rusage);
    461  1.3.4.2  christos }
    462  1.3.4.2  christos 
    463  1.3.4.2  christos int
    464  1.3.4.2  christos linux_sys_osf1_settimeofday(struct lwp *l, const struct linux_sys_osf1_settimeofday_args *uap, register_t *retval)
    465  1.3.4.2  christos {
    466  1.3.4.2  christos 	struct osf1_timeval otv;
    467  1.3.4.2  christos 	struct timeval tv, *tvp;
    468  1.3.4.2  christos 	int error = 0;
    469  1.3.4.2  christos 
    470  1.3.4.2  christos 	if (SCARG(uap, tv) == NULL)
    471  1.3.4.2  christos 		tvp = NULL;
    472  1.3.4.2  christos 	else {
    473  1.3.4.2  christos 		/* get the OSF/1 timeval argument */
    474  1.3.4.2  christos 		error = copyin(SCARG(uap, tv), &otv, sizeof otv);
    475  1.3.4.2  christos 		if (error != 0)
    476  1.3.4.2  christos 			return error;
    477  1.3.4.2  christos 
    478  1.3.4.2  christos 		tv.tv_sec = otv.tv_sec;
    479  1.3.4.2  christos 		tv.tv_usec = otv.tv_usec;
    480  1.3.4.2  christos 		tvp = &tv;
    481  1.3.4.2  christos 	}
    482  1.3.4.2  christos 
    483  1.3.4.2  christos 	/* NetBSD ignores the timezone field */
    484  1.3.4.2  christos 
    485  1.3.4.2  christos 	return settimeofday1(tvp, false, (const void *)SCARG(uap, tzp), l, true);
    486  1.3.4.2  christos }
    487  1.3.4.2  christos 
    488  1.3.4.2  christos int
    489  1.3.4.2  christos linux_sys_osf1_utimes(struct lwp *l, const struct linux_sys_osf1_utimes_args *uap, register_t *retval)
    490  1.3.4.2  christos {
    491  1.3.4.2  christos 	struct osf1_timeval otv;
    492  1.3.4.2  christos 	struct timeval tv[2], *tvp;
    493  1.3.4.2  christos 	int error;
    494  1.3.4.2  christos 
    495  1.3.4.2  christos 	if (SCARG(uap, tptr) == NULL)
    496  1.3.4.2  christos 		tvp = NULL;
    497  1.3.4.2  christos 	else {
    498  1.3.4.2  christos 		/* get the OSF/1 timeval argument */
    499  1.3.4.2  christos 		error = copyin(SCARG(uap, tptr), &otv, sizeof otv);
    500  1.3.4.2  christos 		if (error != 0)
    501  1.3.4.2  christos 			return error;
    502  1.3.4.2  christos 
    503  1.3.4.2  christos 		/* fill in and copy out the NetBSD timeval */
    504  1.3.4.2  christos 		tv[0].tv_sec = otv.tv_sec;
    505  1.3.4.2  christos 		tv[0].tv_usec = otv.tv_usec;
    506  1.3.4.2  christos 		/* Set access and modified to the same time */
    507  1.3.4.2  christos 		tv[1].tv_sec = otv.tv_sec;
    508  1.3.4.2  christos 		tv[1].tv_usec = otv.tv_usec;
    509  1.3.4.2  christos 		tvp = tv;
    510  1.3.4.2  christos 	}
    511  1.3.4.2  christos 
    512  1.3.4.2  christos 	return do_sys_utimes(l, NULL, SCARG(uap, path), FOLLOW,
    513  1.3.4.2  christos 			    tvp, UIO_SYSSPACE);
    514  1.3.4.2  christos }
    515  1.3.4.2  christos 
    516  1.3.4.2  christos int
    517  1.3.4.2  christos linux_sys_osf1_statfs(struct lwp *l, const struct linux_sys_osf1_statfs_args *uap, register_t *retval)
    518  1.3.4.2  christos {
    519  1.3.4.2  christos 	struct mount *mp;
    520  1.3.4.2  christos 	struct statvfs *sp;
    521  1.3.4.2  christos 	struct osf1_statfs osfs;
    522  1.3.4.2  christos 	int error;
    523  1.3.4.2  christos 	struct vnode *vp;
    524  1.3.4.2  christos 
    525  1.3.4.2  christos 	error = namei_simple_user(SCARG(uap, path),
    526  1.3.4.2  christos 				NSM_FOLLOW_TRYEMULROOT, &vp);
    527  1.3.4.2  christos 	if (error != 0)
    528  1.3.4.2  christos 		return (error);
    529  1.3.4.2  christos 	mp = vp->v_mount;
    530  1.3.4.2  christos 	sp = &mp->mnt_stat;
    531  1.3.4.2  christos 	vrele(vp);
    532  1.3.4.2  christos 	if ((error = VFS_STATVFS(mp, sp)))
    533  1.3.4.2  christos 		return (error);
    534  1.3.4.2  christos 	sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
    535  1.3.4.2  christos 	osf1_cvt_statfs_from_native(sp, &osfs);
    536  1.3.4.2  christos 	return copyout(&osfs, SCARG(uap, buf), uimin(sizeof osfs,
    537  1.3.4.2  christos 	    SCARG(uap, len)));
    538  1.3.4.2  christos }
    539  1.3.4.2  christos 
    540  1.3.4.2  christos int
    541  1.3.4.2  christos linux_sys_osf1_fstatfs(struct lwp *l, const struct linux_sys_osf1_fstatfs_args *uap, register_t *retval)
    542  1.3.4.2  christos {
    543  1.3.4.2  christos 	file_t *fp;
    544  1.3.4.2  christos 	struct mount *mp;
    545  1.3.4.2  christos 	struct statvfs *sp;
    546  1.3.4.2  christos 	struct osf1_statfs osfs;
    547  1.3.4.2  christos 	int error;
    548  1.3.4.2  christos 
    549  1.3.4.2  christos 	/* fd_getvnode() will use the descriptor for us */
    550  1.3.4.2  christos 	if ((error = fd_getvnode(SCARG(uap, fd), &fp)))
    551  1.3.4.2  christos 		return (error);
    552  1.3.4.2  christos 	mp = fp->f_vnode->v_mount;
    553  1.3.4.2  christos 	sp = &mp->mnt_stat;
    554  1.3.4.2  christos 	if ((error = VFS_STATVFS(mp, sp)))
    555  1.3.4.2  christos 		goto out;
    556  1.3.4.2  christos 	sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
    557  1.3.4.2  christos 	osf1_cvt_statfs_from_native(sp, &osfs);
    558  1.3.4.2  christos 	error = copyout(&osfs, SCARG(uap, buf), uimin(sizeof osfs,
    559  1.3.4.2  christos 	    SCARG(uap, len)));
    560  1.3.4.2  christos  out:
    561  1.3.4.2  christos  	fd_putfile(SCARG(uap, fd));
    562  1.3.4.2  christos 	return (error);
    563  1.3.4.2  christos }
    564  1.3.4.2  christos 
    565  1.3.4.2  christos int
    566  1.3.4.2  christos linux_sys_osf1_sysinfo(struct lwp *l, const struct linux_sys_osf1_sysinfo_args *uap, register_t *retval)
    567  1.3.4.2  christos {
    568  1.3.4.2  christos 	const char *string;
    569  1.3.4.2  christos 	size_t slen;
    570  1.3.4.2  christos 	int error;
    571  1.3.4.2  christos 
    572  1.3.4.2  christos 	error = 0;
    573  1.3.4.2  christos 	switch (SCARG(uap, cmd)) {
    574  1.3.4.2  christos 	case OSF1_SI_SYSNAME:
    575  1.3.4.2  christos 		string = ostype;
    576  1.3.4.2  christos 		break;
    577  1.3.4.2  christos 
    578  1.3.4.2  christos 	case OSF1_SI_HOSTNAME:
    579  1.3.4.2  christos 		string = hostname;
    580  1.3.4.2  christos 		break;
    581  1.3.4.2  christos 
    582  1.3.4.2  christos 	case OSF1_SI_RELEASE:
    583  1.3.4.2  christos 		string = osrelease;
    584  1.3.4.2  christos 		break;
    585  1.3.4.2  christos 
    586  1.3.4.2  christos 	case OSF1_SI_VERSION:
    587  1.3.4.2  christos 		goto should_handle;
    588  1.3.4.2  christos 
    589  1.3.4.2  christos 	case OSF1_SI_MACHINE:
    590  1.3.4.2  christos 		string = MACHINE;
    591  1.3.4.2  christos 		break;
    592  1.3.4.2  christos 
    593  1.3.4.2  christos 	case OSF1_SI_ARCHITECTURE:
    594  1.3.4.2  christos 		string = MACHINE_ARCH;
    595  1.3.4.2  christos 		break;
    596  1.3.4.2  christos 
    597  1.3.4.2  christos 	case OSF1_SI_HW_SERIAL:
    598  1.3.4.2  christos 		string = "666";			/* OSF/1 emulation?  YES! */
    599  1.3.4.2  christos 		break;
    600  1.3.4.2  christos 
    601  1.3.4.2  christos 	case OSF1_SI_HW_PROVIDER:
    602  1.3.4.2  christos 		string = "unknown";
    603  1.3.4.2  christos 		break;
    604  1.3.4.2  christos 
    605  1.3.4.2  christos 	case OSF1_SI_SRPC_DOMAIN:
    606  1.3.4.2  christos 		goto dont_care;
    607  1.3.4.2  christos 
    608  1.3.4.2  christos 	case OSF1_SI_SET_HOSTNAME:
    609  1.3.4.2  christos 		goto should_handle;
    610  1.3.4.2  christos 
    611  1.3.4.2  christos 	case OSF1_SI_SET_SYSNAME:
    612  1.3.4.2  christos 		goto should_handle;
    613  1.3.4.2  christos 
    614  1.3.4.2  christos 	case OSF1_SI_SET_SRPC_DOMAIN:
    615  1.3.4.2  christos 		goto dont_care;
    616  1.3.4.2  christos 
    617  1.3.4.2  christos 	default:
    618  1.3.4.2  christos should_handle:
    619  1.3.4.2  christos 		printf("osf1_sys_sysinfo(%d, %p, 0x%lx)\n", SCARG(uap, cmd),
    620  1.3.4.2  christos 		    SCARG(uap, buf), SCARG(uap,len));
    621  1.3.4.2  christos dont_care:
    622  1.3.4.2  christos 		return (EINVAL);
    623  1.3.4.2  christos 	};
    624  1.3.4.2  christos 
    625  1.3.4.2  christos 	slen = strlen(string) + 1;
    626  1.3.4.2  christos 	if (SCARG(uap, buf)) {
    627  1.3.4.2  christos 		error = copyout(string, SCARG(uap, buf),
    628  1.3.4.2  christos 				uimin(slen, SCARG(uap, len)));
    629  1.3.4.2  christos 		if (!error && (SCARG(uap, len) > 0) && (SCARG(uap, len) < slen))
    630  1.3.4.2  christos 			error = ustore_char(SCARG(uap, buf)
    631  1.3.4.2  christos 					    + SCARG(uap, len) - 1, 0);
    632  1.3.4.2  christos 	}
    633  1.3.4.2  christos 	if (!error)
    634  1.3.4.2  christos 		retval[0] = slen;
    635  1.3.4.2  christos 
    636  1.3.4.2  christos 	return (error);
    637  1.3.4.2  christos }
    638  1.3.4.2  christos 
    639  1.3.4.2  christos int
    640  1.3.4.2  christos linux_sys_osf1_usleep_thread(struct lwp *l, const struct linux_sys_osf1_usleep_thread_args *uap, register_t *retval)
    641  1.3.4.2  christos {
    642  1.3.4.2  christos 	struct osf1_timeval otv, endotv;
    643  1.3.4.2  christos 	struct timeval tv, ntv, endtv;
    644  1.3.4.2  christos 	u_long ticks;
    645  1.3.4.2  christos 	int error;
    646  1.3.4.2  christos 
    647  1.3.4.2  christos 	if ((error = copyin(SCARG(uap, sleep), &otv, sizeof otv)))
    648  1.3.4.2  christos 		return (error);
    649  1.3.4.2  christos 	tv.tv_sec = otv.tv_sec;
    650  1.3.4.2  christos 	tv.tv_usec = otv.tv_usec;
    651  1.3.4.2  christos 
    652  1.3.4.2  christos 	ticks = howmany((u_long)tv.tv_sec * 1000000 + tv.tv_usec, tick);
    653  1.3.4.2  christos 	if (ticks == 0)
    654  1.3.4.2  christos 		ticks = 1;
    655  1.3.4.2  christos 
    656  1.3.4.2  christos 	getmicrotime(&tv);
    657  1.3.4.2  christos 
    658  1.3.4.2  christos 	tsleep(l, PUSER|PCATCH, "uslpthrd", ticks);	/* XXX */
    659  1.3.4.2  christos 
    660  1.3.4.2  christos 	if (SCARG(uap, slept) != NULL) {
    661  1.3.4.2  christos 		getmicrotime(&ntv);
    662  1.3.4.2  christos 		timersub(&ntv, &tv, &endtv);
    663  1.3.4.2  christos 		if (endtv.tv_sec < 0 || endtv.tv_usec < 0)
    664  1.3.4.2  christos 			endtv.tv_sec = endtv.tv_usec = 0;
    665  1.3.4.2  christos 
    666  1.3.4.2  christos 		endotv.tv_sec = endtv.tv_sec;
    667  1.3.4.2  christos 		endotv.tv_usec = endtv.tv_usec;
    668  1.3.4.2  christos 		error = copyout(&endotv, SCARG(uap, slept), sizeof endotv);
    669  1.3.4.2  christos 	}
    670  1.3.4.2  christos 	return (error);
    671  1.3.4.2  christos }
    672  1.3.4.2  christos 
    673  1.3.4.2  christos int
    674  1.3.4.2  christos linux_sys_osf1_getsysinfo(struct lwp *l, const struct linux_sys_osf1_getsysinfo_args *uap, register_t *retval)
    675  1.3.4.2  christos {
    676  1.3.4.2  christos 	extern int ncpus;
    677  1.3.4.2  christos 	int error;
    678  1.3.4.2  christos 	int unit;
    679  1.3.4.2  christos 	long percpu;
    680  1.3.4.2  christos 	long proctype;
    681  1.3.4.2  christos 	u_int64_t fpflags;
    682  1.3.4.2  christos 	struct osf1_cpu_info cpuinfo;
    683  1.3.4.2  christos 	const void *data;
    684  1.3.4.2  christos 	size_t datalen;
    685  1.3.4.2  christos 
    686  1.3.4.2  christos 	error = 0;
    687  1.3.4.2  christos 
    688  1.3.4.2  christos 	switch(SCARG(uap, op))
    689  1.3.4.2  christos 	{
    690  1.3.4.2  christos 	case OSF_GET_MAX_UPROCS:
    691  1.3.4.2  christos 		data = &maxproc;
    692  1.3.4.2  christos 		datalen = sizeof(maxproc);
    693  1.3.4.2  christos 		break;
    694  1.3.4.2  christos 	case OSF_GET_PHYSMEM:
    695  1.3.4.2  christos 		data = &physmem;
    696  1.3.4.2  christos 		datalen = sizeof(physmem);
    697  1.3.4.2  christos 		break;
    698  1.3.4.2  christos 	case OSF_GET_MAX_CPU:
    699  1.3.4.2  christos 	case OSF_GET_CPUS_IN_BOX:
    700  1.3.4.2  christos 		data = &ncpus;
    701  1.3.4.2  christos 		datalen = sizeof(ncpus);
    702  1.3.4.2  christos 		break;
    703  1.3.4.2  christos 	case OSF_GET_IEEE_FP_CONTROL:
    704  1.3.4.2  christos 		if (((fpflags = alpha_read_fp_c(l)) & IEEE_INHERIT) != 0) {
    705  1.3.4.2  christos 			fpflags |= 1ULL << 63;
    706  1.3.4.2  christos 			fpflags &= ~IEEE_INHERIT;
    707  1.3.4.2  christos 		}
    708  1.3.4.2  christos 		data = &fpflags;
    709  1.3.4.2  christos 		datalen = sizeof(fpflags);
    710  1.3.4.2  christos 		break;
    711  1.3.4.2  christos 	case OSF_GET_CPU_INFO:
    712  1.3.4.2  christos 		memset(&cpuinfo, 0, sizeof(cpuinfo));
    713  1.3.4.2  christos #ifdef __alpha__
    714  1.3.4.2  christos 		unit = alpha_pal_whami();
    715  1.3.4.2  christos #else
    716  1.3.4.2  christos 		unit = 0; /* XXX */
    717  1.3.4.2  christos #endif
    718  1.3.4.2  christos 		cpuinfo.current_cpu = unit;
    719  1.3.4.2  christos 		cpuinfo.cpus_in_box = ncpus;
    720  1.3.4.2  christos 		cpuinfo.cpu_type = LOCATE_PCS(hwrpb, unit)->pcs_proc_type;
    721  1.3.4.2  christos 		cpuinfo.ncpus = ncpus;
    722  1.3.4.2  christos 		cpuinfo.cpus_present = ncpus;
    723  1.3.4.2  christos 		cpuinfo.cpus_running = ncpus;
    724  1.3.4.2  christos 		cpuinfo.cpu_binding = 1;
    725  1.3.4.2  christos 		cpuinfo.cpu_ex_binding = 0;
    726  1.3.4.2  christos 		cpuinfo.mhz = hwrpb->rpb_cc_freq / 1000000;
    727  1.3.4.2  christos 		data = &cpuinfo;
    728  1.3.4.2  christos 		datalen = sizeof(cpuinfo);
    729  1.3.4.2  christos 		break;
    730  1.3.4.2  christos 	case OSF_GET_PROC_TYPE:
    731  1.3.4.2  christos #ifdef __alpha__
    732  1.3.4.2  christos 		unit = alpha_pal_whami();
    733  1.3.4.2  christos 		proctype = LOCATE_PCS(hwrpb, unit)->pcs_proc_type;
    734  1.3.4.2  christos #else
    735  1.3.4.2  christos 		proctype = 0;	/* XXX */
    736  1.3.4.2  christos #endif
    737  1.3.4.2  christos 		data = &proctype;
    738  1.3.4.2  christos 		datalen = sizeof(percpu);
    739  1.3.4.2  christos 		break;
    740  1.3.4.2  christos 	case OSF_GET_HWRPB: /* note -- osf/1 doesn't have rpb_tbhint[8] */
    741  1.3.4.2  christos 		data = hwrpb;
    742  1.3.4.2  christos 		datalen = hwrpb->rpb_size;
    743  1.3.4.2  christos 		break;
    744  1.3.4.2  christos 	case OSF_GET_PLATFORM_NAME:
    745  1.3.4.2  christos 		data = platform.model;
    746  1.3.4.2  christos 		datalen = strlen(platform.model) + 1;
    747  1.3.4.2  christos 		break;
    748  1.3.4.2  christos 	default:
    749  1.3.4.2  christos 		printf("osf1_getsysinfo called with unknown op=%ld\n",
    750  1.3.4.2  christos 		       SCARG(uap, op));
    751  1.3.4.2  christos 		/* return EINVAL; */
    752  1.3.4.2  christos 		return 0;
    753  1.3.4.2  christos 	}
    754  1.3.4.2  christos 
    755  1.3.4.2  christos 	if (SCARG(uap, nbytes) < datalen)
    756  1.3.4.2  christos 		return (EINVAL);
    757  1.3.4.2  christos 	error = copyout(data, SCARG(uap, buffer), datalen);
    758  1.3.4.2  christos 	if (!error)
    759  1.3.4.2  christos 		retval[0] = 1;
    760  1.3.4.2  christos 	return (error);
    761  1.3.4.2  christos }
    762  1.3.4.2  christos 
    763  1.3.4.2  christos int
    764  1.3.4.2  christos linux_sys_osf1_setsysinfo(struct lwp *l, const struct linux_sys_osf1_setsysinfo_args *uap, register_t *retval)
    765  1.3.4.2  christos {
    766  1.3.4.2  christos 	u_int64_t temp;
    767  1.3.4.2  christos 	int error;
    768  1.3.4.2  christos 
    769  1.3.4.2  christos 	error = 0;
    770  1.3.4.2  christos 
    771  1.3.4.2  christos 	switch(SCARG(uap, op)) {
    772  1.3.4.2  christos 	case OSF_SET_IEEE_FP_CONTROL:
    773  1.3.4.2  christos 
    774  1.3.4.2  christos 		if ((error = copyin(SCARG(uap, buffer), &temp, sizeof(temp))))
    775  1.3.4.2  christos 			break;
    776  1.3.4.2  christos 		if (temp >> 63 != 0)
    777  1.3.4.2  christos 			temp |= IEEE_INHERIT;
    778  1.3.4.2  christos 		alpha_write_fp_c(l, temp);
    779  1.3.4.2  christos 		break;
    780  1.3.4.2  christos 	default:
    781  1.3.4.2  christos 		uprintf("osf1_setsysinfo called with op=%ld\n", SCARG(uap, op));
    782  1.3.4.2  christos 		//error = EINVAL;
    783  1.3.4.2  christos 	}
    784  1.3.4.2  christos 	retval[0] = 0;
    785  1.3.4.2  christos 	return (error);
    786  1.3.4.2  christos }
    787