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

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