Skip to contentSkip to conversation

grub-mkelfimage

PATCH In review Robert Millan 2 participants 6 messages Aug 3, 2008 – Aug 14, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 grub-mkelfimage

The elf version of grub-mkimage is multiplatform, so it makes no sense to keep it as arch-specific in the build system IMHO.

This patch renames it to grub-mkelfimage, and arranges the build system & headers so that its build parameters are shared between i386-ieee1275 and i386-coreboot (and in the future, among powerpc-* platforms).

Aside from making life easier for distributors (less duplicated space), the big advantage in doing this is that one can now install grub-coreboot at the same time as grub-pc without causing a file conflict.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
common.rmk +6 -0
Index: conf/common.rmk
===================================================================
@@ -1,5 +1,11 @@
 # -*- makefile -*-
 
+# For grub-mkelfimage.
+bin_UTILITIES += grub-mkelfimage
+grub_mkelfimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
+	util/resolve.c
+util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
+
 # For grub-probe.
 sbin_UTILITIES += grub-probe
 util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
i386-coreboot.rmk +0 -7
Index: conf/i386-coreboot.rmk
===================================================================
@@ -39,18 +39,11 @@
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-	util/resolve.c
-grub_mkimage_LDFLAGS = $(LIBLZO)
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/i386/get_disk_name.c
powerpc-ieee1275.rmk +0 -6
Index: conf/powerpc-ieee1275.rmk
===================================================================
@@ -28,17 +28,11 @@
 pkglib_PROGRAMS = kernel.elf
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
  
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-        util/resolve.c 
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/ieee1275/get_disk_name.c
i386-ieee1275.rmk +0 -7
Index: conf/i386-ieee1275.rmk
===================================================================
@@ -40,18 +40,11 @@
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-	util/resolve.c
-grub_mkimage_LDFLAGS = $(LIBLZO)
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/i386/get_disk_name.c
ieee1275/init.c +1 -0
Index: kern/ieee1275/init.c
===================================================================
@@ -30,6 +30,7 @@
 #include <grub/time.h>
 #include <grub/machine/console.h>
 #include <grub/machine/kernel.h>
+#include <grub/cpu/kernel.h>
 #include <grub/ieee1275/ofdisk.h>
 #include <grub/ieee1275/ieee1275.h>
 
i386/ieee1275/startup.S +3 -3
Index: kern/i386/ieee1275/startup.S
===================================================================
@@ -19,9 +19,9 @@
 #define ASM_FILE	1
 
 #include <grub/symbol.h>
-#include <grub/machine/kernel.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
+#include <grub/cpu/kernel.h>
 #include <multiboot.h>
 #include <multiboot2.h>
 
@@ -45,7 +45,7 @@
 	 *  This is a special data area at a fixed offset from the beginning.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+	. = EXT_C(start) + GRUB_KERNEL_CPU_PREFIX
 
 VARIABLE(grub_prefix)
 	/* to be filled by grub-mkimage */
@@ -54,7 +54,7 @@
 	 *  Leave some breathing room for the prefix.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+	. = EXT_C(start) + GRUB_KERNEL_CPU_DATA_END
 
 codestart:
 	movl %eax, EXT_C(grub_ieee1275_entry_fn)
i386/linuxbios/startup.S +3 -3
Index: kern/i386/linuxbios/startup.S
===================================================================
@@ -19,9 +19,9 @@
 #define ASM_FILE	1
 
 #include <grub/symbol.h>
-#include <grub/machine/kernel.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
+#include <grub/cpu/kernel.h>
 #include <multiboot.h>
 #include <multiboot2.h>
 
@@ -44,7 +44,7 @@
 	 *  This is a special data area at a fixed offset from the beginning.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+	. = EXT_C(start) + GRUB_KERNEL_CPU_PREFIX
 
 VARIABLE(grub_prefix)
 	/* to be filled by grub-mkimage */
@@ -53,7 +53,7 @@
 	 *  Leave some breathing room for the prefix.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+	. = EXT_C(start) + GRUB_KERNEL_CPU_DATA_END
 
 #if 0
 /*
i386/linuxbios/init.c +1 -0
Index: kern/i386/linuxbios/init.c
===================================================================
@@ -33,6 +33,7 @@
 #include <grub/time.h>
 #include <grub/symbol.h>
 #include <grub/cpu/io.h>
+#include <grub/cpu/kernel.h>
 
 #define GRUB_FLOPPY_REG_DIGITAL_OUTPUT		0x3f2
 
grub/powerpc/ieee1275/kernel.h +0 -7
Index: include/grub/powerpc/ieee1275/kernel.h
===================================================================
@@ -21,13 +21,6 @@
 
 #include <grub/symbol.h>
 
-#define GRUB_MOD_ALIGN 0x1000
-
-/* Minimal gap between _end and the start of the modules.  It's a hack
-   for PowerMac to prevent "CLAIM failed" error.  The real fix is to
-   rewrite grub-mkimage to generate valid ELF files.  */
-#define GRUB_MOD_GAP 0x8000
-
 #ifndef ASM_FILE
 
 void EXPORT_FUNC (grub_reboot) (void);
grub/powerpc/kernel.h +33 -0
Index: include/grub/powerpc/kernel.h
===================================================================
@@ -0,0 +1,33 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008  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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER	1
+
+#define GRUB_MOD_ALIGN 0x1000
+
+/* Minimal gap between _end and the start of the modules.  It's a hack
+   for PowerMac to prevent "CLAIM failed" error.  The real fix is to
+   rewrite grub-mkimage to generate valid ELF files.  */
+#define GRUB_MOD_GAP 0x8000
+
+/* prefix not supported on powerpc yet.  */
+#define GRUB_KERNEL_CPU_PREFIX	0
+#define GRUB_KERNEL_CPU_DATA_END	0
+
+#endif
grub/i386/ieee1275/kernel.h +0 -3
Index: include/grub/i386/ieee1275/kernel.h
===================================================================
@@ -1,4 +1 @@
 #include <grub/powerpc/ieee1275/kernel.h>
-
-#define GRUB_KERNEL_MACHINE_PREFIX	0x2
-#define GRUB_KERNEL_MACHINE_DATA_END	0x42
grub/i386/kernel.h +30 -0
Index: include/grub/i386/kernel.h
===================================================================
@@ -0,0 +1,30 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008  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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER	1
+
+#define GRUB_MOD_ALIGN 0x1000
+
+/* Non-zero value is only needed for PowerMacs.  */
+#define GRUB_MOD_GAP 0x0
+
+#define GRUB_KERNEL_CPU_PREFIX	0x2
+#define GRUB_KERNEL_CPU_DATA_END	0x42
+
+#endif
grub/i386/coreboot/kernel.h +0 -8
Index: include/grub/i386/coreboot/kernel.h
===================================================================
@@ -21,16 +21,8 @@
 
 #include <grub/symbol.h>
 
