dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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