The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/mips/include/pmap.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1991 Regents of the University of California.
    3  * All rights reserved.
    4  *
    5  * This code is derived from software contributed to Berkeley by
    6  * the Systems Programming Group of the University of Utah Computer
    7  * Science Department and William Jolitz of UUNET Technologies Inc.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   12  * 1. Redistributions of source code must retain the above copyright
   13  *    notice, this list of conditions and the following disclaimer.
   14  * 2. Redistributions in binary form must reproduce the above copyright
   15  *    notice, this list of conditions and the following disclaimer in the
   16  *    documentation and/or other materials provided with the distribution.
   17  * 4. Neither the name of the University nor the names of its contributors
   18  *    may be used to endorse or promote products derived from this software
   19  *    without specific prior written permission.
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   31  * SUCH DAMAGE.
   32  *
   33  * Derived from hp300 version by Mike Hibler, this version by William
   34  * Jolitz uses a recursive map [a pde points to the page directory] to
   35  * map the page tables using the pagetables themselves. This is done to
   36  * reduce the impact on kernel virtual memory for lots of sparse address
   37  * space, and to reduce the cost of memory to each process.
   38  *
   39  *      from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
   40  *      from: @(#)pmap.h        7.4 (Berkeley) 5/12/91
   41  *      from: src/sys/i386/include/pmap.h,v 1.65.2.2 2000/11/30 01:54:42 peter
   42  *      JNPR: pmap.h,v 1.7.2.1 2007/09/10 07:44:12 girish
   43  *      $FreeBSD$
   44  */
   45 
   46 #ifndef _MACHINE_PMAP_H_
   47 #define _MACHINE_PMAP_H_
   48 
   49 #include <machine/vmparam.h>
   50 #include <machine/pte.h>
   51 
   52 #define NKPT            120     /* actual number of kernel page tables */
   53 
   54 #ifndef LOCORE
   55 
   56 #include <sys/queue.h>
   57 #include <sys/_lock.h>
   58 #include <sys/_mutex.h>
   59 
   60 /*
   61  * Pmap stuff
   62  */
   63 struct pv_entry;
   64 
   65 struct md_page {
   66         int pv_list_count;
   67         int pv_flags;
   68         TAILQ_HEAD(, pv_entry) pv_list;
   69 };
   70 
   71 #define PV_TABLE_MOD            0x01    /* modified */
   72 #define PV_TABLE_REF            0x02    /* referenced */
   73 
   74 #define ASID_BITS               8
   75 #define ASIDGEN_BITS            (32 - ASID_BITS)
   76 #define ASIDGEN_MASK            ((1 << ASIDGEN_BITS) - 1)
   77 
   78 struct pmap {
   79         pd_entry_t *pm_segtab;  /* KVA of segment table */
   80         TAILQ_HEAD(, pv_entry) pm_pvlist;       /* list of mappings in
   81                                                  * pmap */
   82         cpumask_t       pm_active;              /* active on cpus */
   83         struct {
   84                 u_int32_t asid:ASID_BITS;       /* TLB address space tag */
   85                 u_int32_t gen:ASIDGEN_BITS;     /* its generation number */
   86         }      pm_asid[MAXSMPCPU];
   87         struct pmap_statistics pm_stats;        /* pmap statistics */
   88         struct vm_page *pm_ptphint;     /* pmap ptp hint */
   89         struct mtx pm_mtx;
   90 };
   91 
   92 typedef struct pmap *pmap_t;
   93 
   94 #ifdef  _KERNEL
   95 
   96 pt_entry_t *pmap_pte(pmap_t, vm_offset_t);
   97 vm_offset_t pmap_kextract(vm_offset_t va);
   98 
   99 #define vtophys(va)     pmap_kextract(((vm_offset_t) (va)))
  100 #define pmap_asid(pmap) (pmap)->pm_asid[PCPU_GET(cpuid)].asid
  101 
  102 extern struct pmap      kernel_pmap_store;
  103 #define kernel_pmap     (&kernel_pmap_store)
  104 
  105 #define PMAP_LOCK(pmap)         mtx_lock(&(pmap)->pm_mtx)
  106 #define PMAP_LOCK_ASSERT(pmap, type)    mtx_assert(&(pmap)->pm_mtx, (type))
  107 #define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx)
  108 #define PMAP_LOCK_INIT(pmap)    mtx_init(&(pmap)->pm_mtx, "pmap", \
  109                                     NULL, MTX_DEF)
  110 #define PMAP_LOCKED(pmap)       mtx_owned(&(pmap)->pm_mtx)
  111 #define PMAP_MTX(pmap)          (&(pmap)->pm_mtx)
  112 #define PMAP_TRYLOCK(pmap)      mtx_trylock(&(pmap)->pm_mtx)
  113 #define PMAP_UNLOCK(pmap)       mtx_unlock(&(pmap)->pm_mtx)
  114 
  115 /*
  116  * For each vm_page_t, there is a list of all currently valid virtual
  117  * mappings of that page.  An entry is a pv_entry_t, the list is pv_table.
  118  */
  119 typedef struct pv_entry {
  120         pmap_t pv_pmap;         /* pmap where mapping lies */
  121         vm_offset_t pv_va;      /* virtual address for mapping */
  122         TAILQ_ENTRY(pv_entry) pv_list;
  123         TAILQ_ENTRY(pv_entry) pv_plist;
  124         vm_page_t pv_ptem;      /* VM page for pte */
  125 }       *pv_entry_t;
  126 
  127 /*
  128  * physmem_desc[] is a superset of phys_avail[] and describes all the
  129  * memory present in the system.
  130  *
  131  * phys_avail[] is similar but does not include the memory stolen by
  132  * pmap_steal_memory().
  133  *
  134  * Each memory region is described by a pair of elements in the array
  135  * so we can describe up to (PHYS_AVAIL_ENTRIES / 2) distinct memory
  136  * regions.
  137  */
  138 #define PHYS_AVAIL_ENTRIES      10
  139 extern vm_offset_t phys_avail[PHYS_AVAIL_ENTRIES + 2];
  140 extern vm_offset_t physmem_desc[PHYS_AVAIL_ENTRIES + 2];
  141 
  142 extern vm_offset_t virtual_avail;
  143 extern vm_offset_t virtual_end;
  144 
  145 extern vm_paddr_t dump_avail[PHYS_AVAIL_ENTRIES + 2];
  146 
  147 #define pmap_page_get_memattr(m)        VM_MEMATTR_DEFAULT
  148 #define pmap_page_is_mapped(m)  (!TAILQ_EMPTY(&(m)->md.pv_list))
  149 #define pmap_page_set_memattr(m, ma)    (void)0
  150 
  151 void pmap_bootstrap(void);
  152 void *pmap_mapdev(vm_offset_t, vm_size_t);
  153 void pmap_unmapdev(vm_offset_t, vm_size_t);
  154 vm_offset_t pmap_steal_memory(vm_size_t size);
  155 int page_is_managed(vm_offset_t pa);
  156 void pmap_kenter(vm_offset_t va, vm_paddr_t pa);
  157 void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int attr);
  158 void pmap_kremove(vm_offset_t va);
  159 void *pmap_kenter_temporary(vm_paddr_t pa, int i);
  160 void pmap_kenter_temporary_free(vm_paddr_t pa);
  161 int pmap_compute_pages_to_dump(void);
  162 void pmap_flush_pvcache(vm_page_t m);
  163 int pmap_emulate_modified(pmap_t pmap, vm_offset_t va);
  164 #endif                          /* _KERNEL */
  165 
  166 #endif                          /* !LOCORE */
  167 
  168 #endif                          /* !_MACHINE_PMAP_H_ */

Cache object: 589ba945c96026337d810323be40250c


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.