]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2009-02-22 Robert Millan <rmh@aybabtu.com>
authorrobertmh <robertmh@localhost>
Sun, 22 Feb 2009 00:44:22 +0000 (00:44 +0000)
committerrobertmh <robertmh@localhost>
Sun, 22 Feb 2009 00:44:22 +0000 (00:44 +0000)
        * include/multiboot.h (MULTIBOOT_INFO_ALIGN): New macro.
        * loader/i386/pc/multiboot.c (grub_multiboot): Include the MBI
        in our relocation, instead of using it directly from heap.  Also
        use `MULTIBOOT_INFO_ALIGN' to ensure it is aligned.

ChangeLog
include/multiboot.h
loader/i386/pc/multiboot.c

index 0ec24e97010c4def2b6222900545721878d94406..25c27a9aa8162aa5dd79de271c916fcf7749bdbb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-02-22  Robert Millan  <rmh@aybabtu.com>
+
+       * include/multiboot.h (MULTIBOOT_INFO_ALIGN): New macro.
+       * loader/i386/pc/multiboot.c (grub_multiboot): Include the MBI
+       in our relocation, instead of using it directly from heap.  Also
+       use `MULTIBOOT_INFO_ALIGN' to ensure it is aligned.
+
 2009-02-21  Robert Millan  <rmh@aybabtu.com>
 
        Implement USB keyboard support (based on patch by Marco Gerards)
index 9adc8736a349b1334e881d50c75db51e2f974abf..2298fa200f2c55c19ca8a8f1177ef4c0661819a3 100644 (file)
@@ -1,7 +1,7 @@
 /* multiboot.h - multiboot header file. */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2003,2007  Free Software Foundation, Inc.
+ *  Copyright (C) 2003,2007,2009  Free Software Foundation, Inc.
  *
  *  GRUB is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -35,6 +35,9 @@
 /* Alignment of multiboot modules.  */
 #define MULTIBOOT_MOD_ALIGN              0x00001000
 
+/* Alignment of the multiboot info structure.  */
+#define MULTIBOOT_INFO_ALIGN            0x00000004
+
 /* 
  * Flags set in the 'flags' member of the multiboot header.
  */
index c0d1fe1ca493f8931c694f8a950ace498c1c1141..b45bc472a977e4200bce5b5e7ee92833698940c4 100644 (file)
@@ -1,7 +1,7 @@
 /* multiboot.c - boot a multiboot OS image. */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008  Free Software Foundation, Inc.
+ *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009  Free Software Foundation, Inc.
  *
  *  GRUB is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -363,6 +363,7 @@ grub_multiboot (int argc, char *argv[])
   char buffer[MULTIBOOT_SEARCH], *cmdline = 0, *p;
   struct grub_multiboot_header *header;
   grub_ssize_t len;
+  grub_uint32_t mmap_length;
   int i;
 
   grub_loader_unset ();
@@ -417,14 +418,9 @@ grub_multiboot (int argc, char *argv[])
       playground = NULL;
     }
 
-  mbi = grub_malloc (sizeof (struct grub_multiboot_info));
-  if (! mbi)
-    goto fail;
-
-  grub_memset (mbi, 0, sizeof (struct grub_multiboot_info));
+  mmap_length = grub_get_multiboot_mmap_len ();
 
-  mbi->mmap_length = grub_get_multiboot_mmap_len ();
-  grub_multiboot_payload_size = mbi->mmap_length;
+  grub_multiboot_payload_size = sizeof (struct grub_multiboot_info) + mmap_length + MULTIBOOT_INFO_ALIGN;
 
   if (header->flags & MULTIBOOT_AOUT_KLUDGE)
     {
@@ -462,6 +458,11 @@ grub_multiboot (int argc, char *argv[])
   else if (grub_multiboot_load_elf (file, buffer) != GRUB_ERR_NONE)
     goto fail;
 
+  grub_multiboot_payload_size = ALIGN_UP (grub_multiboot_payload_size, MULTIBOOT_INFO_ALIGN);
+
+  mbi = grub_multiboot_payload_orig + grub_multiboot_payload_size - mmap_length - sizeof (struct grub_multiboot_info);
+  grub_memset (mbi, 0, sizeof (struct grub_multiboot_info));
+  mbi->mmap_length = mmap_length;
       
   grub_fill_multiboot_mmap ((struct grub_multiboot_mmap_entry *) (grub_multiboot_payload_orig
                                                                  + grub_multiboot_payload_size