Blame SOURCES/0064-grub-core-kern-i386-pc-mmap.c-Fallback-to-EISA-memor.patch

a85e8e
From dd0a4f1120118f08a4d760ceec511238321779f8 Mon Sep 17 00:00:00 2001
a85e8e
From: Vladimir Serbinenko <phcoder@gmail.com>
a85e8e
Date: Fri, 28 Feb 2014 10:07:11 +0100
a85e8e
Subject: [PATCH 064/260] * grub-core/kern/i386/pc/mmap.c: Fallback to EISA
a85e8e
 memory map if E820 failed to return any regions.
a85e8e
a85e8e
---
a85e8e
 ChangeLog                     |  5 +++++
a85e8e
 grub-core/kern/i386/pc/mmap.c | 40 +++++++++++++++++++++-------------------
a85e8e
 2 files changed, 26 insertions(+), 19 deletions(-)
a85e8e
a85e8e
diff --git a/ChangeLog b/ChangeLog
a85e8e
index 6ed6cf4ec..97cf57e25 100644
a85e8e
--- a/ChangeLog
a85e8e
+++ b/ChangeLog
a85e8e
@@ -1,5 +1,10 @@
a85e8e
 2014-02-28  Vladimir Serbinenko  <phcoder@gmail.com>
a85e8e
 
a85e8e
+	* grub-core/kern/i386/pc/mmap.c: Fallback to EISA memory map
a85e8e
+	if E820 failed to return any regions.
a85e8e
+
a85e8e
+2014-02-28  Vladimir Serbinenko  <phcoder@gmail.com>
a85e8e
+
a85e8e
 	* grub-core/mmap/i386/uppermem.c (lower_hook) [COREBOOT]: Ignore low
a85e8e
 	tables for low memory calculations.
a85e8e
 
a85e8e
diff --git a/grub-core/kern/i386/pc/mmap.c b/grub-core/kern/i386/pc/mmap.c
a85e8e
index 8009e833c..f1375f3e1 100644
a85e8e
--- a/grub-core/kern/i386/pc/mmap.c
a85e8e
+++ b/grub-core/kern/i386/pc/mmap.c
a85e8e
@@ -141,33 +141,35 @@ grub_get_mmap_entry (struct grub_machine_mmap_entry *entry,
a85e8e
 grub_err_t
a85e8e
 grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
a85e8e
 {
a85e8e
-  grub_uint32_t cont;
a85e8e
+  grub_uint32_t cont = 0;
a85e8e
   struct grub_machine_mmap_entry *entry
a85e8e
     = (struct grub_machine_mmap_entry *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
a85e8e
+  int e820_works = 0;
a85e8e
 
a85e8e
-  grub_memset (entry, 0, sizeof (entry));
a85e8e
+  while (1)
a85e8e
+    {
a85e8e
+      grub_memset (entry, 0, sizeof (entry));
a85e8e
 
a85e8e
-  /* Check if grub_get_mmap_entry works.  */
a85e8e
-  cont = grub_get_mmap_entry (entry, 0);
a85e8e
+      cont = grub_get_mmap_entry (entry, cont);
a85e8e
 
a85e8e
-  if (entry->size)
a85e8e
-    do
a85e8e
-      {
a85e8e
-	if (hook (entry->addr, entry->len,
a85e8e
-		  /* GRUB mmaps have been defined to match with the E820 definition.
a85e8e
-		     Therefore, we can just pass type through.  */
a85e8e
-		  entry->type, hook_data))
a85e8e
-	  break;
a85e8e
+      if (!entry->size)
a85e8e
+	break;
a85e8e
 
a85e8e
-	if (! cont)
a85e8e
-	  break;
a85e8e
+      if (entry->len)
a85e8e
+	e820_works = 1;
a85e8e
+      if (entry->len
a85e8e
+	  && hook (entry->addr, entry->len,
a85e8e
+		   /* GRUB mmaps have been defined to match with
a85e8e
+		      the E820 definition.
a85e8e
+		      Therefore, we can just pass type through.  */
a85e8e
+		   entry->type, hook_data))
a85e8e
+	break;
a85e8e
 
a85e8e
-	grub_memset (entry, 0, sizeof (entry));
a85e8e
+      if (! cont)
a85e8e
+	break;
a85e8e
+    }
a85e8e
 
a85e8e
-	cont = grub_get_mmap_entry (entry, cont);
a85e8e
-      }
a85e8e
-    while (entry->size);
a85e8e
-  else
a85e8e
+  if (!e820_works)
a85e8e
     {
a85e8e
       grub_uint32_t eisa_mmap = grub_get_eisa_mmap ();
a85e8e
 
a85e8e
-- 
a85e8e
2.13.0
a85e8e