diff -ru grub-0.92.old/stage2/boot.c grub-0.92/stage2/boot.c --- grub-0.92.old/stage2/boot.c 2002-06-28 21:17:01.000000000 -0300 +++ grub-0.92/stage2/boot.c 2002-06-28 19:43:48.000000000 -0300 @@ -393,6 +394,7 @@ shells. Thus, the code below does a trick to avoid the bug. That is, copy "mem=XXX" to the end of the command-line, and avoid to copy spaces unnecessarily. Hell. */ + if (load_flags & KERNEL_REALLY_LOAD) { char *src = skip_to (0, arg); char *mem; diff -ru grub-0.92.old/stage2/common.c grub-0.92/stage2/common.c --- grub-0.92.old/stage2/common.c 2002-03-25 18:43:55.000000000 -0300 +++ grub-0.92/stage2/common.c 2002-06-28 21:15:13.000000000 -0300 @@ -107,26 +107,43 @@ unsigned long long top; unsigned long addr; int cont; - + top = bottom; - do - { - for (cont = 0, addr = mbi.mmap_addr; - addr < mbi.mmap_addr + mbi.mmap_length; - addr += *((unsigned long *) addr) + 4) + /* If detecting mbi.mem_lower */ + if (bottom == 0) { + /* Initialize to 640Kb */ + top = 0xA0000ULL; + for (addr = mbi.mmap_addr; + addr < mbi.mmap_addr + mbi.mmap_length; + addr += *((unsigned long *) addr) + 4) { + struct AddrRangeDesc *desc = (struct AddrRangeDesc *) addr; + + /* If there is anything reserved below 640Kb */ + if (desc->BaseAddr < top && desc->Length && + desc->Type != MB_ARD_MEMORY) + top = desc->BaseAddr; + } + } + else { + do { - struct AddrRangeDesc *desc = (struct AddrRangeDesc *) addr; - - if (desc->Type == MB_ARD_MEMORY - && desc->BaseAddr <= top - && desc->BaseAddr + desc->Length > top) + for (cont = 0, addr = mbi.mmap_addr; + addr < mbi.mmap_addr + mbi.mmap_length; + addr += *((unsigned long *) addr) + 4) { - top = desc->BaseAddr + desc->Length; - cont++; + struct AddrRangeDesc *desc = (struct AddrRangeDesc *) addr; + + if (desc->Type == MB_ARD_MEMORY + && desc->BaseAddr <= top + && desc->BaseAddr + desc->Length > top) + { + top = desc->BaseAddr + desc->Length; + cont++; + } } } + while (cont); } - while (cont); /* For now, GRUB assumes 32bits addresses, so... */ if (top > 0xFFFFFFFF) @@ -193,6 +210,7 @@ if (mbi.mmap_length) { unsigned long long max_addr; + unsigned long mem_lower = mmap_avail_at (0) >> 10; /* * This is to get the lower memory, and upper memory (up to the @@ -200,7 +218,8 @@ * elements. This is for OS's that don't care about the memory * map, but might care about total RAM available. */ - mbi.mem_lower = mmap_avail_at (0) >> 10; + if (mem_lower < mbi.mem_lower) + mbi.mem_lower = mem_lower; mbi.mem_upper = mmap_avail_at (0x100000) >> 10; /* Find the maximum available address. Ignore any memory holes. */