13584Ssos/*-
2230132Suqs * Copyright (c) 1994 S��ren Schmidt
311397Sswallace * Copyright (c) 1995 Steven Wallace
43584Ssos * All rights reserved.
53584Ssos *
63584Ssos * Redistribution and use in source and binary forms, with or without
73584Ssos * modification, are permitted provided that the following conditions
83584Ssos * are met:
93584Ssos * 1. Redistributions of source code must retain the above copyright
103584Ssos *    notice, this list of conditions and the following disclaimer
113584Ssos *    in this position and unchanged.
123584Ssos * 2. Redistributions in binary form must reproduce the above copyright
133584Ssos *    notice, this list of conditions and the following disclaimer in the
143584Ssos *    documentation and/or other materials provided with the distribution.
153584Ssos * 3. The name of the author may not be used to endorse or promote products
1697748Sschweikh *    derived from this software without specific prior written permission
173584Ssos *
183584Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
193584Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
203584Ssos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
213584Ssos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
223584Ssos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
233584Ssos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
243584Ssos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
253584Ssos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
263584Ssos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
273584Ssos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
283584Ssos */
293584Ssos
30115684Sobrien#include <sys/cdefs.h>
31115684Sobrien__FBSDID("$FreeBSD$");
32115684Sobrien
333584Ssos#include <sys/param.h>
34147822Sjhb#include <sys/lock.h>
35147822Sjhb#include <sys/mutex.h>
363584Ssos#include <sys/systm.h>
3711397Sswallace#include <sys/sysctl.h>
383584Ssos
3911397Sswallace#include <i386/ibcs2/ibcs2_types.h>
4011397Sswallace#include <i386/ibcs2/ibcs2_signal.h>
4111397Sswallace#include <i386/ibcs2/ibcs2_util.h>
4211397Sswallace#include <i386/ibcs2/ibcs2_proto.h>
433584Ssos
4411397Sswallace#define IBCS2_FP_NO     0       /* no fp support */
4511397Sswallace#define IBCS2_FP_SW     1       /* software emulator */
4611397Sswallace#define IBCS2_FP_287    2       /* 80287 FPU */
4711397Sswallace#define IBCS2_FP_387    3       /* 80387 FPU */
483584Ssos
4911397Sswallace#define SI86_FPHW	40
5011397Sswallace#define STIME		54
5111397Sswallace#define SETNAME		56
5211397Sswallace#define SI86_MEM	65
5311397Sswallace
5411865Sphkextern int hw_float;
5511397Sswallace
563584Ssosint
5783366Sjulianibcs2_sysi86(struct thread *td, struct ibcs2_sysi86_args *args)
583584Ssos{
59107849Salfred	switch (args->cmd) {
6011397Sswallace	case SI86_FPHW: {	/* Floating Point information */
613584Ssos		int val, error;
623584Ssos
63188937Sjhb		if (hw_float)
64188937Sjhb			val = IBCS2_FP_387;
65188937Sjhb		else
66188937Sjhb			val = IBCS2_FP_NO;
67107849Salfred		if ((error = copyout(&val, args->arg, sizeof(val))) != 0)
683584Ssos			return error;
693584Ssos		return 0;
703584Ssos		}
713584Ssos
7211397Sswallace        case STIME:       /* set the system time given pointer to long */
7311397Sswallace	  /* gettimeofday; time.tv_sec = *args->arg; settimeofday */
7411397Sswallace	        return EINVAL;
7511397Sswallace
7611397Sswallace	case SETNAME:  {  /* set hostname given string w/ len <= 7 chars */
7712418Sphk	        int name[2];
7811397Sswallace
7912418Sphk		name[0] = CTL_KERN;
8012418Sphk		name[1] = KERN_HOSTNAME;
81186564Sed		return (userland_sysctl(td, name, 2, 0, 0, 0,
82186564Sed		    args->arg, 7, 0, 0));
8312418Sphk	}
8411397Sswallace
8511397Sswallace	case SI86_MEM:	/* size of physical memory */
8683366Sjulian		td->td_retval[0] = ctob(physmem);
873584Ssos		return 0;
883584Ssos
893584Ssos	default:
9016230Snate#ifdef DIAGNOSTIC
913584Ssos		printf("IBCS2: 'sysi86' function %d(0x%x) "
92107849Salfred			"not implemented yet\n", args->cmd, args->cmd);
9316230Snate#endif
943584Ssos		return EINVAL;
953584Ssos	}
963584Ssos}
97