nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

28f7f8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
39700a
From: Vladimir Serbinenko <phcoder@gmail.com>
39700a
Date: Fri, 28 Feb 2014 10:07:11 +0100
28f7f8
Subject: [PATCH] * grub-core/kern/i386/pc/mmap.c: Fallback to EISA memory map
28f7f8
 if E820 failed to return any regions.
39700a
39700a
---
39700a
 grub-core/kern/i386/pc/mmap.c | 40 +++++++++++++++++++++-------------------
28f7f8
 ChangeLog                     |  5 +++++
39700a
 2 files changed, 26 insertions(+), 19 deletions(-)
39700a
39700a
diff --git a/grub-core/kern/i386/pc/mmap.c b/grub-core/kern/i386/pc/mmap.c
28f7f8
index 8009e833c1a..f1375f3e12d 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
 
28f7f8
diff --git a/ChangeLog b/ChangeLog
28f7f8
index 6ed6cf4ec2b..97cf57e253d 100644
28f7f8
--- a/ChangeLog
28f7f8
+++ b/ChangeLog
28f7f8
@@ -1,3 +1,8 @@
28f7f8
+2014-02-28  Vladimir Serbinenko  <phcoder@gmail.com>
28f7f8
+
28f7f8
+	* grub-core/kern/i386/pc/mmap.c: Fallback to EISA memory map
28f7f8
+	if E820 failed to return any regions.
28f7f8
+
28f7f8
 2014-02-28  Vladimir Serbinenko  <phcoder@gmail.com>
28f7f8
 
28f7f8
 	* grub-core/mmap/i386/uppermem.c (lower_hook) [COREBOOT]: Ignore low