[haiku-commits] r35825 - haiku/trunk/src/system/boot/platform/bios_ia32

Author: bonefish
Date: 2010-03-12 17:59:26 +0100 (Fri, 12 Mar 2010)
New Revision: 35825
Changeset: http://dev.haiku-os.org/changeset/35825/haiku
Ticket: http://dev.haiku-os.org/ticket/5550

Modified:
   haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp
Log:
Ignore physical memory ranges that are smaller than 64 KB. Those don't
contribute significantly to the usable memory, but possibly make the MTRR
setup impossible. Might improve #5550.


Modified: haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp
===================================================================
--- haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp      2010-03-12 
16:55:42 UTC (rev 35824)
+++ haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp      2010-03-12 
16:59:26 UTC (rev 35825)
@@ -697,9 +697,24 @@
                        }
                }
 
-               // sort the range
+               // sort the ranges
                sort_addr_range(gKernelArgs.physical_memory_range,
                        gKernelArgs.num_physical_memory_ranges);
+
+               // On some machines we get several ranges that contain only a 
few pages
+               // (or even only one) each, which causes us to run out of MTRRs 
later.
+               // So we remove all ranges smaller than 64 KB, hoping that this 
will
+               // leave us only with a few larger contiguous ranges (ideally 
one).
+               for (int32 i = gKernelArgs.num_physical_memory_ranges - 1; i >= 
0;
+                               i--) {
+                       size_t size = gKernelArgs.physical_memory_range[i].size;
+                       if (size < 64 * 1024) {
+                               addr_t start = 
gKernelArgs.physical_memory_range[i].start;
+                               
remove_address_range(gKernelArgs.physical_memory_range,
+                                       &gKernelArgs.num_physical_memory_ranges,
+                                       MAX_PHYSICAL_MEMORY_RANGE, start, size);
+                       }
+               }
        } else {
                // TODO: for now!
                dprintf("No extended memory block - using 64 MB (fix me!)\n");


Other related posts: