ibcs2_xenix.c revision 11397
1/*- 2 * Copyright (c) 1994 Sean Eric Fagan 3 * Copyright (c) 1994 S�ren Schmidt 4 * Copyright (c) 1995 Steven Wallace 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 * in this position and unchanged. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. The name of the author may not be used to endorse or promote products 17 * derived from this software withough specific prior written permission 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 * $Id: ibcs2_xenix.c,v 1.2 1995/02/03 21:31:35 bde Exp $ 31 */ 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/sysproto.h> 36#include <sys/kernel.h> 37#include <sys/exec.h> 38#include <sys/ioctl.h> 39#include <sys/proc.h> 40#include <sys/vnode.h> 41#include <sys/sysctl.h> 42#include <sys/sysent.h> 43#include <sys/errno.h> 44#include <sys/timeb.h> 45#include <sys/unistd.h> 46 47#include <vm/vm.h> 48#include <machine/cpu.h> 49#include <machine/psl.h> 50#include <machine/reg.h> 51 52#include <i386/ibcs2/ibcs2_types.h> 53#include <i386/ibcs2/ibcs2_signal.h> 54#include <i386/ibcs2/ibcs2_util.h> 55#include <i386/ibcs2/ibcs2_proto.h> 56#include <i386/ibcs2/ibcs2_xenix.h> 57#include <i386/ibcs2/ibcs2_xenix_syscall.h> 58 59extern struct sysent xenix_sysent[]; 60 61int 62ibcs2_xenix(struct proc *p, struct ibcs2_xenix_args *uap, int *retval) 63{ 64 struct trapframe *tf = (struct trapframe *)p->p_md.md_regs; 65 struct sysent *callp; 66 u_int code; 67 68 code = (tf->tf_eax & 0xff00) >> 8; 69 callp = &xenix_sysent[code]; 70 71 if(code < IBCS2_XENIX_MAXSYSCALL) 72 return((*callp->sy_call)(p, (void *)uap, retval)); 73 else 74 return ENOSYS; 75} 76 77int 78xenix_rdchk(p, uap, retval) 79 struct proc *p; 80 struct xenix_rdchk_args *uap; 81 int *retval; 82{ 83 int error; 84 struct ioctl_args sa; 85 caddr_t sg = stackgap_init(); 86 87 DPRINTF(("IBCS2: 'xenix rdchk'\n")); 88 SCARG(&sa, fd) = SCARG(uap, fd); 89 SCARG(&sa, com) = FIONREAD; 90 SCARG(&sa, data) = stackgap_alloc(&sg, sizeof(int)); 91 if (error = ioctl(p, &sa, retval)) 92 return error; 93 *retval = (*((int*)SCARG(&sa, data))) ? 1 : 0; 94 return 0; 95} 96 97int 98xenix_chsize(p, uap, retval) 99 struct proc *p; 100 struct xenix_chsize_args *uap; 101 int *retval; 102{ 103 struct ftruncate_args sa; 104 105 DPRINTF(("IBCS2: 'xenix chsize'\n")); 106 SCARG(&sa, fd) = SCARG(uap, fd); 107 SCARG(&sa, pad) = 0; 108 SCARG(&sa, length) = SCARG(uap, size); 109 return ftruncate(p, &sa, retval); 110} 111 112 113int 114xenix_ftime(p, uap, retval) 115 struct proc *p; 116 struct xenix_ftime_args *uap; 117 int *retval; 118{ 119 struct timeval tv; 120 struct timeb itb; 121 122 DPRINTF(("IBCS2: 'xenix ftime'\n")); 123 microtime(&tv); 124 itb.time = tv.tv_sec; 125 itb.millitm = (tv.tv_usec / 1000); 126 itb.timezone = tz.tz_minuteswest; 127 itb.dstflag = tz.tz_dsttime != DST_NONE; 128 129 return copyout((caddr_t)&itb, (caddr_t)SCARG(uap, tp), 130 sizeof(struct timeb)); 131} 132 133int 134xenix_nap(struct proc *p, struct xenix_nap_args *uap, int *retval) 135{ 136 long period; 137 138 DPRINTF(("IBCS2: 'xenix nap %d ms'\n", SCARG(uap, millisec))); 139 period = (long)SCARG(uap, millisec) / (1000/hz); 140 if (period) 141 while (tsleep(&period, PUSER, "nap", period) 142 != EWOULDBLOCK) ; 143 return 0; 144} 145 146int 147xenix_utsname(struct proc *p, struct xenix_utsname_args *args, int *retval) 148{ 149 struct ibcs2_sco_utsname { 150 char sysname[9]; 151 char nodename[9]; 152 char release[16]; 153 char kernelid[20]; 154 char machine[9]; 155 char bustype[9]; 156 char sysserial[10]; 157 unsigned short sysorigin; 158 unsigned short sysoem; 159 char numusers[9]; 160 unsigned short numcpu; 161 } ibcs2_sco_uname; 162 163 DPRINTF(("IBCS2: 'xenix sco_utsname'\n")); 164 bzero(&ibcs2_sco_uname, sizeof(struct ibcs2_sco_utsname)); 165 strncpy(ibcs2_sco_uname.sysname, ostype, 8); 166 strncpy(ibcs2_sco_uname.nodename, hostname, 8); 167 strncpy(ibcs2_sco_uname.release, osrelease, 15); 168 strncpy(ibcs2_sco_uname.kernelid, version, 19); 169 strncpy(ibcs2_sco_uname.machine, machine, 8); 170 bcopy("ISA/EISA", ibcs2_sco_uname.bustype, 8); 171 bcopy("no charge", ibcs2_sco_uname.sysserial, 9); 172 bcopy("unlim", ibcs2_sco_uname.numusers, 8); 173 ibcs2_sco_uname.sysorigin = 0xFFFF; 174 ibcs2_sco_uname.sysoem = 0xFFFF; 175 ibcs2_sco_uname.numcpu = 1; 176 return copyout((caddr_t)&ibcs2_sco_uname, (caddr_t)args->addr, 177 sizeof(struct ibcs2_sco_utsname)); 178} 179 180int 181xenix_scoinfo(struct proc *p, struct xenix_scoinfo_args *uap, int *retval) 182{ 183 /* scoinfo (not documented) */ 184 *retval = 0; 185 return 0; 186} 187