-#define GRUB_MOD_ALIGN 0x1000
-
-/* Non-zero value is only needed for some IEEE-1275 platforms.  */
-#define GRUB_MOD_GAP 0
-
 #ifndef ASM_FILE
 extern char grub_prefix[];
 #endif
 
-#define GRUB_KERNEL_MACHINE_PREFIX	0x2
-#define GRUB_KERNEL_MACHINE_DATA_END	0x42
-
 #endif /* ! GRUB_KERNEL_MACHINE_HEADER */
ieee1275/grub-install.in +2 -2
Index: util/ieee1275/grub-install.in
===================================================================
@@ -34,7 +34,7 @@
 platform=@platform@
 pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
 
-grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
+grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}`
 grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
 grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
 rootdir=
@@ -182,7 +182,7 @@
 modules="$modules $fs_module $partmap_module $devabstraction_module"
 
 # Now perform the installation.
-"$grub_mkimage" --output=${grubdir}/grub $modules || exit 1
+"$grub_mkimage" --directory=${pkglibdir} --output=${grubdir}/grub $modules || exit 1
 
 if test $update_nvram = yes; then
     set $ofpathname dummy
elf/grub-mkimage.c +3 -3
Index: util/elf/grub-mkimage.c
===================================================================
@@ -30,7 +30,7 @@
 #include <grub/util/misc.h>
 #include <grub/util/resolve.h>
 #include <grub/kernel.h>
-#include <grub/machine/kernel.h>
+#include <grub/cpu/kernel.h>
 
 #define GRUB_IEEE1275_NOTE_NAME "PowerPC"
 #define GRUB_IEEE1275_NOTE_TYPE 0x1275
@@ -297,9 +297,9 @@
 
   if (prefix)
     {
-      if (GRUB_KERNEL_MACHINE_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_MACHINE_DATA_END)
+      if (GRUB_KERNEL_CPU_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_CPU_DATA_END)
         grub_util_error ("prefix too long");
-      grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_MACHINE_PREFIX, out);
+      grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_CPU_PREFIX, out);
     }
 
   free (phdrs);
#1 lore raw
Quoted 10 lines · Robert Millan

The elf version of grub-mkimage is multiplatform, so it makes no sense to keep it as arch-specific in the build system IMHO.

This patch renames it to grub-mkelfimage, and arranges the build system & headers so that its build parameters are shared between i386-ieee1275 and i386-coreboot (and in the future, among powerpc-* platforms).

Aside from making life easier for distributors (less duplicated space), the big advantage in doing this is that one can now install grub-coreboot at the same time as grub-pc without causing a file conflict.

Good idea. Can you send in a changelog entry?

--
Marco

#2 lore raw
Quoted 9 lines · Marco Gerards
Quoted 7 lines · Robert Millan

The elf version of grub-mkimage is multiplatform, so it makes no sense to keep it as arch-specific in the build system IMHO.

This patch renames it to grub-mkelfimage, and arranges the build system & headers so that its build parameters are shared between i386-ieee1275 and i386-coreboot (and in the future, among powerpc-* platforms).

Quoted 5 lines
Quoted 3 lines

Aside from making life easier for distributors (less duplicated space), the big advantage in doing this is that one can now install grub-coreboot at the same time as grub-pc without causing a file conflict.

Good idea. Can you send in a changelog entry?

Here it is.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
common.rmk +6 -0
Index: conf/common.rmk
===================================================================
@@ -1,5 +1,11 @@
 # -*- makefile -*-
 
+# For grub-mkelfimage.
+bin_UTILITIES += grub-mkelfimage
+grub_mkelfimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
+	util/resolve.c
+util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
+
 # For grub-probe.
 sbin_UTILITIES += grub-probe
 util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
i386-coreboot.rmk +0 -7
Index: conf/i386-coreboot.rmk
===================================================================
@@ -39,18 +39,11 @@
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-	util/resolve.c
-grub_mkimage_LDFLAGS = $(LIBLZO)
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/i386/get_disk_name.c
powerpc-ieee1275.rmk +0 -6
Index: conf/powerpc-ieee1275.rmk
===================================================================
@@ -28,17 +28,11 @@
 pkglib_PROGRAMS = kernel.elf
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
  
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-        util/resolve.c 
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/ieee1275/get_disk_name.c
i386-ieee1275.rmk +0 -7
Index: conf/i386-ieee1275.rmk
===================================================================
@@ -40,18 +40,11 @@
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-	util/resolve.c
-grub_mkimage_LDFLAGS = $(LIBLZO)
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/i386/get_disk_name.c
ieee1275/init.c +1 -0
Index: kern/ieee1275/init.c
===================================================================
@@ -30,6 +30,7 @@
 #include <grub/time.h>
 #include <grub/machine/console.h>
 #include <grub/machine/kernel.h>
+#include <grub/cpu/kernel.h>
 #include <grub/ieee1275/ofdisk.h>
 #include <grub/ieee1275/ieee1275.h>
 
i386/ieee1275/startup.S +3 -3
Index: kern/i386/ieee1275/startup.S
===================================================================
@@ -19,9 +19,9 @@
 #define ASM_FILE	1
 
 #include <grub/symbol.h>
-#include <grub/machine/kernel.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
+#include <grub/cpu/kernel.h>
 #include <multiboot.h>
 #include <multiboot2.h>
 
@@ -45,7 +45,7 @@
 	 *  This is a special data area at a fixed offset from the beginning.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+	. = EXT_C(start) + GRUB_KERNEL_CPU_PREFIX
 
 VARIABLE(grub_prefix)
 	/* to be filled by grub-mkimage */
@@ -54,7 +54,7 @@
 	 *  Leave some breathing room for the prefix.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+	. = EXT_C(start) + GRUB_KERNEL_CPU_DATA_END
 
 codestart:
 	movl %eax, EXT_C(grub_ieee1275_entry_fn)
i386/linuxbios/startup.S +3 -3
Index: kern/i386/linuxbios/startup.S
===================================================================
@@ -19,9 +19,9 @@
 #define ASM_FILE	1
 
 #include <grub/symbol.h>
-#include <grub/machine/kernel.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
+#include <grub/cpu/kernel.h>
 #include <multiboot.h>
 #include <multiboot2.h>
 
@@ -44,7 +44,7 @@
 	 *  This is a special data area at a fixed offset from the beginning.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+	. = EXT_C(start) + GRUB_KERNEL_CPU_PREFIX
 
 VARIABLE(grub_prefix)
 	/* to be filled by grub-mkimage */
@@ -53,7 +53,7 @@
 	 *  Leave some breathing room for the prefix.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+	. = EXT_C(start) + GRUB_KERNEL_CPU_DATA_END
 
 #if 0
 /*
i386/linuxbios/init.c +1 -0
Index: kern/i386/linuxbios/init.c
===================================================================
@@ -33,6 +33,7 @@
 #include <grub/time.h>
 #include <grub/symbol.h>
 #include <grub/cpu/io.h>
+#include <grub/cpu/kernel.h>
 
 #define GRUB_FLOPPY_REG_DIGITAL_OUTPUT		0x3f2
 
grub/powerpc/ieee1275/kernel.h +0 -7
Index: include/grub/powerpc/ieee1275/kernel.h
===================================================================
@@ -21,13 +21,6 @@
 
 #include <grub/symbol.h>
 
-#define GRUB_MOD_ALIGN 0x1000
-
-/* Minimal gap between _end and the start of the modules.  It's a hack
-   for PowerMac to prevent "CLAIM failed" error.  The real fix is to
-   rewrite grub-mkimage to generate valid ELF files.  */
-#define GRUB_MOD_GAP 0x8000
-
 #ifndef ASM_FILE
 
 void EXPORT_FUNC (grub_reboot) (void);
grub/powerpc/kernel.h +33 -0
Index: include/grub/powerpc/kernel.h
===================================================================
@@ -0,0 +1,33 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008  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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER	1
+
+#define GRUB_MOD_ALIGN 0x1000
+
+/* Minimal gap between _end and the start of the modules.  It's a hack
+   for PowerMac to prevent "CLAIM failed" error.  The real fix is to
+   rewrite grub-mkimage to generate valid ELF files.  */
+#define GRUB_MOD_GAP 0x8000
+
+/* prefix not supported on powerpc yet.  */
+#define GRUB_KERNEL_CPU_PREFIX	0
+#define GRUB_KERNEL_CPU_DATA_END	0
+
+#endif
grub/i386/ieee1275/kernel.h +0 -3
Index: include/grub/i386/ieee1275/kernel.h
===================================================================
@@ -1,4 +1 @@
 #include <grub/powerpc/ieee1275/kernel.h>
-
-#define GRUB_KERNEL_MACHINE_PREFIX	0x2
-#define GRUB_KERNEL_MACHINE_DATA_END	0x42
grub/i386/kernel.h +30 -0
Index: include/grub/i386/kernel.h
===================================================================
@@ -0,0 +1,30 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008  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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER	1
+
+#define GRUB_MOD_ALIGN 0x1000
+
+/* Non-zero value is only needed for PowerMacs.  */
+#define GRUB_MOD_GAP 0x0
+
+#define GRUB_KERNEL_CPU_PREFIX	0x2
+#define GRUB_KERNEL_CPU_DATA_END	0x42
+
+#endif
grub/i386/coreboot/kernel.h +0 -8
Index: include/grub/i386/coreboot/kernel.h
===================================================================
@@ -21,16 +21,8 @@
 
 #include <grub/symbol.h>
 
-#define GRUB_MOD_ALIGN 0x1000
-
-/* Non-zero value is only needed for some IEEE-1275 platforms.  */
-#define GRUB_MOD_GAP 0
-
 #ifndef ASM_FILE
 extern char grub_prefix[];
 #endif
 
-#define GRUB_KERNEL_MACHINE_PREFIX	0x2
-#define GRUB_KERNEL_MACHINE_DATA_END	0x42
-
 #endif /* ! GRUB_KERNEL_MACHINE_HEADER */
ieee1275/grub-install.in +2 -2
Index: util/ieee1275/grub-install.in
===================================================================
@@ -34,7 +34,7 @@
 platform=@platform@
 pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
 
-grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
+grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}`
 grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
 grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
 rootdir=
