diff options
author | Roy Franz <roy.franz@linaro.org> | 2014-01-28 13:41:28 -0500 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2014-04-17 07:28:55 -0400 |
commit | 9bb40191e88d23563fd0467ac195debf5f6daaf9 (patch) | |
tree | 2a8bcbe9635013b5f39083ac16959c7757182061 /drivers/firmware | |
parent | f966ea021f947b20c22b31194d7e3042375c7f24 (diff) |
efi: Add get_dram_base() helper function
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>
Diffstat (limited to 'drivers/firmware')
-rw-r--r-- | drivers/firmware/efi/efi-stub-helper.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c index 1bf439be9138..a168dd20511f 100644 --- a/drivers/firmware/efi/efi-stub-helper.c +++ b/drivers/firmware/efi/efi-stub-helper.c | |||
@@ -11,6 +11,10 @@ | |||
11 | */ | 11 | */ |
12 | #define EFI_READ_CHUNK_SIZE (1024 * 1024) | 12 | #define EFI_READ_CHUNK_SIZE (1024 * 1024) |
13 | 13 | ||
14 | /* error code which can't be mistaken for valid address */ | ||
15 | #define EFI_ERROR (~0UL) | ||
16 | |||
17 | |||
14 | struct file_info { | 18 | struct file_info { |
15 | efi_file_handle_t *handle; | 19 | efi_file_handle_t *handle; |
16 | u64 size; | 20 | u64 size; |
@@ -83,6 +87,32 @@ fail: | |||
83 | return status; | 87 | return status; |
84 | } | 88 | } |
85 | 89 | ||
90 | |||
91 | static unsigned long __init get_dram_base(efi_system_table_t *sys_table_arg) | ||
92 | { | ||
93 | efi_status_t status; | ||
94 | unsigned long map_size; | ||
95 | unsigned long membase = EFI_ERROR; | ||
96 | struct efi_memory_map map; | ||
97 | efi_memory_desc_t *md; | ||
98 | |||
99 | status = efi_get_memory_map(sys_table_arg, (efi_memory_desc_t **)&map.map, | ||
100 | &map_size, &map.desc_size, NULL, NULL); | ||
101 | if (status != EFI_SUCCESS) | ||
102 | return membase; | ||
103 | |||
104 | map.map_end = map.map + map_size; | ||
105 | |||
106 | for_each_efi_memory_desc(&map, md) | ||
107 | if (md->attribute & EFI_MEMORY_WB) | ||
108 | if (membase > md->phys_addr) | ||
109 | membase = md->phys_addr; | ||
110 | |||
111 | efi_call_early(free_pool, map.map); | ||
112 | |||
113 | return membase; | ||
114 | } | ||
115 | |||
86 | /* | 116 | /* |
87 | * Allocate at the highest possible address that is not above 'max'. | 117 | * Allocate at the highest possible address that is not above 'max'. |
88 | */ | 118 | */ |