grub-install for PPC
PATCH 1/1 grub-install for PPC
This patch creates a grub-install for PPC. Right now it requires ofpathname (see earlier mail) to be installed in /usr/sbin. It also requires /sbin/nvsetenv to be present for full functionality.
Here's the basic scenario: /boot/grub is a mounted firmware-readable filesystem, such as HFS or FAT (I have just reused my yaboot partition). It contains grub.cfg, grub itself, and modules. Firmware is directed to boot the grub ELF file by setting the boot-device firmware variable. (Note that you don't tell grub-install what device to install onto; that is discovered from /proc/mounts.)
This patch has been tested (along with make install). It has not been extensively tested or proofread or examined for error-checking.
Please try running grub-install after applying this patch. Note that it will make your system boot GRUB, so you may want to remember how to get back to yaboot for now...
-Hollis
P.S. Don't think I've forgotten about renaming "grubof"...
Index: Makefile.in
===================================================================
RCS file: /cvsroot/grub/grub2/Makefile.in,v
retrieving revision 1.14
Makefile.in +2 -2
@@ -106,7 +106,7 @@ install: install-local install-local: all $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) - @list='$(pkgdata_IMAGES) $(pkgdata_MODULES) $(pkgdata_DATA)'; \ + @list='$(DATA)'; \ for file in $$list; do \ if test -f "$$file"; then dir=; else dir="$(srcdir)"; fi; \ dest="`echo $$file | sed 's,.*/,,'`"; \
@@ -134,7 +134,7 @@ install-strip: $(MAKE) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" install uninstall: - @list='$(pkgdata_IMAGES) $(pkgdata_MODULES) $(pkgdata_DATA)'; \ + @list='$(DATA)'; \ for file in $$list; do \ dest="`echo $$file | sed 's,.*/,,'`"; \ rm -f $(DESTDIR)$(pkgdatadir)/$$dest; \
Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.44
powerpc-ieee1275.rmk +8 -1
@@ -25,7 +25,8 @@ kernel_syms.lst: $(addprefix include/gru pkgdata_PROGRAMS = grubof # Utilities. -bin_UTILITIES = grub-emu grub-mkimage +bin_UTILITIES = grub-emu +sbin_UTILITIES = grub-mkimage noinst_UTILITIES = genmoddep # For grub-mkimage.
@@ -70,6 +71,12 @@ grubof_LDFLAGS = -nostdlib -static-libgc # For genmoddep. genmoddep_SOURCES = util/genmoddep.c + +# Scripts. +sbin_SCRIPTS = grub-install + +# For grub-install. +grub_install_SOURCES = util/powerpc/ieee1275/grub-install.in # Modules. pkgdata_MODULES = _linux.mod linux.mod fat.mod ufs.mod ext2.mod minix.mod \
Index: util/powerpc/ieee1275/grub-install.in
===================================================================
RCS file: util/powerpc/ieee1275/grub-install.in
powerpc/ieee1275/grub-install.in new file +187 -0
187 lines not on this page · raw message
Index: util/powerpc/ieee1275/grub-mkimage.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/powerpc/ieee1275/grub-mkimage.c,v retrieving revision 1.3
powerpc/ieee1275/grub-mkimage.c +3 -2
@@ -32,8 +32,6 @@#define ALIGN_UP (addr, align) ((long)((char *)addr + align - 1) & ~(align - 1)) -static char *kernel_path ="grubof" ; -#define GRUB_IEEE1275_NOTE_NAME "PowerPC"#define GRUB_IEEE1275_NOTE_TYPE 0x1275
@@ -165,10 +163,12 @@ add_segments (char *dir, FILE *out, intElf32_Phdr *phdrs =NULL ;Elf32_Phdr *phdr;FILE *in; +char *kernel_path;off_t phdroff;int i;/* Read ELF header. */ + kernel_path =grub_util_get_path (dir,"grubof" ); in =fopen (kernel_path,"rb" );if (! in)grub_util_error ("cannot open %s" , kernel_path);
@@ -245,6 +245,7 @@ add_segments (char *dir, FILE *out, intgrub_util_write_image_at (&ehdr,sizeof (ehdr),0 , out);free (phdrs); +free (kernel_path); } static struct option options[] =