]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Make grub_prefix into module to fix the arbitrary limit and save
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 18 Oct 2011 13:21:51 +0000 (15:21 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 18 Oct 2011 13:21:51 +0000 (15:21 +0200)
some space.

* grub-core/kern/emu/main.c (grub_prefix): Removed.
* grub-core/kern/i386/coreboot/startup.S (grub_prefix): Likewise.
* grub-core/kern/i386/efi/startup.S (grub_prefix): Likewise.
* grub-core/kern/i386/ieee1275/startup.S (grub_prefix): Likewise.
* grub-core/kern/i386/pc/startup.S (grub_prefix): Likewise.
* grub-core/kern/i386/qemu/startup.S (grub_prefix): Likewise.
* grub-core/kern/ia64/efi/startup.S (grub_prefix): Likewise.
* grub-core/kern/mips/startup.S (grub_prefix): Likewise.
* grub-core/kern/powerpc/ieee1275/startup.S (grub_prefix): Likewise.
* grub-core/kern/sparc64/ieee1275/crt0.S (grub_prefix): Likewise.
* grub-core/kern/x86_64/efi/startup.S (grub_prefix): Likewise.
* include/grub/ia64/efi/kernel.h: Removed.
* include/grub/kernel.h: New module type OBJ_TYPE_PREFIX.
(grub_prefix): Removed.
* include/grub/offsets.h (GRUB_KERNEL_I386_PC_PREFIX): Removed.
(GRUB_KERNEL_I386_PC_PREFIX_END): Likewise.
(GRUB_KERNEL_I386_QEMU_PREFIX): Likewise.
(GRUB_KERNEL_I386_QEMU_PREFIX_END): Likewise.
(GRUB_KERNEL_SPARC64_IEEE1275_PREFIX): Likewise.
(GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END): Likewise.
(GRUB_KERNEL_POWERPC_IEEE1275_PREFIX): Likewise.
(GRUB_KERNEL_POWERPC_IEEE1275_PREFIX_END): Likewise.
(GRUB_KERNEL_MIPS_LOONGSON_PREFIX): Likewise.
(GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END): Likewise.
(GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX): Likewise.
(GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END): Likewise.
(GRUB_KERNEL_MIPS_ARC_PREFIX): Likewise.
(GRUB_KERNEL_MIPS_ARC_PREFIX_END): Likewise.
(GRUB_KERNEL_I386_EFI_PREFIX): Likewise.
(GRUB_KERNEL_I386_EFI_PREFIX_END): Likewise.
(GRUB_KERNEL_IA64_EFI_PREFIX): Likewise.
(GRUB_KERNEL_IA64_EFI_PREFIX_END): Likewise.
(GRUB_KERNEL_X86_64_EFI_PREFIX): Likewise.
(GRUB_KERNEL_X86_64_EFI_PREFIX_END): Likewise.
(GRUB_KERNEL_I386_COREBOOT_PREFIX): Likewise.
(GRUB_KERNEL_I386_COREBOOT_PREFIX_END): Likewise.
(GRUB_KERNEL_I386_MULTIBOOT_PREFIX): Likewise.
(GRUB_KERNEL_I386_MULTIBOOT_PREFIX_END): Likewise.
(GRUB_KERNEL_I386_IEEE1275_PREFIX): Likewise.
(GRUB_KERNEL_I386_IEEE1275_PREFIX_END): Likewise.
(GRUB_KERNEL_MACHINE_PREFIX): Likewise.
(GRUB_KERNEL_MACHINE_PREFIX_END): Likewise.
* grub-core/kern/main.c (grub_set_prefix_and_root): Retrieve grub_prefix
from module.
* util/grub-mkimage.c (image_target_desc): Removed prefix and
prefix_end.
(image_targets): Likewise.
(generate_image): Put prefix as a module.

17 files changed:
ChangeLog
grub-core/kern/emu/main.c
grub-core/kern/i386/coreboot/startup.S
grub-core/kern/i386/efi/startup.S
grub-core/kern/i386/ieee1275/startup.S
grub-core/kern/i386/pc/startup.S
grub-core/kern/i386/qemu/startup.S
grub-core/kern/ia64/efi/startup.S
grub-core/kern/main.c
grub-core/kern/mips/startup.S
grub-core/kern/powerpc/ieee1275/startup.S
grub-core/kern/sparc64/ieee1275/crt0.S
grub-core/kern/x86_64/efi/startup.S
include/grub/ia64/efi/kernel.h [deleted file]
include/grub/kernel.h
include/grub/offsets.h
util/grub-mkimage.c

index 2ce132a1425b79d21422da1fa943174d2e8a43ac..a758fc275ce6ce5531b01d79f9fff4b21d4d35d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,57 @@
+2011-10-18  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Make grub_prefix into module to fix the arbitrary limit and save
+       some space.
+
+       * grub-core/kern/emu/main.c (grub_prefix): Removed.
+       * grub-core/kern/i386/coreboot/startup.S (grub_prefix): Likewise.
+       * grub-core/kern/i386/efi/startup.S (grub_prefix): Likewise.
+       * grub-core/kern/i386/ieee1275/startup.S (grub_prefix): Likewise.
+       * grub-core/kern/i386/pc/startup.S (grub_prefix): Likewise.
+       * grub-core/kern/i386/qemu/startup.S (grub_prefix): Likewise.
+       * grub-core/kern/ia64/efi/startup.S (grub_prefix): Likewise.
+       * grub-core/kern/mips/startup.S (grub_prefix): Likewise.
+       * grub-core/kern/powerpc/ieee1275/startup.S (grub_prefix): Likewise.
+       * grub-core/kern/sparc64/ieee1275/crt0.S (grub_prefix): Likewise.
+       * grub-core/kern/x86_64/efi/startup.S (grub_prefix): Likewise.
+       * include/grub/ia64/efi/kernel.h: Removed.
+       * include/grub/kernel.h: New module type OBJ_TYPE_PREFIX.
+       (grub_prefix): Removed.
+       * include/grub/offsets.h (GRUB_KERNEL_I386_PC_PREFIX): Removed.
+       (GRUB_KERNEL_I386_PC_PREFIX_END): Likewise.
+       (GRUB_KERNEL_I386_QEMU_PREFIX): Likewise.
+       (GRUB_KERNEL_I386_QEMU_PREFIX_END): Likewise.
+       (GRUB_KERNEL_SPARC64_IEEE1275_PREFIX): Likewise.
+       (GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END): Likewise.
+       (GRUB_KERNEL_POWERPC_IEEE1275_PREFIX): Likewise.
+       (GRUB_KERNEL_POWERPC_IEEE1275_PREFIX_END): Likewise.
+       (GRUB_KERNEL_MIPS_LOONGSON_PREFIX): Likewise.
+       (GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END): Likewise.
+       (GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX): Likewise.
+       (GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END): Likewise.
+       (GRUB_KERNEL_MIPS_ARC_PREFIX): Likewise.
+       (GRUB_KERNEL_MIPS_ARC_PREFIX_END): Likewise.
+       (GRUB_KERNEL_I386_EFI_PREFIX): Likewise.
+       (GRUB_KERNEL_I386_EFI_PREFIX_END): Likewise.
+       (GRUB_KERNEL_IA64_EFI_PREFIX): Likewise.
+       (GRUB_KERNEL_IA64_EFI_PREFIX_END): Likewise.
+       (GRUB_KERNEL_X86_64_EFI_PREFIX): Likewise.
+       (GRUB_KERNEL_X86_64_EFI_PREFIX_END): Likewise.
+       (GRUB_KERNEL_I386_COREBOOT_PREFIX): Likewise.
+       (GRUB_KERNEL_I386_COREBOOT_PREFIX_END): Likewise.
+       (GRUB_KERNEL_I386_MULTIBOOT_PREFIX): Likewise.
+       (GRUB_KERNEL_I386_MULTIBOOT_PREFIX_END): Likewise.
+       (GRUB_KERNEL_I386_IEEE1275_PREFIX): Likewise.
+       (GRUB_KERNEL_I386_IEEE1275_PREFIX_END): Likewise.
+       (GRUB_KERNEL_MACHINE_PREFIX): Likewise.
+       (GRUB_KERNEL_MACHINE_PREFIX_END): Likewise.
+       * grub-core/kern/main.c (grub_set_prefix_and_root): Retrieve grub_prefix
+       from module.
+       * util/grub-mkimage.c (image_target_desc): Removed prefix and
+       prefix_end.
+       (image_targets): Likewise.
+       (generate_image): Put prefix as a module.
+
 2011-10-16  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Replace grub_module_iterate with FOR_MODULES.
index d5c09ad47e6c2bd70e99c7c8401548ce6bc8978d..8d15f17c54ab70cb230a0190228773c4d0136b55 100644 (file)
@@ -79,8 +79,6 @@ grub_machine_fini (void)
   grub_console_fini ();
 }
 