@@ -182,7 +182,7 @@
 modules="$modules $fs_module $partmap_module $devabstraction_module"
 
 # Now perform the installation.
-"$grub_mkimage" --output=${grubdir}/grub $modules || exit 1
+"$grub_mkimage" --directory=${pkglibdir} --output=${grubdir}/grub $modules || exit 1
 
 if test $update_nvram = yes; then
     set $ofpathname dummy
elf/grub-mkimage.c +3 -3
Index: util/elf/grub-mkimage.c
===================================================================
@@ -30,7 +30,7 @@
 #include <grub/util/misc.h>
 #include <grub/util/resolve.h>
 #include <grub/kernel.h>
-#include <grub/machine/kernel.h>
+#include <grub/cpu/kernel.h>
 
 #define GRUB_IEEE1275_NOTE_NAME "PowerPC"
 #define GRUB_IEEE1275_NOTE_TYPE 0x1275
@@ -297,9 +297,9 @@
 
   if (prefix)
     {
-      if (GRUB_KERNEL_MACHINE_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_MACHINE_DATA_END)
+      if (GRUB_KERNEL_CPU_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_CPU_DATA_END)
         grub_util_error ("prefix too long");
-      grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_MACHINE_PREFIX, out);
+      grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_CPU_PREFIX, out);
     }
 
   free (phdrs);
common.rmk +6 -0
Index: conf/common.rmk
===================================================================
@@ -1,5 +1,11 @@
 # -*- makefile -*-
 
+# For grub-mkelfimage.
+bin_UTILITIES += grub-mkelfimage
+grub_mkelfimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
+	util/resolve.c
+util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
+
 # For grub-probe.
 sbin_UTILITIES += grub-probe
 util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
powerpc-ieee1275.rmk +0 -6
Index: conf/powerpc-ieee1275.rmk
===================================================================
@@ -28,17 +28,11 @@
 pkglib_PROGRAMS = kernel.elf
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
  
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-        util/resolve.c 
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/ieee1275/get_disk_name.c
i386-coreboot.rmk +0 -7
Index: conf/i386-coreboot.rmk
===================================================================
@@ -44,18 +44,11 @@
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-	util/resolve.c
-grub_mkimage_LDFLAGS = $(LIBLZO)
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/i386/get_disk_name.c
i386-ieee1275.rmk +0 -7
Index: conf/i386-ieee1275.rmk
===================================================================
@@ -41,18 +41,11 @@
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-	util/resolve.c
-grub_mkimage_LDFLAGS = $(LIBLZO)
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/i386/get_disk_name.c
ieee1275/init.c +1 -0
Index: kern/ieee1275/init.c
===================================================================
@@ -30,6 +30,7 @@
 #include <grub/time.h>
 #include <grub/machine/console.h>
 #include <grub/machine/kernel.h>
+#include <grub/cpu/kernel.h>
 #include <grub/ieee1275/ofdisk.h>
 #include <grub/ieee1275/ieee1275.h>
 
i386/ieee1275/startup.S +3 -3
Index: kern/i386/ieee1275/startup.S
===================================================================
@@ -19,9 +19,9 @@
 #define ASM_FILE	1
 
 #include <grub/symbol.h>
