Deleted Added
full compact
pmap.h (112837) pmap.h (112841)
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 *

--- 28 unchanged lines hidden (view full) ---

37 * Derived from hp300 version by Mike Hibler, this version by William
38 * Jolitz uses a recursive map [a pde points to the page directory] to
39 * map the page tables using the pagetables themselves. This is done to
40 * reduce the impact on kernel virtual memory for lots of sparse address
41 * space, and to reduce the cost of memory to each process.
42 *
43 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
44 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
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 *

--- 28 unchanged lines hidden (view full) ---

37 * Derived from hp300 version by Mike Hibler, this version by William
38 * Jolitz uses a recursive map [a pde points to the page directory] to
39 * map the page tables using the pagetables themselves. This is done to
40 * reduce the impact on kernel virtual memory for lots of sparse address
41 * space, and to reduce the cost of memory to each process.
42 *
43 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
44 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
45 * $FreeBSD: head/sys/i386/include/pmap.h 112837 2003-03-30 01:44:16Z jake $
45 * $FreeBSD: head/sys/i386/include/pmap.h 112841 2003-03-30 05:24:52Z jake $
46 */
47
48#ifndef _MACHINE_PMAP_H_
49#define _MACHINE_PMAP_H_
50
51/*
52 * Page-directory and page-table entires follow this format, with a few
53 * of the fields not present here and there, depending on a lot of things.

--- 29 unchanged lines hidden (view full) ---

83#define PGEX_U 0x04 /* access from User mode (UPL) */
84
85/*
86 * Size of Kernel address space. This is the number of page table pages
87 * (4MB each) to use for the kernel. 256 pages == 1 Gigabyte.
88 * This **MUST** be a multiple of 4 (eg: 252, 256, 260, etc).
89 */
90#ifndef KVA_PAGES
46 */
47
48#ifndef _MACHINE_PMAP_H_
49#define _MACHINE_PMAP_H_
50
51/*
52 * Page-directory and page-table entires follow this format, with a few
53 * of the fields not present here and there, depending on a lot of things.

--- 29 unchanged lines hidden (view full) ---

83#define PGEX_U 0x04 /* access from User mode (UPL) */
84
85/*
86 * Size of Kernel address space. This is the number of page table pages
87 * (4MB each) to use for the kernel. 256 pages == 1 Gigabyte.
88 * This **MUST** be a multiple of 4 (eg: 252, 256, 260, etc).
89 */
90#ifndef KVA_PAGES
91#ifdef PAE
92#define KVA_PAGES 512
93#else
91#define KVA_PAGES 256
92#endif
94#define KVA_PAGES 256
95#endif
96#endif
93
94/*
95 * Pte related macros
96 */
97#define VADDR(pdi, pti) ((vm_offset_t)(((pdi)<<PDRSHIFT)|((pti)<<PAGE_SHIFT)))
98
99#ifndef NKPT
97
98/*
99 * Pte related macros
100 */
101#define VADDR(pdi, pti) ((vm_offset_t)(((pdi)<<PDRSHIFT)|((pti)<<PAGE_SHIFT)))
102
103#ifndef NKPT
104#ifdef PAE
105#define NKPT 120 /* actual number of kernel page tables */
106#else
100#define NKPT 30 /* actual number of kernel page tables */
101#endif
107#define NKPT 30 /* actual number of kernel page tables */
108#endif
109#endif
102#ifndef NKPDE
103#ifdef SMP
104#define NKPDE (KVA_PAGES - (NPGPTD + 1)) /* number of page tables/pde's */
105#else
106#define NKPDE (KVA_PAGES - NPGPTD) /* number of page tables/pde's */
107#endif
108#endif
109

--- 19 unchanged lines hidden (view full) ---

129 */
130#define ISA_HOLE_START 0xa0000
131#define ISA_HOLE_LENGTH (0x100000-ISA_HOLE_START)
132
133#ifndef LOCORE
134
135#include <sys/queue.h>
136
110#ifndef NKPDE
111#ifdef SMP
112#define NKPDE (KVA_PAGES - (NPGPTD + 1)) /* number of page tables/pde's */
113#else
114#define NKPDE (KVA_PAGES - NPGPTD) /* number of page tables/pde's */
115#endif
116#endif
117

--- 19 unchanged lines hidden (view full) ---

