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