-#include <grub/machine/kernel.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
+#include <grub/cpu/kernel.h>
 #include <multiboot.h>
 #include <multiboot2.h>
 
@@ -45,7 +45,7 @@
 	 *  This is a special data area at a fixed offset from the beginning.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+	. = EXT_C(start) + GRUB_KERNEL_CPU_PREFIX
 
 VARIABLE(grub_prefix)
 	/* to be filled by grub-mkimage */
@@ -54,7 +54,7 @@
 	 *  Leave some breathing room for the prefix.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+	. = EXT_C(start) + GRUB_KERNEL_CPU_DATA_END
 
 codestart:
 	movl %eax, EXT_C(grub_ieee1275_entry_fn)
i386/linuxbios/startup.S +3 -3
Index: kern/i386/linuxbios/startup.S
===================================================================
@@ -19,9 +19,9 @@
 #define ASM_FILE	1
 
 #include <grub/symbol.h>
-#include <grub/machine/kernel.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
+#include <grub/cpu/kernel.h>
 #include <multiboot.h>
 #include <multiboot2.h>
 
@@ -44,7 +44,7 @@
 	 *  This is a special data area at a fixed offset from the beginning.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+	. = EXT_C(start) + GRUB_KERNEL_CPU_PREFIX
 
 VARIABLE(grub_prefix)
 	/* to be filled by grub-mkimage */
@@ -53,7 +53,7 @@
 	 *  Leave some breathing room for the prefix.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+	. = EXT_C(start) + GRUB_KERNEL_CPU_DATA_END
 
 #if 0
 /*
i386/linuxbios/init.c +1 -0
Index: kern/i386/linuxbios/init.c
===================================================================
@@ -33,6 +33,7 @@
 #include <grub/time.h>
 #include <grub/symbol.h>
 #include <grub/cpu/io.h>
+#include <grub/cpu/kernel.h>
 
 #define GRUB_FLOPPY_REG_DIGITAL_OUTPUT		0x3f2
 
grub/powerpc/ieee1275/kernel.h +0 -7
Index: include/grub/powerpc/ieee1275/kernel.h
===================================================================
@@ -21,13 +21,6 @@
 
 #include <grub/symbol.h>
 
-#define GRUB_MOD_ALIGN 0x1000
-
-/* Minimal gap between _end and the start of the modules.  It's a hack
-   for PowerMac to prevent "CLAIM failed" error.  The real fix is to
-   rewrite grub-mkimage to generate valid ELF files.  */
-#define GRUB_MOD_GAP 0x8000
-
 #ifndef ASM_FILE
 
 void EXPORT_FUNC (grub_reboot) (void);
grub/powerpc/kernel.h +33 -0
Index: include/grub/powerpc/kernel.h
===================================================================
@@ -0,0 +1,33 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008  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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER	1
+
+#define GRUB_MOD_ALIGN 0x1000
+
+/* Minimal gap between _end and the start of the modules.  It's a hack
+   for PowerMac to prevent "CLAIM failed" error.  The real fix is to
+   rewrite grub-mkimage to generate valid ELF files.  */
+#define GRUB_MOD_GAP 0x8000
+
+/* prefix not supported on powerpc yet.  */
+#define GRUB_KERNEL_CPU_PREFIX	0
+#define GRUB_KERNEL_CPU_DATA_END	0
+
+#endif
grub/i386/ieee1275/kernel.h +0 -3
Index: include/grub/i386/ieee1275/kernel.h
===================================================================
@@ -1,4 +1 @@
 #include <grub/powerpc/ieee1275/kernel.h>
-
-#define GRUB_KERNEL_MACHINE_PREFIX	0x2
-#define GRUB_KERNEL_MACHINE_DATA_END	0x42
grub/i386/kernel.h +30 -0
Index: include/grub/i386/kernel.h
===================================================================
@@ -0,0 +1,30 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008  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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER	1
+
+#define GRUB_MOD_ALIGN 0x1000
+
+/* Non-zero value is only needed for PowerMacs.  */
+#define GRUB_MOD_GAP 0x0
+
+#define GRUB_KERNEL_CPU_PREFIX	0x2
+#define GRUB_KERNEL_CPU_DATA_END	0x42
+
+#endif
grub/i386/coreboot/kernel.h +0 -8
Index: include/grub/i386/coreboot/kernel.h
===================================================================
@@ -21,16 +21,8 @@
 
 #include <grub/symbol.h>
 
-#define GRUB_MOD_ALIGN 0x1000
-
-/* Non-zero value is only needed for some IEEE-1275 platforms.  */
-#define GRUB_MOD_GAP 0
-
 #ifndef ASM_FILE
 extern char grub_prefix[];
 #endif
 
-#define GRUB_KERNEL_MACHINE_PREFIX	0x2
-#define GRUB_KERNEL_MACHINE_DATA_END	0x42
-
 #endif /* ! GRUB_KERNEL_MACHINE_HEADER */
ieee1275/grub-install.in +2 -2
Index: util/ieee1275/grub-install.in
===================================================================
@@ -34,7 +34,7 @@
 platform=@platform@
 pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
 
-grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
+grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}`
 grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
 grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
 rootdir=
@@ -182,7 +182,7 @@
 modules="$modules $fs_module $partmap_module $devabstraction_module"
 
 # Now perform the installation.
-"$grub_mkimage" --output=${grubdir}/grub $modules || exit 1
+"$grub_mkimage" --directory=${pkglibdir} --output=${grubdir}/grub $modules || exit 1
 
 if test $update_nvram = yes; then
     set $ofpathname dummy
elf/grub-mkimage.c +3 -3
Index: util/elf/grub-mkimage.c
===================================================================
@@ -30,7 +30,7 @@
 #include <grub/util/misc.h>
 #include <grub/util/resolve.h>
 #include <grub/kernel.h>
-#include <grub/machine/kernel.h>
+#include <grub/cpu/kernel.h>
 
 #define GRUB_IEEE1275_NOTE_NAME "PowerPC"
 #define GRUB_IEEE1275_NOTE_TYPE 0x1275
@@ -297,9 +297,9 @@
 
   if (prefix)
     {
-      if (GRUB_KERNEL_MACHINE_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_MACHINE_DATA_END)
+      if (GRUB_KERNEL_CPU_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_CPU_DATA_END)
         grub_util_error ("prefix too long");
-      grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_MACHINE_PREFIX, out);
+      grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_CPU_PREFIX, out);
     }
 
   free (phdrs);
#3 lore raw

If there are no objections, I will check this in soon.

The implicit idea is that later we could do the same renames for:

efi -> grub-mkpeimage
pc -> grub-mkrawimage

or something like that. So if someone doesn't like this, it's better to bring it up now.

Quoted 714 lines · Robert Millan
Quoted 9 lines · Marco Gerards
Quoted 7 lines · Robert Millan

The elf version of grub-mkimage is multiplatform, so it makes no sense to keep it as arch-specific in the build system IMHO.

This patch renames it to grub-mkelfimage, and arranges the build system & headers so that its build parameters are shared between i386-ieee1275 and i386-coreboot (and in the future, among powerpc-* platforms).

Quoted 5 lines
Quoted 3 lines

Aside from making life easier for distributors (less duplicated space), the big advantage in doing this is that one can now install grub-coreboot at the same time as grub-pc without causing a file conflict.

Good idea. Can you send in a changelog entry?

Here it is.

Signature · 8 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."

Index: conf/common.rmk
===================================================================
common.rmk +6 -0
@@ -1,5 +1,11 @@
 # -*- makefile -*-
 
+# For grub-mkelfimage.
+bin_UTILITIES += grub-mkelfimage
+grub_mkelfimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
+	util/resolve.c
+util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
+
 # For grub-probe.
 sbin_UTILITIES += grub-probe
 util/grub-probe.c_DEPENDENCIES = grub_probe_init.h

Index: conf/i386-coreboot.rmk
===================================================================

i386-coreboot.rmk +0 -7
@@ -39,18 +39,11 @@
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-	util/resolve.c
-grub_mkimage_LDFLAGS = $(LIBLZO)
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/i386/get_disk_name.c

Index: conf/powerpc-ieee1275.rmk
===================================================================

powerpc-ieee1275.rmk +0 -6
@@ -28,17 +28,11 @@
 pkglib_PROGRAMS = kernel.elf
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-        util/resolve.c 
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/ieee1275/get_disk_name.c

Index: conf/i386-ieee1275.rmk
===================================================================

i386-ieee1275.rmk +0 -7
@@ -40,18 +40,11 @@
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-	util/resolve.c
-grub_mkimage_LDFLAGS = $(LIBLZO)
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/i386/get_disk_name.c

Index: kern/ieee1275/init.c
===================================================================

ieee1275/init.c +1 -0
@@ -30,6 +30,7 @@
 #include <grub/time.h>
 #include <grub/machine/console.h>
 #include <grub/machine/kernel.h>
+#include <grub/cpu/kernel.h>
 #include <grub/ieee1275/ofdisk.h>
 #include <grub/ieee1275/ieee1275.h>
 

Index: kern/i386/ieee1275/startup.S
===================================================================

i386/ieee1275/startup.S +3 -3
@@ -19,9 +19,9 @@
 #define ASM_FILE	1
 
 #include <grub/symbol.h>
-#include <grub/machine/kernel.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
+#include <grub/cpu/kernel.h>
 #include <multiboot.h>
 #include <multiboot2.h>
 
@@ -45,7 +45,7 @@
 	 *  This is a special data area at a fixed offset from the beginning.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+	. = EXT_C(start) + GRUB_KERNEL_CPU_PREFIX
 
 VARIABLE(grub_prefix)
 	/* to be filled by grub-mkimage */
@@ -54,7 +54,7 @@
 	 *  Leave some breathing room for the prefix.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+	. = EXT_C(start) + GRUB_KERNEL_CPU_DATA_END
 
 codestart:
 	movl %eax, EXT_C(grub_ieee1275_entry_fn)

Index: kern/i386/linuxbios/startup.S
===================================================================

i386/linuxbios/startup.S +3 -3
@@ -19,9 +19,9 @@
 #define ASM_FILE	1
 
 #include <grub/symbol.h>
-#include <grub/machine/kernel.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
+#include <grub/cpu/kernel.h>
 #include <multiboot.h>
 #include <multiboot2.h>
 
@@ -44,7 +44,7 @@
 	 *  This is a special data area at a fixed offset from the beginning.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+	. = EXT_C(start) + GRUB_KERNEL_CPU_PREFIX
 
 VARIABLE(grub_prefix)
 	/* to be filled by grub-mkimage */
@@ -53,7 +53,7 @@
 	 *  Leave some breathing room for the prefix.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+	. = EXT_C(start) + GRUB_KERNEL_CPU_DATA_END
 
 #if 0
 /*

Index: kern/i386/linuxbios/init.c
===================================================================

i386/linuxbios/init.c +1 -0
@@ -33,6 +33,7 @@
 #include <grub/time.h>
 #include <grub/symbol.h>
 #include <grub/cpu/io.h>
+#include <grub/cpu/kernel.h>
 
 #define GRUB_FLOPPY_REG_DIGITAL_OUTPUT		0x3f2
 

Index: include/grub/powerpc/ieee1275/kernel.h
===================================================================

grub/powerpc/ieee1275/kernel.h +0 -7
@@ -21,13 +21,6 @@
 
 #include <grub/symbol.h>
 
-#define GRUB_MOD_ALIGN 0x1000
-
-/* Minimal gap between _end and the start of the modules.  It's a hack
-   for PowerMac to prevent "CLAIM failed" error.  The real fix is to
-   rewrite grub-mkimage to generate valid ELF files.  */
-#define GRUB_MOD_GAP 0x8000
-
 #ifndef ASM_FILE
 
 void EXPORT_FUNC (grub_reboot) (void);

Index: include/grub/powerpc/kernel.h
===================================================================

grub/powerpc/kernel.h +33 -0
@@ -0,0 +1,33 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008  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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER	1
+
+#define GRUB_MOD_ALIGN 0x1000
+
+/* Minimal gap between _end and the start of the modules.  It's a hack
+   for PowerMac to prevent "CLAIM failed" error.  The real fix is to
+   rewrite grub-mkimage to generate valid ELF files.  */
+#define GRUB_MOD_GAP 0x8000
+
+/* prefix not supported on powerpc yet.  */
+#define GRUB_KERNEL_CPU_PREFIX	0
+#define GRUB_KERNEL_CPU_DATA_END	0
+
+#endif

Index: include/grub/i386/ieee1275/kernel.h
===================================================================

grub/i386/ieee1275/kernel.h +0 -3
@@ -1,4 +1 @@
 #include <grub/powerpc/ieee1275/kernel.h>
-
-#define GRUB_KERNEL_MACHINE_PREFIX	0x2
-#define GRUB_KERNEL_MACHINE_DATA_END	0x42

Index: include/grub/i386/kernel.h
===================================================================

grub/i386/kernel.h +30 -0
@@ -0,0 +1,30 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008  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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER	1
+
+#define GRUB_MOD_ALIGN 0x1000
+
+/* Non-zero value is only needed for PowerMacs.  */
+#define GRUB_MOD_GAP 0x0
+
+#define GRUB_KERNEL_CPU_PREFIX	0x2
+#define GRUB_KERNEL_CPU_DATA_END	0x42
+
+#endif

Index: include/grub/i386/coreboot/kernel.h
===================================================================

grub/i386/coreboot/kernel.h +0 -8
@@ -21,16 +21,8 @@
 
 #include <grub/symbol.h>
 
-#define GRUB_MOD_ALIGN 0x1000
-
-/* Non-zero value is only needed for some IEEE-1275 platforms.  */
-#define GRUB_MOD_GAP 0
-
 #ifndef ASM_FILE
 extern char grub_prefix[];
 #endif
 
-#define GRUB_KERNEL_MACHINE_PREFIX	0x2
-#define GRUB_KERNEL_MACHINE_DATA_END	0x42
-
 #endif /* ! GRUB_KERNEL_MACHINE_HEADER */

Index: util/ieee1275/grub-install.in
===================================================================

ieee1275/grub-install.in +2 -2
@@ -34,7 +34,7 @@
 platform=@platform@
 pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
 
-grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
+grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}`
 grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
 grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
 rootdir=
