@@ -4,6 +4,7 @@
*/
#include <efi_loader.h>
+#include <lmb.h>
#include <asm/e820.h>
#include <asm/global_data.h>
@@ -41,15 +42,11 @@ void efi_add_known_memory(void)
{
struct e820_entry e820[E820MAX];
unsigned int i, num;
- u64 start, ram_top;
+ u64 start;
int type;
num = install_e820_map(ARRAY_SIZE(e820), e820);
- ram_top = (u64)gd->ram_top & ~EFI_PAGE_MASK;
- if (!ram_top)
- ram_top = 0x100000000ULL;
-
for (i = 0; i < num; ++i) {
start = e820[i].addr;
@@ -72,13 +69,41 @@ void efi_add_known_memory(void)
break;
}
- if (type == EFI_CONVENTIONAL_MEMORY) {
- efi_add_conventional_memory_map(start,
- start + e820[i].size,
- ram_top);
- } else {
+ if (type != EFI_CONVENTIONAL_MEMORY)
efi_add_memory_map(start, e820[i].size, type);
- }
}
}
#endif /* CONFIG_IS_ENABLED(EFI_LOADER) */
+
+#if CONFIG_IS_ENABLED(LMB)
+void lmb_add_memory(void)
+{
+ struct e820_entry e820[E820MAX];
+ unsigned int i, num;
+ u64 ram_top;
+
+ num = install_e820_map(ARRAY_SIZE(e820), e820);
+
+ ram_top = (u64)gd->ram_top & ~EFI_PAGE_MASK;
+ if (!ram_top)
+ ram_top = 0x100000000ULL;
+
+ for (i = 0; i < num; ++i) {
+ if (e820[i].type == E820_RAM) {
+ u64 start, size, rgn_top;
+
+ start = e820[i].addr;
+ size = e820[i].size;
+ rgn_top = start + size;
+
+ if (start > ram_top)
+ continue;
+
+ if (rgn_top > ram_top)
+ size -= rgn_top - ram_top;
+
+ lmb_add(start, size);
+ }
+ }
+}
+#endif /* CONFIG_IS_ENABLED(LMB) */
The EFI_CONVENTIONAL_MEMORY type is now being managed through the LMB module. Add a separate function, lmb_add_memory() to add the RAM memory to the LMB memory map. The efi_add_known_memory() function is now used for adding any other memory type to the EFI memory map. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> --- Changes since V1: New patch arch/x86/lib/e820.c | 47 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-)