summaryrefslogtreecommitdiff
path: root/arch/x86/machine/biosmem.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2016-09-05 18:56:49 +0200
committerRichard Braun <rbraun@sceen.net>2016-09-05 22:21:58 +0200
commitc35dbefc2803651482bf9935014e2203c7f7fe67 (patch)
treeda96b1e5154e1f7cd995a4bd6699882a5addd7d9 /arch/x86/machine/biosmem.h
parent31ddc921d18c9d440aab18b7f504dc8cd571be2c (diff)
x86/biosmem: explicitely track boot data
Even after its last rework, the biosmem module suffered a number of problems. First, the biosmem_find_heap function was too naive, and may have fail if the boot data were not properly sorted. Second, the biosmem_free_usable function forced the user to save all boot data, and would fail in a way similar to biosmem_find_heap depending on the memory map, the kernel and the heap ranges. This change finally brings a true solution to the problem of early allocation by properly tracking all boot data in a sorted array. When registering boot data, the user can mark them temporary, so that they're automatically unregistered when releasing additional memory once the VM system is ready. It also makes the biosmem module a lot less dependent on the multiboot information, using them only to build its internal memory map. The registration of boot data is now performed by the boot module.
Diffstat (limited to 'arch/x86/machine/biosmem.h')
-rw-r--r--arch/x86/machine/biosmem.h37
1 files changed, 26 insertions, 11 deletions
diff --git a/arch/x86/machine/biosmem.h b/arch/x86/machine/biosmem.h
index 2c0829d..d1de115 100644
--- a/arch/x86/machine/biosmem.h
+++ b/arch/x86/machine/biosmem.h
@@ -42,26 +42,42 @@
#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.
+ *
+ * This function is called before paging is enabled.
*/
-void biosmem_bootstrap(struct multiboot_raw_info *mbi);
+void biosmem_register_boot_data(phys_addr_t start, phys_addr_t end, bool 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.
+ *
+ * This function is called before paging is enabled.
+ */
+void biosmem_bootstrap(const struct multiboot_raw_info *mbi);
/*
* 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)
* which means they can be freed like other regular pages. Users should
* fix up the type of those pages once the VM system is initialized.
+ *
+ * This function is called before paging is enabled.
*/
void * biosmem_bootalloc(unsigned int nr_pages);
@@ -79,9 +95,8 @@ void biosmem_setup(void);
/*
* Free all usable memory.
*
- * This includes ranges that weren't part of the bootstrap allocator initial
- * heap, e.g. because they contained boot data. Any boot data to keep must
- * be saved before calling this function.
+ * This function releases all pages that aren't used by boot data and have
+ * not already been loaded into the VM system.
*/
void biosmem_free_usable(void);