2002-12-27 08:53:07 +00:00
|
|
|
|
/* mm.c - functions for memory manager */
|
|
|
|
|
/*
|
2004-04-04 13:46:03 +00:00
|
|
|
|
* GRUB -- GRand Unified Bootloader
|
2004-02-24 17:21:53 +00:00
|
|
|
|
* Copyright (C) 2002 Free Software Foundation, Inc.
|
2002-12-27 08:53:07 +00:00
|
|
|
|
*
|
2004-04-04 13:46:03 +00:00
|
|
|
|
* GRUB is free software; you can redistribute it and/or modify
|
2002-12-27 08:53:07 +00:00
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program 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
|
2004-04-04 13:46:03 +00:00
|
|
|
|
* along with GRUB; if not, write to the Free Software
|
2002-12-27 08:53:07 +00:00
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
2004-04-04 13:46:03 +00:00
|
|
|
|
#include <grub/mm.h>
|
|
|
|
|
#include <grub/misc.h>
|
|
|
|
|
#include <grub/err.h>
|
|
|
|
|
#include <grub/types.h>
|
|
|
|
|
#include <grub/disk.h>
|
|
|
|
|
#include <grub/dl.h>
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
/* Magic words. */
|
2004-04-04 13:46:03 +00:00
|
|
|
|
#define GRUB_MM_FREE_MAGIC 0x2d3c2808
|
|
|
|
|
#define GRUB_MM_ALLOC_MAGIC 0x6db08fa4
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
typedef struct grub_mm_header
|
2002-12-27 08:53:07 +00:00
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_mm_header *next;
|
|
|
|
|
grub_size_t size;
|
|
|
|
|
grub_size_t magic;
|
|
|
|
|
#if GRUB_CPU_SIZEOF_VOID_P == 4
|
2002-12-27 08:53:07 +00:00
|
|
|
|
char padding[4];
|
2004-04-04 13:46:03 +00:00
|
|
|
|
#elif GRUB_CPU_SIZEOF_VOID_P == 8
|
2002-12-27 08:53:07 +00:00
|
|
|
|
char padding[8];
|
|
|
|
|
#else
|
|
|
|
|
# error "unknown word size"
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2004-04-04 13:46:03 +00:00
|
|
|
|
*grub_mm_header_t;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
#if GRUB_CPU_SIZEOF_VOID_P == 4
|
|
|
|
|
# define GRUB_MM_ALIGN_LOG2 4
|
|
|
|
|
#elif GRUB_CPU_SIZEOF_VOID_P == 8
|
|
|
|
|
# define GRUB_MM_ALIGN_LOG2 8
|
2002-12-27 08:53:07 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
#define GRUB_MM_ALIGN (1 << GRUB_MM_ALIGN_LOG2)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
typedef struct grub_mm_region
|
2002-12-27 08:53:07 +00:00
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_mm_header *first;
|
|
|
|
|
struct grub_mm_region *next;
|
|
|
|
|
grub_addr_t addr;
|
|
|
|
|
grub_size_t size;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
}
|
2004-04-04 13:46:03 +00:00
|
|
|
|
*grub_mm_region_t;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
static grub_mm_region_t base;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
/* Get a header from the pointer PTR, and set *P and *R to a pointer
|
|
|
|
|
to the header and a pointer to its region, respectively. PTR must
|
|
|
|
|
be allocated. */
|
|
|
|
|
static void
|
2004-04-04 13:46:03 +00:00
|
|
|
|
get_header_from_pointer (void *ptr, grub_mm_header_t *p, grub_mm_region_t *r)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
{
|
2005-01-20 17:25:39 +00:00
|
|
|
|
if ((grub_addr_t) ptr & (GRUB_MM_ALIGN - 1))
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_fatal ("unaligned pointer %p", ptr);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
for (*r = base; *r; *r = (*r)->next)
|
2005-01-20 17:25:39 +00:00
|
|
|
|
if ((grub_addr_t) ptr > (*r)->addr
|
|
|
|
|
&& (grub_addr_t) ptr <= (*r)->addr + (*r)->size)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (! *r)
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_fatal ("out of range pointer %p", ptr);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
*p = (grub_mm_header_t) ptr - 1;
|
|
|
|
|
if ((*p)->magic != GRUB_MM_ALLOC_MAGIC)
|
|
|
|
|
grub_fatal ("alloc magic is broken at %p", *p);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Initialize a region starting from ADDR and whose size is SIZE,
|
|
|
|
|
to use it as free space. */
|
|
|
|
|
void
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_mm_init_region (void *addr, grub_size_t size)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_mm_header_t h;
|
|
|
|
|
grub_mm_region_t r, *p, q;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
2003-01-17 02:52:05 +00:00
|
|
|
|
#if 0
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_printf ("%s:%d: addr=%p, size=%u\n", __FILE__, __LINE__, addr, size);
|
2003-01-17 02:52:05 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-12-27 08:53:07 +00:00
|
|
|
|
/* If this region is too small, ignore it. */
|
2004-04-04 13:46:03 +00:00
|
|
|
|
if (size < GRUB_MM_ALIGN * 2)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Allocate a region from the head. */
|
2004-04-04 13:46:03 +00:00
|
|
|
|
r = (grub_mm_region_t) (((grub_addr_t) addr + GRUB_MM_ALIGN - 1)
|
|
|
|
|
& (~(GRUB_MM_ALIGN - 1)));
|
2002-12-27 08:53:07 +00:00
|
|
|
|
size -= (char *) r - (char *) addr + sizeof (*r);
|
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
h = (grub_mm_header_t) ((char *) r + GRUB_MM_ALIGN);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
h->next = h;
|
2004-04-04 13:46:03 +00:00
|
|
|
|
h->magic = GRUB_MM_FREE_MAGIC;
|
|
|
|
|
h->size = (size >> GRUB_MM_ALIGN_LOG2);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
r->first = h;
|
2004-04-04 13:46:03 +00:00
|
|
|
|
r->addr = (grub_addr_t) h;
|
|
|
|
|
r->size = (h->size << GRUB_MM_ALIGN_LOG2);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
/* Find where to insert this region. Put a smaller one before bigger ones,
|
|
|
|
|
to prevent fragmentations. */
|
|
|
|
|
for (p = &base, q = *p; q; p = &(q->next), q = *p)
|
|
|
|
|
if (q->size > r->size)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
*p = r;
|
|
|
|
|
r->next = q;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Allocate the number of units N with the alignment ALIGN from the ring
|
|
|
|
|
buffer starting from *FIRST. ALIGN must be a power of two. Return a
|
|
|
|
|
non-NULL if successful, otherwise return NULL. */
|
|
|
|
|
static void *
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_mm_header_t p, q;
|
2003-01-31 03:26:56 +00:00
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
if ((*first)->magic == GRUB_MM_ALLOC_MAGIC)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
for (q = *first, p = q->next; ; q = p, p = p->next)
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_off_t extra;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
extra = ((grub_addr_t) (p + 1) >> GRUB_MM_ALIGN_LOG2) % align;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
if (extra)
|
|
|
|
|
extra = align - extra;
|
|
|
|
|
|
|
|
|
|
if (! p)
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_fatal ("null in the ring");
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
if (p->magic != GRUB_MM_FREE_MAGIC)
|
|
|
|
|
grub_fatal ("free magic is broken at %p: 0x%x", p, p->magic);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
if (p->size >= n + extra)
|
|
|
|
|
{
|
|
|
|
|
if (extra == 0 && p->size == n)
|
|
|
|
|
{
|
|
|
|
|
q->next = p->next;
|
2004-04-04 13:46:03 +00:00
|
|
|
|
p->magic = GRUB_MM_ALLOC_MAGIC;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
}
|
|
|
|
|
else if (extra == 0 || p->size == n + extra)
|
|
|
|
|
{
|
|
|
|
|
p->size -= n;
|
|
|
|
|
p += p->size;
|
|
|
|
|
p->size = n;
|
2004-04-04 13:46:03 +00:00
|
|
|
|
p->magic = GRUB_MM_ALLOC_MAGIC;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_mm_header_t r;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
r = p + extra + n;
|
2004-04-04 13:46:03 +00:00
|
|
|
|
r->magic = GRUB_MM_FREE_MAGIC;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
r->size = p->size - extra - n;
|
|
|
|
|
r->next = p->next;
|
|
|
|
|
|
|
|
|
|
p->size = extra;
|
|
|
|
|
p->next = r;
|
|
|
|
|
p += extra;
|
|
|
|
|
p->size = n;
|
2004-04-04 13:46:03 +00:00
|
|
|
|
p->magic = GRUB_MM_ALLOC_MAGIC;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*first = q;
|
2003-01-20 04:13:46 +00:00
|
|
|
|
|
2002-12-27 08:53:07 +00:00
|
|
|
|
return p + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (p == *first)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Allocate SIZE bytes with the alignment ALIGN and return the pointer. */
|
|
|
|
|
void *
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_memalign (grub_size_t align, grub_size_t size)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_mm_region_t r;
|
|
|
|
|
grub_size_t n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1;
|
2003-01-06 00:01:35 +00:00
|
|
|
|
int count = 0;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
align = (align >> GRUB_MM_ALIGN_LOG2);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
if (align == 0)
|
|
|
|
|
align = 1;
|
|
|
|
|
|
|
|
|
|
again:
|
|
|
|
|
|
|
|
|
|
for (r = base; r; r = r->next)
|
|
|
|
|
{
|
|
|
|
|
void *p;
|
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
p = grub_real_malloc (&(r->first), n, align);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
if (p)
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-06 00:01:35 +00:00
|
|
|
|
/* If failed, increase free memory somehow. */
|
|
|
|
|
switch (count)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
{
|
2003-01-06 00:01:35 +00:00
|
|
|
|
case 0:
|
|
|
|
|
/* Invalidate disk caches. */
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_disk_cache_invalidate_all ();
|
2003-01-06 00:01:35 +00:00
|
|
|
|
count++;
|
|
|
|
|
goto again;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
/* Unload unneeded modules. */
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_dl_unload_unneeded ();
|
2003-01-06 00:01:35 +00:00
|
|
|
|
count++;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
goto again;
|
|
|
|
|
|
2003-01-06 00:01:35 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
|
2002-12-27 08:53:07 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Allocate SIZE bytes and return the pointer. */
|
|
|
|
|
void *
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_malloc (grub_size_t size)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
return grub_memalign (0, size);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Deallocate the pointer PTR. */
|
|
|
|
|
void
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_free (void *ptr)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_mm_header_t p;
|
|
|
|
|
grub_mm_region_t r;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
if (! ptr)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
get_header_from_pointer (ptr, &p, &r);
|
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
if (r->first->magic == GRUB_MM_ALLOC_MAGIC)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
p->magic = GRUB_MM_FREE_MAGIC;
|
2003-01-20 04:13:46 +00:00
|
|
|
|
r->first = p->next = p;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_mm_header_t q;
|
2003-01-20 04:13:46 +00:00
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
q = r->first;
|
|
|
|
|
do
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_printf ("%s:%d: q=%p, q->size=0x%x, q->magic=0x%x\n",
|
2003-01-20 04:13:46 +00:00
|
|
|
|
__FILE__, __LINE__, q, q->size, q->magic);
|
|
|
|
|
q = q->next;
|
|
|
|
|
}
|
|
|
|
|
while (q != r->first);
|
|
|
|
|
#endif
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
for (q = r->first; q >= p || q->next <= p; q = q->next)
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
if (q->magic != GRUB_MM_FREE_MAGIC)
|
|
|
|
|
grub_fatal ("free magic is broken at %p: 0x%x", q, q->magic);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
if (q >= q->next && (q < p || q->next > p))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
p->magic = GRUB_MM_FREE_MAGIC;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
p->next = q->next;
|
|
|
|
|
q->next = p;
|
|
|
|
|
|
|
|
|
|
if (p + p->size == p->next)
|
|
|
|
|
{
|
|
|
|
|
p->next->magic = 0;
|
|
|
|
|
p->size += p->next->size;
|
|
|
|
|
p->next = p->next->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (q + q->size == p)
|
|
|
|
|
{
|
|
|
|
|
p->magic = 0;
|
|
|
|
|
q->size += p->size;
|
|
|
|
|
q->next = p->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r->first = q;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Reallocate SIZE bytes and return the pointer. The contents will be
|
|
|
|
|
the same as that of PTR. */
|
|
|
|
|
void *
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_realloc (void *ptr, grub_size_t size)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_mm_header_t p;
|
|
|
|
|
grub_mm_region_t r;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
void *q;
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_size_t n;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
if (! ptr)
|
2004-04-04 13:46:03 +00:00
|
|
|
|
return grub_malloc (size);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
|
|
if (! size)
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_free (ptr);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: Not optimal. */
|
2004-04-04 13:46:03 +00:00
|
|
|
|
n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
get_header_from_pointer (ptr, &p, &r);
|
|
|
|
|
|
|
|
|
|
if (p->size >= n)
|
2004-07-12 17:53:07 +00:00
|
|
|
|
return ptr;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
q = grub_malloc (size);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
if (! q)
|
|
|
|
|
return q;
|
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_memcpy (q, ptr, size);
|
|
|
|
|
grub_free (ptr);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
return q;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if MM_DEBUG
|
|
|
|
|
void
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_mm_dump (unsigned lineno)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_mm_region_t r;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_printf ("called at line %u\n", lineno);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
for (r = base; r; r = r->next)
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_mm_header_t p;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
for (p = (grub_mm_header_t) ((r->addr + GRUB_MM_ALIGN - 1)
|
|
|
|
|
& (~(GRUB_MM_ALIGN - 1)));
|
|
|
|
|
(grub_addr_t) p < r->addr + r->size;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
p++)
|
|
|
|
|
{
|
|
|
|
|
switch (p->magic)
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
case GRUB_MM_FREE_MAGIC:
|
|
|
|
|
grub_printf ("F:%p:%u:%p\n",
|
|
|
|
|
p, p->size << GRUB_MM_ALIGN_LOG2, p->next);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
break;
|
2004-04-04 13:46:03 +00:00
|
|
|
|
case GRUB_MM_ALLOC_MAGIC:
|
|
|
|
|
grub_printf ("A:%p:%u\n", p, p->size << GRUB_MM_ALIGN_LOG2);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_printf ("\n");
|
2002-12-27 08:53:07 +00:00
|
|
|
|
}
|
|
|
|
|
#endif /* MM_DEBUG */
|