summaryrefslogtreecommitdiffstats
path: root/sys/amd64/amd64/pmap.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-09-28 09:41:00 +0000
committerkib <kib@FreeBSD.org>2016-09-28 09:41:00 +0000
commit499ea4330f87cb09882bbc5a73eec2230b57ee25 (patch)
treecf91e5b1bbd427d865ea57cfdbde8e81b30824c4 /sys/amd64/amd64/pmap.c
parentdd9bf1d1aa3f561c8dfdd64536c59ece13fd0981 (diff)
downloadFreeBSD-src-499ea4330f87cb09882bbc5a73eec2230b57ee25.zip
FreeBSD-src-499ea4330f87cb09882bbc5a73eec2230b57ee25.tar.gz
MFC r306087:
Export the pmap_cache_bits() and pmap_pinit_pml4() functions from the amd64 pmap.
Diffstat (limited to 'sys/amd64/amd64/pmap.c')
-rw-r--r--sys/amd64/amd64/pmap.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index c147d61..81ce359 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -1324,7 +1324,7 @@ pmap_swap_pat(pmap_t pmap, pt_entry_t entry)
* Determine the appropriate bits to set in a PTE or PDE for a specified
* caching mode.
*/
-static int
+int
pmap_cache_bits(pmap_t pmap, int mode, boolean_t is_pde)
{
int cache_bits, pat_flag, pat_idx;
@@ -2345,6 +2345,29 @@ pmap_pinit0(pmap_t pmap)
CPU_FILL(&kernel_pmap->pm_active);
}
+void
+pmap_pinit_pml4(vm_page_t pml4pg)
+{
+ pml4_entry_t *pm_pml4;
+ int i;
+
+ pm_pml4 = (pml4_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(pml4pg));
+
+ /* Wire in kernel global address entries. */
+ for (i = 0; i < NKPML4E; i++) {
+ pm_pml4[KPML4BASE + i] = (KPDPphys + ptoa(i)) | X86_PG_RW |
+ X86_PG_V | PG_U;
+ }
+ for (i = 0; i < ndmpdpphys; i++) {
+ pm_pml4[DMPML4I + i] = (DMPDPphys + ptoa(i)) | X86_PG_RW |
+ X86_PG_V | PG_U;
+ }
+
+ /* install self-referential address mapping entry(s) */
+ pm_pml4[PML4PML4I] = VM_PAGE_TO_PHYS(pml4pg) | X86_PG_V | X86_PG_RW |
+ X86_PG_A | X86_PG_M;
+}
+
/*
* Initialize a preallocated and zeroed pmap structure,
* such as one in a vmspace structure.
@@ -2381,20 +2404,7 @@ pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type, int flags)
*/
if ((pmap->pm_type = pm_type) == PT_X86) {
pmap->pm_cr3 = pml4phys;
-
- /* Wire in kernel global address entries. */
- for (i = 0; i < NKPML4E; i++) {
- pmap->pm_pml4[KPML4BASE + i] = (KPDPphys + ptoa(i)) |
- X86_PG_RW | X86_PG_V | PG_U;
- }
- for (i = 0; i < ndmpdpphys; i++) {
- pmap->pm_pml4[DMPML4I + i] = (DMPDPphys + ptoa(i)) |
- X86_PG_RW | X86_PG_V | PG_U;
- }
-
- /* install self-referential address mapping entry(s) */
- pmap->pm_pml4[PML4PML4I] = VM_PAGE_TO_PHYS(pml4pg) |
- X86_PG_V | X86_PG_RW | X86_PG_A | X86_PG_M;
+ pmap_pinit_pml4(pml4pg);
}
pmap->pm_root.rt_root = 0;
OpenPOWER on IntegriCloud