@@ -182,7 +182,7 @@
 modules="$modules $fs_module $partmap_module $devabstraction_module"
 
 # Now perform the installation.
-"$grub_mkimage" --output=${grubdir}/grub $modules || exit 1
+"$grub_mkimage" --directory=${pkglibdir} --output=${grubdir}/grub $modules || exit 1
 
 if test $update_nvram = yes; then
     set $ofpathname dummy

Index: util/elf/grub-mkimage.c
===================================================================

elf/grub-mkimage.c +3 -3
@@ -30,7 +30,7 @@
 #include <grub/util/misc.h>
 #include <grub/util/resolve.h>
 #include <grub/kernel.h>
-#include <grub/machine/kernel.h>
+#include <grub/cpu/kernel.h>
 
 #define GRUB_IEEE1275_NOTE_NAME "PowerPC"
 #define GRUB_IEEE1275_NOTE_TYPE 0x1275
@@ -297,9 +297,9 @@
 
   if (prefix)
     {
-      if (GRUB_KERNEL_MACHINE_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_MACHINE_DATA_END)
+      if (GRUB_KERNEL_CPU_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_CPU_DATA_END)
         grub_util_error ("prefix too long");
-      grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_MACHINE_PREFIX, out);
+      grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_CPU_PREFIX, out);
     }
 
   free (phdrs);

Index: conf/common.rmk
===================================================================

common.rmk +6 -0
@@ -1,5 +1,11 @@
 # -*- makefile -*-
 
+# For grub-mkelfimage.
+bin_UTILITIES += grub-mkelfimage
+grub_mkelfimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
+	util/resolve.c
+util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
+
 # For grub-probe.
 sbin_UTILITIES += grub-probe
 util/grub-probe.c_DEPENDENCIES = grub_probe_init.h

Index: conf/powerpc-ieee1275.rmk
===================================================================

powerpc-ieee1275.rmk +0 -6
@@ -28,17 +28,11 @@
 pkglib_PROGRAMS = kernel.elf
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-        util/resolve.c 
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/ieee1275/get_disk_name.c

Index: conf/i386-coreboot.rmk
===================================================================

i386-coreboot.rmk +0 -7
@@ -44,18 +44,11 @@
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-	util/resolve.c
-grub_mkimage_LDFLAGS = $(LIBLZO)
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/i386/get_disk_name.c

Index: conf/i386-ieee1275.rmk
===================================================================

i386-ieee1275.rmk +0 -7
@@ -41,18 +41,11 @@
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-	util/resolve.c
-grub_mkimage_LDFLAGS = $(LIBLZO)
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/i386/get_disk_name.c

Index: kern/ieee1275/init.c
===================================================================

ieee1275/init.c +1 -0
@@ -30,6 +30,7 @@
 #include <grub/time.h>
 #include <grub/machine/console.h>
 #include <grub/machine/kernel.h>
+#include <grub/cpu/kernel.h>
 #include <grub/ieee1275/ofdisk.h>
 #include <grub/ieee1275/ieee1275.h>
 

Index: kern/i386/ieee1275/startup.S
===================================================================

i386/ieee1275/startup.S +3 -3
@@ -19,9 +19,9 @@
 #define ASM_FILE	1
 
 #include <grub/symbol.h>
-#include <grub/machine/kernel.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
+#include <grub/cpu/kernel.h>
 #include <multiboot.h>
 #include <multiboot2.h>
 
@@ -45,7 +45,7 @@
 	 *  This is a special data area at a fixed offset from the beginning.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+	. = EXT_C(start) + GRUB_KERNEL_CPU_PREFIX
 
 VARIABLE(grub_prefix)
 	/* to be filled by grub-mkimage */
@@ -54,7 +54,7 @@
 	 *  Leave some breathing room for the prefix.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+	. = EXT_C(start) + GRUB_KERNEL_CPU_DATA_END
 
 codestart:
 	movl %eax, EXT_C(grub_ieee1275_entry_fn)

Index: kern/i386/linuxbios/startup.S
===================================================================

i386/linuxbios/startup.S +3 -3
@@ -19,9 +19,9 @@
 #define ASM_FILE	1
 
 #include <grub/symbol.h>
-#include <grub/machine/kernel.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
+#include <grub/cpu/kernel.h>
 #include <multiboot.h>
 #include <multiboot2.h>
 
@@ -44,7 +44,7 @@
 	 *  This is a special data area at a fixed offset from the beginning.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+	. = EXT_C(start) + GRUB_KERNEL_CPU_PREFIX
 
 VARIABLE(grub_prefix)
 	/* to be filled by grub-mkimage */
@@ -53,7 +53,7 @@
 	 *  Leave some breathing room for the prefix.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+	. = EXT_C(start) + GRUB_KERNEL_CPU_DATA_END
 
 #if 0
 /*

Index: kern/i386/linuxbios/init.c
===================================================================

i386/linuxbios/init.c +1 -0
@@ -33,6 +33,7 @@
 #include <grub/time.h>
 #include <grub/symbol.h>
 #include <grub/cpu/io.h>
+#include <grub/cpu/kernel.h>
 
 #define GRUB_FLOPPY_REG_DIGITAL_OUTPUT		0x3f2
 

Index: include/grub/powerpc/ieee1275/kernel.h
===================================================================

grub/powerpc/ieee1275/kernel.h +0 -7
@@ -21,13 +21,6 @@
 
 #include <grub/symbol.h>
 
-#define GRUB_MOD_ALIGN 0x1000
-
-/* Minimal gap between _end and the start of the modules.  It's a hack
-   for PowerMac to prevent "CLAIM failed" error.  The real fix is to
-   rewrite grub-mkimage to generate valid ELF files.  */
-#define GRUB_MOD_GAP 0x8000
-
 #ifndef ASM_FILE
 
 void EXPORT_FUNC (grub_reboot) (void);

Index: include/grub/powerpc/kernel.h
===================================================================

