Skip to content

Commit

Permalink
[pcbios] Merge adjacent memory regions of same type
Browse files Browse the repository at this point in the history
Some BIOSes can report multiple memory regions which may be adjacent
and the same type.  Since only the first region is used in the
mboot.c32 layer it's possible to run out of memory when loading all of
the boot modules.  One may get around this problem by having iPXE
merge these memory regions internally.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
ehabkost authored and mcb30 committed Feb 17, 2011
1 parent 72d387e commit 3293eb8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/arch/i386/firmware/pcbios/memmap.c
Expand Up @@ -156,6 +156,7 @@ unsigned int extmemsize ( void ) {
*/
static int meme820 ( struct memory_map *memmap ) {
struct memory_region *region = memmap->regions;
struct memory_region *prev_region = NULL;
uint32_t next = 0;
uint32_t smap;
size_t size;
Expand Down Expand Up @@ -238,8 +239,15 @@ static int meme820 ( struct memory_map *memmap ) {

region->start = e820buf.start;
region->end = e820buf.start + e820buf.len;
region++;
memmap->count++;

/* Check for adjacent regions and merge them */
if ( prev_region && ( region->start == prev_region->end ) ) {
prev_region->end = region->end;
} else {
prev_region = region;
region++;
memmap->count++;
}

if ( memmap->count >= ( sizeof ( memmap->regions ) /
sizeof ( memmap->regions[0] ) ) ) {
Expand Down

0 comments on commit 3293eb8

Please sign in to comment.