-char grub_prefix[64] = "";
-
 \f
 
 static struct option options[] =
index 07c5437c07efd5cffc0231d561675f1bc6bc9991..5e7767bb96534f85847c9ded6f70f465eedf472f 100644 (file)
@@ -40,21 +40,6 @@ start:
 _start:
        jmp codestart
 
-       /*
-        *  This is a special data area at a fixed offset from the beginning.
-        */
-
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX
-
-VARIABLE(grub_prefix)
-       /* to be filled by grub-mkimage */
-
-       /*
-        *  Leave some breathing room for the prefix.
-        */
-
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX_END
-
 /*
  *  Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).
  */
index 5b464ab83c3fe70048785053b238fa834adcc795..49b05c1e65ce15a0a722a8dcc4895249bb6ecca9 100644 (file)
@@ -41,17 +41,6 @@ _start:
          *  This is a special data area 8 bytes from the beginning.
          */
 
-        . = _start + 0x8
-
-VARIABLE(grub_prefix)
-       /* to be filled by grub-mkimage */
-
-        /*
-         *  Leave some breathing room for the prefix.
-         */
-
-        . = _start + 0x50
-
 codestart:
        /*
         *  EFI_SYSTEM_TABLE * and EFI_HANDLE are passed on the stack.
index 82087323b5137fcc4ae4da121311edd5281b436f..6b39f5f3abd2a2ecd546ce566d20d41bb0e5e0c2 100644 (file)
 
 start:
 _start:
-       jmp codestart
-
-       /*
-        *  This is a special data area at a fixed offset from the beginning.
-        */
-
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX
-
-VARIABLE(grub_prefix)
-       /* to be filled by grub-mkimage */
-
-       /*
-        *  Leave some breathing room for the prefix.
-        */
-
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX_END
-
-codestart:
        movl %eax, EXT_C(grub_ieee1275_entry_fn)
        jmp EXT_C(grub_main)
 
