Inline all the [lr]cr[023]() `functions' in cpufunc.h.

This commit is contained in:
mycroft 1994-01-03 16:21:48 +00:00
parent 7131e8517e
commit c0e772492e
9 changed files with 122 additions and 90 deletions

View File

@ -1214,67 +1214,6 @@ ENTRY(lgdt)
movl $8,4(%esp)
lret
/*
* void lidt(struct region_descriptor *rdp);
*/
ENTRY(lidt)
movl 4(%esp),%eax
lidt (%eax)
ret
/*
* void lldt(u_short sel)
*/
ENTRY(lldt)
lldt 4(%esp)
ret
/*
* void ltr(u_short sel)
*/
ENTRY(ltr)
ltr 4(%esp)
ret
/*
* void lcr3(caddr_t cr3)
*/
ALIGN_TEXT
ENTRY(load_cr3)
ALTENTRY(lcr3)
movl 4(%esp),%eax
movl %eax,%cr3
ret
# tlbflush()
ENTRY(tlbflush)
movl %cr3,%eax
movl %eax,%cr3
ret
# lcr0(cr0)
ENTRY(lcr0)
ALTENTRY(load_cr0)
movl 4(%esp),%eax
movl %eax,%cr0
ret
# rcr0()
ENTRY(rcr0)
movl %cr0,%eax
ret
# rcr2()
ENTRY(rcr2)
movl %cr2,%eax
ret
# rcr3()
ENTRY(_cr3)
ALTENTRY(rcr3)
movl %cr3,%eax
ret
# ssdtosd(*ssdp,*sdp)
ENTRY(ssdtosd)
pushl %ebx

View File

@ -725,7 +725,7 @@ setregs(p, entry, stack, retval)
tf->tf_cs = _ucodesel;
p->p_addr->u_pcb.pcb_flags &= 0 /* FM_SYSCTRC */; /* no fp at all */
load_cr0(rcr0() | CR0_TS); /* start emulating */
lcr0(rcr0() | CR0_TS); /* start emulating */
#if NNPX > 0
npxinit(__INITIAL_NPXCW__);
#endif
@ -902,13 +902,11 @@ extern IDTVEC(div), IDTVEC(dbg), IDTVEC(nmi), IDTVEC(bpt), IDTVEC(ofl),
IDTVEC(rsvd9), IDTVEC(rsvd10), IDTVEC(rsvd11), IDTVEC(rsvd12),
IDTVEC(rsvd13), IDTVEC(rsvd14), IDTVEC(rsvd14), IDTVEC(syscall);
int lcr0(), lcr3(), rcr0(), rcr2();
void
init386(first_avail)
vm_offset_t first_avail;
{
extern ssdtosd(), lgdt(), lidt(), lldt(), etext;
extern ssdtosd(), lgdt(), etext;
int x, *pi;
unsigned biosbasemem, biosextmem;
struct gate_descriptor *gdp;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
* $Id: trap.c,v 1.21 1993/12/20 17:16:47 ws Exp $
* $Id: trap.c,v 1.22 1994/01/03 16:21:54 mycroft Exp $
*/
/*
@ -58,6 +58,7 @@
#include <vm/vm_map.h>
#include <machine/cpu.h>
#include <machine/cpufunc.h>
#include <machine/psl.h>
#include <machine/reg.h>
#include <machine/trap.h>

View File

@ -45,17 +45,18 @@
#include "npx.h"
#include "param.h"
#include "systm.h"
#include "proc.h"
#include "malloc.h"
#include "buf.h"
#include "user.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/malloc.h>
#include <sys/buf.h>
#include <sys/user.h>
#include "../include/cpu.h"
#include <vm/vm.h>
#include <vm/vm_kern.h>
#include "vm/vm.h"
#include "vm/vm_kern.h"
#include <machine/cpu.h>
#include <machine/cpufunc.h>
/*
* Finish a fork operation, with process p2 nearly set up.

View File

@ -1,8 +1,37 @@
/*
* Functions to provide access to special i386 instructions.
* XXX - bezillions more are defined in locore.s but are not declared anywhere.
* Copyright (c) 1993 Charles Hannum.
* All rights reserved.
*
* $Id: cpufunc.h,v 1.3 1993/12/20 09:08:11 mycroft Exp $
* 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 Charles Hannum.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software withough 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 POSSIBILITY OF SUCH DAMAGE.
*
* $Id: cpufunc.h,v 1.4 1994/01/03 16:22:05 mycroft Exp $
*/
/*
* Functions to provide access to i386-specific instructions.
*/
#include <sys/cdefs.h>
@ -14,10 +43,77 @@ static __inline int bdb(void)
if (!bdb_exists)
return (0);
__asm("int $3");
__asm __volatile("int $3");
return (1);
}
static __inline void
lidt(void *p)
{
__asm __volatile("lidt (%0)" : : "r" (p));
}
static __inline void
lldt(u_short sel)
{
__asm __volatile("lldt %0" : : "r" (sel));
}
static __inline void
ltr(u_short sel)
{
__asm __volatile("ltr %0" : : "r" (sel));
}
static __inline void
tlbflush(void)
{
__asm __volatile("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3" : : : "%eax");
}
static __inline void
lcr0(u_int val)
{
__asm __volatile("movl %0,%%cr0" : : "r" (val));
}
static __inline u_int
rcr0(void)
{
u_int val;
__asm __volatile("movl %%cr0,%0" : "=a" (val));
return val;
}
static __inline u_int
rcr2(void)
{
u_int val;
__asm __volatile("movl %%cr2,%0" : "=a" (val));
return val;
}
static __inline void
lcr3(u_int val)
{
__asm __volatile("movl %0,%%cr3" : : "r" (val));
}
static __inline u_int
rcr3(void)
{
u_int val;
__asm __volatile("movl %%cr3,%0" : "=a" (val));
return val;
}
#ifdef notyet
void setidt __P((int idx, /*XXX*/caddr_t func, int typ, int dpl));
#endif
/* XXXX ought to be in psl.h with spl() functions */
static __inline void
disable_intr(void)
{
@ -30,6 +126,3 @@ enable_intr(void)
__asm __volatile("sti");
}
#ifdef notyet
void setidt __P((int idx, /*XXX*/caddr_t func, int typ, int dpl));
#endif

View File

@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* from: @(#)npx.c 7.2 (Berkeley) 5/12/91
* $Id: npx.c,v 1.11 1993/12/20 09:12:04 mycroft Exp $
* $Id: npx.c,v 1.12 1994/01/03 16:22:15 mycroft Exp $
*/
#include "npx.h"
#if NNPX > 0
@ -234,7 +234,7 @@ npxprobe1(dvp)
* Try setting CR0_NE to get correct error reporting on 486DX's.
* Setting it should fail or do nothing on lesser processors.
*/
load_cr0(rcr0() | CR0_MP | CR0_NE);
lcr0(rcr0() | CR0_MP | CR0_NE);
/*
* But don't trap while we're probing.
*/

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
* $Id: wd.c,v 1.30 1993/12/24 13:56:14 ws Exp $
* $Id: wd.c,v 1.31 1994/01/03 16:22:18 mycroft Exp $
*/
/* Note: This code heavily modified by tih@barsoom.nhh.no; use at own risk! */
@ -1518,7 +1518,7 @@ wddump(dev_t dev)
pmap_enter(kernel_pmap, CADDR1, trunc_page(addr), VM_PROT_READ, TRUE);
#else
*(int *)CMAP1 = PG_V | PG_KW | ctob((long)addr);
load_cr3(rcr3());
tlbflush();
#endif
/* compute disk address */

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
* $Id: wd.c,v 1.30 1993/12/24 13:56:14 ws Exp $
* $Id: wd.c,v 1.31 1994/01/03 16:22:18 mycroft Exp $
*/
/* Note: This code heavily modified by tih@barsoom.nhh.no; use at own risk! */
@ -1518,7 +1518,7 @@ wddump(dev_t dev)
pmap_enter(kernel_pmap, CADDR1, trunc_page(addr), VM_PROT_READ, TRUE);
#else
*(int *)CMAP1 = PG_V | PG_KW | ctob((long)addr);
load_cr3(rcr3());
tlbflush();
#endif
/* compute disk address */

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
* $Id: wd.c,v 1.30 1993/12/24 13:56:14 ws Exp $
* $Id: wd.c,v 1.31 1994/01/03 16:22:18 mycroft Exp $
*/
/* Note: This code heavily modified by tih@barsoom.nhh.no; use at own risk! */
@ -1518,7 +1518,7 @@ wddump(dev_t dev)
pmap_enter(kernel_pmap, CADDR1, trunc_page(addr), VM_PROT_READ, TRUE);
#else
*(int *)CMAP1 = PG_V | PG_KW | ctob((long)addr);
load_cr3(rcr3());
tlbflush();
#endif
/* compute disk address */