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 without 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.
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/fcntl.h>
37 #include <sys/namei.h>
38 #include <sys/sysproto.h>
39 #include <sys/clock.h>
41 #include <sys/kernel.h>
42 #include <sys/malloc.h>
43 #include <sys/filio.h>
44 #include <sys/vnode.h>
45 #include <sys/syscallsubr.h>
46 #include <sys/sysctl.h>
47 #include <sys/sysent.h>
48 #include <sys/unistd.h>
50 #include <machine/cpu.h>
52 #include <i386/ibcs2/ibcs2_types.h>
53 #include <i386/ibcs2/ibcs2_unistd.h>
54 #include <i386/ibcs2/ibcs2_signal.h>
55 #include <i386/ibcs2/ibcs2_util.h>
56 #include <i386/ibcs2/ibcs2_proto.h>
57 #include <i386/ibcs2/ibcs2_xenix.h>
58 #include <i386/ibcs2/ibcs2_xenix_syscall.h>
61 extern struct sysent xenix_sysent[];
64 ibcs2_xenix(struct thread *td, struct ibcs2_xenix_args *uap)
66 struct trapframe *tf = td->td_frame;
71 code = (tf->tf_eax & 0xff00) >> 8;
72 callp = &xenix_sysent[code];
74 if (code < IBCS2_XENIX_MAXSYSCALL)
75 error = ((*callp->sy_call)(td, (void *)uap));
84 struct xenix_rdchk_args *uap;
88 DPRINTF(("IBCS2: 'xenix rdchk'\n"));
90 error = kern_ioctl(td, uap->fd, FIONREAD, (caddr_t)&data);
93 td->td_retval[0] = data ? 1 : 0;
100 struct xenix_chsize_args *uap;
102 struct ftruncate_args sa;
104 DPRINTF(("IBCS2: 'xenix chsize'\n"));
106 sa.length = uap->size;
107 return sys_ftruncate(td, &sa);
114 struct xenix_ftime_args *uap;
118 unsigned long time __packed;
119 unsigned short millitm;
124 DPRINTF(("IBCS2: 'xenix ftime'\n"));
126 itb.time = tv.tv_sec;
127 itb.millitm = (tv.tv_usec / 1000);
128 itb.timezone = tz_minuteswest;
129 itb.dstflag = tz_dsttime != DST_NONE;
131 return copyout((caddr_t)&itb, (caddr_t)uap->tp,
132 sizeof(struct ibcs2_timeb));
136 xenix_nap(struct thread *td, struct xenix_nap_args *uap)
140 DPRINTF(("IBCS2: 'xenix nap %d ms'\n", uap->millisec));
141 period = (long)uap->millisec / (1000/hz);
143 pause("nap", period);
148 xenix_utsname(struct thread *td, struct xenix_utsname_args *uap)
150 struct ibcs2_sco_utsname {
158 unsigned short sysorigin;
159 unsigned short sysoem;
161 unsigned short numcpu;
164 DPRINTF(("IBCS2: 'xenix sco_utsname'\n"));
165 bzero(&ibcs2_sco_uname, sizeof(struct ibcs2_sco_utsname));
166 strncpy(ibcs2_sco_uname.sysname, ostype,
167 sizeof(ibcs2_sco_uname.sysname) - 1);
168 getcredhostname(td->td_ucred, ibcs2_sco_uname.nodename,
169 sizeof(ibcs2_sco_uname.nodename) - 1);
170 strncpy(ibcs2_sco_uname.release, osrelease,
171 sizeof(ibcs2_sco_uname.release) - 1);
172 strncpy(ibcs2_sco_uname.kernelid, version,
173 sizeof(ibcs2_sco_uname.kernelid) - 1);
174 strncpy(ibcs2_sco_uname.machine, machine,
175 sizeof(ibcs2_sco_uname.machine) - 1);
176 strncpy(ibcs2_sco_uname.bustype, "ISA/EISA",
177 sizeof(ibcs2_sco_uname.bustype) - 1);
178 strncpy(ibcs2_sco_uname.sysserial, "no charge",
179 sizeof(ibcs2_sco_uname.sysserial) - 1);
180 strncpy(ibcs2_sco_uname.numusers, "unlim",
181 sizeof(ibcs2_sco_uname.numusers) - 1);
182 ibcs2_sco_uname.sysorigin = 0xFFFF;
183 ibcs2_sco_uname.sysoem = 0xFFFF;
184 ibcs2_sco_uname.numcpu = 1;
185 return copyout((caddr_t)&ibcs2_sco_uname,
186 (caddr_t)(void *)(intptr_t)uap->addr,
187 sizeof(struct ibcs2_sco_utsname));
191 xenix_scoinfo(struct thread *td, struct xenix_scoinfo_args *uap)
193 /* scoinfo (not documented) */
194 td->td_retval[0] = 0;
199 xenix_eaccess(struct thread *td, struct xenix_eaccess_args *uap)
202 int error, bsd_flags;
205 if (uap->flags & IBCS2_R_OK)
207 if (uap->flags & IBCS2_W_OK)
209 if (uap->flags & IBCS2_X_OK)
212 CHECKALTEXIST(td, uap->path, &path);
213 error = kern_accessat(td, AT_FDCWD, path, UIO_SYSSPACE,
214 AT_EACCESS, bsd_flags);