diff options
Diffstat (limited to 'lib/efi_loader/efi_memory.c')
-rw-r--r-- | lib/efi_loader/efi_memory.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 8a1e249..71a3d19 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -220,7 +220,7 @@ efi_status_t efi_allocate_pages(int type, int memory_type, switch (type) { case 0: /* Any page */ - addr = efi_find_free_memory(len, gd->ram_top); + addr = efi_find_free_memory(len, gd->start_addr_sp); if (!addr) { r = EFI_NOT_FOUND; break; @@ -286,10 +286,13 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size, uint32_t *descriptor_version) { ulong map_size = 0; + int map_entries = 0; struct list_head *lhandle; list_for_each(lhandle, &efi_mem) - map_size += sizeof(struct efi_mem_desc); + map_entries++; + + map_size = map_entries * sizeof(struct efi_mem_desc); *memory_map_size = map_size; @@ -301,12 +304,14 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size, /* Copy list into array */ if (memory_map) { + /* Return the list in ascending order */ + memory_map = &memory_map[map_entries - 1]; list_for_each(lhandle, &efi_mem) { struct efi_mem_list *lmem; lmem = list_entry(lhandle, struct efi_mem_list, link); *memory_map = lmem->desc; - memory_map++; + memory_map--; } } @@ -315,9 +320,9 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size, int efi_memory_init(void) { - uint64_t runtime_start, runtime_end, runtime_pages; - uint64_t uboot_start, uboot_pages; - uint64_t uboot_stack_size = 16 * 1024 * 1024; + unsigned long runtime_start, runtime_end, runtime_pages; + unsigned long uboot_start, uboot_pages; + unsigned long uboot_stack_size = 16 * 1024 * 1024; int i; /* Add RAM */ |