diff options
author | Richard Braun <rbraun@sceen.net> | 2016-09-20 21:34:07 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2016-09-21 00:19:59 +0200 |
commit | 66a878640573dd9101e3915db44408b661220038 (patch) | |
tree | b030d125bc83e9c52b5e915fbe50de17d5eaf2bf /i386/i386at | |
parent | 8322083864500f5726f4f04f80427acee4b52c9a (diff) |
Remove phys_first_addr and phys_last_addr global variables
The old assumption that all physical memory is directly mapped in
kernel space is about to go away. Those variables are directly linked
to that assumption.
* i386/i386/model_dep.h (phys_first_addr): Remove extern declaration.
(phys_last_addr): Likewise.
* i386/i386/phys.c (pmap_zero_page): Use VM_PAGE_DIRECTMAP_LIMIT
instead of phys_last_addr.
(pmap_copy_page, copy_to_phys, copy_from_phys): Likewise.
* i386/i386/trap.c (user_trap): Remove check against phys_last_addr.
* i386/i386at/biosmem.c (biosmem_bootstrap_common): Don't set
phys_last_addr.
* i386/i386at/mem.c (memmmap): Use vm_page_lookup_pa to determine if
a physical address references physical memory.
* i386/i386at/model_dep.c (phys_first_addr): Remove variable.
(phys_last_addr): Likewise.
(pmap_free_pages, pmap_valid_page): Remove functions.
* i386/intel/pmap.c: Include i386at/biosmem.h.
(pa_index): Turn into an alias for vm_page_table_index.
(pmap_bootstrap): Replace uses of phys_first_addr and phys_last_addr
as appropriate.
(pmap_virtual_space): Use vm_page_table_size instead of phys_first_addr
and phys_last_addr to obtain the number of physical pages.
(pmap_verify_free): Remove function.
(valid_page): Turn this macro into an inline function and rewrite
using vm_page_lookup_pa.
(pmap_page_table_page_alloc): Build the pmap VM object using
vm_page_table_size to determine its size.
(pmap_remove_range, pmap_page_protect, phys_attribute_clear,
phys_attribute_test): Turn page indexes into unsigned long integers.
(pmap_enter): Likewise. In addition, use either vm_page_lookup_pa or
biosmem_directmap_end to determine if a physical address references
physical memory.
* i386/xen/xen.c (hyp_p2m_init): Use vm_page_table_size instead of
phys_last_addr to obtain the number of physical pages.
* kern/startup.c (phys_first_addr): Remove extern declaration.
(phys_last_addr): Likewise.
* linux/dev/init/main.c (linux_init): Use vm_page_seg_end with the
appropriate segment selector instead of phys_last_addr to determine
where high memory starts.
* vm/pmap.h: Update requirements description.
(pmap_free_pages, pmap_valid_page): Remove declarations.
* vm/vm_page.c (vm_page_seg_end, vm_page_boot_table_size,
vm_page_table_size, vm_page_table_index): New functions.
* vm/vm_page.h (vm_page_seg_end, vm_page_table_size,
vm_page_table_index): New function declarations.
* vm/vm_resident.c (vm_page_bucket_count, vm_page_hash_mask): Define
as unsigned long integers.
(vm_page_bootstrap): Compute VP table size based on the page table
size instead of the value returned by pmap_free_pages.
Diffstat (limited to 'i386/i386at')
-rw-r--r-- | i386/i386at/biosmem.c | 15 | ||||
-rw-r--r-- | i386/i386at/mem.c | 22 | ||||
-rw-r--r-- | i386/i386at/model_dep.c | 22 |
3 files changed, 21 insertions, 38 deletions
diff --git a/i386/i386at/biosmem.c b/i386/i386at/biosmem.c index 90ae54a9..62be567c 100644 --- a/i386/i386at/biosmem.c +++ b/i386/i386at/biosmem.c @@ -650,7 +650,7 @@ biosmem_setup_allocator(const struct multiboot_raw_info *mbi) static void __boot biosmem_bootstrap_common(void) { - phys_addr_t phys_start, phys_end, last_addr; + phys_addr_t phys_start, phys_end; int error; biosmem_map_adjust(); @@ -663,7 +663,6 @@ biosmem_bootstrap_common(void) boot_panic(biosmem_panic_noseg_msg); biosmem_set_segment(VM_PAGE_SEG_DMA, phys_start, phys_end); - last_addr = phys_end; phys_start = VM_PAGE_DMA_LIMIT; #ifdef VM_PAGE_DMA32_LIMIT @@ -671,10 +670,9 @@ biosmem_bootstrap_common(void) error = biosmem_map_find_avail(&phys_start, &phys_end); if (error) - goto out; + return; biosmem_set_segment(VM_PAGE_SEG_DMA32, phys_start, phys_end); - last_addr = phys_end; phys_start = VM_PAGE_DMA32_LIMIT; #endif /* VM_PAGE_DMA32_LIMIT */ @@ -682,23 +680,18 @@ biosmem_bootstrap_common(void) error = biosmem_map_find_avail(&phys_start, &phys_end); if (error) - goto out; + return; biosmem_set_segment(VM_PAGE_SEG_DIRECTMAP, phys_start, phys_end); - last_addr = phys_end; phys_start = VM_PAGE_DIRECTMAP_LIMIT; phys_end = VM_PAGE_HIGHMEM_LIMIT; error = biosmem_map_find_avail(&phys_start, &phys_end); if (error) - goto out; + return; biosmem_set_segment(VM_PAGE_SEG_HIGHMEM, phys_start, phys_end); - -out: - /* XXX phys_last_addr must be part of the direct physical mapping */ - phys_last_addr = last_addr; } #ifdef MACH_HYP diff --git a/i386/i386at/mem.c b/i386/i386at/mem.c index f239afac..eac2549f 100644 --- a/i386/i386at/mem.c +++ b/i386/i386at/mem.c @@ -36,12 +36,24 @@ dev_t dev; vm_offset_t off; vm_prot_t prot; { + struct vm_page *p; + if (off == 0) return 0; - else if (off < 0xa0000) - return -1; - else if (off >= 0x100000 && off < phys_last_addr) + + /* + * The legacy device mappings are included in the page tables and + * need their own test. + */ + if (off >= 0xa0000 && off < 0x100000) + goto out; + + p = vm_page_lookup_pa(off); + + if (p != NULL) { return -1; - else - return i386_btop(off); + } + +out: + return i386_btop(off); } diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index ab850442..239f63f4 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -106,11 +106,6 @@ static unsigned elf_shdr_shndx; #define RESERVED_BIOS 0x10000 -/* These indicate the total extent of physical memory addresses we're using. - They are page-aligned. */ -vm_offset_t phys_first_addr = 0; -vm_offset_t phys_last_addr; - /* A copy of the multiboot info structure passed by the boot loader. */ #ifdef MACH_XEN struct start_info boot_info; @@ -690,11 +685,6 @@ resettodr(void) writetodc(); } -unsigned int pmap_free_pages(void) -{ - return vm_page_atop(phys_last_addr); /* XXX */ -} - boolean_t init_alloc_aligned(vm_size_t size, vm_offset_t *addrp) { @@ -717,15 +707,3 @@ pmap_grab_page(void) panic("Not enough memory to initialize Mach"); return addr; } - -boolean_t pmap_valid_page(vm_offset_t x) -{ - /* XXX is this OK? What does it matter for? */ - return (((phys_first_addr <= x) && (x < phys_last_addr)) -#ifndef MACH_HYP - && !( - ((boot_info.mem_lower * 1024) <= x) && - (x < 1024*1024)) -#endif /* MACH_HYP */ - ); -} |