summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEduardo Habkost2011-02-16 19:41:24 +0100
committerMichael Brown2011-02-17 02:25:08 +0100
commit3293eb8e7305bc0cdaeb1359873576899c7e33e4 (patch)
tree36d19f1e82a210c29af0a15c07fd3cd8a30a2909 /src
parent[3c90x] Clean up reset code (diff)
downloadipxe-3293eb8e7305bc0cdaeb1359873576899c7e33e4.tar.gz
ipxe-3293eb8e7305bc0cdaeb1359873576899c7e33e4.tar.xz
ipxe-3293eb8e7305bc0cdaeb1359873576899c7e33e4.zip
[pcbios] Merge adjacent memory regions of same type
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>
Diffstat (limited to 'src')
-rw-r--r--src/arch/i386/firmware/pcbios/memmap.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/arch/i386/firmware/pcbios/memmap.c b/src/arch/i386/firmware/pcbios/memmap.c
index 01080c7b8..493d2c201 100644
--- a/src/arch/i386/firmware/pcbios/memmap.c
+++ b/src/arch/i386/firmware/pcbios/memmap.c
@@ -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;
@@ -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] ) ) ) {