DISKLESS
+GENERIC
GENERICADP
GENERICOTHER
INSTADP
INSTOTHER
+LOCAL
TDR
+/* $OpenBSD: autoconf.c,v 1.5 1996/04/17 05:18:49 mickey Exp $ */
/* $NetBSD: autoconf.c,v 1.14 1995/12/28 19:16:48 thorpej Exp $ */
/*-
/*
* Determine i/o configuration for a machine.
*/
+void
configure()
{
/*
* Configure swap space and related parameters.
*/
+void
swapconf()
{
register struct swdevt *swp;
* If we can do so, and not instructed not to do so,
* change rootdev to correspond to the load device.
*/
+void
setroot()
{
int majdev, mindev, unit, part, adaptor;
-/* $OpenBSD: db_interface.c,v 1.2 1996/03/11 11:16:42 mickey Exp $ */
+/* $OpenBSD: db_interface.c,v 1.3 1996/04/17 05:18:50 mickey Exp $ */
/* $NetBSD: db_interface.c,v 1.18 1995/10/10 04:45:03 mycroft Exp $ */
/*
}
}
-int
+void
Debugger()
{
asm("int $3");
-/* $NetBSD: freebsd_machdep.c,v 1.5 1996/01/04 22:21:55 jtc Exp $ */
+/* $OpenBSD: freebsd_machdep.c,v 1.3 1996/04/17 05:18:51 mickey Exp $ */
+/* $NetBSD: freebsd_machdep.c,v 1.7 1996/04/11 07:47:44 mycroft Exp $ */
/*-
- * Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
+ * Copyright (c) 1993, 1994, 1995, 1996 Charles M. Hannum. All rights reserved.
* Copyright (c) 1992 Terrence R. Lambert.
* Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
* All rights reserved.
#include <sys/systm.h>
#include <sys/signalvar.h>
#include <sys/proc.h>
+#include <sys/user.h>
#include <sys/exec.h>
#include <sys/mount.h>
#include <machine/cpufunc.h>
#include <machine/npx.h>
#include <machine/reg.h>
+#include <machine/vm86.h>
#include <machine/freebsd_machdep.h>
#include <compat/freebsd/freebsd_syscallargs.h>
if (tf->tf_eflags & PSL_VM) {
frame.sf_sc.sc_es = tf->tf_vm86_es;
frame.sf_sc.sc_ds = tf->tf_vm86_ds;
+ frame.sf_sc.sc_eflags = get_vflags(p);
+ tf->tf_eflags &= ~PSL_VM;
} else
#endif
{
frame.sf_sc.sc_es = tf->tf_es;
frame.sf_sc.sc_ds = tf->tf_ds;
+ frame.sf_sc.sc_eflags = tf->tf_eflags;
}
- frame.sf_sc.sc_edi = tf->tf_edi;
- frame.sf_sc.sc_esi = tf->tf_esi;
- frame.sf_sc.sc_ebp = tf->tf_ebp;
- frame.sf_sc.sc_isp = 0; /* don't have to pass kernel sp to user. */
- frame.sf_sc.sc_ebx = tf->tf_ebx;
- frame.sf_sc.sc_edx = tf->tf_edx;
- frame.sf_sc.sc_ecx = tf->tf_ecx;
- frame.sf_sc.sc_eax = tf->tf_eax;
- frame.sf_sc.sc_eip = tf->tf_eip;
- frame.sf_sc.sc_cs = tf->tf_cs;
- frame.sf_sc.sc_eflags = tf->tf_eflags;
- frame.sf_sc.sc_esp = tf->tf_esp;
- frame.sf_sc.sc_ss = tf->tf_ss;
+ frame.sf_sc.sc_edi = tf->tf_edi;
+ frame.sf_sc.sc_esi = tf->tf_esi;
+ frame.sf_sc.sc_ebp = tf->tf_ebp;
+ frame.sf_sc.sc_isp = 0; /* don't have to pass kernel sp to user. */
+ frame.sf_sc.sc_ebx = tf->tf_ebx;
+ frame.sf_sc.sc_edx = tf->tf_edx;
+ frame.sf_sc.sc_ecx = tf->tf_ecx;
+ frame.sf_sc.sc_eax = tf->tf_eax;
+ frame.sf_sc.sc_eip = tf->tf_eip;
+ frame.sf_sc.sc_cs = tf->tf_cs;
+ frame.sf_sc.sc_esp = tf->tf_esp;
+ frame.sf_sc.sc_ss = tf->tf_ss;
if (copyout(&frame, fp, sizeof(frame)) != 0) {
/*
/*
* Build context to run handler in.
*/
- tf->tf_esp = (int)fp;
+ tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL);
+ tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
tf->tf_eip = (int)(((char *)PS_STRINGS) -
(freebsd_esigcode - freebsd_sigcode));
-#ifdef VM86
- tf->tf_eflags &= ~PSL_VM;
-#endif
tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
- tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
- tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL);
+ tf->tf_esp = (int)fp;
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
}
* psl to gain improper privileges or to cause
* a machine fault.
*/
+int
freebsd_sys_sigreturn(p, v, retval)
struct proc *p;
void *v;
if (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0)
return (EFAULT);
- /*
- * Check for security violations. If we're returning to protected
- * mode, the CPU will validate the segment registers automatically
- * and generate a trap on violations. We handle the trap, rather
- * than doing all of the checking here.
- */
- if (((context.sc_eflags ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
- !USERMODE(context.sc_cs, context.sc_eflags))
- return (EINVAL);
-
- if (context.sc_onstack & 01)
- p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
- p->p_sigmask = context.sc_mask & ~sigcantmask;
-
/*
* Restore signal context.
*/
if (context.sc_eflags & PSL_VM) {
tf->tf_vm86_es = context.sc_es;
tf->tf_vm86_ds = context.sc_ds;
+ set_vflags(p, context.sc_eflags);
} else
#endif
{
+ /*
+ * Check for security violations. If we're returning to
+ * protected mode, the CPU will validate the segment registers
+ * automatically and generate a trap on violations. We handle
+ * the trap, rather than doing all of the checking here.
+ */
+ if (((context.sc_eflags ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
+ !USERMODE(context.sc_cs, context.sc_eflags))
+ return (EINVAL);
+
tf->tf_es = context.sc_es;
tf->tf_ds = context.sc_ds;
+ tf->tf_eflags = context.sc_eflags;
}
- tf->tf_edi = context.sc_edi;
- tf->tf_esi = context.sc_esi;
- tf->tf_ebp = context.sc_ebp;
+ tf->tf_edi = context.sc_edi;
+ tf->tf_esi = context.sc_esi;
+ tf->tf_ebp = context.sc_ebp;
/* FreeBSD's context.sc_isp is useless. (`popal' ignores it.) */
- tf->tf_ebx = context.sc_ebx;
- tf->tf_edx = context.sc_edx;
- tf->tf_ecx = context.sc_ecx;
- tf->tf_eax = context.sc_eax;
- tf->tf_eip = context.sc_eip;
- tf->tf_cs = context.sc_cs;
- tf->tf_eflags = context.sc_eflags;
- tf->tf_esp = context.sc_esp;
- tf->tf_ss = context.sc_ss;
+ tf->tf_ebx = context.sc_ebx;
+ tf->tf_edx = context.sc_edx;
+ tf->tf_ecx = context.sc_ecx;
+ tf->tf_eax = context.sc_eax;
+ tf->tf_eip = context.sc_eip;
+ tf->tf_cs = context.sc_cs;
+ tf->tf_esp = context.sc_esp;
+ tf->tf_ss = context.sc_ss;
+
+ if (context.sc_onstack & 01)
+ p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
+ else
+ p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
+ p->p_sigmask = context.sc_mask & ~sigcantmask;
return (EJUSTRETURN);
}
-/* $NetBSD: gdt.c,v 1.6 1996/01/30 12:18:26 mycroft Exp $ */
+/* $OpenBSD: gdt.c,v 1.6 1996/04/17 05:18:52 mickey Exp $ */
+/* $NetBSD: gdt.c,v 1.7 1996/02/27 22:45:01 jtc Exp $ */
-/*
- * Copyright (c) 1995 Charles M. Hannum. All rights reserved.
- * Copyright (c) 1995 John T. Kohl. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by John T. Kohl and Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- *
*/
#include <sys/param.h>
int slot = NGDT, oslot;
for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
- PHOLD(p);
pcb = &p->p_addr->u_pcb;
oslot = IDXSEL(pcb->pcb_tss_sel);
if (oslot >= gdt_count) {
dynamic_gdt[oslot].gd.gd_type = SDT_SYSNULL;
pcb->pcb_ldt_sel = GSEL(slot, SEL_KPL);
}
- PRELE(p);
}
for (; slot < gdt_count; slot++)
if (dynamic_gdt[slot].gd.gd_type == SDT_SYSNULL)
-/* $OpenBSD: linux_machdep.c,v 1.3 1996/03/11 11:16:48 mickey Exp $ */
-/* $NetBSD: linux_machdep.c,v 1.24 1996/01/04 22:21:57 jtc Exp $ */
+/* $OpenBSD: linux_machdep.c,v 1.4 1996/04/17 05:18:53 mickey Exp $ */
+/* $NetBSD: linux_machdep.c,v 1.26 1996/04/11 07:47:45 mycroft Exp $ */
/*
* Copyright (c) 1995 Frank van der Linden
#include <machine/segments.h>
#include <machine/specialreg.h>
#include <machine/sysarch.h>
+#include <machine/vm86.h>
#include <machine/linux_machdep.h>
/*
frame.sf_sc.sc_fs = tf->tf_vm86_fs;
frame.sf_sc.sc_es = tf->tf_vm86_es;
frame.sf_sc.sc_ds = tf->tf_vm86_ds;
+ frame.sf_sc.sc_eflags = get_vflags(p);
+ tf->tf_eflags &= ~PSL_VM;
} else
#endif
{
__asm("movl %%fs,%w0" : "=r" (frame.sf_sc.sc_fs));
frame.sf_sc.sc_es = tf->tf_es;
frame.sf_sc.sc_ds = tf->tf_ds;
+ frame.sf_sc.sc_eflags = tf->tf_eflags;
}
- frame.sf_sc.sc_edi = tf->tf_edi;
- frame.sf_sc.sc_esi = tf->tf_esi;
- frame.sf_sc.sc_ebp = tf->tf_ebp;
- frame.sf_sc.sc_ebx = tf->tf_ebx;
- frame.sf_sc.sc_edx = tf->tf_edx;
- frame.sf_sc.sc_ecx = tf->tf_ecx;
- frame.sf_sc.sc_eax = tf->tf_eax;
- frame.sf_sc.sc_eip = tf->tf_eip;
- frame.sf_sc.sc_cs = tf->tf_cs;
- frame.sf_sc.sc_eflags = tf->tf_eflags;
+ frame.sf_sc.sc_edi = tf->tf_edi;
+ frame.sf_sc.sc_esi = tf->tf_esi;
+ frame.sf_sc.sc_ebp = tf->tf_ebp;
+ frame.sf_sc.sc_ebx = tf->tf_ebx;
+ frame.sf_sc.sc_edx = tf->tf_edx;
+ frame.sf_sc.sc_ecx = tf->tf_ecx;
+ frame.sf_sc.sc_eax = tf->tf_eax;
+ frame.sf_sc.sc_eip = tf->tf_eip;
+ frame.sf_sc.sc_cs = tf->tf_cs;
frame.sf_sc.sc_esp_at_signal = tf->tf_esp;
- frame.sf_sc.sc_ss = tf->tf_ss;
- frame.sf_sc.sc_err = tf->tf_err;
+ frame.sf_sc.sc_ss = tf->tf_ss;
+ frame.sf_sc.sc_err = tf->tf_err;
frame.sf_sc.sc_trapno = tf->tf_trapno;
if (copyout(&frame, fp, sizeof(frame)) != 0) {
/*
* Build context to run handler in.
*/
- tf->tf_esp = (int)fp;
+ tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL);
+ tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
tf->tf_eip = (int)(((char *)PS_STRINGS) -
(linux_esigcode - linux_sigcode));
-#ifdef VM86
- tf->tf_eflags &= ~PSL_VM;
-#endif
tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
- tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
- tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL);
+ tf->tf_esp = (int)fp;
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
}
if (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0)
return (EFAULT);
- /*
- * Check for security violations.
- */
- if (((context.sc_eflags ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
- !USERMODE(context.sc_cs, context.sc_eflags))
- return (EINVAL);
-
- p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
- p->p_sigmask = context.sc_mask & ~sigcantmask;
-
/*
* Restore signal context.
*/
tf->tf_vm86_fs = context.sc_fs;
tf->tf_vm86_es = context.sc_es;
tf->tf_vm86_ds = context.sc_ds;
+ set_vflags(p, context.sc_eflags);
} else
#endif
{
+ /*
+ * Check for security violations. If we're returning to
+ * protected mode, the CPU will validate the segment registers
+ * automatically and generate a trap on violations. We handle
+ * the trap, rather than doing all of the checking here.
+ */
+ if (((context.sc_eflags ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
+ !USERMODE(context.sc_cs, context.sc_eflags))
+ return (EINVAL);
+
/* %fs and %gs were restored by the trampoline. */
tf->tf_es = context.sc_es;
tf->tf_ds = context.sc_ds;
+ tf->tf_eflags = context.sc_eflags;
}
- tf->tf_edi = context.sc_edi;
- tf->tf_esi = context.sc_esi;
- tf->tf_ebp = context.sc_ebp;
- tf->tf_ebx = context.sc_ebx;
- tf->tf_edx = context.sc_edx;
- tf->tf_ecx = context.sc_ecx;
- tf->tf_eax = context.sc_eax;
- tf->tf_eip = context.sc_eip;
- tf->tf_cs = context.sc_cs;
- tf->tf_eflags = context.sc_eflags;
- tf->tf_esp = context.sc_esp_at_signal;
- tf->tf_ss = context.sc_ss;
+ tf->tf_edi = context.sc_edi;
+ tf->tf_esi = context.sc_esi;
+ tf->tf_ebp = context.sc_ebp;
+ tf->tf_ebx = context.sc_ebx;
+ tf->tf_edx = context.sc_edx;
+ tf->tf_ecx = context.sc_ecx;
+ tf->tf_eax = context.sc_eax;
+ tf->tf_eip = context.sc_eip;
+ tf->tf_cs = context.sc_cs;
+ tf->tf_esp = context.sc_esp_at_signal;
+ tf->tf_ss = context.sc_ss;
+
+ p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
+ p->p_sigmask = context.sc_mask & ~sigcantmask;
return (EJUSTRETURN);
}
break;
#endif
default:
-#ifdef DIAGNOSTIC
printf("linux_machdepioctl: invalid ioctl %08x\n", com);
-#endif
return EINVAL;
}
SCARG(&bia, com) = com;
-/* $OpenBSD: machdep.c,v 1.8 1996/03/11 11:16:50 mickey Exp $ */
+/* $OpenBSD: machdep.c,v 1.9 1996/04/17 05:18:54 mickey Exp $ */
/* $NetBSD: machdep.c,v 1.191 1996/03/01 21:49:49 scottr Exp $ */
/*-
{ "Cx486DLC", CPUCLASS_486 }, /* CPU_486DLC (Cyrix) */
};
+void
identifycpu()
{
int len;
frame.sf_sc.sc_fs = tf->tf_vm86_fs;
frame.sf_sc.sc_es = tf->tf_vm86_es;
frame.sf_sc.sc_ds = tf->tf_vm86_ds;
- frame.sf_sc.sc_eflags = tf->tf_eflags;
- SETFLAGS(frame.sf_sc.sc_eflags, VM86_EFLAGS(p),
- VM86_FLAGMASK(p)|PSL_VIF);
+ frame.sf_sc.sc_eflags = get_vflag(p);
+ tf->tf_eflags &= ~PSL_VM;
} else
#endif
{
tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
tf->tf_eip = (int)(((char *)PS_STRINGS) - (esigcode - sigcode));
tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
-#ifdef VM86
- tf->tf_eflags &= ~PSL_VM;
-#endif
tf->tf_esp = (int)fp;
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
}
* psl to gain improper privileges or to cause
* a machine fault.
*/
+int
sys_sigreturn(p, v, retval)
struct proc *p;
void *v;
if (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0)
return (EFAULT);
- /*
- * Check for security violations. If we're returning to protected
- * mode, the CPU will validate the segment registers automatically
- * and generate a trap on violations. We handle the trap, rather
- * than doing all of the checking here.
- */
- if (((context.sc_eflags ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
- !USERMODE(context.sc_cs, context.sc_eflags))
- return (EINVAL);
-
- if (context.sc_onstack & 01)
- p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
- p->p_sigmask = context.sc_mask & ~sigcantmask;
-
/*
* Restore signal context.
*/
tf->tf_vm86_fs = context.sc_fs;
tf->tf_vm86_es = context.sc_es;
tf->tf_vm86_ds = context.sc_ds;
- tf->tf_eflags = context.sc_eflags;
- SETFLAGS(VM86_EFLAGS(p), context.sc_eflags,
- VM86_FLAGMASK(p)|PSL_VIF);
+ set_vflags(p, context.sc_eflags);
} else
#endif
{
+ /*
+ * Check for security violations. If we're returning to
+ * protected mode, the CPU will validate the segment registers
+ * automatically and generate a trap on violations. We handle
+ * the trap, rather than doing all of the checking here.
+ */
+ if (((context.sc_eflags ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
+ !USERMODE(context.sc_cs, context.sc_eflags))
+ return (EINVAL);
+
/* %fs and %gs were restored by the trampoline. */
tf->tf_es = context.sc_es;
tf->tf_ds = context.sc_ds;
tf->tf_esp = context.sc_esp;
tf->tf_ss = context.sc_ss;
+ if (context.sc_onstack & 01)
+ p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
+ else
+ p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
+ p->p_sigmask = context.sc_mask & ~sigcantmask;
+
return (EJUSTRETURN);
}
void
boot(howto)
- register int howto;
+ int howto;
{
extern int cold;
+/* $OpenBSD: pmap.c,v 1.6 1996/04/17 05:18:55 mickey Exp $ */
/* $NetBSD: pmap.c,v 1.34 1995/12/09 07:39:02 mycroft Exp $ */
/*
/*
* Miscellaneous support routines follow
*/
-
+void
i386_protection_init()
{
+/* $OpenBSD: pmap.old.c,v 1.6 1996/04/17 05:18:55 mickey Exp $ */
/* $NetBSD: pmap.c,v 1.34 1995/12/09 07:39:02 mycroft Exp $ */
/*
/*
* Miscellaneous support routines follow
*/
-
+void
i386_protection_init()
{
-/* $NetBSD: process_machdep.c,v 1.20 1996/01/13 06:14:44 mycroft Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.3 1996/04/17 05:18:56 mickey Exp $ */
+/* $NetBSD: process_machdep.c,v 1.21 1996/04/11 07:47:48 mycroft Exp $ */
/*
- * Copyright (c) 1995 Charles M. Hannum. All rights reserved.
+ * Copyright (c) 1995, 1996 Charles M. Hannum. All rights reserved.
* Copyright (c) 1993 The Regents of the University of California.
* Copyright (c) 1993 Jan-Simon Pendry
* All rights reserved.
regs->r_fs = tf->tf_vm86_fs;
regs->r_es = tf->tf_vm86_es;
regs->r_ds = tf->tf_vm86_ds;
- regs->r_eflags = tf->tf_eflags;
- SETFLAGS(regs->r_eflags, VM86_EFLAGS(p),
- VM86_FLAGMASK(p)|PSL_VIF);
+ regs->r_eflags = get_vflags(p);
} else
#endif
{
struct trapframe *tf = process_frame(p);
struct pcb *pcb = &p->p_addr->u_pcb;
- /*
- * Check for security violations.
- */
- if (((regs->r_eflags ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
- !USERMODE(regs->r_cs, regs->r_eflags))
- return (EINVAL);
-
#ifdef VM86
if (tf->tf_eflags & PSL_VM) {
tf->tf_vm86_gs = regs->r_gs;
tf->tf_vm86_fs = regs->r_fs;
tf->tf_vm86_es = regs->r_es;
tf->tf_vm86_ds = regs->r_ds;
- tf->tf_eflags = regs->r_eflags;
- SETFLAGS(VM86_EFLAGS(p), regs->r_eflags,
- VM86_FLAGMASK(p)|PSL_VIF);
+ set_vflags(p, regs->r_eflags);
} else
#endif
{
#define valid_sel(sel) (ISPL(sel) == SEL_UPL && verr(sel))
#define null_sel(sel) (!ISLDT(sel) && IDXSEL(sel) == 0)
+ /*
+ * Check for security violations.
+ */
+ if (((regs->r_eflags ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
+ !USERMODE(regs->r_cs, regs->r_eflags))
+ return (EINVAL);
+
if ((regs->r_gs != pcb->pcb_gs && \
!valid_sel(regs->r_gs) && !null_sel(regs->r_gs)) ||
(regs->r_fs != pcb->pcb_fs && \
-/* $NetBSD: svr4_machdep.c,v 1.20 1996/01/04 22:22:04 jtc Exp $ */
+/* $OpenBSD: svr4_machdep.c,v 1.3 1996/04/17 05:18:57 mickey Exp $ */
+/* $NetBSD: svr4_machdep.c,v 1.21 1996/04/11 07:47:50 mycroft Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
#include <machine/reg.h>
#include <machine/specialreg.h>
#include <machine/sysarch.h>
+#include <machine/vm86.h>
#include <machine/svr4_machdep.h>
static void svr4_getsiginfo __P((union svr4_siginfo *, int, u_long, caddr_t));
r[SVR4_X86_FS] = tf->tf_vm86_fs;
r[SVR4_X86_ES] = tf->tf_vm86_es;
r[SVR4_X86_DS] = tf->tf_vm86_ds;
+ r[SVR4_X86_EFL] = get_vflags(p);
+ tf->tf_eflags &= ~PSL_VM;
} else
#endif
{
__asm("movl %%fs,%w0" : "=r" (r[SVR4_X86_FS]));
r[SVR4_X86_ES] = tf->tf_es;
r[SVR4_X86_DS] = tf->tf_ds;
+ r[SVR4_X86_EFL] = tf->tf_eflags;
}
r[SVR4_X86_EDI] = tf->tf_edi;
r[SVR4_X86_ESI] = tf->tf_esi;
r[SVR4_X86_ERR] = 0;
r[SVR4_X86_EIP] = tf->tf_eip;
r[SVR4_X86_CS] = tf->tf_cs;
- r[SVR4_X86_EFL] = tf->tf_eflags;
r[SVR4_X86_UESP] = 0;
r[SVR4_X86_SS] = tf->tf_ss;
tf = p->p_md.md_regs;
- /*
- * Check for security violations.
- */
- if (((r[SVR4_X86_EFL] ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
- !USERMODE(r[SVR4_X86_CS], r[SVR4_X86_EFL]))
- return (EINVAL);
-
- /*
- * restore signal stack
- */
- svr4_to_bsd_sigaltstack(s, sf);
-
- /*
- * restore signal mask
- */
- svr4_to_bsd_sigset(&uc->uc_sigmask, &mask);
- p->p_sigmask = mask & ~sigcantmask;
-
/*
* Restore register context.
*/
tf->tf_vm86_fs = r[SVR4_X86_FS];
tf->tf_vm86_es = r[SVR4_X86_ES];
tf->tf_vm86_ds = r[SVR4_X86_DS];
+ set_vflags(p, r[SVR4_X86_EFL]);
} else
#endif
{
+ /*
+ * Check for security violations. If we're returning to
+ * protected mode, the CPU will validate the segment registers
+ * automatically and generate a trap on violations. We handle
+ * the trap, rather than doing all of the checking here.
+ */
+ if (((r[SVR4_X86_EFL] ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
+ !USERMODE(r[SVR4_X86_CS], r[SVR4_X86_EFL]))
+ return (EINVAL);
+
/* %fs and %gs were restored by the trampoline. */
tf->tf_es = r[SVR4_X86_ES];
tf->tf_ds = r[SVR4_X86_DS];
+ tf->tf_eflags = r[SVR4_X86_EFL];
}
tf->tf_edi = r[SVR4_X86_EDI];
tf->tf_esi = r[SVR4_X86_ESI];
tf->tf_eax = r[SVR4_X86_EAX];
tf->tf_eip = r[SVR4_X86_EIP];
tf->tf_cs = r[SVR4_X86_CS];
- tf->tf_eflags = r[SVR4_X86_EFL];
tf->tf_ss = r[SVR4_X86_SS];
tf->tf_esp = r[SVR4_X86_ESP];
+ /*
+ * restore signal stack
+ */
+ svr4_to_bsd_sigaltstack(s, sf);
+
+ /*
+ * restore signal mask
+ */
+ svr4_to_bsd_sigset(&uc->uc_sigmask, &mask);
+ p->p_sigmask = mask & ~sigcantmask;
+
return EJUSTRETURN;
}
+/* $OpenBSD: swapgeneric.c,v 1.2 1996/04/17 05:18:58 mickey Exp $ */
/* $NetBSD: swapgeneric.c,v 1.9 1994/11/04 09:57:52 mycroft Exp $ */
/*-
extern int ffs_mountroot();
int (*mountroot)() = ffs_mountroot;
+void
setconf()
{
register struct genericconf *gc;
rootdev = dumpdev;
}
+void
gets(cp)
char *cp;
{
-/* $NetBSD: vm86.c,v 1.3 1996/01/08 22:23:35 mycroft Exp $ */
-
-/*
- * Copyright (c) 1995 John T. Kohl
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+/* $OpenBSD: vm86.c,v 1.2 1996/04/17 05:18:59 mickey Exp $ */
+/* $NetBSD: vm86.c,v 1.8 1996/04/11 10:07:17 mycroft Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by John T. Kohl and Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- *
*/
#include <sys/param.h>
#include <machine/sysarch.h>
#include <machine/vm86.h>
-static void return_to_32bit __P((struct proc *, int));
static void fast_intxx __P((struct proc *, int));
-#define SETDIRECT ((~(PSL_USERSTATIC|PSL_NT)) & 0xffff)
-#define GETDIRECT (SETDIRECT|0x02a) /* add in two MBZ bits */
-
+#define CS(tf) (*(u_short *)&tf->tf_cs)
#define IP(tf) (*(u_short *)&tf->tf_eip)
+#define SS(tf) (*(u_short *)&tf->tf_ss)
#define SP(tf) (*(u_short *)&tf->tf_esp)
}
-static __inline__ void
-set_vif(p)
- struct proc *p;
-{
-
- VM86_EFLAGS(p) |= PSL_VIF;
- if (VM86_EFLAGS(p) & PSL_VIP)
- return_to_32bit(p, VM86_STI);
-}
-
-static __inline__ void
-set_vflags(p, flags)
- struct proc *p;
- int flags;
-{
- struct trapframe *tf = p->p_md.md_regs;
-
- SETFLAGS(VM86_EFLAGS(p), flags, VM86_FLAGMASK(p));
- SETFLAGS(tf->tf_eflags, flags, SETDIRECT);
- if (flags & PSL_I)
- set_vif(p);
-}
-
-static __inline__ void
-set_vflags_short(p, flags)
- struct proc *p;
- int flags;
-{
- struct trapframe *tf = p->p_md.md_regs;
-
- SETFLAGS(VM86_EFLAGS(p), flags, VM86_FLAGMASK(p) & 0xffff);
- SETFLAGS(tf->tf_eflags, flags, SETDIRECT);
- if (flags & PSL_I)
- set_vif(p);
-}
-
-static __inline__ int
-get_vflags(p)
- struct proc *p;
-{
- struct trapframe *tf = p->p_md.md_regs;
- int flags = 0;
-
- SETFLAGS(flags, VM86_EFLAGS(p), VM86_FLAGMASK(p));
- SETFLAGS(flags, tf->tf_eflags, GETDIRECT);
- if (VM86_EFLAGS(p) & PSL_VIF)
- flags |= PSL_I;
- return (flags);
-}
-
-
#define V86_AH(regs) (((u_char *)&((regs)->tf_eax))[1])
#define V86_AL(regs) (((u_char *)&((regs)->tf_eax))[0])
* requested special handling, return to user space with indication
* of which INT was requested.
*/
- cs = tf->tf_cs;
+ cs = CS(tf);
if (cs == BIOSSEG || is_bitset(intrno, &u_vm86p->int_byuser[0]))
goto vector;
* Otherwise, push flags, cs, eip, and jump to handler to
* simulate direct INT call.
*/
- ss = tf->tf_ss << 4;
+ ss = SS(tf) << 4;
sp = SP(tf);
- putword(ss, sp, get_vflags(p));
- putword(ss, sp, tf->tf_cs);
+ putword(ss, sp, get_vflags_short(p));
+ putword(ss, sp, CS(tf));
putword(ss, sp, IP(tf));
SP(tf) = sp;
IP(tf) = ihand.ip;
- tf->tf_cs = ihand.cs;
+ CS(tf) = ihand.cs;
/* disable further "hardware" interrupts, turn off any tracing. */
- VM86_EFLAGS(p) &= ~PSL_VIF;
- tf->tf_eflags &= ~PSL_VIF|PSL_T;
+ tf->tf_eflags &= ~PSL_T;
+ clr_vif(p);
return;
vector:
- return_to_32bit(p, VM86_MAKEVAL(VM86_INTx, intrno));
+ vm86_return(p, VM86_MAKEVAL(VM86_INTx, intrno));
return;
bad:
- return_to_32bit(p, VM86_UNKNOWN);
+ vm86_return(p, VM86_UNKNOWN);
return;
}
-static void
-return_to_32bit(p, retval)
+void
+vm86_return(p, retval)
struct proc *p;
int retval;
{
/*
* We can't set the virtual flags in our real trap frame,
* since it's used to jump to the signal handler. Instead we
- * let sendsig() pull in the VM86_EFLAGS bits.
+ * let sendsig() pull in the vm86_eflags bits.
*/
if (p->p_sigmask & sigmask(SIGURG)) {
#ifdef DIAGNOSTIC
u_char tmpbyte;
u_long cs, ip, ss, sp;
- cs = tf->tf_cs << 4;
+ cs = CS(tf) << 4;
ip = IP(tf);
- ss = tf->tf_ss << 4;
+ ss = SS(tf) << 4;
sp = SP(tf);
/*
* For most of these, we must set all the registers before calling
- * macros/functions which might do a return_to_32bit.
+ * macros/functions which might do a vm86_return.
*/
tmpbyte = getbyte(cs, ip);
IP(tf) = ip;
switch (tmpbyte) {
case CLI:
/* simulate handling of IF */
- VM86_EFLAGS(p) &= ~PSL_VIF;
- tf->tf_eflags &= ~PSL_VIF;
+ clr_vif(p);
break;
case STI:
break;
case PUSHF:
- putword(ss, sp, get_vflags(p));
+ putword(ss, sp, get_vflags_short(p));
SP(tf) = sp;
break;
case IRET:
IP(tf) = getword(ss, sp);
- tf->tf_cs = getword(ss, sp);
+ CS(tf) = getword(ss, sp);
case POPF:
set_vflags_short(p, getword(ss, sp));
SP(tf) = sp;
IP(tf) = ip;
switch (tmpbyte) {
case PUSHF:
- putdword(ss, sp, get_vflags(p));
+ putdword(ss, sp, get_vflags(p) & ~PSL_VM);
SP(tf) = sp;
break;
case IRET:
IP(tf) = getdword(ss, sp);
- tf->tf_cs = getdword(ss, sp);
+ CS(tf) = getdword(ss, sp);
case POPF:
- set_vflags(p, getdword(ss, sp));
+ set_vflags(p, getdword(ss, sp) | PSL_VM);
SP(tf) = sp;
break;
return;
bad:
- return_to_32bit(p, VM86_UNKNOWN);
+ vm86_return(p, VM86_UNKNOWN);
return;
}
register_t *retval;
{
struct trapframe *tf = p->p_md.md_regs;
+ struct pcb *pcb = &p->p_addr->u_pcb;
struct vm86_kern vm86s;
int err;
if (err = copyin(args, &vm86s, sizeof(vm86s)))
return err;
- p->p_addr->u_pcb.vm86_userp = (void *)args;
+ pcb->vm86_userp = (void *)args;
+
+ /*
+ * Keep mask of flags we simulate to simulate a particular type of
+ * processor.
+ */
+ switch (vm86s.ss_cpu_type) {
+ case VCPU_086:
+ case VCPU_186:
+ case VCPU_286:
+ pcb->vm86_flagmask = 0;
+ break;
+ case VCPU_386:
+ pcb->vm86_flagmask = PSL_NT|PSL_IOPL;
+ break;
+ case VCPU_486:
+ pcb->vm86_flagmask = PSL_AC|PSL_NT|PSL_IOPL;
+ break;
+ case VCPU_586:
+ default:
+ pcb->vm86_flagmask = PSL_ID|PSL_AC|PSL_NT|PSL_IOPL;
+ break;
+ }
#define DOVREG(reg) tf->tf_vm86_##reg = (u_short) vm86s.regs.vmsc.sc_##reg
#define DOREG(reg) tf->tf_##reg = (u_short) vm86s.regs.vmsc.sc_##reg
#undef DOVREG
#undef DOREG
- SETFLAGS(VM86_EFLAGS(p), vm86s.regs.vmsc.sc_eflags, VM86_FLAGMASK(p)|PSL_VIF);
- SETFLAGS(tf->tf_eflags, vm86s.regs.vmsc.sc_eflags, SETDIRECT);
- tf->tf_eflags |= PSL_VM;
-
- /*
- * Keep mask of flags we simulate to simulate a particular type of
- * processor.
- */
- switch (vm86s.ss_cpu_type) {
- case VCPU_086:
- case VCPU_186:
- case VCPU_286:
- VM86_FLAGMASK(p) = 0;
- break;
- case VCPU_386:
- VM86_FLAGMASK(p) = PSL_NT|PSL_IOPL;
- break;
- case VCPU_486:
- VM86_FLAGMASK(p) = PSL_AC|PSL_NT|PSL_IOPL;
- break;
- case VCPU_586:
- default:
- VM86_FLAGMASK(p) = PSL_ID|PSL_AC|PSL_NT|PSL_IOPL;
- break;
- }
-
/* Going into vm86 mode jumps off the signal stack. */
- p->p_sigacts->ps_sigstk.ss_flags &= ~SA_ONSTACK;
+ p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
+
+ set_vflags(p, vm86s.regs.vmsc.sc_eflags | PSL_VM);
return (EJUSTRETURN);
}
-/* $OpenBSD: vm_machdep.c,v 1.7 1996/03/19 21:09:24 mickey Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.8 1996/04/17 05:19:00 mickey Exp $ */
/* $NetBSD: vm_machdep.c,v 1.58 1996/02/05 02:00:35 christos Exp $ */
/*-
/*
* Set a red zone in the kernel stack after the u. area.
*/
+void
setredzone(pte, vaddr)
u_short *pte;
caddr_t vaddr;
* Both addresses are assumed to reside in the Sysmap,
* and size must be a multiple of CLSIZE.
*/
+void
pagemove(from, to, size)
register caddr_t from, to;
int size;
-/* $NetBSD: ansi.h,v 1.5 1994/10/27 04:15:54 cgd Exp $ */
+/* $OpenBSD: ansi.h,v 1.2 1996/04/17 05:19:01 mickey Exp $ */
+/* $NetBSD: ansi.h,v 1.6 1996/03/16 01:31:50 jtc Exp $ */
/*-
* Copyright (c) 1990, 1993
* defined for ctype.h.
*/
#define _BSD_WCHAR_T_ int /* wchar_t */
+#define _BSD_WINT_T_ int /* wint_t */
#define _BSD_RUNE_T_ int /* rune_t */
#endif /* _ANSI_H_ */
} \
} while (0)
#endif
+void delay __P((int));
/*
* pull in #defines for kinds of processors
-/* $NetBSD: pio.h,v 1.12 1995/12/20 07:53:09 mycroft Exp $ */
+/* $OpenBSD: pio.h,v 1.3 1996/04/17 05:19:03 mickey Exp $ */
+/* $NetBSD: pio.h,v 1.13 1996/03/08 20:15:23 cgd Exp $ */
/*
* Copyright (c) 1993, 1995 Charles M. Hannum. All rights reserved.
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _I386_PIO_H_
+#define _I386_PIO_H_
+
/*
* Functions to provide access to i386 programmed I/O instructions.
*
"d" (port), "S" (addr), "c" (cnt) :
"%esi", "%ecx");
}
+
+#endif /* _I386_PIO_H_ */
-/* $NetBSD: vm86.h,v 1.1 1996/01/08 13:51:45 mycroft Exp $ */
+/* $OpenBSD: vm86.h,v 1.2 1996/04/17 05:19:04 mickey Exp $ */
+/* $NetBSD: vm86.h,v 1.4 1996/04/11 10:07:25 mycroft Exp $ */
-/*
- * Copyright (c) 1995 John T. Kohl
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+#define VM86_USE_VIF
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by John T. Kohl and Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- *
*/
#define SETFLAGS(targ, new, newmask) (targ) = ((targ) & ~(newmask)) | ((new) & (newmask))
-#define VM86_EFLAGS(p) ((p)->p_addr->u_pcb.vm86_eflags)
-#define VM86_FLAGMASK(p) ((p)->p_addr->u_pcb.vm86_flagmask)
#define VM86_TYPE(x) ((x) & 0xff)
#define VM86_ARG(x) (((x) & 0xff00) >> 8)
#define VM86_SIGNAL 2
#define VM86_UNKNOWN 3
+#define VM86_SETDIRECT (~PSL_USERSTATIC)
+#define VM86_GETDIRECT (VM86_SETDIRECT|PSL_MBO|PSL_MBZ)
+
struct vm86_regs {
struct sigcontext vmsc;
};
#ifdef _KERNEL
int i386_vm86 __P((struct proc *, char *, register_t *));
void vm86_gpfault __P((struct proc *, int));
+void vm86_return __P((struct proc *, int));
+
+static __inline__ void
+clr_vif(p)
+ struct proc *p;
+{
+ struct pcb *pcb = &p->p_addr->u_pcb;
+
+#ifndef VM86_USE_VIF
+ pcb->vm86_eflags &= ~PSL_I;
+#else
+ pcb->vm86_eflags &= ~PSL_VIF;
+#endif
+}
+
+static __inline__ void
+set_vif(p)
+ struct proc *p;
+{
+ struct pcb *pcb = &p->p_addr->u_pcb;
+
+#ifndef VM86_USE_VIF
+ pcb->vm86_eflags |= PSL_I;
+ if ((pcb->vm86_eflags & (PSL_I|PSL_VIP)) == (PSL_I|PSL_VIP))
+#else
+ pcb->vm86_eflags |= PSL_VIF;
+ if ((pcb->vm86_eflags & (PSL_VIF|PSL_VIP)) == (PSL_VIF|PSL_VIP))
+#endif
+ vm86_return(p, VM86_STI);
+}
+
+static __inline__ void
+set_vflags(p, flags)
+ struct proc *p;
+ int flags;
+{
+ struct trapframe *tf = p->p_md.md_regs;
+ struct pcb *pcb = &p->p_addr->u_pcb;
+
+ SETFLAGS(pcb->vm86_eflags, flags, pcb->vm86_flagmask | ~VM86_GETDIRECT);
+ SETFLAGS(tf->tf_eflags, flags, VM86_SETDIRECT);
+#ifndef VM86_USE_VIF
+ if ((pcb->vm86_eflags & (PSL_I|PSL_VIP)) == (PSL_I|PSL_VIP))
+#else
+ if ((pcb->vm86_eflags & (PSL_VIF|PSL_VIP)) == (PSL_VIF|PSL_VIP))
+#endif
+ vm86_return(p, VM86_STI);
+}
+
+static __inline__ int
+get_vflags(p)
+ struct proc *p;
+{
+ struct trapframe *tf = p->p_md.md_regs;
+ struct pcb *pcb = &p->p_addr->u_pcb;
+ int flags = 0;
+
+ SETFLAGS(flags, pcb->vm86_eflags, pcb->vm86_flagmask | ~VM86_GETDIRECT);
+ SETFLAGS(flags, tf->tf_eflags, VM86_GETDIRECT);
+ return (flags);
+}
+
+static __inline__ void
+set_vflags_short(p, flags)
+ struct proc *p;
+ int flags;
+{
+ struct trapframe *tf = p->p_md.md_regs;
+ struct pcb *pcb = &p->p_addr->u_pcb;
+
+ SETFLAGS(pcb->vm86_eflags, flags, (pcb->vm86_flagmask | ~VM86_GETDIRECT) & 0xffff);
+ SETFLAGS(tf->tf_eflags, flags, VM86_SETDIRECT & 0xffff);
+#ifndef VM86_USE_VIF
+ if ((pcb->vm86_eflags & (PSL_I|PSL_VIP)) == (PSL_I|PSL_VIP))
+ vm86_return(p, VM86_STI);
+#endif
+}
+
+static __inline__ int
+get_vflags_short(p)
+ struct proc *p;
+{
+ struct trapframe *tf = p->p_md.md_regs;
+ struct pcb *pcb = &p->p_addr->u_pcb;
+ int flags = 0;
+
+ SETFLAGS(flags, pcb->vm86_eflags, (pcb->vm86_flagmask | ~VM86_GETDIRECT) & 0xffff);
+ SETFLAGS(flags, tf->tf_eflags, VM86_GETDIRECT & 0xffff);
+ return (flags);
+}
#else
int i386_vm86 __P((struct vm86_struct *vmcp));
#endif