mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
efi: Iterate over efi.memmap in for_each_efi_memory_desc()
Most of the users of for_each_efi_memory_desc() are equally happy iterating over the EFI memory map in efi.memmap instead of 'memmap', since the former is usually a pointer to the latter. For those users that want to specify an EFI memory map other than efi.memmap, that can be done using for_each_efi_memory_desc_in_map(). One such example is in the libstub code where the firmware is queried directly for the memory map, it gets iterated over, and then freed. This change goes part of the way toward deleting the global 'memmap' variable, which is not universally available on all architectures (notably IA64) and is rather poorly named. Signed-off-by: Matt Fleming <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Leif Lindholm <[email protected]> Cc: Mark Salter <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
30d7bf034c
commit
78ce248faa
9 changed files with 39 additions and 56 deletions
|
|
@ -40,7 +40,7 @@ static phys_addr_t efi_to_phys(unsigned long addr)
|
|||
{
|
||||
efi_memory_desc_t *md;
|
||||
|
||||
for_each_efi_memory_desc(&memmap, md) {
|
||||
for_each_efi_memory_desc_in_map(&memmap, md) {
|
||||
if (!(md->attribute & EFI_MEMORY_RUNTIME))
|
||||
continue;
|
||||
if (md->virt_addr == 0)
|
||||
|
|
@ -145,7 +145,7 @@ static __init void reserve_regions(void)
|
|||
if (efi_enabled(EFI_DBG))
|
||||
pr_info("Processing EFI memory map:\n");
|
||||
|
||||
for_each_efi_memory_desc(&memmap, md) {
|
||||
for_each_efi_memory_desc_in_map(&memmap, md) {
|
||||
paddr = md->phys_addr;
|
||||
npages = md->num_pages;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static bool __init efi_virtmap_init(void)
|
|||
init_new_context(NULL, &efi_mm);
|
||||
|
||||
systab_found = false;
|
||||
for_each_efi_memory_desc(&memmap, md) {
|
||||
for_each_efi_memory_desc(md) {
|
||||
phys_addr_t phys = md->phys_addr;
|
||||
int ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -620,16 +620,12 @@ char * __init efi_md_typeattr_format(char *buf, size_t size,
|
|||
*/
|
||||
u64 __weak efi_mem_attributes(unsigned long phys_addr)
|
||||
{
|
||||
struct efi_memory_map *map;
|
||||
efi_memory_desc_t *md;
|
||||
void *p;
|
||||
|
||||
if (!efi_enabled(EFI_MEMMAP))
|
||||
return 0;
|
||||
|
||||
map = efi.memmap;
|
||||
for (p = map->map; p < map->map_end; p += map->desc_size) {
|
||||
md = p;
|
||||
for_each_efi_memory_desc(md) {
|
||||
if ((md->phys_addr <= phys_addr) &&
|
||||
(phys_addr < (md->phys_addr +
|
||||
(md->num_pages << EFI_PAGE_SHIFT))))
|
||||
|
|
|
|||
|
|
@ -68,8 +68,7 @@ void __init efi_fake_memmap(void)
|
|||
return;
|
||||
|
||||
/* count up the number of EFI memory descriptor */
|
||||
for (old = memmap.map; old < memmap.map_end; old += memmap.desc_size) {
|
||||
md = old;
|
||||
for_each_efi_memory_desc(md) {
|
||||
start = md->phys_addr;
|
||||
end = start + (md->num_pages << EFI_PAGE_SHIFT) - 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -125,10 +125,12 @@ unsigned long get_dram_base(efi_system_table_t *sys_table_arg)
|
|||
|
||||
map.map_end = map.map + map_size;
|
||||
|
||||
for_each_efi_memory_desc(&map, md)
|
||||
if (md->attribute & EFI_MEMORY_WB)
|
||||
for_each_efi_memory_desc_in_map(&map, md) {
|
||||
if (md->attribute & EFI_MEMORY_WB) {
|
||||
if (membase > md->phys_addr)
|
||||
membase = md->phys_addr;
|
||||
}
|
||||
}
|
||||
|
||||
efi_call_early(free_pool, map.map);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue