Home | History | Annotate | Line # | Download | only in include
pmap.h revision 1.1
      1 /*-
      2  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
      3  * All rights reserved.
      4  *
      5  * This code is derived from software contributed to The NetBSD Foundation
      6  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      7  * NASA Ames Research Center and by Chris G. Demetriou.
      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  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *	This product includes software developed by the NetBSD
     20  *	Foundation, Inc. and its contributors.
     21  * 4. Neither the name of The NetBSD Foundation nor the names of its
     22  *    contributors may be used to endorse or promote products derived
     23  *    from this software without specific prior written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     26  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 /*-
     39  * Copyright (c) 1991 Regents of the University of California.
     40  * All rights reserved.
     41  *
     42  * This code is derived from software contributed to Berkeley by
     43  * the Systems Programming Group of the University of Utah Computer
     44  * Science Department and William Jolitz of UUNET Technologies Inc.
     45  *
     46  * Redistribution and use in source and binary forms, with or without
     47  * modification, are permitted provided that the following conditions
     48  * are met:
     49  * 1. Redistributions of source code must retain the above copyright
     50  *    notice, this list of conditions and the following disclaimer.
     51  * 2. Redistributions in binary form must reproduce the above copyright
     52  *    notice, this list of conditions and the following disclaimer in the
     53  *    documentation and/or other materials provided with the distribution.
     54  * 4. Neither the name of the University nor the names of its contributors
     55  *    may be used to endorse or promote products derived from this software
     56  *    without specific prior written permission.
     57  *
     58  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     59  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     60  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     61  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     62  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     63  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     64  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     65  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     66  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     67  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     68  * SUCH DAMAGE.
     69  *
     70  * Derived from hp300 version by Mike Hibler, this version by William
     71  * Jolitz uses a recursive map [a pde points to the page directory] to
     72  * map the page tables using the pagetables themselves. This is done to
     73  * reduce the impact on kernel virtual memory for lots of sparse address
     74  * space, and to reduce the cost of memory to each process.
     75  *
     76  *	from: hp300: @(#)pmap.h	7.2 (Berkeley) 12/16/90
     77  *	from: @(#)pmap.h	7.4 (Berkeley) 5/12/91
     78  *	from: i386 pmap.h,v 1.54 1997/11/20 19:30:35 bde Exp
     79  * $FreeBSD: src/sys/ia64/include/pmap.h,v 1.25 2005/09/03 23:53:50 marcel Exp $
     80  */
     81 
     82 #ifndef _PMAP_MACHINE_
     83 #define _PMAP_MACHINE_
     84 
     85 paddr_t vtophys(vaddr_t);
     86 
     87 struct pv_entry;	/* Forward declaration. */
     88 
     89 struct pmap {
     90 	TAILQ_ENTRY(pmap)	pm_list;	/* list of all pmaps */
     91 	TAILQ_HEAD(,pv_entry)	pm_pvlist;	/* list of mappings in pmap */
     92 	int			pm_count;	/* pmap reference count */
     93 	struct simplelock	pm_slock;	/* lock on pmap */
     94 	u_int32_t		pm_rid[5];	/* base RID for pmap */
     95 	int			pm_active;	/* active flag */
     96 	struct pmap_statistics	pm_stats;	/* pmap statistics */
     97 	unsigned long		pm_cpus;	/* mask of CPUs using pmap */
     98 
     99 };
    100 
    101 typedef struct pmap	*pmap_t;
    102 
    103 /*
    104  * For each vm_page_t, there is a list of all currently valid virtual
    105  * mappings of that page.  An entry is a pv_entry_t, the list is pv_pvlist.
    106  */
    107 typedef struct pv_entry {
    108 	pmap_t		pv_pmap;	/* pmap where mapping lies */
    109 	vaddr_t		pv_va;		/* virtual address for mapping */
    110 	TAILQ_ENTRY(pv_entry)	pv_list;
    111 	TAILQ_ENTRY(pv_entry)	pv_plist;
    112 } *pv_entry_t;
    113 
    114 /* pvh_attrs */
    115 #define	PGA_MODIFIED		0x01		/* modified */
    116 #define	PGA_REFERENCED		0x02		/* referenced */
    117 
    118 
    119 extern struct pmap	kernel_pmap_store;
    120 
    121 #define pmap_kernel()			(&kernel_pmap_store)
    122 
    123 #define	pmap_resident_count(pmap)	((pmap)->pm_stats.resident_count)
    124 #define	pmap_wired_count(pmap)		((pmap)->pm_stats.wired_count)
    125 
    126 #define	pmap_copy(dp, sp, da, l, sa)	/* nothing */
    127 #define	pmap_update(pmap)		/* nothing (yet) */
    128 
    129 void pmap_bootstrap(void);
    130 
    131 #define	pmap_is_referenced(pg)						\
    132 	(((pg)->mdpage.pvh_attrs & PGA_REFERENCED) != 0)
    133 #define	pmap_is_modified(pg)						\
    134 	(((pg)->mdpage.pvh_attrs & PGA_MODIFIED) != 0)
    135 
    136 
    137 #define PMAP_STEAL_MEMORY		/* enable pmap_steal_memory() */
    138 
    139 /*
    140  * Alternate mapping hooks for pool pages.  Avoids thrashing the TLB.
    141  */
    142 #define	PMAP_MAP_POOLPAGE(pa)		IA64_PHYS_TO_RR7((pa))
    143 #define	PMAP_UNMAP_POOLPAGE(va)		IA64_RR_MASK((va))
    144 
    145 /*
    146  * Macros for locking pmap structures.
    147  *
    148  * Note that we if we access the kernel pmap in interrupt context, it
    149  * is only to update statistics.  Since stats are updated using atomic
    150  * operations, locking the kernel pmap is not necessary.  Therefore,
    151  * it is not necessary to block interrupts when locking pmap strucutres.
    152  */
    153 #define	PMAP_LOCK(pmap)		simple_lock(&(pmap)->pm_slock)
    154 #define	PMAP_UNLOCK(pmap)	simple_unlock(&(pmap)->pm_slock)
    155 
    156 
    157 #define PMAP_VHPT_LOG2SIZE 16
    158 
    159 
    160 #endif /* _PMAP_MACHINE_ */
    161