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

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