]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/loader/i386/linux.c (prot_init_space): New variable.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 7 Mar 2012 22:45:20 +0000 (23:45 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 7 Mar 2012 22:45:20 +0000 (23:45 +0100)
(allocate_pages): Improve dprintf.
(grub_cmd_linux): Fill prot_init_space. Fix improper usage of
code32_start. Fill code32_start and kernel_alignment in params.
(grub_cmd_initrd): Use prot_init_space.

ChangeLog
grub-core/loader/i386/linux.c

index 4776e2b46c049b2de5a8b668b786b5662e4aaafc..7c2f35aa71e6cab64c8b0ab938ea9c99ec4d3a12 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-03-07  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/loader/i386/linux.c (prot_init_space): New variable.
+       (allocate_pages): Improve dprintf.
+       (grub_cmd_linux): Fill prot_init_space. Fix improper usage of
+       code32_start. Fill code32_start and kernel_alignment in params.
+       (grub_cmd_initrd): Use prot_init_space.
+
 2012-03-06  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * util/grub-mkstandalone.in: Propagate grub-mkimage.c change.
index 06253462af65949adf26961a8b6374b79cd069ab..13e880f6b656e6a1c0d13a0a8abacc978d267315 100644 (file)
@@ -73,6 +73,7 @@ static void *initrd_mem;
 static grub_addr_t initrd_mem_target;
 static grub_uint32_t real_mode_pages;
 static grub_uint32_t prot_mode_pages;
+static grub_size_t prot_init_space;
 static grub_uint32_t initrd_pages;
 static struct grub_relocator *relocator = NULL;
 static void *efi_mmap_buf;
@@ -311,11 +312,12 @@ allocate_pages (grub_size_t prot_size, grub_size_t *align,
     prot_mode_target = get_physical_target_address (ch);
   }
 
-  grub_dprintf ("linux", "real_mode_mem = %lx, real_mode_pages = %x, "
-                "prot_mode_mem = %lx, prot_mode_pages = %x\n",
-                (unsigned long) real_mode_mem, (unsigned) real_mode_pages,
-                (unsigned long) prot_mode_mem, (unsigned) prot_mode_pages);
-
+  grub_dprintf ("linux", "real_mode_mem = %lx, real_mode_target = %lx, real_mode_pages = %x\n",
+                (unsigned long) real_mode_mem, (unsigned long) real_mode_target,
+               (unsigned) real_mode_pages);
+  grub_dprintf ("linux", "prot_mode_mem = %lx, prot_mode_target = %lx, prot_mode_pages = %x\n",
+                (unsigned long) prot_mode_mem, (unsigned long) prot_mode_target,
+               (unsigned) prot_mode_pages);
   return GRUB_ERR_NONE;
 
  fail:
@@ -756,13 +758,16 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
     {
       min_align = lh.min_alignment;
       prot_size = grub_le_to_cpu32 (lh.init_size);
+      prot_init_space = page_align (prot_size);
       preffered_address = grub_le_to_cpu64 (lh.pref_address);
     }
   else
     {
-      min_align = 0;
+      min_align = align;
       prot_size = prot_file_size;
-      preffered_address = grub_le_to_cpu32 (lh.code32_start);
+      preffered_address = GRUB_LINUX_BZIMAGE_ADDR;
+      /* Usually, the compression ratio is about 50%.  */
+      prot_init_space = page_align (prot_size) * 3;
     }
 
   if (allocate_pages (prot_size, &align,
@@ -774,6 +779,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
   grub_memset (params, 0, GRUB_LINUX_CL_OFFSET + maximal_cmdline_size);
   grub_memcpy (&params->setup_sects, &lh.setup_sects, sizeof (lh) - 0x1F1);
 
+  params->code32_start = prot_mode_target + lh.code32_start - GRUB_LINUX_BZIMAGE_ADDR;
+  params->kernel_alignment = (1 << align);
   params->ps_mouse = params->padding10 =  0;
 
   len = 0x400 - sizeof (lh);
@@ -1066,8 +1073,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
      worse than that of Linux 2.3.xx, so avoid the last 64kb.  */
   addr_max -= 0x10000;
 
-  /* Usually, the compression ratio is about 50%.  */
-  addr_min = (grub_addr_t) prot_mode_target + ((prot_mode_pages * 3) << 12)
+  addr_min = (grub_addr_t) prot_mode_target + prot_init_space
              + page_align (size);
 
   /* Put the initrd as high as possible, 4KiB aligned.  */