Skip to content

Commit

Permalink
efi: Add get_dram_base() helper function
Browse files Browse the repository at this point in the history
Add the get_dram_base() function, shared by arm/arm64.

Signed-off-by: Roy Franz <roy.franz@linaro.org>
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
  • Loading branch information
Roy Franz authored and Matt Fleming committed Apr 17, 2014
1 parent f966ea0 commit 9bb4019
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions drivers/firmware/efi/efi-stub-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
*/
#define EFI_READ_CHUNK_SIZE (1024 * 1024)

/* error code which can't be mistaken for valid address */
#define EFI_ERROR (~0UL)


struct file_info {
efi_file_handle_t *handle;
u64 size;
Expand Down Expand Up @@ -83,6 +87,32 @@ static efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
return status;
}


static unsigned long __init get_dram_base(efi_system_table_t *sys_table_arg)
{
efi_status_t status;
unsigned long map_size;
unsigned long membase = EFI_ERROR;
struct efi_memory_map map;
efi_memory_desc_t *md;

status = efi_get_memory_map(sys_table_arg, (efi_memory_desc_t **)&map.map,
&map_size, &map.desc_size, NULL, NULL);
if (status != EFI_SUCCESS)
return membase;

map.map_end = map.map + map_size;

for_each_efi_memory_desc(&map, md)
if (md->attribute & EFI_MEMORY_WB)
if (membase > md->phys_addr)
membase = md->phys_addr;

efi_call_early(free_pool, map.map);

return membase;
}

/*
* Allocate at the highest possible address that is not above 'max'.
*/
Expand Down

0 comments on commit 9bb4019

Please sign in to comment.