From 44b83271e6fcce68824d23354f46323fef62248e Mon Sep 17 00:00:00 2001 From: hollisb Date: Wed, 23 Nov 2005 04:25:16 +0000 Subject: [PATCH] 2005-11-22 Mike Small * util/powerpc/ieee1275/grub-install.in (grubdir): Fixed partition number regex so multidigit numbers are recognized correctly. * loader/powerpc/ieee1275/linux.c (grub_rescue_cmd_linux): Add a debugging message before attempting to claim memory. (grub_rescue_cmd_initrd): Add a claim debugging message and try multiple addresses in case of failure. --- ChangeLog | 12 +++++++ conf/common.mk | 46 +++++++++++++++++++++++++++ conf/powerpc-ieee1275.mk | 3 +- loader/powerpc/ieee1275/linux.c | 19 +++++++++-- util/powerpc/ieee1275/grub-install.in | 2 +- 5 files changed, 77 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 173480ccb..1918abf65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-11-22 Mike Small + + * util/powerpc/ieee1275/grub-install.in (grubdir): Fixed partition + number regex so multidigit numbers are recognized correctly. + +2005-11-22 Mike Small + + * loader/powerpc/ieee1275/linux.c (grub_rescue_cmd_linux): Add a + debugging message before attempting to claim memory. + (grub_rescue_cmd_initrd): Add a claim debugging message and try + multiple addresses in case of failure. + 2005-11-22 Hollis Blanchard * term/tparm.c (get_space): Remove empty `if' statement. diff --git a/conf/common.mk b/conf/common.mk index 38c38ac95..9422456b5 100644 --- a/conf/common.mk +++ b/conf/common.mk @@ -1309,6 +1309,52 @@ search_mod_LDFLAGS = $(COMMON_LDFLAGS) # For test.mod. test_mod_SOURCES = commands/test.c +CLEANFILES += test.mod mod-test.o mod-test.c pre-test.o test_mod-commands_test.o def-test.lst und-test.lst +MOSTLYCLEANFILES += test_mod-commands_test.d +DEFSYMFILES += def-test.lst +UNDSYMFILES += und-test.lst + +test.mod: pre-test.o mod-test.o + -rm -f $@ + $(LD) $(test_mod_LDFLAGS) $(LDFLAGS) -r -d -o $@ $^ + $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@ + +pre-test.o: test_mod-commands_test.o + -rm -f $@ + $(LD) $(test_mod_LDFLAGS) -r -d -o $@ $^ + +mod-test.o: mod-test.c + $(CC) $(CPPFLAGS) $(CFLAGS) $(test_mod_CFLAGS) -c -o $@ $< + +mod-test.c: moddep.lst genmodsrc.sh + sh $(srcdir)/genmodsrc.sh 'test' $< > $@ || (rm -f $@; exit 1) + +def-test.lst: pre-test.o + $(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 test/' > $@ + +und-test.lst: pre-test.o + echo 'test' > $@ + $(NM) -u -P -p $< | cut -f1 -d' ' >> $@ + +test_mod-commands_test.o: commands/test.c + $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(test_mod_CFLAGS) -c -o $@ $< + +test_mod-commands_test.d: commands/test.c + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(test_mod_CFLAGS) -M $< | sed 's,test\.o[ :]*,test_mod-commands_test.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ + +-include test_mod-commands_test.d + +CLEANFILES += cmd-test_mod-commands_test.lst fs-test_mod-commands_test.lst +COMMANDFILES += cmd-test_mod-commands_test.lst +FSFILES += fs-test_mod-commands_test.lst + +cmd-test_mod-commands_test.lst: commands/test.c gencmdlist.sh + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(test_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh test > $@ || (rm -f $@; exit 1) + +fs-test_mod-commands_test.lst: commands/test.c genfslist.sh + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(test_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh test > $@ || (rm -f $@; exit 1) + + test_mod_CFLAGS = $(COMMON_CFLAGS) test_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/powerpc-ieee1275.mk b/conf/powerpc-ieee1275.mk index d658d8ebf..900a75d15 100644 --- a/conf/powerpc-ieee1275.mk +++ b/conf/powerpc-ieee1275.mk @@ -876,8 +876,7 @@ pkgdata_MODULES = halt.mod \ linux.mod \ normal.mod \ reboot.mod \ - suspend.mod \ - test.mod + suspend.mod # For _linux.mod. _linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c diff --git a/loader/powerpc/ieee1275/linux.c b/loader/powerpc/ieee1275/linux.c index dd4cf3af5..b69ba5c37 100644 --- a/loader/powerpc/ieee1275/linux.c +++ b/loader/powerpc/ieee1275/linux.c @@ -173,6 +173,8 @@ grub_rescue_cmd_linux (int argc, char *argv[]) try some other addresses just like yaboot does. */ for (linux_addr = entry; linux_addr < entry + 200 * 0x100000; linux_addr += 0x100000) { + grub_dprintf ("loader", "Attempting to claim at 0x%x, size 0x%x.\n", + linux_addr, linux_size); found_addr = grub_claimmap (linux_addr, linux_size); if (found_addr != -1) break; @@ -261,7 +263,9 @@ grub_rescue_cmd_initrd (int argc, char *argv[]) { grub_file_t file = 0; grub_ssize_t size; + grub_addr_t first_addr; grub_addr_t addr; + int found_addr = 0; if (argc == 0) { @@ -279,10 +283,21 @@ grub_rescue_cmd_initrd (int argc, char *argv[]) if (! file) goto fail; - addr = linux_addr + linux_size; + first_addr = linux_addr + linux_size; size = grub_file_size (file); - if (grub_claimmap (addr, size) == -1) + /* Attempt to claim at a series of addresses until successful in + the same way that grub_rescue_cmd_linux does. */ + for (addr = first_addr; addr < first_addr + 200 * 0x100000; addr += 0x100000) + { + grub_dprintf ("loader", "Attempting to claim at 0x%x, size 0x%x.\n", + addr, size); + found_addr = grub_claimmap (addr, size); + if (found_addr != -1) + break; + } + + if (found_addr == -1) { grub_error (GRUB_ERR_OUT_OF_MEMORY, "Can not claim memory"); goto fail; diff --git a/util/powerpc/ieee1275/grub-install.in b/util/powerpc/ieee1275/grub-install.in index 5e66123e3..4405894fd 100644 --- a/util/powerpc/ieee1275/grub-install.in +++ b/util/powerpc/ieee1275/grub-install.in @@ -171,7 +171,7 @@ if test $update_nvram = yes; then # Get the Open Firmware device tree path translation. dev=`echo $install_device | sed -e 's/\/dev\///' -e 's/[0-9]\+//'` - partno=`echo $install_device | sed -e 's/.*\([0-9]\+\)$/\1/'` + partno=`echo $install_device | sed -e 's/.*[^0-9]\([0-9]\+\)$/\1/'` ofpath=`$ofpathname $dev` || { echo "Couldn't find Open Firmware device tree path for $dev." echo "You will have to set boot-device manually."