index 0fe114add47aaa724c722a9eda577604954b10b6..3bbe34753734c0a10255157f63f0247077a94046 100644 (file)
@@ -455,17 +455,6 @@ gate_a20_check_state:
  */
        . = _start + GRUB_KERNEL_MACHINE_RAW_SIZE
 
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX
-VARIABLE(grub_prefix)
-       /* to be filled by grub-mkimage */
-
-       /*
-        *  Leave some breathing room for the prefix.
-        */
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX_END
-
-
-
 /*
  * grub_exit()
  *
index 7834d1df57af52b0c6e7dd3cf73279b60e4fc5ed..6500de6203fd4ba8a247ca92a7554ebf19b7864d 100644 (file)
@@ -34,14 +34,6 @@ VARIABLE(grub_core_entry_addr)
        .long   0
 VARIABLE(grub_kernel_image_size)
        .long   0
-VARIABLE(grub_prefix)
-       /* to be filled by grub-mkimage */
-
-       /*
-        *  Leave some breathing room for the prefix.
-        */
-
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX_END
 
 codestart:
        /* Relocate to low memory.  First we figure out our location.
index b5e26a2042adcfe3047cfd9a258b509ea6ac8cfe..d75c6d7cc741d5eb38e77b9f8d9bffc76b6ef99a 100644 (file)
@@ -42,13 +42,3 @@ _start:
        br.ret.sptk.few rp
 
        .endp _start
-
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX
-VARIABLE(grub_prefix)
-       .byte 0
-       /* to be filled by grub-mkimage */
-
-       /*
-        *  Leave some breathing room for the prefix.
-        */
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX_END
index 9e1971773d1527f986e085e9431ebca4db332144..77be114220cb3dd44182cab98a33845400d6aa32 100644 (file)
@@ -105,25 +105,32 @@ grub_set_prefix_and_root (void)
   char *path = NULL;
   char *fwdevice = NULL;
   char *fwpath = NULL;
+  char *prefix;
+  struct grub_module_header *header;
+
+  FOR_MODULES (header)
+    if (header->type == OBJ_TYPE_PREFIX)
+      prefix = (char *) header + sizeof (struct grub_module_header);
 
   grub_register_variable_hook ("root", 0, grub_env_write_root);
 
