[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm*
From: |
Leif Lindholm |
Subject: |
Re: [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm* |
Date: |
Tue, 8 Aug 2017 17:04:54 +0100 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On Thu, Aug 03, 2017 at 03:30:40PM +0000, Vladimir 'phcoder' Serbinenko wrote:
> Any reason to use plain error numbers without grub_error?
Well, no.
In the way I'm using it, it will cascade down to a
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
on failure.
Do we need a specific one for "unable to determine memory start address"?
Or is there an existing error string we could reuse?
/
Leif
> Le Thu, Aug 3, 2017 à 12:09 PM, Leif Lindholm <address@hidden> a
> écrit :
>
> > 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 arm/arm64 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 31ca703ec..8413c19e5 100644
> > --- a/grub-core/kern/efi/mm.c
> > +++ b/grub-core/kern/efi/mm.c
> > @@ -569,3 +569,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_uintn_t mmap_size;
> > + grub_efi_uintn_t desc_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)
> > + if (desc->physical_start < *base_addr)
> > + *base_addr = desc->physical_start;
> > + }
> > +
> > + grub_free(memory_map);
> > +
> > + return GRUB_ERR_NONE;
> > +}
> > +#endif
> > diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
> > index 3984de083..80ab56795 100644
> > --- a/include/grub/efi/efi.h
> > +++ b/include/grub/efi/efi.h
> > @@ -85,6 +85,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config))
> > (grub_efi_handle_t hnd,
> > #if defined(__arm__) || defined(__aarch64__)
> > void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
> > #endif
> > +#if defined(__aarch64__)
> > +grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
> > +#endif
> >
> > grub_addr_t grub_efi_modules_addr (void);
> >
> > --
> > 2.11.0
> >
> >
> > _______________________________________________
> > Grub-devel mailing list
> > address@hidden
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> >
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/grub-devel
- [PATCH v2 00/14] efi: improved correctness, arm unification, and cleanup, Leif Lindholm, 2017/08/03
- [PATCH v2 01/14] arm64/efi: move EFI_PAGE definitions to efi/memory.h, Leif Lindholm, 2017/08/03
- [PATCH v2 04/14] efi: add grub_efi_get_ram_base() function for arm*, Leif Lindholm, 2017/08/03
- [PATCH v2 02/14] efi: add central copy of grub_efi_find_mmap_size, Leif Lindholm, 2017/08/03
- [PATCH v2 03/14] loader: drop local implementations of find_efi_mmap_size, Leif Lindholm, 2017/08/03
- [PATCH v2 06/14] efi: move fdt helper library, Leif Lindholm, 2017/08/03
- [PATCH v2 05/14] efi: refactor grub_efi_allocate_pages, Leif Lindholm, 2017/08/03
- [PATCH v2 07/14] efi: Add GRUB_PE32_MAGIC definition, Leif Lindholm, 2017/08/03