[U-Boot] [PATCH 1/1] efi_loader: memory reservations according to e820 table

Alexander Graf agraf at suse.de
Tue Jan 16 14:40:15 UTC 2018



On 14.01.18 16:59, Heinrich Schuchardt wrote:
> On 01/14/2018 04:27 AM, Heinrich Schuchardt wrote:
>> On the x86 architecture the e820 BIOS table defines reserved memory.
>> Mark it as EFI reserved memory.
>>
> 
> Hello Simon, hello Bin,
> 
> is there a place in the x86 start up code where we could put the new
> e820_memory_reservation() function?
> 
> Putting this into the EFI mainline code is a bit awkward.

Maybe you could just use the e820 table for all RAM population?
Something like this:


diff --git a/arch/x86/lib/e820.c b/arch/x86/lib/e820.c
index 5babfde268..b88a4f8d3c 100644
--- a/arch/x86/lib/e820.c
+++ b/arch/x86/lib/e820.c
@@ -35,3 +35,32 @@ __weak unsigned install_e820_map(unsigned max_entries,

 	return 4;
 }
+
+#ifdef CONFIG_EFI_LOADER
+#include <efi_loader.h>
+
+void efi_add_known_memory(void)
+{
+    struct e820entry e820[32];
+    unsigned int i, num;
+    unsigned long start, pages;
+
+    num = install_e820_map(ARRAY_SIZE(e820), e820);
+
+    for (i = 0; i < num; ++i) {
+	start = e820[i].addr;
+	pages = ALIGN(e820[i].size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT;
+
+	switch (e820[i].type) {
+	case E820_RESERVED:
+		efi_add_memory_map(start, pages,
+				   EFI_RESERVED_MEMORY_TYPE, false);
+		break;
+	case E820_RAM:
+		efi_add_memory_map(start, pages,
+				   EFI_CONVENTIONAL_MEMORY, false);
+		break;
+        }
+    }
+}
+#endif


More information about the U-Boot mailing list