137 */
138#define ISA_HOLE_START 0xa0000
139#define ISA_HOLE_LENGTH (0x100000-ISA_HOLE_START)
140
141#ifndef LOCORE
142
143#include <sys/queue.h>
144
137typedef u_int32_t pd_entry_t;
138typedef u_int32_t pt_entry_t;
145#ifdef PAE
139
146
147typedef uint64_t pdpt_entry_t;
148typedef uint64_t pd_entry_t;
149typedef uint64_t pt_entry_t;
150
151#define PTESHIFT (3)
152#define PDESHIFT (3)
153
154#else
155
156typedef uint32_t pd_entry_t;
157typedef uint32_t pt_entry_t;
158
140#define PTESHIFT (2)
141#define PDESHIFT (2)
142
159#define PTESHIFT (2)
160#define PDESHIFT (2)
161
162#endif
163
143/*
144 * Address of current and alternate address space page table maps
145 * and directories.
146 */
147#ifdef _KERNEL
148extern pt_entry_t PTmap[], APTmap[];
149extern pd_entry_t PTD[], APTD[];
150extern pd_entry_t PTDpde[], APTDpde[];
151
164/*
165 * Address of current and alternate address space page table maps
166 * and directories.
167 */
168#ifdef _KERNEL
169extern pt_entry_t PTmap[], APTmap[];
170extern pd_entry_t PTD[], APTD[];
171extern pd_entry_t PTDpde[], APTDpde[];
172
173#ifdef PAE
174extern pdpt_entry_t *IdlePDPT;
175#endif
152extern pd_entry_t *IdlePTD; /* physical address of "Idle" state directory */
153#endif
154
155#ifdef _KERNEL
156/*
157 * virtual address to page table entry and
158 * to physical address. Likewise for alternate address space.
159 * Note: these work recursively, thus vtopte of a pte will give

--- 18 unchanged lines hidden (view full) ---

178 } else {
179 pa = *vtopte(va);
180 pa = (pa & PG_FRAME) | (va & PAGE_MASK);
181 }
182 return pa;
183}
184
185#define vtophys(va) pmap_kextract(((vm_offset_t) (va)))
176extern pd_entry_t *IdlePTD; /* physical address of "Idle" state directory */
177#endif
178
179#ifdef _KERNEL
180/*
181 * virtual address to page table entry and
182 * to physical address. Likewise for alternate address space.
183 * Note: these work recursively, thus vtopte of a pte will give

--- 18 unchanged lines hidden (view full) ---

202 } else {
203 pa = *vtopte(va);
204 pa = (pa & PG_FRAME) | (va & PAGE_MASK);
205 }
206 return pa;
207}
208
209#define vtophys(va) pmap_kextract(((vm_offset_t) (va)))
210
211#ifdef PAE
212
213static __inline pt_entry_t
214pte_load_clear(pt_entry_t *pte)
215{
216 pt_entry_t r;
217
218 r = *pte;
219 __asm __volatile(
220 "1:\n"
221 "\tcmpxchg8b %1\n"
222 "\tjnz 1b"
223 : "+A" (r)
224 : "m" (*pte), "b" (0), "c" (0));
225 return (r);
226}
227
228#else
229
230#define pte_load_clear(pte) atomic_readandclear_int(pte)
231
186#endif
187
232#endif
233
234#endif
235
188/*
189 * Pmap stuff
190 */
191struct pv_entry;
192
193struct md_page {
194 int pv_list_count;
195 TAILQ_HEAD(,pv_entry) pv_list;
196};
197
198struct pmap {
199 pd_entry_t *pm_pdir; /* KVA of page directory */
200 vm_object_t pm_pteobj; /* Container for pte's */
201 TAILQ_HEAD(,pv_entry) pm_pvlist; /* list of mappings in pmap */
202 int pm_active; /* active on cpus */
203 struct pmap_statistics pm_stats; /* pmap statistics */
204 LIST_ENTRY(pmap) pm_list; /* List of all pmaps */
236/*
237 * Pmap stuff
238 */
239struct pv_entry;
240
241struct md_page {
242 int pv_list_count;
243 TAILQ_HEAD(,pv_entry) pv_list;
244};
245
246struct pmap {
247 pd_entry_t *pm_pdir; /* KVA of page directory */
248 vm_object_t pm_pteobj; /* Container for pte's */
249 TAILQ_HEAD(,pv_entry) pm_pvlist; /* list of mappings in pmap */
250 int pm_active; /* active on cpus */
251 struct pmap_statistics pm_stats; /* pmap statistics */
252 LIST_ENTRY(pmap) pm_list; /* List of all pmaps */
253#ifdef PAE
254 pdpt_entry_t *pm_pdpt; /* KVA of page director pointer
255 table */
256#endif
205};
206
207#define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list))
208#define pmap_resident_count(pmap) (pmap)->pm_stats.resident_count
209
210typedef struct pmap *pmap_t;
211
212#ifdef _KERNEL

--- 53 unchanged lines hidden ---
257};
258
259#define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list))
260#define pmap_resident_count(pmap) (pmap)->pm_stats.resident_count
261
262typedef struct pmap *pmap_t;
263
264#ifdef _KERNEL

--- 53 unchanged lines hidden ---