Fix potential memmap circular dependency issue

This commit is contained in:
mintsuki 2020-09-26 15:06:59 +02:00
parent 0403a29f76
commit 11240b59a5
3 changed files with 14 additions and 11 deletions

Binary file not shown.

View File

@ -207,12 +207,14 @@ void stivale_load(char *cmdline, int boot_drive) {
size_t memmap_entries; size_t memmap_entries;
struct e820_entry_t *memmap = get_memmap(&memmap_entries); struct e820_entry_t *memmap = get_memmap(&memmap_entries);
stivale_struct.memory_map_entries = (uint64_t)memmap_entries;
stivale_struct.memory_map_addr = (uint64_t)(size_t)memmap;
bool want_5lv = level5pg && (stivale_hdr.flags & (1 << 1)); bool want_5lv = level5pg && (stivale_hdr.flags & (1 << 1));
pagemap_t pagemap = stivale_build_pagemap(want_5lv, memmap, memmap_entries); pagemap_t pagemap = stivale_build_pagemap(want_5lv, memmap, memmap_entries);
memmap = get_memmap(&memmap_entries);
stivale_struct.memory_map_entries = (uint64_t)memmap_entries;
stivale_struct.memory_map_addr = (uint64_t)(size_t)memmap;
stivale_spinup(bits, want_5lv, pagemap, stivale_spinup(bits, want_5lv, pagemap,
entry_point, &stivale_struct, stivale_hdr.stack); entry_point, &stivale_struct, stivale_hdr.stack);
} }

View File

@ -292,7 +292,15 @@ void stivale2_load(char *cmdline, int boot_drive) {
} }
size_t memmap_entries; size_t memmap_entries;
struct e820_entry_t *memmap; struct e820_entry_t *memmap = get_memmap(&memmap_entries);
// Check if 5-level paging tag is requesting support
bool level5pg_requested = get_tag(&stivale2_hdr, STIVALE2_HEADER_TAG_5LV_PAGING_ID) ? true : false;
pagemap_t pagemap = {0};
if (bits == 64)
pagemap = stivale_build_pagemap(level5pg && level5pg_requested,
memmap, memmap_entries);
////////////////////////////////////////////// //////////////////////////////////////////////
// Create memmap struct tag // Create memmap struct tag
@ -308,17 +316,10 @@ void stivale2_load(char *cmdline, int boot_drive) {
void *tag_memmap = conv_mem_alloc_aligned(sizeof(struct e820_entry_t) * memmap_entries, 1); void *tag_memmap = conv_mem_alloc_aligned(sizeof(struct e820_entry_t) * memmap_entries, 1);
memcpy(tag_memmap, memmap, sizeof(struct e820_entry_t) * memmap_entries); memcpy(tag_memmap, memmap, sizeof(struct e820_entry_t) * memmap_entries);
print_memmap(memmap, memmap_entries);
append_tag(&stivale2_struct, (struct stivale2_tag *)tag); append_tag(&stivale2_struct, (struct stivale2_tag *)tag);
} }
// Check if 5-level paging tag is requesting support
bool level5pg_requested = get_tag(&stivale2_hdr, STIVALE2_HEADER_TAG_5LV_PAGING_ID) ? true : false;
pagemap_t pagemap = {0};
if (bits == 64)
pagemap = stivale_build_pagemap(level5pg && level5pg_requested,
memmap, memmap_entries);
////////////////////////////////////////////// //////////////////////////////////////////////
// Create SMP struct tag // Create SMP struct tag
////////////////////////////////////////////// //////////////////////////////////////////////