-  {
-    char *pptr = NULL;
-    if (grub_prefix[0] == '(')
-      {
-       pptr = grub_strrchr (grub_prefix, ')');
-       if (pptr)
-         {
-           device = grub_strndup (grub_prefix + 1, pptr - grub_prefix - 1);
-           pptr++;
-         }
-      }
-    if (!pptr)
-      pptr = grub_prefix;
-    if (pptr[0])
-      path = grub_strdup (pptr);
-  }
+  if (prefix)
+    {
+      char *pptr = NULL;
+      if (prefix[0] == '(')
+       {
+         pptr = grub_strrchr (prefix, ')');
+         if (pptr)
+           {
+             device = grub_strndup (prefix + 1, pptr - prefix - 1);
+             pptr++;
+           }
+       }
+      if (!pptr)
+       pptr = prefix;
+      if (pptr[0])
+       path = grub_strdup (pptr);
+    }
   if ((!device || device[0] == ',' || !device[0]) || !path)
     grub_machine_get_bootlocation (&fwdevice, &fwpath);
 
@@ -152,13 +159,13 @@ grub_set_prefix_and_root (void)
     path = fwpath;
   if (device)
     {
-      char *prefix;
+      char *prefix_set;
     
-      prefix = grub_xasprintf ("(%s)%s", device, path ? : "");
-      if (prefix)
+      prefix_set = grub_xasprintf ("(%s)%s", device, path ? : "");
+      if (prefix_set)
        {
-         grub_env_set ("prefix", prefix);
-         grub_free (prefix);
+         grub_env_set ("prefix", prefix_set);
+         grub_free (prefix_set);
        }
       grub_env_set ("root", device);
     }
index da6450237ef78ecf322cb483827ce6ffe549aa00..2476038bc0478b6504a07ea7d94d2fdaa57e0270 100644 (file)
@@ -40,17 +40,6 @@ start:
 VARIABLE(grub_total_modules_size)
        .long 0
 
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX
-
-VARIABLE(grub_prefix)
-
-       /* to be filled by grub-mkimage */
-
-       /*
-        *  Leave some breathing room for the prefix.
-        */
-
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX_END
 VARIABLE (grub_arch_busclock)
        .long 0
 VARIABLE (grub_arch_cpuclock)
index 0b1c233465a2ad58ad6eb4f77a198ca621a864e2..b26c47edbaca7984e1bed93702d23f67d1589a36 100644 (file)
        .globl  start, _start
 start:
 _start:
-       b       codestart
-
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX
-
-VARIABLE(grub_prefix)
-       /* to be filled by grub-mkimage */
-
-       /*
-        *  Leave some breathing room for the prefix.
-        */
-
-       . = _start + GRUB_KERNEL_MACHINE_PREFIX_END
-
-codestart:
        li      2, 0
        li      13, 0
 
index cebdca2b60e67022a8bd75b676f7ab5f0e1a0c83..1466a56f8a12a512d1d91f69ca531b5e2508eaa4 100644 (file)
@@ -35,14 +35,6 @@ VARIABLE(grub_kernel_image_size)
        .word   0
 VARIABLE(grub_compressed_size)
        .word   0
-VARIABLE(grub_prefix)
-       /* to be filled by grub-mkimage */
-
-       /*
-        *  Leave some breathing room for the prefix.
-        */
-
-       . = EXT_C(_start) + GRUB_KERNEL_MACHINE_PREFIX_END
 
 codestart:
        /* Copy the modules past the end of the kernel image.
index fb4fc7b64b6d66bcf105a35afba9568a080c3c50..37efde7fcf78169e95f89ebd7bf3a533238d638f 100644 (file)
@@ -39,21 +39,6 @@ _start:
         . = _start + 0x6
         .byte   GRUB_BOOT_VERSION_MAJOR, GRUB_BOOT_VERSION_MINOR
 
-        /*
-         *  This is a special data area 8 bytes from the beginning.
-         */
-
-        . = _start + 0x8
-
-VARIABLE(grub_prefix)
-       /* to be filled by grub-mkimage */
-
-        /*
-         *  Leave some breathing room for the prefix.
-         */
-
-        . = _start + 0x50
-
 codestart:
        movq    %rcx, EXT_C(grub_efi_image_handle)(%rip)
        movq    %rdx, EXT_C(grub_efi_system_table)(%rip)
