* kern/efi/mm.c (grub_efi_mm_init): Handle systems with memory maps

larger than MEMORY_MAP_SIZE.
This commit is contained in:
Colin Watson 2010-06-21 17:59:51 +01:00
parent 14d3f08e70
commit d6e98a17d7
2 changed files with 25 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2010-06-21 Colin Watson <cjwatson@ubuntu.com>
* kern/efi/mm.c (grub_efi_mm_init): Handle systems with memory maps
larger than MEMORY_MAP_SIZE.
2010-06-21 BVK Chaitanya <bvk.groups@gmail.com>
Fix parallel build.

View File

@ -346,6 +346,7 @@ grub_efi_mm_init (void)
grub_efi_uintn_t desc_size;
grub_efi_uint64_t total_pages;
grub_efi_uint64_t required_pages;
int mm_status;
/* First of all, allocate pages to maintain allocations. */
allocated_pages
@ -361,16 +362,32 @@ grub_efi_mm_init (void)
if (! memory_map)
grub_fatal ("cannot allocate memory");
filtered_memory_map = NEXT_MEMORY_DESCRIPTOR (memory_map, MEMORY_MAP_SIZE);
/* Obtain descriptors for available memory. */
map_size = MEMORY_MAP_SIZE;
if (grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0) < 0)
mm_status = grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0);
if (mm_status == 0)
{
grub_efi_free_pages
((grub_efi_physical_address_t) ((grub_addr_t) memory_map),
2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
memory_map = grub_efi_allocate_pages (0, 2 * BYTES_TO_PAGES (map_size));
if (! memory_map)
grub_fatal ("cannot allocate memory");
mm_status = grub_efi_get_memory_map (&map_size, memory_map, 0,
&desc_size, 0);
}
if (mm_status < 0)
grub_fatal ("cannot get memory map");
memory_map_end = NEXT_MEMORY_DESCRIPTOR (memory_map, map_size);
filtered_memory_map = memory_map_end;
filtered_memory_map_end = filter_memory_map (memory_map, filtered_memory_map,
desc_size, memory_map_end);