]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Replace the region at 0 from coreboot tables to available in BSD
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 25 Mar 2013 09:23:04 +0000 (10:23 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 25 Mar 2013 09:23:04 +0000 (10:23 +0100)
memory map.

ChangeLog
grub-core/commands/lsmmap.c
grub-core/kern/i386/coreboot/mmap.c
grub-core/loader/i386/bsd.c
grub-core/mmap/mmap.c
include/grub/memory.h

index 981991bd702a2e15f2d27655bfebf8807ed69eb9..8425aff66fc0dd5641f0f9e9034fb12ec87c638f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-25  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Replace the region at 0 from coreboot tables to available in BSD
+       memory map.
+
 2013-03-24  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * util/grub.d/20_linux_xen.in: Automatically add no-real-mode edd=off on
index c1a05d82920215a4b49d10ecd722d928bd855a19..0d298559c8cdb303209d89552084e39d503be62e 100644 (file)
@@ -37,6 +37,7 @@ static const char *names[] =
        is required to save accross hibernations.  */
     [GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage RAM"),
     [GRUB_MEMORY_BADRAM] = N_("faulty RAM (BadRAM)"),
+    [GRUB_MEMORY_COREBOOT_TABLES] = N_("RAM holding coreboot tables"),
     [GRUB_MEMORY_CODE] = N_("RAM holding firmware code"),
     [GRUB_MEMORY_HOLE] = N_("Address range not associated with RAM")
   };
index 6a14d2910cd767dd38580d7cefc41555a0ba9784..0aade62e1dcc71b67c3ddff753e7e4d1d1bc90ba 100644 (file)
@@ -86,6 +86,8 @@ struct grub_machine_mmap_iterate_ctx
   void *hook_data;
 };
 
+#define GRUB_MACHINE_MEMORY_BADRAM     5
+
 /* Helper for grub_machine_mmap_iterate.  */
 static int
 iterate_linuxbios_table (grub_linuxbios_table_item_t table_item, void *data)
@@ -105,7 +107,9 @@ iterate_linuxbios_table (grub_linuxbios_table_item_t table_item, void *data)
                     /* Multiboot mmaps match with the coreboot mmap
                        definition.  Therefore, we can just pass type
                        through.  */
-                    mem_region->type, ctx->hook_data))
+                    (((mem_region->type <= GRUB_MACHINE_MEMORY_BADRAM) && (mem_region->type >= GRUB_MACHINE_MEMORY_AVAILABLE))
+                     || mem_region->type == GRUB_MEMORY_COREBOOT_TABLES) ? mem_region->type : GRUB_MEMORY_RESERVED,
+                    ctx->hook_data))
        return 1;
 
       mem_region++;
index e89ec2690f7674a27b932d99a375e83517056417..5fe586fd12a296811dfec45d5c13d36b660f38cc 100644 (file)
@@ -268,6 +268,7 @@ struct grub_e820_mmap
 #define GRUB_E820_ACPI       3
 #define GRUB_E820_NVS        4
 #define GRUB_E820_BADRAM     5
+#define GRUB_E820_COREBOOT_TABLES 0x10
 
 /* Context for generate_e820_mmap.  */
 struct generate_e820_mmap_ctx
@@ -299,13 +300,21 @@ generate_e820_mmap_iter (grub_uint64_t addr, grub_uint64_t size,
     case GRUB_MEMORY_NVS:
       ctx->cur.type = GRUB_E820_NVS;
       break;
-
+    case GRUB_MEMORY_COREBOOT_TABLES:
+      /* Nowadays the tables at 0 don't contain anything important but
+       *BSD needs the memory at 0 for own needs.
+       */
+      if (addr == 0)
+       ctx->cur.type = GRUB_E820_RAM;
+      else
+       ctx->cur.type = GRUB_E820_COREBOOT_TABLES;
+      break;
     default:
     case GRUB_MEMORY_CODE:
     case GRUB_MEMORY_RESERVED:
       ctx->cur.type = GRUB_E820_RESERVED;
       break;
-    }
+    }  
 
   /* Merge regions if possible. */
   if (ctx->count && ctx->cur.type == ctx->prev.type
index 40ffb2e511b14ac0b442022b44495b28a11c6ab8..d8bd8d2e691ee79d957ae84430cc4534cdb4261e 100644 (file)
@@ -47,6 +47,7 @@ static const int priority[] =
   [GRUB_MEMORY_AVAILABLE] = 1,
   [GRUB_MEMORY_RESERVED] = 3,
   [GRUB_MEMORY_ACPI] = 2,
+  [GRUB_MEMORY_COREBOOT_TABLES] = 2,
   [GRUB_MEMORY_CODE] = 3,
   [GRUB_MEMORY_NVS] = 3,
   [GRUB_MEMORY_HOLE] = 4,
index 3311fcb941d7dc2ecb6520b1f0bfb60339866803..0df807424deb52ff703864057bb4e4bff78fb9de 100644 (file)
@@ -30,6 +30,7 @@ typedef enum grub_memory_type
     GRUB_MEMORY_ACPI = 3,
     GRUB_MEMORY_NVS = 4,
     GRUB_MEMORY_BADRAM = 5,
+    GRUB_MEMORY_COREBOOT_TABLES = 16,
     GRUB_MEMORY_CODE = 20,
     /* This one is special: it's used internally but is never reported
        by firmware. */