BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / i386 / include / pmap.h
index 20d8e8a..3df944d 100644 (file)
@@ -1,16 +1,43 @@
 /* 
 /* 
- * Copyright (c) 1987 Carnegie-Mellon University
  * Copyright (c) 1991 Regents of the University of California.
  * All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Copyright (c) 1991 Regents of the University of California.
  * All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
- * The Mach Operating System project at Carnegie-Mellon University.
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department and William Jolitz of UUNET Technologies Inc.
  *
  *
- * The CMU software License Agreement specifies the terms and conditions
- * for use and redistribution.
+ * 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 University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- * This version by William Jolitz for UUNET Technologies, Inc.
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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.
  *
  *
+ *     @(#)pmap.h      7.4 (Berkeley) 5/12/91
+ */
+
+/*
  * Derived from hp300 version by Mike Hibler, this version by William
  * Jolitz uses a recursive map [a pde points to the page directory] to
  * map the page tables using the pagetables themselves. This is done to
  * Derived from hp300 version by Mike Hibler, this version by William
  * Jolitz uses a recursive map [a pde points to the page directory] to
  * map the page tables using the pagetables themselves. This is done to
  * space, and to reduce the cost of memory to each process.
  *
  * from hp300: @(#)pmap.h      7.2 (Berkeley) 12/16/90
  * space, and to reduce the cost of memory to each process.
  *
  * from hp300: @(#)pmap.h      7.2 (Berkeley) 12/16/90
- *
- *     @(#)pmap.h      1.4 (Berkeley) %G%
  */
 
 #ifndef        _PMAP_MACHINE_
 #define        _PMAP_MACHINE_  1
 
  */
 
 #ifndef        _PMAP_MACHINE_
 #define        _PMAP_MACHINE_  1
 
-#include "sys/lock.h"
-#include "machine/vmparam.h"
-#include "vm/vm_statistics.h"
-
 /*
  * 386 page table entry and page table directory
  * W.Jolitz, 8/89
 /*
  * 386 page table entry and page table directory
  * W.Jolitz, 8/89
@@ -99,9 +120,6 @@ unsigned int
 typedef struct pde     pd_entry_t;     /* page directory entry */
 typedef struct pte     pt_entry_t;     /* Mach page table entry */
 
 typedef struct pde     pd_entry_t;     /* page directory entry */
 typedef struct pte     pt_entry_t;     /* Mach page table entry */
 
-#define        PD_ENTRY_NULL   ((pd_entry_t *) 0)
-#define        PT_ENTRY_NULL   ((pt_entry_t *) 0)
-
 /*
  * One page directory, shared between
  * kernel and user modes.
 /*
  * One page directory, shared between
  * kernel and user modes.
@@ -117,16 +135,17 @@ typedef struct pte        pt_entry_t;     /* Mach page table entry */
 #define        KPTDI_FIRST     0x3f8           /* start of kernel virtual pde's */
 #define        KPTDI_LAST      0x3fA           /* last of kernel virtual pde's */
 
 #define        KPTDI_FIRST     0x3f8           /* start of kernel virtual pde's */
 #define        KPTDI_LAST      0x3fA           /* last of kernel virtual pde's */
 
-extern pt_entry_t      *Sysmap;
-
 /*
  * Address of current and alternate address space page table maps
  * and directories.
  */
 /*
  * Address of current and alternate address space page table maps
  * and directories.
  */
-extern struct pte PTmap[], APTmap[], Upte;
-extern struct pde PTD[], APTD[], PTDpde, APTDpde, Upde;
+#ifdef KERNEL
+extern struct pte      PTmap[], APTmap[], Upte;
+extern struct pde      PTD[], APTD[], PTDpde, APTDpde, Upde;
+extern pt_entry_t      *Sysmap;
 
 
-extern int IdlePTD;
+extern int     IdlePTD;        /* physical address of "Idle" state directory */
+#endif
 
 /*
  * virtual address to page table entry and
 
 /*
  * virtual address to page table entry and
@@ -154,11 +173,9 @@ extern int IdlePTD;
 /*
  * Pmap stuff
  */
 /*
  * Pmap stuff
  */
-#define PMAP_NULL      ((pmap_t) 0)
 
 struct pmap {
        pd_entry_t              *pm_pdir;       /* KVA of page directory */
 
 struct pmap {
        pd_entry_t              *pm_pdir;       /* KVA of page directory */
-       /* caddr_t                      *pm_ptobj;      /* page table object */
        boolean_t               pm_pdchanged;   /* pdir changed */
        short                   pm_dref;        /* page directory ref count */
        short                   pm_count;       /* pmap reference count */
        boolean_t               pm_pdchanged;   /* pdir changed */
        short                   pm_dref;        /* page directory ref count */
        short                   pm_count;       /* pmap reference count */
@@ -169,16 +186,18 @@ struct pmap {
 
 typedef struct pmap    *pmap_t;
 
 
 typedef struct pmap    *pmap_t;
 
+#ifdef KERNEL
 extern pmap_t          kernel_pmap;
 extern pmap_t          kernel_pmap;
+#endif
 
 /*
  * Macros for speed
  */
 #define PMAP_ACTIVATE(pmapp, pcbp) \
 
 /*
  * Macros for speed
  */
 #define PMAP_ACTIVATE(pmapp, pcbp) \
-       if ((pmapp) != PMAP_NULL /*&& (pmapp)->pm_pdchanged */) {  \
+       if ((pmapp) != NULL /*&& (pmapp)->pm_pdchanged */) {  \
                (pcbp)->pcb_cr3 = \
                    pmap_extract(kernel_pmap, (pmapp)->pm_pdir); \
                (pcbp)->pcb_cr3 = \
                    pmap_extract(kernel_pmap, (pmapp)->pm_pdir); \
-               if ((pmapp) == u.u_procp->p_map->pmap) \
+               if ((pmapp) == &curproc->p_vmspace->vm_pmap) \
                        load_cr3((pcbp)->pcb_cr3); \
                (pmapp)->pm_pdchanged = FALSE; \
        }
                        load_cr3((pcbp)->pcb_cr3); \
                (pmapp)->pm_pdchanged = FALSE; \
        }