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