Resync with trunk
This commit is contained in:
commit
e68d3b243f
706 changed files with 157184 additions and 45875 deletions
153
kern/efi/efi.c
153
kern/efi/efi.c
|
@ -1,7 +1,7 @@
|
|||
/* efi.c - generic EFI support */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include <grub/misc.h>
|
||||
#include <grub/charset.h>
|
||||
#include <grub/efi/api.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/console_control.h>
|
||||
|
@ -42,13 +43,12 @@ grub_efi_locate_protocol (grub_efi_guid_t *protocol, void *registration)
|
|||
{
|
||||
void *interface;
|
||||
grub_efi_status_t status;
|
||||
|
||||
status = grub_efi_system_table->boot_services->locate_protocol (protocol,
|
||||
registration,
|
||||
&interface);
|
||||
|
||||
status = efi_call_3 (grub_efi_system_table->boot_services->locate_protocol,
|
||||
protocol, registration, &interface);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
return 0;
|
||||
|
||||
|
||||
return interface;
|
||||
}
|
||||
|
||||
|
@ -65,13 +65,13 @@ grub_efi_locate_handle (grub_efi_locate_search_type_t search_type,
|
|||
grub_efi_status_t status;
|
||||
grub_efi_handle_t *buffer;
|
||||
grub_efi_uintn_t buffer_size = 8 * sizeof (grub_efi_handle_t);
|
||||
|
||||
|
||||
buffer = grub_malloc (buffer_size);
|
||||
if (! buffer)
|
||||
return 0;
|
||||
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
status = b->locate_handle (search_type, protocol, search_key,
|
||||
status = efi_call_5 (b->locate_handle, search_type, protocol, search_key,
|
||||
&buffer_size, buffer);
|
||||
if (status == GRUB_EFI_BUFFER_TOO_SMALL)
|
||||
{
|
||||
|
@ -79,8 +79,8 @@ grub_efi_locate_handle (grub_efi_locate_search_type_t search_type,
|
|||
buffer = grub_malloc (buffer_size);
|
||||
if (! buffer)
|
||||
return 0;
|
||||
|
||||
status = b->locate_handle (search_type, protocol, search_key,
|
||||
|
||||
status = efi_call_5 (b->locate_handle, search_type, protocol, search_key,
|
||||
&buffer_size, buffer);
|
||||
}
|
||||
|
||||
|
@ -102,14 +102,14 @@ grub_efi_open_protocol (grub_efi_handle_t handle,
|
|||
grub_efi_boot_services_t *b;
|
||||
grub_efi_status_t status;
|
||||
void *interface;
|
||||
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
status = b->open_protocol (handle,
|
||||
protocol,
|
||||
&interface,
|
||||
grub_efi_image_handle,
|
||||
0,
|
||||
attributes);
|
||||
status = efi_call_6 (b->open_protocol, handle,
|
||||
protocol,
|
||||
&interface,
|
||||
grub_efi_image_handle,
|
||||
0,
|
||||
attributes);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
return 0;
|
||||
|
||||
|
@ -127,13 +127,13 @@ grub_efi_set_text_mode (int on)
|
|||
/* No console control protocol instance available, assume it is
|
||||
already in text mode. */
|
||||
return 1;
|
||||
|
||||
if (c->get_mode (c, &mode, 0, 0) != GRUB_EFI_SUCCESS)
|
||||
|
||||
if (efi_call_4 (c->get_mode, c, &mode, 0, 0) != GRUB_EFI_SUCCESS)
|
||||
return 0;
|
||||
|
||||
new_mode = on ? GRUB_EFI_SCREEN_TEXT : GRUB_EFI_SCREEN_GRAPHICS;
|
||||
if (mode != new_mode)
|
||||
if (c->set_mode (c, new_mode) != GRUB_EFI_SUCCESS)
|
||||
if (efi_call_2 (c->set_mode, c, new_mode) != GRUB_EFI_SUCCESS)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
@ -142,7 +142,7 @@ grub_efi_set_text_mode (int on)
|
|||
void
|
||||
grub_efi_stall (grub_efi_uintn_t microseconds)
|
||||
{
|
||||
grub_efi_system_table->boot_services->stall (microseconds);
|
||||
efi_call_1 (grub_efi_system_table->boot_services->stall, microseconds);
|
||||
}
|
||||
|
||||
grub_efi_loaded_image_t *
|
||||
|
@ -157,9 +157,25 @@ void
|
|||
grub_exit (void)
|
||||
{
|
||||
grub_efi_fini ();
|
||||
grub_efi_system_table->boot_services->exit (grub_efi_image_handle,
|
||||
GRUB_EFI_SUCCESS,
|
||||
0, 0);
|
||||
efi_call_4 (grub_efi_system_table->boot_services->exit,
|
||||
grub_efi_image_handle, GRUB_EFI_SUCCESS, 0, 0);
|
||||
for (;;) ;
|
||||
}
|
||||
|
||||
void
|
||||
grub_reboot (void)
|
||||
{
|
||||
grub_efi_fini ();
|
||||
efi_call_4 (grub_efi_system_table->runtime_services->reset_system,
|
||||
GRUB_EFI_RESET_COLD, GRUB_EFI_SUCCESS, 0, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
grub_halt (void)
|
||||
{
|
||||
grub_efi_fini ();
|
||||
efi_call_4 (grub_efi_system_table->runtime_services->reset_system,
|
||||
GRUB_EFI_RESET_SHUTDOWN, GRUB_EFI_SUCCESS, 0, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -167,12 +183,31 @@ grub_efi_exit_boot_services (grub_efi_uintn_t map_key)
|
|||
{
|
||||
grub_efi_boot_services_t *b;
|
||||
grub_efi_status_t status;
|
||||
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
status = b->exit_boot_services (grub_efi_image_handle, map_key);
|
||||
status = efi_call_2 (b->exit_boot_services, grub_efi_image_handle, map_key);
|
||||
return status == GRUB_EFI_SUCCESS;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_efi_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
|
||||
grub_efi_uintn_t descriptor_size,
|
||||
grub_efi_uint32_t descriptor_version,
|
||||
grub_efi_memory_descriptor_t *virtual_map)
|
||||
{
|
||||
grub_efi_runtime_services_t *r;
|
||||
grub_efi_status_t status;
|
||||
|
||||
r = grub_efi_system_table->runtime_services;
|
||||
status = efi_call_4 (r->set_virtual_address_map, memory_map_size,
|
||||
descriptor_size, descriptor_version, virtual_map);
|
||||
|
||||
if (status == GRUB_EFI_SUCCESS)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
return grub_error (GRUB_ERR_IO, "set_virtual_address_map failed");
|
||||
}
|
||||
|
||||
grub_uint32_t
|
||||
grub_get_rtc (void)
|
||||
{
|
||||
|
@ -180,7 +215,7 @@ grub_get_rtc (void)
|
|||
grub_efi_runtime_services_t *r;
|
||||
|
||||
r = grub_efi_system_table->runtime_services;
|
||||
if (r->get_time (&time, 0) != GRUB_EFI_SUCCESS)
|
||||
if (efi_call_2 (r->get_time, &time, 0) != GRUB_EFI_SUCCESS)
|
||||
/* What is possible in this case? */
|
||||
return 0;
|
||||
|
||||
|
@ -201,7 +236,7 @@ grub_arch_modules_addr (void)
|
|||
struct grub_pe32_section_table *section;
|
||||
struct grub_module_info *info;
|
||||
grub_uint16_t i;
|
||||
|
||||
|
||||
image = grub_efi_get_loaded_image (grub_efi_image_handle);
|
||||
if (! image)
|
||||
return 0;
|
||||
|
@ -236,7 +271,7 @@ char *
|
|||
grub_efi_get_filename (grub_efi_device_path_t *dp)
|
||||
{
|
||||
char *name = 0;
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp);
|
||||
|
@ -260,7 +295,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp)
|
|||
}
|
||||
else
|
||||
size = 0;
|
||||
|
||||
|
||||
len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4)
|
||||
/ sizeof (grub_efi_char16_t));
|
||||
p = grub_realloc (name, size + len * 4 + 1);
|
||||
|
@ -353,8 +388,8 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
|||
grub_memcpy (&mmapped, dp, len);
|
||||
grub_printf ("/MMap(%x,%llx,%llx)",
|
||||
(unsigned) mmapped.memory_type,
|
||||
mmapped.start_address,
|
||||
mmapped.end_address);
|
||||
(unsigned long long) mmapped.start_address,
|
||||
(unsigned long long) mmapped.end_address);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE:
|
||||
|
@ -406,17 +441,17 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
|||
grub_efi_expanded_acpi_device_path_t eacpi;
|
||||
grub_memcpy (&eacpi, dp, sizeof (eacpi));
|
||||
grub_printf ("/ACPI(");
|
||||
|
||||
|
||||
if (GRUB_EFI_EXPANDED_ACPI_HIDSTR (dp)[0] == '\0')
|
||||
grub_printf ("%x,", (unsigned) eacpi.hid);
|
||||
else
|
||||
grub_printf ("%s,", GRUB_EFI_EXPANDED_ACPI_HIDSTR (dp));
|
||||
|
||||
|
||||
if (GRUB_EFI_EXPANDED_ACPI_UIDSTR (dp)[0] == '\0')
|
||||
grub_printf ("%x,", (unsigned) eacpi.uid);
|
||||
else
|
||||
grub_printf ("%s,", GRUB_EFI_EXPANDED_ACPI_UIDSTR (dp));
|
||||
|
||||
|
||||
if (GRUB_EFI_EXPANDED_ACPI_CIDSTR (dp)[0] == '\0')
|
||||
grub_printf ("%x)", (unsigned) eacpi.cid);
|
||||
else
|
||||
|
@ -456,14 +491,15 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
|||
grub_efi_fibre_channel_device_path_t fc;
|
||||
grub_memcpy (&fc, dp, len);
|
||||
grub_printf ("/FibreChannel(%llx,%llx)",
|
||||
fc.wwn, fc.lun);
|
||||
(unsigned long long) fc.wwn,
|
||||
(unsigned long long) fc.lun);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_1394_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_1394_device_path_t firewire;
|
||||
grub_memcpy (&firewire, dp, len);
|
||||
grub_printf ("/1394(%llx)", firewire.guid);
|
||||
grub_printf ("/1394(%llx)", (unsigned long long) firewire.guid);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_USB_DEVICE_PATH_SUBTYPE:
|
||||
|
@ -560,9 +596,9 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
|||
grub_memcpy (&ib, dp, len);
|
||||
grub_printf ("/InfiniBand(%x,%llx,%llx,%llx)",
|
||||
(unsigned) ib.port_gid[0], /* XXX */
|
||||
ib.remote_id,
|
||||
ib.target_port_id,
|
||||
ib.device_id);
|
||||
(unsigned long long) ib.remote_id,
|
||||
(unsigned long long) ib.target_port_id,
|
||||
(unsigned long long) ib.device_id);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_UART_DEVICE_PATH_SUBTYPE:
|
||||
|
@ -570,7 +606,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
|||
grub_efi_uart_device_path_t uart;
|
||||
grub_memcpy (&uart, dp, len);
|
||||
grub_printf ("/UART(%llu,%u,%x,%x)",
|
||||
uart.baud_rate,
|
||||
(unsigned long long) uart.baud_rate,
|
||||
uart.data_bits,
|
||||
uart.parity,
|
||||
uart.stop_bits);
|
||||
|
@ -609,8 +645,8 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
|||
grub_memcpy (&hd, dp, len);
|
||||
grub_printf ("/HD(%u,%llx,%llx,%02x%02x%02x%02x%02x%02x%02x%02x,%x,%x)",
|
||||
hd.partition_number,
|
||||
hd.partition_start,
|
||||
hd.partition_size,
|
||||
(unsigned long long) hd.partition_start,
|
||||
(unsigned long long) hd.partition_size,
|
||||
(unsigned) hd.partition_signature[0],
|
||||
(unsigned) hd.partition_signature[1],
|
||||
(unsigned) hd.partition_signature[2],
|
||||
|
@ -629,8 +665,8 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
|||
grub_memcpy (&cd, dp, len);
|
||||
grub_printf ("/CD(%u,%llx,%llx)",
|
||||
cd.boot_entry,
|
||||
cd.partition_start,
|
||||
cd.partition_size);
|
||||
(unsigned long long) cd.partition_start,
|
||||
(unsigned long long) cd.partition_size);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE:
|
||||
|
@ -712,10 +748,33 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
|||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
|
||||
break;
|
||||
|
||||
dp = (grub_efi_device_path_t *) ((char *) dp + len);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
grub_efi_finish_boot_services (void)
|
||||
{
|
||||
grub_efi_uintn_t mmap_size = 0;
|
||||
grub_efi_uintn_t map_key;
|
||||
grub_efi_uintn_t desc_size;
|
||||
grub_efi_uint32_t desc_version;
|
||||
void *mmap_buf = 0;
|
||||
|
||||
if (grub_efi_get_memory_map (&mmap_size, mmap_buf, &map_key,
|
||||
&desc_size, &desc_version) < 0)
|
||||
return 0;
|
||||
|
||||
mmap_buf = grub_malloc (mmap_size);
|
||||
|
||||
if (grub_efi_get_memory_map (&mmap_size, mmap_buf, &map_key,
|
||||
&desc_size, &desc_version) <= 0)
|
||||
return 0;
|
||||
|
||||
return grub_efi_exit_boot_services (map_key);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ void
|
|||
grub_efi_set_prefix (void)
|
||||
{
|
||||
grub_efi_loaded_image_t *image;
|
||||
|
||||
|
||||
image = grub_efi_get_loaded_image (grub_efi_image_handle);
|
||||
if (image)
|
||||
{
|
||||
|
@ -52,12 +52,12 @@ grub_efi_set_prefix (void)
|
|||
|
||||
device = grub_efidisk_get_device_name (image->device_handle);
|
||||
file = grub_efi_get_filename (image->file_path);
|
||||
|
||||
|
||||
if (device && file)
|
||||
{
|
||||
char *p;
|
||||
char *prefix;
|
||||
|
||||
|
||||
/* Get the directory. */
|
||||
p = grub_strrchr (file, '/');
|
||||
if (p)
|
||||
|
@ -72,7 +72,7 @@ grub_efi_set_prefix (void)
|
|||
grub_free (prefix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
grub_free (device);
|
||||
grub_free (file);
|
||||
}
|
||||
|
@ -82,6 +82,5 @@ void
|
|||
grub_efi_fini (void)
|
||||
{
|
||||
grub_efidisk_fini ();
|
||||
grub_efi_mm_fini ();
|
||||
grub_console_fini ();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* mm.c - generic EFI memory management */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,14 +22,16 @@
|
|||
#include <grub/efi/api.h>
|
||||
#include <grub/efi/efi.h>
|
||||
|
||||
//#define DEBUG_MM
|
||||
|
||||
#define NEXT_MEMORY_DESCRIPTOR(desc, size) \
|
||||
((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
|
||||
|
||||
#define BYTES_TO_PAGES(bytes) ((bytes + 0xfff) >> 12)
|
||||
#define PAGES_TO_BYTES(pages) ((pages) << 12)
|
||||
|
||||
/* The size of a memory map obtained from the firmware. This must be
|
||||
a multiplier of 4KB. */
|
||||
#define MEMORY_MAP_SIZE 0x3000
|
||||
|
||||
/* Maintain the list of allocated pages. */
|
||||
struct allocated_page
|
||||
{
|
||||
|
@ -45,7 +47,8 @@ static struct allocated_page *allocated_pages = 0;
|
|||
|
||||
/* The minimum and maximum heap size for GRUB itself. */
|
||||
#define MIN_HEAP_SIZE 0x100000
|
||||
#define MAX_HEAP_SIZE (16 * 0x100000)
|
||||
#define MAX_HEAP_SIZE (1600 * 0x100000)
|
||||
|
||||
|
||||
/* Allocate pages. Return the pointer to the first of allocated pages. */
|
||||
void *
|
||||
|
@ -56,11 +59,13 @@ grub_efi_allocate_boot_pages (grub_efi_physical_address_t address,
|
|||
grub_efi_status_t status;
|
||||
grub_efi_boot_services_t *b;
|
||||
|
||||
#if GRUB_CPU_SIZEOF_VOID_P < 8
|
||||
#if GRUB_TARGET_SIZEOF_VOID_P < 8
|
||||
/* Limit the memory access to less than 4GB for 32-bit platforms. */
|
||||
if (address > 0xffffffff)
|
||||
return 0;
|
||||
|
||||
#endif
|
||||
|
||||
#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL)
|
||||
if (address == 0)
|
||||
{
|
||||
type = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
|
||||
|
@ -76,7 +81,7 @@ grub_efi_allocate_boot_pages (grub_efi_physical_address_t address,
|
|||
#endif
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
status = b->allocate_pages (type, GRUB_EFI_LOADER_DATA, pages, &address);
|
||||
status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
return 0;
|
||||
|
||||
|
@ -84,13 +89,13 @@ grub_efi_allocate_boot_pages (grub_efi_physical_address_t address,
|
|||
{
|
||||
/* Uggh, the address 0 was allocated... This is too annoying,
|
||||
so reallocate another one. */
|
||||
status = b->allocate_pages (type, GRUB_EFI_LOADER_DATA, pages, &address);
|
||||
status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address);
|
||||
grub_efi_free_boot_pages (0, pages);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (void *)address;
|
||||
|
||||
return (void *) address;
|
||||
}
|
||||
|
||||
/* Free pages starting from ADDRESS. */
|
||||
|
@ -111,7 +116,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
|
|||
{
|
||||
address = grub_efi_allocate_boot_pages (address, pages);
|
||||
|
||||
if (address != 0 && allocated_pages)
|
||||
if (address && allocated_pages)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
|
@ -126,7 +131,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
|
|||
if (i == MAX_ALLOCATED_PAGES)
|
||||
grub_fatal ("too many page allocations");
|
||||
}
|
||||
|
||||
|
||||
return (void *) ((grub_addr_t) address);
|
||||
}
|
||||
|
||||
|
@ -140,7 +145,7 @@ grub_efi_free_pages (grub_efi_physical_address_t address,
|
|||
!= address))
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
|
||||
for (i = 0; i < MAX_ALLOCATED_PAGES; i++)
|
||||
if (allocated_pages[i].addr == address)
|
||||
{
|
||||
|
@ -171,9 +176,9 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size,
|
|||
map_key = &key;
|
||||
if (! descriptor_version)
|
||||
descriptor_version = &version;
|
||||
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
status = b->get_memory_map (memory_map_size, memory_map, map_key,
|
||||
status = efi_call_5 (b->get_memory_map, memory_map_size, memory_map, map_key,
|
||||
descriptor_size, descriptor_version);
|
||||
if (status == GRUB_EFI_SUCCESS)
|
||||
return 1;
|
||||
|
@ -191,13 +196,13 @@ sort_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
|||
{
|
||||
grub_efi_memory_descriptor_t *d1;
|
||||
grub_efi_memory_descriptor_t *d2;
|
||||
|
||||
|
||||
for (d1 = memory_map;
|
||||
d1 < memory_map_end;
|
||||
d1 = NEXT_MEMORY_DESCRIPTOR (d1, desc_size))
|
||||
{
|
||||
grub_efi_memory_descriptor_t *max_desc = d1;
|
||||
|
||||
|
||||
for (d2 = NEXT_MEMORY_DESCRIPTOR (d1, desc_size);
|
||||
d2 < memory_map_end;
|
||||
d2 = NEXT_MEMORY_DESCRIPTOR (d2, desc_size))
|
||||
|
@ -232,14 +237,14 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
|||
desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
|
||||
{
|
||||
if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
|
||||
#if GRUB_CPU_SIZEOF_VOID_P < 8
|
||||
#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL)
|
||||
&& desc->physical_start <= 0xffffffff
|
||||
#endif
|
||||
&& desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
|
||||
&& desc->num_pages != 0)
|
||||
{
|
||||
grub_memcpy (filtered_desc, desc, desc_size);
|
||||
|
||||
|
||||
/* Avoid less than 1MB, because some loaders seem to be confused. */
|
||||
if (desc->physical_start < 0x100000)
|
||||
{
|
||||
|
@ -247,8 +252,8 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
|||
- desc->physical_start);
|
||||
desc->physical_start = 0x100000;
|
||||
}
|
||||
|
||||
#if GRUB_CPU_SIZEOF_VOID_P < 8
|
||||
|
||||
#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL)
|
||||
if (BYTES_TO_PAGES (filtered_desc->physical_start)
|
||||
+ filtered_desc->num_pages
|
||||
> BYTES_TO_PAGES (0x100000000LL))
|
||||
|
@ -256,10 +261,10 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
|||
= (BYTES_TO_PAGES (0x100000000LL)
|
||||
- BYTES_TO_PAGES (filtered_desc->physical_start));
|
||||
#endif
|
||||
|
||||
|
||||
if (filtered_desc->num_pages == 0)
|
||||
continue;
|
||||
|
||||
|
||||
filtered_desc = NEXT_MEMORY_DESCRIPTOR (filtered_desc, desc_size);
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +280,7 @@ get_total_pages (grub_efi_memory_descriptor_t *memory_map,
|
|||
{
|
||||
grub_efi_memory_descriptor_t *desc;
|
||||
grub_efi_uint64_t total = 0;
|
||||
|
||||
|
||||
for (desc = memory_map;
|
||||
desc < memory_map_end;
|
||||
desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
|
||||
|
@ -343,7 +348,7 @@ print_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
|||
{
|
||||
grub_efi_memory_descriptor_t *desc;
|
||||
int i;
|
||||
|
||||
|
||||
for (desc = memory_map, i = 0;
|
||||
desc < memory_map_end;
|
||||
desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size), i++)
|
||||
|
@ -401,7 +406,7 @@ grub_efi_mm_init (void)
|
|||
grub_fatal ("cannot get memory map");
|
||||
|
||||
memory_map_end = NEXT_MEMORY_DESCRIPTOR (memory_map, map_size);
|
||||
|
||||
|
||||
filtered_memory_map_end = filter_memory_map (memory_map, filtered_memory_map,
|
||||
desc_size, memory_map_end);
|
||||
|
||||
|
@ -434,7 +439,7 @@ grub_efi_mm_init (void)
|
|||
NEXT_MEMORY_DESCRIPTOR (memory_map, map_size));
|
||||
grub_abort ();
|
||||
#endif
|
||||
|
||||
|
||||
/* Release the memory maps. */
|
||||
grub_efi_free_pages ((grub_addr_t) memory_map,
|
||||
2 * BYTES_TO_PAGES (memory_map_size));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue