diff options
author | Richard Braun <rbraun@sceen.net> | 2016-09-05 23:47:22 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2016-09-06 00:02:03 +0200 |
commit | ae902513130a14ffded5d00216e8729d3f5ed7fa (patch) | |
tree | 3f14e5be9f791d0a32721f8463fd85b913dce959 /i386/i386at/biosmem.h | |
parent | f6a2436d282a06e5f34789c8c5917e838fa26643 (diff) | |
download | gnumach-ae902513130a14ffded5d00216e8729d3f5ed7fa.tar.gz gnumach-ae902513130a14ffded5d00216e8729d3f5ed7fa.tar.bz2 gnumach-ae902513130a14ffded5d00216e8729d3f5ed7fa.zip |
Make early physical page allocation truely reliable
Import upstream biosmem changes and adjust for local modifications.
Specifically, this change makes the biosmem module reliably track all
boot data by storing their addresses in a sorted array. This allows
both the early page allocator and the biosmem_free_usable function
to accurately find any range of free pages.
* i386/i386at/biosmem.c: Remove inclusion of <i386at/elf.h>.
(_start, _end): Remove variable declarations.
(BIOSMEM_MAX_BOOT_DATA): New macro.
(struct biosmem_boot_data): New type.
(biosmem_boot_data_array, biosmem_nr_boot_data): New variables.
(biosmem_heap_start, biosmem_heap_bottom, biosmem_heap_top,
biosmem_heap_end): Change type to phys_addr_t.
(biosmem_panic_inval_boot_data): New variable.
(biosmem_panic_too_many_boot_data): Likewise.
(biosmem_panic_toobig_msg): Variable renamed ...
(biosmem_panic_too_big_msg): ... to this.
(biosmem_register_boot_data): New function.
(biosmem_unregister_boot_data): Likewise.
(biosmem_map_adjust): Update reference to panic message.
(biosmem_map_find_avail): Add detailed description.
(biosmem_save_cmdline_sizes): Remove function.
(biosmem_find_heap_clip): Likewise.
(biosmem_find_heap): Likewise.
(biosmem_find_avail_clip, biosmem_find_avail): New functions.
(biosmem_setup_allocator): Receive const multiboot info, replace
calls to biosmem_find_heap with calls to biosmem_find_avail and
update accordingly. Register the heap as boot data.
(biosmem_xen_bootstrap): Register the Xen boot info and the heap as
boot data.
(biosmem_bootstrap): Receive const multiboot information. Remove call
to biosmem_save_cmdline_sizes.
(biosmem_bootalloc): Remove assertion on the VM system state.
(biosmem_type_desc, biosmem_map_show): Build only if DEBUG is true.
(biosmem_unregister_temporary_boot_data): New function.
(biosmem_free_usable_range): Change address range format.
(biosmem_free_usable_entry): Rewrite to use biosmem_find_avail
without abusing it.
(biosmem_free_usable): Call biosmem_unregister_temporary_boot_data,
update call to biosmem_free_usable_entry.
* i386/i386at/biosmem.h (biosmem_register_boot_data): New function.
(biosmem_bootalloc): Update description.
(biosmem_bootstrap): Update description and declaration.
(biosmem_free_usable): Likewise.
* i386/i386at/model_dep.c: Include <i386at/elf.h>.
(machine_init): Update call to biosmem_free_usable.
(register_boot_data): New function.
(i386at_init): Call register_boot_data where appropriate.
Diffstat (limited to 'i386/i386at/biosmem.h')
-rw-r--r-- | i386/i386at/biosmem.h | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/i386/i386at/biosmem.h b/i386/i386at/biosmem.h index f48cfc30..7824c168 100644 --- a/i386/i386at/biosmem.h +++ b/i386/i386at/biosmem.h @@ -40,25 +40,39 @@ #define BIOSMEM_END 0x100000 /* - * Early initialization of the biosmem module. + * Report reserved addresses to the biosmem module. * - * This function processes the given multiboot data for BIOS-provided - * memory information, and sets up a bootstrap physical page allocator. + * Once all boot data have been registered, the user can set up the + * early page allocator. * - * It is called before paging is enabled. + * If the range is marked temporary, it will be unregistered when + * biosmem_free_usable() is called, so that pages that used to store + * these boot data may be released to the VM system. + */ +void biosmem_register_boot_data(phys_addr_t start, phys_addr_t end, + boolean_t temporary); + +/* + * Initialize the early page allocator. + * + * This function uses the memory map provided by the boot loader along + * with the registered boot data addresses to set up a heap of free pages + * of physical memory. + * + * Note that on Xen, this function registers all the Xen boot information + * as boot data itself. */ #ifdef MACH_HYP void biosmem_xen_bootstrap(void); #else /* MACH_HYP */ -void biosmem_bootstrap(struct multiboot_raw_info *mbi); +void biosmem_bootstrap(const struct multiboot_raw_info *mbi); #endif /* MACH_HYP */ /* * Allocate contiguous physical pages during bootstrap. * - * This function is called before paging is enabled. The pages returned - * are guaranteed to be part of the direct physical mapping when paging - * is enabled. + * The pages returned are guaranteed to be part of the direct physical + * mapping when paging is enabled. * * This function should only be used to allocate initial page table pages. * Those pages are later loaded into the VM system (as reserved pages) @@ -80,9 +94,10 @@ void biosmem_setup(void); /* * Free all usable memory. + * + * This function releases all pages that aren't used by boot data and have + * not already been loaded into the VM system. */ -#ifndef MACH_HYP -void biosmem_free_usable(struct multiboot_raw_info *mbi); -#endif /* MACH_HYP */ +void biosmem_free_usable(void); #endif /* _X86_BIOSMEM_H */ |