2N/A/* mm.c - generic EFI memory management */ 2N/A * GRUB -- GRand Unified Bootloader 2N/A * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. 2N/A * GRUB is free software: you can redistribute it and/or modify 2N/A * it under the terms of the GNU General Public License as published by 2N/A * the Free Software Foundation, either version 3 of the License, or 2N/A * (at your option) any later version. 2N/A * GRUB is distributed in the hope that it will be useful, 2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of 2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2N/A * GNU General Public License for more details. 2N/A * You should have received a copy of the GNU General Public License 2N/A/* The size of a memory map obtained from the firmware. This must be 2N/A a multiplier of 4KB. */ 2N/A/* The minimum and maximum heap size for GRUB itself. */ 2N/A/* Allocate pages. Return the pointer to the first of allocated pages. */ 2N/A /* Limit the memory access to less than 4GB for 32-bit platforms. */ 2N/A /* Uggh, the address 0 was allocated... This is too annoying, 2N/A so reallocate another one. */ 2N/A/* Free pages starting from ADDRESS. */ 2N/A/* Get the memory map as defined in the EFI spec. Return 1 if successful, 2N/A return 0 if partial, or return -1 if an error occurs. */ 2N/A /* Allow some parameters to be missing. */ 2N/A/* Sort the memory map in place. */ 2N/A/* Filter the descriptors. GRUB needs only available memory. */ 2N/A /* Avoid less than 1MB, because some loaders seem to be confused. */ 2N/A/* Return the total number of pages. */ 2N/A/* Add memory regions. */ 2N/A grub_fatal (
"cannot allocate conventional memory %p with %u pages",
2N/A/* Print the memory map. */ 2N/A /* Prepare a memory region to store two memory maps. */ 2N/A /* Obtain descriptors for available memory. */ 2N/A /* By default, request a quarter of the available memory. */ 2N/A /* Sort the filtered descriptors, so that GRUB can allocate pages 2N/A from smaller regions. */ 2N/A /* Allocate memory regions for GRUB's memory management. */ 2N/A /* Release the memory maps. */ 2N/A/* Find the optimal number of pages for the memory map. */ 2N/A /* Increase the size a bit for safety, because GRUB allocates more on 2N/A later, and EFI itself may allocate more. */