/* Mmap management. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
{
&desc_version) < 0)
return grub_errno;
if (! map_buf)
return grub_errno;
&desc_version) <= 0)
{
return grub_errno;
}
{
(unsigned long long) desc->physical_start,
(unsigned long long) desc->physical_start
{
break;
case GRUB_EFI_UNUSABLE_MEMORY:
break;
break;
default:
grub_printf ("Unknown memory type %d, considering reserved\n",
case GRUB_EFI_PAL_CODE:
break;
case GRUB_EFI_LOADER_CODE:
case GRUB_EFI_LOADER_DATA:
break;
break;
case GRUB_EFI_ACPI_MEMORY_NVS:
break;
}
}
return GRUB_ERR_NONE;
}
static inline grub_efi_memory_type_t
{
switch (type)
{
case GRUB_MEMORY_CODE:
return GRUB_EFI_RUNTIME_SERVICES_CODE;
/* No way to remove a chunk of memory from EFI mmap.
So mark it as unusable. */
case GRUB_MEMORY_HOLE:
case GRUB_MEMORY_RESERVED:
return GRUB_EFI_UNUSABLE_MEMORY;
case GRUB_MEMORY_AVAILABLE:
return GRUB_EFI_CONVENTIONAL_MEMORY;
case GRUB_MEMORY_ACPI:
return GRUB_EFI_ACPI_RECLAIM_MEMORY;
case GRUB_MEMORY_NVS:
return GRUB_EFI_ACPI_MEMORY_NVS;
}
return GRUB_EFI_UNUSABLE_MEMORY;
}
struct overlay
{
int handle;
};
int
{
if (! curover)
return 0;
{
return 0;
}
if (status != GRUB_EFI_SUCCESS)
{
return 0;
}
}
{
{
{
if (prevover != 0)
else
return GRUB_ERR_NONE;
}
}
}
/* Result is always page-aligned. */
void *
{
if (! curover)
return 0;
address = 0xffffffff;
#if GRUB_TARGET_SIZEOF_VOID_P < 8
/* Limit the memory access to less than 4GB for 32-bit platforms. */
#else
#endif
if (status != GRUB_EFI_SUCCESS)
{
return 0;
}
if (address == 0)
{
/* Uggh, the address 0 was allocated... This is too annoying,
so reallocate another one. */
address = 0xffffffff;
grub_efi_free_pages (0, pages);
if (status != GRUB_EFI_SUCCESS)
return 0;
}
}
void
{
}