diff --git a/include/grub/ia64/efi/kernel.h b/include/grub/ia64/efi/kernel.h
deleted file mode 100644 (file)
index ae75380..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2002,2003,2007,2008,2010  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
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  GRUB is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GRUB_MACHINE_KERNEL_HEADER
-#define GRUB_MACHINE_KERNEL_HEADER   1
-
-/* The offset of GRUB_PREFIX.  */
-#define GRUB_KERNEL_MACHINE_PREFIX             0x8
-
-/* End of the data section. */
-#define GRUB_KERNEL_MACHINE_DATA_END           0x50
-
-#ifndef ASM_FILE
-/* The prefix which points to the directory where GRUB modules and its
-   configuration file are located.  */
-extern char grub_prefix[];
-#endif
-
-#endif /* ! GRUB_MACHINE_KERNEL_HEADER */
index d8c0fed33795a2a413425e04c8716cacc99d95d1..2ff6b246915d58b4ea268638d7d09fb22f5db0c2 100644 (file)
@@ -26,7 +26,8 @@ enum
 {
   OBJ_TYPE_ELF,
   OBJ_TYPE_MEMDISK,
-  OBJ_TYPE_CONFIG
+  OBJ_TYPE_CONFIG,
+  OBJ_TYPE_PREFIX
 };
 
 /* The module header.  */
@@ -98,9 +99,4 @@ void grub_register_exported_symbols (void);
 
 extern void (*EXPORT_VAR(grub_net_poll_cards_idle)) (void);
 
-
-#if ! defined (ASM_FILE)
-extern char grub_prefix[];
-#endif
-
 #endif /* ! GRUB_KERNEL_HEADER */
index e8170fcbe4a4b1c2a74ab97046f5031387d5adcd..526cfee68abc3bb8183b07a39590ed5468adda82 100644 (file)
 
 #define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x730
 
-/* The offset of GRUB_PREFIX.  */
-#define GRUB_KERNEL_I386_PC_PREFIX             GRUB_KERNEL_I386_PC_RAW_SIZE
-
-/* End of the data section. */
-#define GRUB_KERNEL_I386_PC_PREFIX_END         (GRUB_KERNEL_I386_PC_PREFIX + 0x40)
-
 /* The segment where the kernel is loaded.  */
 #define GRUB_BOOT_I386_PC_KERNEL_SEG   0x800
 
 /* The offset of GRUB_KERNEL_IMAGE_SIZE.  */
 #define GRUB_KERNEL_I386_QEMU_KERNEL_IMAGE_SIZE        0xc
 
-/* The offset of GRUB_PREFIX.  */
-#define GRUB_KERNEL_I386_QEMU_PREFIX           0x10
-
-/* End of the data section. */
-#define GRUB_KERNEL_I386_QEMU_PREFIX_END               0x50
-
 #define GRUB_KERNEL_I386_QEMU_LINK_ADDR         0x8200
 
 /* The offset of GRUB_TOTAL_MODULE_SIZE.  */
 /* The offset of GRUB_COMPRESSED_SIZE.  */
 #define GRUB_KERNEL_SPARC64_IEEE1275_COMPRESSED_SIZE   0x10
 
-/* The offset of GRUB_PREFIX.  */
-#define GRUB_KERNEL_SPARC64_IEEE1275_PREFIX            0x14
-
-/* End of the data section. */
-#define GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END                0x114
-
 #define GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE   12
 
 #define GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS       0x4400
 #define GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE                   0
 #define GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR 0x4400
 
-#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX            0x4
-#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX_END        0x44
 #define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
 #define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR 0x200000
 
 #define GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR        0x10
 
 #define GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE    0x08
-#define GRUB_KERNEL_MIPS_LOONGSON_PREFIX               0x0c
-#define GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END           0x54
 
 #define GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR         0x80200000
 #define GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN  32
 #define GRUB_KERNEL_MIPS_QEMU_MIPS_UNCOMPRESSED_SIZE        0xc
 #define GRUB_KERNEL_MIPS_QEMU_MIPS_UNCOMPRESSED_ADDR        0x10
 #define GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE   0x08
-#define GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX              0x0c
-#define GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END          0x54
 
 #define GRUB_KERNEL_MIPS_ARC_LINK_ADDR         0x8bd00000
 
 #define GRUB_KERNEL_MIPS_ARC_UNCOMPRESSED_ADDR        0x10
 
 #define GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE 0x08
-#define GRUB_KERNEL_MIPS_ARC_PREFIX            0x0c
-#define GRUB_KERNEL_MIPS_ARC_PREFIX_END                0x54
-
-/* The offset of GRUB_PREFIX.  */
-#define GRUB_KERNEL_I386_EFI_PREFIX            0x8
 
