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