loader/multiboot_mbi2: Use central copy of grub_efi_find_mmap_size()
Delete local copy of function to determine required buffer size for the UEFI memory map, use helper in kern/efi/mm.c. Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
330dadc2bb
commit
1f245b31a8
1 changed files with 1 additions and 37 deletions
|
@ -411,42 +411,6 @@ acpiv2_size (void)
|
||||||
|
|
||||||
static grub_efi_uintn_t efi_mmap_size = 0;
|
static grub_efi_uintn_t efi_mmap_size = 0;
|
||||||
|
|
||||||
/* Find the optimal number of pages for the memory map. Is it better to
|
|
||||||
move this code to efi/mm.c? */
|
|
||||||
static void
|
|
||||||
find_efi_mmap_size (void)
|
|
||||||
{
|
|
||||||
efi_mmap_size = (1 << 12);
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
grub_efi_memory_descriptor_t *mmap;
|
|
||||||
grub_efi_uintn_t desc_size;
|
|
||||||
grub_efi_uintn_t cur_mmap_size = efi_mmap_size;
|
|
||||||
|
|
||||||
mmap = grub_malloc (cur_mmap_size);
|
|
||||||
if (! mmap)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ret = grub_efi_get_memory_map (&cur_mmap_size, mmap, 0, &desc_size, 0);
|
|
||||||
grub_free (mmap);
|
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
return;
|
|
||||||
else if (ret > 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (efi_mmap_size < cur_mmap_size)
|
|
||||||
efi_mmap_size = cur_mmap_size;
|
|
||||||
efi_mmap_size += (1 << 12);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Increase the size a bit for safety, because GRUB allocates more on
|
|
||||||
later, and EFI itself may allocate more. */
|
|
||||||
efi_mmap_size += (3 << 12);
|
|
||||||
|
|
||||||
efi_mmap_size = ALIGN_UP (efi_mmap_size, 4096);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static grub_size_t
|
static grub_size_t
|
||||||
|
@ -467,7 +431,7 @@ grub_multiboot2_get_mbi_size (void)
|
||||||
{
|
{
|
||||||
#ifdef GRUB_MACHINE_EFI
|
#ifdef GRUB_MACHINE_EFI
|
||||||
if (!keep_bs && !efi_mmap_size)
|
if (!keep_bs && !efi_mmap_size)
|
||||||
find_efi_mmap_size ();
|
efi_mmap_size = grub_efi_find_mmap_size ();
|
||||||
#endif
|
#endif
|
||||||
return 2 * sizeof (grub_uint32_t) + sizeof (struct multiboot_tag)
|
return 2 * sizeof (grub_uint32_t) + sizeof (struct multiboot_tag)
|
||||||
+ sizeof (struct multiboot_tag)
|
+ sizeof (struct multiboot_tag)
|
||||||
|
|
Loading…
Reference in a new issue