mmap.c revision 2
/* 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/>.
*/
#define min(a,b) (((a) < (b)) ? (a) : (b))
static void *hooktarget = 0;
static grub_uint16_t grub_machine_mmaphook_int12offset = 0;
static grub_uint16_t grub_machine_mmaphook_int12segment = 0;
struct grub_e820_mmap_entry
{
} __attribute__((packed));
static grub_err_t
{
{
hookmmapcur++;
return 0;
}
if (! hooktarget)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"no space is allocated for memory hook");
/* Correct BDA. */
/* Save old interrupt handlers. */
/* Install the interrupt handlers. */
return GRUB_ERR_NONE;
}
static grub_err_t
preboot_rest (void)
{
/* Restore old interrupt handlers. */
return GRUB_ERR_NONE;
}
static grub_err_t
malloc_hook (void)
{
static int reentry = 0;
static int mmapregion = 0;
static int slots_available = 0;
int hooksize;
int regcount = 0;
{
regcount++;
return 0;
}
if (reentry)
return GRUB_ERR_NONE;
/* Mapping hook itself may introduce up to 2 additional regions. */
regcount += 2;
if (regcount <= slots_available)
return GRUB_ERR_NONE;
if (mmapregion)
{
mmapregion = 0;
hooktarget = 0;
}
+ regcount * sizeof (struct grub_e820_mmap_entry);
/* Allocate an integer number of KiB. */
/ sizeof (struct grub_e820_mmap_entry);
reentry = 1;
reentry = 0;
if (! hooktarget)
{
slots_available = 0;
}
return GRUB_ERR_NONE;
}
{
static struct grub_preboot *preb_handle = 0;
err = malloc_hook ();
if (err)
return err;
if (! preb_handle)
{
if (! preb_handle)
return grub_errno;
}
return GRUB_ERR_NONE;
}
{
return GRUB_ERR_NONE;
}