2 * Copyright (c) 1994 Sean Eric Fagan
3 * Copyright (c) 1994 Søren Schmidt
4 * Copyright (c) 1995 Steven Wallace
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/namei.h>
36 #include <sys/sysproto.h>
37 #include <sys/kernel.h>
38 #include <sys/filio.h>
39 #include <sys/vnode.h>
40 #include <sys/sysctl.h>
42 #include <machine/cpu.h>
44 #include <i386/ibcs2/ibcs2_types.h>
45 #include <i386/ibcs2/ibcs2_unistd.h>
46 #include <i386/ibcs2/ibcs2_signal.h>
47 #include <i386/ibcs2/ibcs2_util.h>
48 #include <i386/ibcs2/ibcs2_proto.h>
49 #include <i386/ibcs2/ibcs2_xenix.h>
50 #include <i386/ibcs2/ibcs2_xenix_syscall.h>
52 extern struct sysent xenix_sysent[];
55 ibcs2_xenix(struct proc *p, struct ibcs2_xenix_args *uap)
57 struct trapframe *tf = p->p_md.md_regs;
61 code = (tf->tf_eax & 0xff00) >> 8;
62 callp = &xenix_sysent[code];
64 if(code < IBCS2_XENIX_MAXSYSCALL)
65 return((*callp->sy_call)(p, (void *)uap));
73 struct xenix_rdchk_args *uap;
77 caddr_t sg = stackgap_init();
79 DPRINTF(("IBCS2: 'xenix rdchk'\n"));
80 SCARG(&sa, fd) = SCARG(uap, fd);
81 SCARG(&sa, com) = FIONREAD;
82 SCARG(&sa, data) = stackgap_alloc(&sg, sizeof(int));
83 if ((error = ioctl(p, &sa)) != 0)
85 p->p_retval[0] = (*((int*)SCARG(&sa, data))) ? 1 : 0;
92 struct xenix_chsize_args *uap;
94 struct ftruncate_args sa;
96 DPRINTF(("IBCS2: 'xenix chsize'\n"));
97 SCARG(&sa, fd) = SCARG(uap, fd);
99 SCARG(&sa, length) = SCARG(uap, size);
100 return ftruncate(p, &sa);
107 struct xenix_ftime_args *uap;
111 unsigned long time __attribute__((packed));
112 unsigned short millitm;
117 DPRINTF(("IBCS2: 'xenix ftime'\n"));
119 itb.time = tv.tv_sec;
120 itb.millitm = (tv.tv_usec / 1000);
121 itb.timezone = tz.tz_minuteswest;
122 itb.dstflag = tz.tz_dsttime != DST_NONE;
124 return copyout((caddr_t)&itb, (caddr_t)SCARG(uap, tp),
125 sizeof(struct ibcs2_timeb));
129 xenix_nap(struct proc *p, struct xenix_nap_args *uap)
133 DPRINTF(("IBCS2: 'xenix nap %d ms'\n", SCARG(uap, millisec)));
134 period = (long)SCARG(uap, millisec) / (1000/hz);
136 while (tsleep(&period, PPAUSE, "nap", period)
142 xenix_utsname(struct proc *p, struct xenix_utsname_args *uap)
144 struct ibcs2_sco_utsname {
152 unsigned short sysorigin;
153 unsigned short sysoem;
155 unsigned short numcpu;
158 DPRINTF(("IBCS2: 'xenix sco_utsname'\n"));
159 bzero(&ibcs2_sco_uname, sizeof(struct ibcs2_sco_utsname));
160 strncpy(ibcs2_sco_uname.sysname, ostype,
161 sizeof(ibcs2_sco_uname.sysname) - 1);
162 strncpy(ibcs2_sco_uname.nodename, hostname,
163 sizeof(ibcs2_sco_uname.nodename) - 1);
164 strncpy(ibcs2_sco_uname.release, osrelease,
165 sizeof(ibcs2_sco_uname.release) - 1);
166 strncpy(ibcs2_sco_uname.kernelid, version,
167 sizeof(ibcs2_sco_uname.kernelid) - 1);
168 strncpy(ibcs2_sco_uname.machine, machine,
169 sizeof(ibcs2_sco_uname.machine) - 1);
170 strncpy(ibcs2_sco_uname.bustype, "ISA/EISA",
171 sizeof(ibcs2_sco_uname.bustype) - 1);
172 strncpy(ibcs2_sco_uname.sysserial, "no charge",
173 sizeof(ibcs2_sco_uname.sysserial) - 1);
174 strncpy(ibcs2_sco_uname.numusers, "unlim",
175 sizeof(ibcs2_sco_uname.numusers) - 1);
176 ibcs2_sco_uname.sysorigin = 0xFFFF;
177 ibcs2_sco_uname.sysoem = 0xFFFF;
178 ibcs2_sco_uname.numcpu = 1;
179 return copyout((caddr_t)&ibcs2_sco_uname,
180 (caddr_t)(void *)(intptr_t)uap->addr,
181 sizeof(struct ibcs2_sco_utsname));
185 xenix_scoinfo(struct proc *p, struct xenix_scoinfo_args *uap)
187 /* scoinfo (not documented) */
193 xenix_eaccess(struct proc *p, struct xenix_eaccess_args *uap)
195 struct ucred *cred = p->p_ucred;
199 caddr_t sg = stackgap_init();
201 CHECKALTEXIST(p, &sg, SCARG(uap, path));
203 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
204 SCARG(uap, path), p);
205 if ((error = namei(&nd)) != 0)
209 /* Flags == 0 means only check for existence. */
210 if (SCARG(uap, flags)) {
212 if (SCARG(uap, flags) & IBCS2_R_OK)
214 if (SCARG(uap, flags) & IBCS2_W_OK)
216 if (SCARG(uap, flags) & IBCS2_X_OK)
218 if ((flags & VWRITE) == 0 || (error = vn_writechk(vp)) == 0)
219 error = VOP_ACCESS(vp, flags, cred, p);