On Wed, Jun 27, 2018 at 06:17:16PM +0100, Leif Lindholm wrote:
> Since ARM platforms do not have a common memory map, add a helper
> function that finds the lowest address region with the EFI_MEMORY_WB
> attribute set in the UEFI memory map.
>
> Required for the arm64 efi linux loader to restrict the initrd
> location to where it will be accessible by the kernel at runtime.
>
> Signed-off-by: Leif Lindholm <address@hidden>
> ---
> grub-core/kern/efi/mm.c | 36 ++++++++++++++++++++++++++++++++++++
> include/grub/efi/efi.h | 3 +++
> 2 files changed, 39 insertions(+)
>
> diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
> index fd39d23b4..10ffa2c9b 100644
> --- a/grub-core/kern/efi/mm.c
> +++ b/grub-core/kern/efi/mm.c
> @@ -629,3 +629,39 @@ grub_efi_mm_init (void)
> grub_efi_free_pages ((grub_addr_t) memory_map,
> 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
> }
> +
> +#if defined (__aarch64__)
> +grub_err_t
> +grub_efi_get_ram_base(grub_addr_t *base_addr)
> +{
> + grub_efi_memory_descriptor_t *memory_map;
> + grub_efi_memory_descriptor_t *desc;
grub_efi_memory_descriptor_t *desc, *memory_map;
For readability and ease of understanding, I think mmap_size should be renamed to memory_map_size (or the other way around) to explicit/uniformize naming.
> + grub_efi_uintn_t mmap_size;
> + grub_efi_uintn_t desc_size;
grub_efi_uintn_t desc_size, mmap_size;
> + int ret;
> +
> + mmap_size = grub_efi_find_mmap_size();
> +
> + memory_map = grub_malloc (mmap_size);
> + if (! memory_map)
> + return GRUB_ERR_OUT_OF_MEMORY;
> + ret = grub_efi_get_memory_map (&mmap_size, memory_map, NULL,
> + &desc_size, NULL);
> +
> + if (ret < 1)
> + return GRUB_ERR_BUG;
> +
> + for (desc = memory_map, *base_addr = GRUB_UINT_MAX;
> + (grub_addr_t) desc < ((grub_addr_t) memory_map + mmap_size);
> + desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
> + {
> + if (desc->attribute & GRUB_EFI_MEMORY_WB)
*base_addr = grub_min (*base_addr, desc->physical_start);
> + if (desc->physical_start < *base_addr)
> + *base_addr = desc->physical_start;
> + }
And then you can drop these curly brackets.
Daniel
_______________________________________________
Grub-devel mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/grub-devel