-/* End of the data section. */
-#define GRUB_KERNEL_I386_EFI_PREFIX_END                0x50
-
-/* The offset of GRUB_PREFIX.  */
-#define GRUB_KERNEL_IA64_EFI_PREFIX            0x50
-
-/* End of the data section. */
-#define GRUB_KERNEL_IA64_EFI_PREFIX_END                0xa0
-
-/* The offset of GRUB_PREFIX.  */
-#define GRUB_KERNEL_X86_64_EFI_PREFIX          0x8
-
-/* End of the data section. */
-#define GRUB_KERNEL_X86_64_EFI_PREFIX_END              0x50
-
-#define GRUB_KERNEL_I386_COREBOOT_PREFIX       0x2
-#define GRUB_KERNEL_I386_COREBOOT_PREFIX_END   0x42
 #define GRUB_KERNEL_I386_COREBOOT_LINK_ADDR    0x8200
 
-#define GRUB_KERNEL_I386_MULTIBOOT_PREFIX      GRUB_KERNEL_I386_COREBOOT_PREFIX
-#define GRUB_KERNEL_I386_MULTIBOOT_PREFIX_END  GRUB_KERNEL_I386_COREBOOT_PREFIX_END
-
-#define GRUB_KERNEL_I386_IEEE1275_PREFIX       0x2
-#define GRUB_KERNEL_I386_IEEE1275_PREFIX_END   0x42
 #define GRUB_KERNEL_I386_IEEE1275_LINK_ADDR    0x10000
 
 #define GRUB_KERNEL_I386_IEEE1275_MOD_ALIGN    0x1000
 #define GRUB_KERNEL_MACHINE_UNCOMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _UNCOMPRESSED_SIZE)
 #define GRUB_KERNEL_MACHINE_UNCOMPRESSED_ADDR GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _UNCOMPRESSED_ADDR)
 
-#define GRUB_KERNEL_MACHINE_PREFIX GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _PREFIX)
-#define GRUB_KERNEL_MACHINE_PREFIX_END GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _PREFIX_END)
 #define GRUB_BOOT_MACHINE_KERNEL_SEG GRUB_OFFSETS_CONCAT (GRUB_BOOT_, GRUB_MACHINE, _KERNEL_SEG)
 #define GRUB_MEMORY_MACHINE_UPPER GRUB_OFFSETS_CONCAT (GRUB_MEMORY_, GRUB_MACHINE, _UPPER)
 #define GRUB_KERNEL_MACHINE_RAW_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _RAW_SIZE)
index 420690923c5d3a1af7b3c0e5088590643ffb16a7..4440fdd127a1bbc0c448a3b55eb2727c2dd01cfb 100644 (file)
@@ -77,8 +77,6 @@ struct image_target_desc
       PLATFORM_FLAGS_DECOMPRESSORS = 2,
       PLATFORM_FLAGS_MODULES_BEFORE_KERNEL = 4,
     } flags;
-  unsigned prefix;
-  unsigned prefix_end;
   unsigned raw_size;
   unsigned total_module_size;
   unsigned kernel_image_size;
@@ -110,8 +108,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0,
       .id = IMAGE_COREBOOT,
       .flags = PLATFORM_FLAGS_NONE,
-      .prefix = GRUB_KERNEL_I386_COREBOOT_PREFIX,
-      .prefix_end = GRUB_KERNEL_I386_COREBOOT_PREFIX_END,
       .raw_size = 0,
       .total_module_size = TARGET_NO_FIELD,
       .kernel_image_size = TARGET_NO_FIELD,
@@ -133,8 +129,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0,
       .id = IMAGE_COREBOOT,
       .flags = PLATFORM_FLAGS_NONE,
-      .prefix = GRUB_KERNEL_I386_MULTIBOOT_PREFIX,
-      .prefix_end = GRUB_KERNEL_I386_MULTIBOOT_PREFIX_END,
       .raw_size = 0,
       .total_module_size = TARGET_NO_FIELD,
       .kernel_image_size = TARGET_NO_FIELD,
@@ -156,8 +150,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0,
       .id = IMAGE_I386_PC, 
       .flags = PLATFORM_FLAGS_LZMA,
-      .prefix = GRUB_KERNEL_I386_PC_PREFIX,
-      .prefix_end = GRUB_KERNEL_I386_PC_PREFIX_END,
       .raw_size = GRUB_KERNEL_I386_PC_RAW_SIZE,
       .total_module_size = GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE,
       .kernel_image_size = GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE,
@@ -175,8 +167,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0,
       .id = IMAGE_I386_PC_PXE, 
       .flags = PLATFORM_FLAGS_LZMA,
-      .prefix = GRUB_KERNEL_I386_PC_PREFIX,
-      .prefix_end = GRUB_KERNEL_I386_PC_PREFIX_END,
       .raw_size = GRUB_KERNEL_I386_PC_RAW_SIZE,
       .total_module_size = GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE,
       .kernel_image_size = GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE,
