efi: Misc bug fixes
This commit is contained in:
parent
0c46de53d8
commit
3b18864e6f
|
@ -321,8 +321,8 @@ void init_memmap(void) {
|
|||
|
||||
allocations_disallowed = false;
|
||||
|
||||
// Let's leave 64MiB to the firmware
|
||||
ext_mem_alloc_type(65536, MEMMAP_EFI_RECLAIMABLE);
|
||||
// Let's leave 16MiB to the firmware
|
||||
ext_mem_alloc_type(0x1000000, MEMMAP_EFI_RECLAIMABLE);
|
||||
|
||||
memcpy(untouched_memmap, memmap, memmap_entries * sizeof(struct e820_entry_t));
|
||||
untouched_memmap_entries = memmap_entries;
|
||||
|
@ -453,6 +453,8 @@ void pmm_reclaim_uefi_mem(void) {
|
|||
void pmm_release_uefi_mem(void) {
|
||||
EFI_STATUS status;
|
||||
|
||||
sanitise_entries(memmap, &memmap_entries, true);
|
||||
|
||||
for (size_t i = 0; i < memmap_entries; i++) {
|
||||
if (memmap[i].type != MEMMAP_USABLE
|
||||
&& memmap[i].type != MEMMAP_BOOTLOADER_RECLAIMABLE) {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <lib/fb.h>
|
||||
#include <lib/uri.h>
|
||||
#include <lib/print.h>
|
||||
#include <lib/libc.h>
|
||||
#include <sys/idt.h>
|
||||
#include <drivers/vga_textmode.h>
|
||||
#include <mm/pmm.h>
|
||||
|
@ -119,8 +120,14 @@ void chainload(char *config) {
|
|||
if (!uri_open(image, image_path))
|
||||
panic("chainload: Failed to open image with path `%s`. Is the path correct?", image_path);
|
||||
|
||||
void *ptr = freadall(image, MEMMAP_RESERVED);
|
||||
void *_ptr = freadall(image, MEMMAP_RESERVED);
|
||||
size_t image_size = image->size;
|
||||
void *ptr;
|
||||
status = uefi_call_wrapper(gBS->AllocatePool, 3,
|
||||
EfiLoaderData, image_size, &ptr);
|
||||
if (status)
|
||||
panic("chainload: Allocation failure");
|
||||
memcpy(ptr, _ptr, image_size);
|
||||
|
||||
term_deinit();
|
||||
|
||||
|
|
|
@ -86,10 +86,15 @@ void stivale2_main(struct stivale2_struct *info) {
|
|||
struct stivale2_struct_tag_memmap *m = (struct stivale2_struct_tag_memmap *)tag;
|
||||
e9_puts("Memmap tag:");
|
||||
e9_printf("\tEntries: %d", m->entries);
|
||||
size_t total_mem = 0;
|
||||
for (size_t i = 0; i < m->entries; i++) {
|
||||
struct stivale2_mmap_entry me = m->memmap[i];
|
||||
e9_printf("\t\t[%x+%x] %x", me.base, me.length, me.type);
|
||||
if (m->memmap[i].type == 1) {
|
||||
total_mem += m->memmap[i].length;
|
||||
}
|
||||
}
|
||||
e9_printf("\tTotal usable memory: %d", total_mem);
|
||||
break;
|
||||
}
|
||||
case STIVALE2_STRUCT_TAG_FRAMEBUFFER_ID: {
|
||||
|
|
Loading…
Reference in New Issue