Remove grub_efi_allocate_pages.
grub_efi_allocate_pages Essentially does 2 unrelated things: * Allocate at fixed address. * Allocate at any address. To switch between 2 different functions it uses address == 0 as magic value which is wrong as 0 is a perfectly valid fixed adress to allocate at.
This commit is contained in:
parent
dd5fde2df8
commit
4bc909bf89
8 changed files with 32 additions and 34 deletions
|
@ -146,7 +146,7 @@ grub_efi_allocate_loader_memory (grub_uint32_t min_offset, grub_uint32_t size)
|
|||
continue;
|
||||
grub_dprintf("mm", "%s: let's allocate some (0x%x) pages @ 0x%08x...\n",
|
||||
__FUNCTION__, (size >> PAGE_SHIFT), (grub_addr_t) start);
|
||||
mem = grub_efi_allocate_pages (start, (size >> PAGE_SHIFT) + 1);
|
||||
mem = grub_efi_allocate_fixed (start, (size >> PAGE_SHIFT) + 1);
|
||||
grub_dprintf("mm", "%s: retval=0x%08x\n",
|
||||
__FUNCTION__, (grub_addr_t) mem);
|
||||
if (! mem)
|
||||
|
@ -189,7 +189,7 @@ grub_efi_prepare_platform (void)
|
|||
mmap_size = find_mmap_size ();
|
||||
if (! mmap_size)
|
||||
return GRUB_ERR_OUT_OF_MEMORY;
|
||||
mmap_buf = grub_efi_allocate_pages (0, page_align (mmap_size) >> 12);
|
||||
mmap_buf = grub_efi_allocate_any_pages (page_align (mmap_size) >> 12);
|
||||
if (! mmap_buf)
|
||||
return GRUB_ERR_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
@ -83,20 +83,19 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address,
|
|||
}
|
||||
|
||||
void *
|
||||
grub_efi_allocate_pages (grub_efi_physical_address_t address,
|
||||
grub_efi_allocate_any_pages (grub_efi_uintn_t pages)
|
||||
{
|
||||
return grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS,
|
||||
pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS,
|
||||
GRUB_EFI_LOADER_DATA);
|
||||
}
|
||||
|
||||
void *
|
||||
grub_efi_allocate_fixed (grub_efi_physical_address_t address,
|
||||
grub_efi_uintn_t pages)
|
||||
{
|
||||
grub_efi_allocate_type_t alloctype;
|
||||
|
||||
if (address == 0)
|
||||
{
|
||||
alloctype = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
|
||||
address = GRUB_EFI_MAX_USABLE_ADDRESS;
|
||||
}
|
||||
else
|
||||
alloctype = GRUB_EFI_ALLOCATE_ADDRESS;
|
||||
|
||||
return grub_efi_allocate_pages_real (address, pages, alloctype,
|
||||
return grub_efi_allocate_pages_real (address, pages,
|
||||
GRUB_EFI_ALLOCATE_ADDRESS,
|
||||
GRUB_EFI_LOADER_DATA);
|
||||
}
|
||||
|
||||
|
@ -404,7 +403,7 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map,
|
|||
pages = required_pages;
|
||||
}
|
||||
|
||||
addr = grub_efi_allocate_pages (start, pages);
|
||||
addr = grub_efi_allocate_fixed (start, pages);
|
||||
if (! addr)
|
||||
grub_fatal ("cannot allocate conventional memory %p with %u pages",
|
||||
(void *) ((grub_addr_t) start),
|
||||
|
@ -456,8 +455,7 @@ grub_efi_mm_init (void)
|
|||
int mm_status;
|
||||
|
||||
/* Prepare a memory region to store two memory maps. */
|
||||
memory_map = grub_efi_allocate_pages (0,
|
||||
2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
|
||||
memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
|
||||
if (! memory_map)
|
||||
grub_fatal ("cannot allocate memory");
|
||||
|
||||
|
@ -475,7 +473,7 @@ grub_efi_mm_init (void)
|
|||
/* Freeing/allocating operations may increase memory map size. */
|
||||
map_size += desc_size * 32;
|
||||
|
||||
memory_map = grub_efi_allocate_pages (0, 2 * BYTES_TO_PAGES (map_size));
|
||||
memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (map_size));
|
||||
if (! memory_map)
|
||||
grub_fatal ("cannot allocate memory");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue