pmap.h (a7496c776d77fa07a5fcf3b73e16cb649982521d) | pmap.h (34c15db9cd101bd7eecfd4f08a231f18366f0f8a) |
---|---|
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 * --- 49 unchanged lines hidden (view full) --- 58#define PG_M 0x040 /* D Dirty */ 59#define PG_PS 0x080 /* PS Page size (0=4k,1=4M) */ 60#define PG_PTE_PAT 0x080 /* PAT PAT index */ 61#define PG_G 0x100 /* G Global */ 62#define PG_AVAIL1 0x200 /* / Available for system */ 63#define PG_AVAIL2 0x400 /* < programmers use */ 64#define PG_AVAIL3 0x800 /* \ */ 65#define PG_PDE_PAT 0x1000 /* PAT PAT index */ | 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 * --- 49 unchanged lines hidden (view full) --- 58#define PG_M 0x040 /* D Dirty */ 59#define PG_PS 0x080 /* PS Page size (0=4k,1=4M) */ 60#define PG_PTE_PAT 0x080 /* PAT PAT index */ 61#define PG_G 0x100 /* G Global */ 62#define PG_AVAIL1 0x200 /* / Available for system */ 63#define PG_AVAIL2 0x400 /* < programmers use */ 64#define PG_AVAIL3 0x800 /* \ */ 65#define PG_PDE_PAT 0x1000 /* PAT PAT index */ |
66#ifdef PAE | 66#if defined(PAE) || defined(PAE_TABLES) |
67#define PG_NX (1ull<<63) /* No-execute */ 68#endif 69 70 71/* Our various interpretations of the above */ 72#define PG_W PG_AVAIL1 /* "Wired" pseudoflag */ 73#define PG_MANAGED PG_AVAIL2 | 67#define PG_NX (1ull<<63) /* No-execute */ 68#endif 69 70 71/* Our various interpretations of the above */ 72#define PG_W PG_AVAIL1 /* "Wired" pseudoflag */ 73#define PG_MANAGED PG_AVAIL2 |
74#ifdef PAE | 74#if defined(PAE) || defined(PAE_TABLES) |
75#define PG_FRAME (0x000ffffffffff000ull) 76#define PG_PS_FRAME (0x000fffffffe00000ull) 77#else 78#define PG_FRAME (~PAGE_MASK) 79#define PG_PS_FRAME (0xffc00000) 80#endif 81#define PG_PROT (PG_RW|PG_U) /* all protection bits . */ 82#define PG_N (PG_NC_PWT|PG_NC_PCD) /* Non-cacheable */ --- 22 unchanged lines hidden (view full) --- 105/* 106 * Size of Kernel address space. This is the number of page table pages 107 * (4MB each) to use for the kernel. 256 pages == 1 Gigabyte. 108 * This **MUST** be a multiple of 4 (eg: 252, 256, 260, etc). 109 * For PAE, the page table page unit size is 2MB. This means that 512 pages 110 * is 1 Gigabyte. Double everything. It must be a multiple of 8 for PAE. 111 */ 112#ifndef KVA_PAGES | 75#define PG_FRAME (0x000ffffffffff000ull) 76#define PG_PS_FRAME (0x000fffffffe00000ull) 77#else 78#define PG_FRAME (~PAGE_MASK) 79#define PG_PS_FRAME (0xffc00000) 80#endif 81#define PG_PROT (PG_RW|PG_U) /* all protection bits . */ 82#define PG_N (PG_NC_PWT|PG_NC_PCD) /* Non-cacheable */ --- 22 unchanged lines hidden (view full) --- 105/* 106 * Size of Kernel address space. This is the number of page table pages 107 * (4MB each) to use for the kernel. 256 pages == 1 Gigabyte. 108 * This **MUST** be a multiple of 4 (eg: 252, 256, 260, etc). 109 * For PAE, the page table page unit size is 2MB. This means that 512 pages 110 * is 1 Gigabyte. Double everything. It must be a multiple of 8 for PAE. 111 */ 112#ifndef KVA_PAGES |
113#ifdef PAE | 113#if defined(PAE) || defined(PAE_TABLES) |
114#define KVA_PAGES 512 115#else 116#define KVA_PAGES 256 117#endif 118#endif 119 120/* 121 * Pte related macros 122 */ 123#define VADDR(pdi, pti) ((vm_offset_t)(((pdi)<<PDRSHIFT)|((pti)<<PAGE_SHIFT))) 124 125/* 126 * The initial number of kernel page table pages that are constructed 127 * by locore must be sufficient to map vm_page_array. That number can 128 * be calculated as follows: 129 * max_phys / PAGE_SIZE * sizeof(struct vm_page) / NBPDR 130 * PAE: max_phys 16G, sizeof(vm_page) 76, NBPDR 2M, 152 page table pages. | 114#define KVA_PAGES 512 115#else 116#define KVA_PAGES 256 117#endif 118#endif 119 120/* 121 * Pte related macros 122 */ 123#define VADDR(pdi, pti) ((vm_offset_t)(((pdi)<<PDRSHIFT)|((pti)<<PAGE_SHIFT))) 124 125/* 126 * The initial number of kernel page table pages that are constructed 127 * by locore must be sufficient to map vm_page_array. That number can 128 * be calculated as follows: 129 * max_phys / PAGE_SIZE * sizeof(struct vm_page) / NBPDR 130 * PAE: max_phys 16G, sizeof(vm_page) 76, NBPDR 2M, 152 page table pages. |
131 * PAE_TABLES: max_phys 4G, sizeof(vm_page) 68, NBPDR 2M, 36 page table pages. |
|
131 * Non-PAE: max_phys 4G, sizeof(vm_page) 68, NBPDR 4M, 18 page table pages. 132 */ 133#ifndef NKPT | 132 * Non-PAE: max_phys 4G, sizeof(vm_page) 68, NBPDR 4M, 18 page table pages. 133 */ 134#ifndef NKPT |
134#ifdef PAE | 135#if defined(PAE) |
135#define NKPT 240 | 136#define NKPT 240 |
137#elif defined(PAE_TABLES) 138#define NKPT 60 |
|
136#else 137#define NKPT 30 138#endif 139#endif 140 141#ifndef NKPDE 142#define NKPDE (KVA_PAGES) /* number of page tables/pde's */ 143#endif --- 17 unchanged lines hidden (view full) --- 161 162#include <sys/queue.h> 163#include <sys/_cpuset.h> 164#include <sys/_lock.h> 165#include <sys/_mutex.h> 166 167#include <vm/_vm_radix.h> 168 | 139#else 140#define NKPT 30 141#endif 142#endif 143 144#ifndef NKPDE 145#define NKPDE (KVA_PAGES) /* number of page tables/pde's */ 146#endif --- 17 unchanged lines hidden (view full) --- 164 165#include <sys/queue.h> 166#include <sys/_cpuset.h> 167#include <sys/_lock.h> 168#include <sys/_mutex.h> 169 170#include <vm/_vm_radix.h> 171 |
169#ifdef PAE | 172#if defined(PAE) || defined(PAE_TABLES) |
170 171typedef uint64_t pdpt_entry_t; 172typedef uint64_t pd_entry_t; 173typedef uint64_t pt_entry_t; 174 175#define PTESHIFT (3) 176#define PDESHIFT (3) 177 --- 10 unchanged lines hidden (view full) --- 188/* 189 * Address of current address space page table maps and directories. 190 */ 191#ifdef _KERNEL 192extern pt_entry_t PTmap[]; 193extern pd_entry_t PTD[]; 194extern pd_entry_t PTDpde[]; 195 | 173 174typedef uint64_t pdpt_entry_t; 175typedef uint64_t pd_entry_t; 176typedef uint64_t pt_entry_t; 177 178#define PTESHIFT (3) 179#define PDESHIFT (3) 180 --- 10 unchanged lines hidden (view full) --- 191/* 192 * Address of current address space page table maps and directories. 193 */ 194#ifdef _KERNEL 195extern pt_entry_t PTmap[]; 196extern pd_entry_t PTD[]; 197extern pd_entry_t PTDpde[]; 198 |
196#ifdef PAE | 199#if defined(PAE) || defined(PAE_TABLES) |
197extern pdpt_entry_t *IdlePDPT; 198#endif 199extern pd_entry_t *IdlePTD; /* physical address of "Idle" state directory */ 200 201/* 202 * Translate a virtual address to the kernel virtual address of its page table 203 * entry (PTE). This can be used recursively. If the address of a PTE as 204 * previously returned by this macro is itself given as the argument, then the --- 121 unchanged lines hidden (view full) --- 326 return (pa); 327} 328#endif 329 330#if !defined(XEN) 331#define PT_UPDATES_FLUSH() 332#endif 333 | 200extern pdpt_entry_t *IdlePDPT; 201#endif 202extern pd_entry_t *IdlePTD; /* physical address of "Idle" state directory */ 203 204/* 205 * Translate a virtual address to the kernel virtual address of its page table 206 * entry (PTE). This can be used recursively. If the address of a PTE as 207 * previously returned by this macro is itself given as the argument, then the --- 121 unchanged lines hidden (view full) --- 329 return (pa); 330} 331#endif 332 333#if !defined(XEN) 334#define PT_UPDATES_FLUSH() 335#endif 336 |
334#if defined(PAE) && !defined(XEN) | 337#if (defined(PAE) || defined(PAE_TABLES)) && !defined(XEN) |
335 336#define pde_cmpset(pdep, old, new) atomic_cmpset_64_i586(pdep, old, new) 337#define pte_load_store(ptep, pte) atomic_swap_64_i586(ptep, pte) 338#define pte_load_clear(ptep) atomic_swap_64_i586(ptep, 0) 339#define pte_store(ptep, pte) atomic_store_rel_64_i586(ptep, pte) 340 341extern pt_entry_t pg_nx; 342 | 338 339#define pde_cmpset(pdep, old, new) atomic_cmpset_64_i586(pdep, old, new) 340#define pte_load_store(ptep, pte) atomic_swap_64_i586(ptep, pte) 341#define pte_load_clear(ptep) atomic_swap_64_i586(ptep, 0) 342#define pte_store(ptep, pte) atomic_store_rel_64_i586(ptep, pte) 343 344extern pt_entry_t pg_nx; 345 |
343#elif !defined(PAE) && !defined(XEN) | 346#elif !defined(PAE) && !defined(PAE_TABLES) && !defined(XEN) |
344 345#define pde_cmpset(pdep, old, new) atomic_cmpset_int(pdep, old, new) 346#define pte_load_store(ptep, pte) atomic_swap_int(ptep, pte) 347#define pte_load_clear(ptep) atomic_swap_int(ptep, 0) 348#define pte_store(ptep, pte) do { \ 349 *(u_int *)(ptep) = (u_int)(pte); \ 350} while (0) 351 --- 18 unchanged lines hidden (view full) --- 370 371struct pmap { 372 struct mtx pm_mtx; 373 pd_entry_t *pm_pdir; /* KVA of page directory */ 374 TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */ 375 cpuset_t pm_active; /* active on cpus */ 376 struct pmap_statistics pm_stats; /* pmap statistics */ 377 LIST_ENTRY(pmap) pm_list; /* List of all pmaps */ | 347 348#define pde_cmpset(pdep, old, new) atomic_cmpset_int(pdep, old, new) 349#define pte_load_store(ptep, pte) atomic_swap_int(ptep, pte) 350#define pte_load_clear(ptep) atomic_swap_int(ptep, 0) 351#define pte_store(ptep, pte) do { \ 352 *(u_int *)(ptep) = (u_int)(pte); \ 353} while (0) 354 --- 18 unchanged lines hidden (view full) --- 373 374struct pmap { 375 struct mtx pm_mtx; 376 pd_entry_t *pm_pdir; /* KVA of page directory */ 377 TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */ 378 cpuset_t pm_active; /* active on cpus */ 379 struct pmap_statistics pm_stats; /* pmap statistics */ 380 LIST_ENTRY(pmap) pm_list; /* List of all pmaps */ |
378#ifdef PAE 379 pdpt_entry_t *pm_pdpt; /* KVA of page director pointer | 381#if defined(PAE) || defined(PAE_TABLES) 382 pdpt_entry_t *pm_pdpt; /* KVA of page directory pointer |
380 table */ 381#endif 382 struct vm_radix pm_root; /* spare page table pages */ 383}; 384 385typedef struct pmap *pmap_t; 386 387#ifdef _KERNEL --- 86 unchanged lines hidden --- | 383 table */ 384#endif 385 struct vm_radix pm_root; /* spare page table pages */ 386}; 387 388typedef struct pmap *pmap_t; 389 390#ifdef _KERNEL --- 86 unchanged lines hidden --- |