grub/powerpc/kernel.h +33 -0
@@ -0,0 +1,33 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008  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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER	1
+
+#define GRUB_MOD_ALIGN 0x1000
+
+/* Minimal gap between _end and the start of the modules.  It's a hack
+   for PowerMac to prevent "CLAIM failed" error.  The real fix is to
+   rewrite grub-mkimage to generate valid ELF files.  */
+#define GRUB_MOD_GAP 0x8000
+
+/* prefix not supported on powerpc yet.  */
+#define GRUB_KERNEL_CPU_PREFIX	0
+#define GRUB_KERNEL_CPU_DATA_END	0
+
+#endif

Index: include/grub/i386/ieee1275/kernel.h
===================================================================

grub/i386/ieee1275/kernel.h +0 -3
@@ -1,4 +1 @@
 #include <grub/powerpc/ieee1275/kernel.h>
-
-#define GRUB_KERNEL_MACHINE_PREFIX	0x2
-#define GRUB_KERNEL_MACHINE_DATA_END	0x42

Index: include/grub/i386/kernel.h
===================================================================

grub/i386/kernel.h +30 -0
@@ -0,0 +1,30 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008  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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER	1
+
+#define GRUB_MOD_ALIGN 0x1000
+
+/* Non-zero value is only needed for PowerMacs.  */
+#define GRUB_MOD_GAP 0x0
+
+#define GRUB_KERNEL_CPU_PREFIX	0x2
+#define GRUB_KERNEL_CPU_DATA_END	0x42
+
+#endif

Index: include/grub/i386/coreboot/kernel.h
===================================================================

grub/i386/coreboot/kernel.h +0 -8
@@ -21,16 +21,8 @@
 
 #include <grub/symbol.h>
 
-#define GRUB_MOD_ALIGN 0x1000
-
-/* Non-zero value is only needed for some IEEE-1275 platforms.  */
-#define GRUB_MOD_GAP 0
-
 #ifndef ASM_FILE
 extern char grub_prefix[];
 #endif
 
-#define GRUB_KERNEL_MACHINE_PREFIX	0x2
-#define GRUB_KERNEL_MACHINE_DATA_END	0x42
-
 #endif /* ! GRUB_KERNEL_MACHINE_HEADER */

Index: util/ieee1275/grub-install.in
===================================================================

ieee1275/grub-install.in +2 -2
@@ -34,7 +34,7 @@
 platform=@platform@
 pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
 
-grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
+grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}`
 grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
 grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
 rootdir=
@@ -182,7 +182,7 @@
 modules="$modules $fs_module $partmap_module $devabstraction_module"
 
 # Now perform the installation.
-"$grub_mkimage" --output=${grubdir}/grub $modules || exit 1
+"$grub_mkimage" --directory=${pkglibdir} --output=${grubdir}/grub $modules || exit 1
 
 if test $update_nvram = yes; then
     set $ofpathname dummy

Index: util/elf/grub-mkimage.c
===================================================================

elf/grub-mkimage.c +3 -3
@@ -30,7 +30,7 @@
 #include <grub/util/misc.h>
 #include <grub/util/resolve.h>
 #include <grub/kernel.h>
-#include <grub/machine/kernel.h>
+#include <grub/cpu/kernel.h>
 
 #define GRUB_IEEE1275_NOTE_NAME "PowerPC"
 #define GRUB_IEEE1275_NOTE_TYPE 0x1275
@@ -297,9 +297,9 @@
 
   if (prefix)
     {
-      if (GRUB_KERNEL_MACHINE_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_MACHINE_DATA_END)
+      if (GRUB_KERNEL_CPU_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_CPU_DATA_END)
         grub_util_error ("prefix too long");
-      grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_MACHINE_PREFIX, out);
+      grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_CPU_PREFIX, out);
     }
 
   free (phdrs);

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#4 lore raw
Quoted 1 line · Robert Millan

If there are no objections, I will check this in soon.

Looks fine to me.

Didn't you break the ability to cross compile for PPC on x86 along the way?

--
Marco

#5 lore raw
In reply to Robert Millan

Committed.

Quoted 366 lines · Robert Millan

The elf version of grub-mkimage is multiplatform, so it makes no sense to keep it as arch-specific in the build system IMHO.

This patch renames it to grub-mkelfimage, and arranges the build system & headers so that its build parameters are shared between i386-ieee1275 and i386-coreboot (and in the future, among powerpc-* platforms).

Aside from making life easier for distributors (less duplicated space), the big advantage in doing this is that one can now install grub-coreboot at the same time as grub-pc without causing a file conflict.

Signature · 8 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."

Index: conf/common.rmk
===================================================================
common.rmk +6 -0
@@ -1,5 +1,11 @@
 # -*- makefile -*-
 
+# For grub-mkelfimage.
+bin_UTILITIES += grub-mkelfimage
+grub_mkelfimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
+	util/resolve.c
+util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
+
 # For grub-probe.
 sbin_UTILITIES += grub-probe
 util/grub-probe.c_DEPENDENCIES = grub_probe_init.h

Index: conf/i386-coreboot.rmk
===================================================================

i386-coreboot.rmk +0 -7
@@ -39,18 +39,11 @@
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-	util/resolve.c
-grub_mkimage_LDFLAGS = $(LIBLZO)
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/i386/get_disk_name.c

Index: conf/powerpc-ieee1275.rmk
===================================================================

powerpc-ieee1275.rmk +0 -6
@@ -28,17 +28,11 @@
 pkglib_PROGRAMS = kernel.elf
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-        util/resolve.c 
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/ieee1275/get_disk_name.c

Index: conf/i386-ieee1275.rmk
===================================================================

i386-ieee1275.rmk +0 -7
@@ -40,18 +40,11 @@
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
 # Utilities.
-bin_UTILITIES = grub-mkimage
 sbin_UTILITIES = grub-mkdevicemap
 ifeq ($(enable_grub_emu), yes)
 sbin_UTILITIES += grub-emu
 endif
 
-# For grub-mkimage.
-grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
-	util/resolve.c
-grub_mkimage_LDFLAGS = $(LIBLZO)
-util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
-
 # For grub-mkdevicemap.
 grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c		\
 	util/i386/get_disk_name.c

Index: kern/ieee1275/init.c
===================================================================

ieee1275/init.c +1 -0
@@ -30,6 +30,7 @@
 #include <grub/time.h>
 #include <grub/machine/console.h>
 #include <grub/machine/kernel.h>
+#include <grub/cpu/kernel.h>
 #include <grub/ieee1275/ofdisk.h>
 #include <grub/ieee1275/ieee1275.h>
 

Index: kern/i386/ieee1275/startup.S
===================================================================

i386/ieee1275/startup.S +3 -3
@@ -19,9 +19,9 @@
 #define ASM_FILE	1
 
 #include <grub/symbol.h>
-#include <grub/machine/kernel.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
+#include <grub/cpu/kernel.h>
 #include <multiboot.h>
 #include <multiboot2.h>
 
@@ -45,7 +45,7 @@
 	 *  This is a special data area at a fixed offset from the beginning.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+	. = EXT_C(start) + GRUB_KERNEL_CPU_PREFIX
 
 VARIABLE(grub_prefix)
 	/* to be filled by grub-mkimage */
@@ -54,7 +54,7 @@
 	 *  Leave some breathing room for the prefix.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+	. = EXT_C(start) + GRUB_KERNEL_CPU_DATA_END
 
 codestart:
 	movl %eax, EXT_C(grub_ieee1275_entry_fn)

Index: kern/i386/linuxbios/startup.S
===================================================================

i386/linuxbios/startup.S +3 -3
@@ -19,9 +19,9 @@
 #define ASM_FILE	1
 
 #include <grub/symbol.h>
-#include <grub/machine/kernel.h>
 #include <grub/machine/memory.h>
 #include <grub/cpu/linux.h>
+#include <grub/cpu/kernel.h>
 #include <multiboot.h>
 #include <multiboot2.h>
 
@@ -44,7 +44,7 @@
 	 *  This is a special data area at a fixed offset from the beginning.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_PREFIX
+	. = EXT_C(start) + GRUB_KERNEL_CPU_PREFIX
 
 VARIABLE(grub_prefix)
 	/* to be filled by grub-mkimage */
@@ -53,7 +53,7 @@
 	 *  Leave some breathing room for the prefix.
 	 */
 
-	. = EXT_C(start) + GRUB_KERNEL_MACHINE_DATA_END
+	. = EXT_C(start) + GRUB_KERNEL_CPU_DATA_END
 
 #if 0
 /*

Index: kern/i386/linuxbios/init.c
===================================================================

i386/linuxbios/init.c +1 -0
@@ -33,6 +33,7 @@
 #include <grub/time.h>
 #include <grub/symbol.h>
 #include <grub/cpu/io.h>
+#include <grub/cpu/kernel.h>
 
 #define GRUB_FLOPPY_REG_DIGITAL_OUTPUT		0x3f2
 

Index: include/grub/powerpc/ieee1275/kernel.h
===================================================================

grub/powerpc/ieee1275/kernel.h +0 -7
@@ -21,13 +21,6 @@
 
 #include <grub/symbol.h>
 
-#define GRUB_MOD_ALIGN 0x1000
-
-/* Minimal gap between _end and the start of the modules.  It's a hack
-   for PowerMac to prevent "CLAIM failed" error.  The real fix is to
-   rewrite grub-mkimage to generate valid ELF files.  */
-#define GRUB_MOD_GAP 0x8000
-
 #ifndef ASM_FILE
 
 void EXPORT_FUNC (grub_reboot) (void);

Index: include/grub/powerpc/kernel.h
===================================================================

grub/powerpc/kernel.h +33 -0
@@ -0,0 +1,33 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008  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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER	1
+
+#define GRUB_MOD_ALIGN 0x1000
+
+/* Minimal gap between _end and the start of the modules.  It's a hack
+   for PowerMac to prevent "CLAIM failed" error.  The real fix is to
+   rewrite grub-mkimage to generate valid ELF files.  */
+#define GRUB_MOD_GAP 0x8000
+
+/* prefix not supported on powerpc yet.  */
+#define GRUB_KERNEL_CPU_PREFIX	0
+#define GRUB_KERNEL_CPU_DATA_END	0
+
+#endif

Index: include/grub/i386/ieee1275/kernel.h
===================================================================

grub/i386/ieee1275/kernel.h +0 -3
@@ -1,4 +1 @@
 #include <grub/powerpc/ieee1275/kernel.h>
-
-#define GRUB_KERNEL_MACHINE_PREFIX	0x2
-#define GRUB_KERNEL_MACHINE_DATA_END	0x42

Index: include/grub/i386/kernel.h
===================================================================

grub/i386/kernel.h +30 -0
@@ -0,0 +1,30 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005,2006,2007,2008  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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER	1
+
+#define GRUB_MOD_ALIGN 0x1000
+
+/* Non-zero value is only needed for PowerMacs.  */
+#define GRUB_MOD_GAP 0x0
+
+#define GRUB_KERNEL_CPU_PREFIX	0x2
+#define GRUB_KERNEL_CPU_DATA_END	0x42
+
+#endif

Index: include/grub/i386/coreboot/kernel.h
===================================================================

grub/i386/coreboot/kernel.h +0 -8
@@ -21,16 +21,8 @@
 
 #include <grub/symbol.h>
 
-#define GRUB_MOD_ALIGN 0x1000
-
-/* Non-zero value is only needed for some IEEE-1275 platforms.  */
-#define GRUB_MOD_GAP 0
-
 #ifndef ASM_FILE
 extern char grub_prefix[];
 #endif
 
-#define GRUB_KERNEL_MACHINE_PREFIX	0x2
-#define GRUB_KERNEL_MACHINE_DATA_END	0x42
-
 #endif /* ! GRUB_KERNEL_MACHINE_HEADER */

Index: util/ieee1275/grub-install.in
===================================================================

ieee1275/grub-install.in +2 -2
@@ -34,7 +34,7 @@
 platform=@platform@
 pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
 
-grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
+grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}`
 grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
 grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
 rootdir=
@@ -182,7 +182,7 @@
 modules="$modules $fs_module $partmap_module $devabstraction_module"
 
 # Now perform the installation.
-"$grub_mkimage" --output=${grubdir}/grub $modules || exit 1
+"$grub_mkimage" --directory=${pkglibdir} --output=${grubdir}/grub $modules || exit 1
 
 if test $update_nvram = yes; then
     set $ofpathname dummy

Index: util/elf/grub-mkimage.c
===================================================================

elf/grub-mkimage.c +3 -3
@@ -30,7 +30,7 @@
 #include <grub/util/misc.h>
 #include <grub/util/resolve.h>
 #include <grub/kernel.h>
-#include <grub/machine/kernel.h>
+#include <grub/cpu/kernel.h>
 
 #define GRUB_IEEE1275_NOTE_NAME "PowerPC"
 #define GRUB_IEEE1275_NOTE_TYPE 0x1275
@@ -297,9 +297,9 @@
 
   if (prefix)
     {
-      if (GRUB_KERNEL_MACHINE_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_MACHINE_DATA_END)
+      if (GRUB_KERNEL_CPU_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_CPU_DATA_END)
         grub_util_error ("prefix too long");
-      grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_MACHINE_PREFIX, out);
+      grub_util_write_image_at (prefix, strlen (prefix) + 1, first_segment + GRUB_KERNEL_CPU_PREFIX, out);
     }
 
   free (phdrs);

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."