@@ -194,8 +184,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0,
       .id = IMAGE_EFI,
       .flags = PLATFORM_FLAGS_NONE,
-      .prefix = GRUB_KERNEL_I386_EFI_PREFIX,
-      .prefix_end = GRUB_KERNEL_I386_EFI_PREFIX_END,
       .raw_size = 0,
       .total_module_size = TARGET_NO_FIELD,
       .kernel_image_size = TARGET_NO_FIELD,
@@ -219,8 +207,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0,
       .id = IMAGE_I386_IEEE1275, 
       .flags = PLATFORM_FLAGS_NONE,
-      .prefix = GRUB_KERNEL_I386_IEEE1275_PREFIX,
-      .prefix_end = GRUB_KERNEL_I386_IEEE1275_PREFIX_END,
       .raw_size = 0,
       .total_module_size = TARGET_NO_FIELD,
       .kernel_image_size = TARGET_NO_FIELD,
@@ -242,8 +228,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0,
       .id = IMAGE_QEMU, 
       .flags = PLATFORM_FLAGS_NONE,
-      .prefix = GRUB_KERNEL_I386_QEMU_PREFIX,
-      .prefix_end = GRUB_KERNEL_I386_QEMU_PREFIX_END,
       .raw_size = 0,
       .total_module_size = TARGET_NO_FIELD,
       .compressed_size = TARGET_NO_FIELD,
@@ -261,8 +245,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0, 
       .id = IMAGE_EFI, 
       .flags = PLATFORM_FLAGS_NONE,
-      .prefix = GRUB_KERNEL_X86_64_EFI_PREFIX,
-      .prefix_end = GRUB_KERNEL_X86_64_EFI_PREFIX_END,
       .raw_size = 0,
       .total_module_size = TARGET_NO_FIELD,
       .kernel_image_size = TARGET_NO_FIELD,
@@ -281,8 +263,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0,
       .id = IMAGE_YEELOONG_FLASH, 
       .flags = PLATFORM_FLAGS_DECOMPRESSORS,
-      .prefix = GRUB_KERNEL_MIPS_LOONGSON_PREFIX,
-      .prefix_end = GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END,
       .raw_size = 0,
       .total_module_size = GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE,
       .compressed_size = TARGET_NO_FIELD,
@@ -303,8 +283,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0,
       .id = IMAGE_FULOONG2F_FLASH, 
       .flags = PLATFORM_FLAGS_DECOMPRESSORS,
-      .prefix = GRUB_KERNEL_MIPS_LOONGSON_PREFIX,
-      .prefix_end = GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END,
       .raw_size = 0,
       .total_module_size = GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE,
       .compressed_size = TARGET_NO_FIELD,
@@ -327,8 +305,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0,
       .id = IMAGE_LOONGSON_ELF, 
       .flags = PLATFORM_FLAGS_DECOMPRESSORS,
-      .prefix = GRUB_KERNEL_MIPS_LOONGSON_PREFIX,
-      .prefix_end = GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END,
       .raw_size = 0,
       .total_module_size = GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE,
       .compressed_size = TARGET_NO_FIELD,
@@ -349,8 +325,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 1,
       .id = IMAGE_PPC, 
       .flags = PLATFORM_FLAGS_NONE,
-      .prefix = GRUB_KERNEL_POWERPC_IEEE1275_PREFIX,
-      .prefix_end = GRUB_KERNEL_POWERPC_IEEE1275_PREFIX_END,
       .raw_size = 0,
       .total_module_size = TARGET_NO_FIELD,
       .kernel_image_size = TARGET_NO_FIELD,
@@ -372,8 +346,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 1, 
       .id = IMAGE_SPARC64_RAW,
       .flags = PLATFORM_FLAGS_NONE,
-      .prefix = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX,
-      .prefix_end = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END,
       .raw_size = GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE,
       .total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
       .kernel_image_size = GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE,
@@ -391,8 +363,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 1,
       .id = IMAGE_SPARC64_AOUT,
       .flags = PLATFORM_FLAGS_NONE,
-      .prefix = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX,
-      .prefix_end = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END,
       .raw_size = GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE,
       .total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
       .kernel_image_size = GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE,
@@ -410,8 +380,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0, 
       .id = IMAGE_EFI, 
       .flags = PLATFORM_FLAGS_NONE,
-      .prefix = GRUB_KERNEL_IA64_EFI_PREFIX,
-      .prefix_end = GRUB_KERNEL_IA64_EFI_PREFIX_END,
       .raw_size = 0,
       .total_module_size = TARGET_NO_FIELD,
       .kernel_image_size = TARGET_NO_FIELD,
@@ -431,8 +399,6 @@ struct image_target_desc image_targets[] =
       .id = IMAGE_MIPS_ARC, 
       .flags = (PLATFORM_FLAGS_DECOMPRESSORS
                | PLATFORM_FLAGS_MODULES_BEFORE_KERNEL),
-      .prefix = GRUB_KERNEL_MIPS_ARC_PREFIX,
-      .prefix_end = GRUB_KERNEL_MIPS_ARC_PREFIX_END,
       .raw_size = 0,
       .total_module_size = GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE,
       .compressed_size = TARGET_NO_FIELD,
@@ -453,8 +419,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0,
       .id = IMAGE_LOONGSON_ELF, 
       .flags = PLATFORM_FLAGS_DECOMPRESSORS,
-      .prefix = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX,
-      .prefix_end = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END,
       .raw_size = 0,
       .total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
       .compressed_size = TARGET_NO_FIELD,
@@ -475,8 +439,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 1,
       .id = IMAGE_QEMU_MIPS_FLASH, 
       .flags = PLATFORM_FLAGS_DECOMPRESSORS,
-      .prefix = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX,
-      .prefix_end = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END,
       .raw_size = 0,
       .total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
       .compressed_size = TARGET_NO_FIELD,
@@ -497,8 +459,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 0,
       .id = IMAGE_QEMU_MIPS_FLASH, 
       .flags = PLATFORM_FLAGS_DECOMPRESSORS,
-      .prefix = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX,
-      .prefix_end = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END,
       .raw_size = 0,
       .total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
       .compressed_size = TARGET_NO_FIELD,
@@ -519,8 +479,6 @@ struct image_target_desc image_targets[] =
       .bigendian = 1,
       .id = IMAGE_LOONGSON_ELF, 
       .flags = PLATFORM_FLAGS_DECOMPRESSORS,
-      .prefix = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX,
-      .prefix_end = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END,
       .raw_size = 0,
       .total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
       .compressed_size = TARGET_NO_FIELD,
@@ -797,6 +755,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
   char *kernel_img, *core_img;
   size_t kernel_size, total_module_size, core_size, exec_size;
   size_t memdisk_size = 0, config_size = 0, config_size_pure = 0;
+  size_t prefix_size = 0;
   char *kernel_path;
   size_t offset;
   struct grub_util_path_list *path_list, *p, *next;
@@ -833,6 +792,12 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
       total_module_size += config_size + sizeof (struct grub_module_header);
     }
 
+  if (prefix)
+    {
+      prefix_size = ALIGN_ADDR (strlen (prefix) + 1);
+      total_module_size += prefix_size + sizeof (struct grub_module_header);
+    }
+
   for (p = path_list; p; p = p->next)
     total_module_size += (ALIGN_ADDR (grub_util_get_image_size (p->name))
                          + sizeof (struct grub_module_header));
@@ -848,10 +813,6 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
                               total_module_size, &start_address, &rel_section,
                               &reloc_size, &align, image_target);
 
-  if (image_target->prefix + strlen (prefix) + 1 > image_target->prefix_end)
-    grub_util_error (_("prefix is too long"));
-  strcpy (kernel_img + image_target->prefix, prefix);
-
   if ((image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS)
       && (image_target->total_module_size != TARGET_NO_FIELD))
     *((grub_uint32_t *) (kernel_img + image_target->total_module_size))
@@ -943,6 +904,21 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
       offset += config_size;
     }
 
+  if (prefix)
+    {
+      struct grub_module_header *header;
+
+      header = (struct grub_module_header *) (kernel_img + offset);
+      memset (header, 0, sizeof (struct grub_module_header));
+      header->type = grub_host_to_target32 (OBJ_TYPE_PREFIX);
+      header->size = grub_host_to_target32 (prefix_size + sizeof (*header));
+      offset += sizeof (*header);
+
+      grub_memset (kernel_img + offset, 0, prefix_size);
+      grub_strcpy (kernel_img + offset, prefix);
+      offset += prefix_size;
+    }
+
   grub_util_info ("kernel_img=%p, kernel_size=0x%x", kernel_img, kernel_size);
   compress_kernel (image_target, kernel_img, kernel_size + total_module_size,
                   &core_img, &core_size, comp);