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

6b3c76
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
6b3c76
Subject: [PATCH 064/261] * grub-core/kern/i386/pc/mmap.c: Fallback to EISA
6b3c76
 memory map if E820 failed to return any regions.
a85e8e
a85e8e
---
d41074
 ChangeLog                     |  5 +++++
6b3c76
 grub-core/kern/i386/pc/mmap.c | 40 +++++++++++++++++++++-------------------
a85e8e
 2 files changed, 26 insertions(+), 19 deletions(-)
a85e8e
6b3c76
diff --git a/ChangeLog b/ChangeLog
6b3c76
index 6ed6cf4ec..97cf57e25 100644
6b3c76
--- a/ChangeLog
6b3c76
+++ b/ChangeLog
6b3c76
@@ -1,5 +1,10 @@
6b3c76
 2014-02-28  Vladimir Serbinenko  <phcoder@gmail.com>
6b3c76
 
6b3c76
+	* grub-core/kern/i386/pc/mmap.c: Fallback to EISA memory map
6b3c76
+	if E820 failed to return any regions.
6b3c76
+
6b3c76
+2014-02-28  Vladimir Serbinenko  <phcoder@gmail.com>
6b3c76
+
6b3c76
 	* grub-core/mmap/i386/uppermem.c (lower_hook) [COREBOOT]: Ignore low
6b3c76
 	tables for low memory calculations.
6b3c76
 
a85e8e
diff --git a/grub-core/kern/i386/pc/mmap.c b/grub-core/kern/i386/pc/mmap.c
6b3c76
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
 
6b3c76
-- 
6b3c76
2.13.5
6b3c76