Also generalised a small number of static functions within biosmem.c
to support deferred multiboot2 implementation.
---
i386/i386at/biosmem.c | 22 ++++++++++++++--------
i386/i386at/biosmem.h | 4 +++-
i386/i386at/model_dep.c | 6 +++++-
3 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/i386/i386at/biosmem.c b/i386/i386at/biosmem.c
index 99af593f..0e87ce08 100644
--- a/i386/i386at/biosmem.c
+++ b/i386/i386at/biosmem.c
@@ -301,19 +301,19 @@ biosmem_map_build(const struct multiboot_raw_info *mbi)
}
static void __boot
-biosmem_map_build_simple(const struct multiboot_raw_info *mbi)
+biosmem_map_build_simple(const uint32_t mem_lower, const uint32_t mem_upper)
{
struct biosmem_map_entry *entry;
entry = biosmem_map;
entry->base_addr = 0;
- entry->length = mbi->mem_lower << 10;
+ entry->length = mem_lower << 10;
entry->type = BIOSMEM_TYPE_AVAILABLE;
biosmem_map_adjust_alignment(entry);
entry++;
entry->base_addr = BIOSMEM_END;
- entry->length = mbi->mem_upper << 10;
+ entry->length = mem_upper << 10;
entry->type = BIOSMEM_TYPE_AVAILABLE;
biosmem_map_adjust_alignment(entry);
@@ -625,7 +625,7 @@ biosmem_find_avail(phys_addr_t start, phys_addr_t end,
#ifndef MACH_HYP
static void __boot
-biosmem_setup_allocator(const struct multiboot_raw_info *mbi)
+biosmem_setup_allocator(const uint32_t mem_upper)
{
phys_addr_t heap_start, heap_end, max_heap_start, max_heap_end;
phys_addr_t start, end;
@@ -635,7 +635,7 @@ biosmem_setup_allocator(const struct multiboot_raw_info
*mbi)
* Find some memory for the heap. Look for the largest unused area in
* upper memory, carefully avoiding all boot data.
*/
- end = vm_page_trunc((mbi->mem_upper + 1024) << 10);
+ end = vm_page_trunc((mem_upper + 1024) << 10);
if (end > VM_PAGE_DIRECTMAP_LIMIT)
end = VM_PAGE_DIRECTMAP_LIMIT;
@@ -797,15 +797,21 @@ biosmem_xen_bootstrap(void)
#else /* MACH_HYP */
void __boot
-biosmem_bootstrap(const struct multiboot_raw_info *mbi)
+biosmem_mb1_bootstrap(const struct multiboot_raw_info *mbi)
{
if (mbi->flags & MULTIBOOT_LOADER_MMAP)
biosmem_map_build(mbi);
else
- biosmem_map_build_simple(mbi);
+ biosmem_map_build_simple(mbi->mem_lower, mbi->mem_upper);
biosmem_bootstrap_common();
- biosmem_setup_allocator(mbi);
+ biosmem_setup_allocator(mbi->mem_upper);
+}
+
+void __boot
+biosmem_mb2_bootstrap(const struct multiboot2_raw_info* mbi)
+{
+ (void)mbi;
}
#endif /* MACH_HYP */
diff --git a/i386/i386at/biosmem.h b/i386/i386at/biosmem.h
index 76ab23a0..e20f6e6c 100644
--- a/i386/i386at/biosmem.h
+++ b/i386/i386at/biosmem.h
@@ -20,6 +20,7 @@
#include <mach/machine/vm_types.h>
#include <mach/machine/multiboot.h>
+#include <mach/machine/multiboot2.h>
/*
* Address where the address of the Extended BIOS Data Area segment can be
@@ -65,7 +66,8 @@ void biosmem_register_boot_data(phys_addr_t start,
phys_addr_t end,
#ifdef MACH_HYP
void biosmem_xen_bootstrap(void);
#else /* MACH_HYP */
-void biosmem_bootstrap(const struct multiboot_raw_info *mbi);
+void biosmem_mb1_bootstrap(const struct multiboot_raw_info *mbi);
+void biosmem_mb2_bootstrap(const struct multiboot2_raw_info *mbi);
#endif /* MACH_HYP */
/*
diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
index 173c60f4..27c52385 100644
--- a/i386/i386at/model_dep.c
+++ b/i386/i386at/model_dep.c
@@ -427,7 +427,11 @@ i386at_init(void)
biosmem_xen_bootstrap();
#else /* MACH_HYP */
register_boot_data(mb2_info);
- biosmem_bootstrap((struct multiboot_raw_info *) &boot_info);
+
+ if (mb2_info != NULL)
+ biosmem_mb2_bootstrap(mb2_info);
+ else
+ biosmem_mb1_bootstrap(&boot_info);
#endif /* MACH_HYP */
#ifdef MACH_XEN
--
2.47.3