Author: hailfinger
Date: 2007-11-27 15:38:43 +0100 (Tue, 27 Nov 2007)
New Revision: 523
Modified:
LinuxBIOSv3/arch/x86/Makefile
LinuxBIOSv3/arch/x86/stage1.c
LinuxBIOSv3/lib/lar.c
LinuxBIOSv3/mainboard/adl/msm800sev/Makefile
LinuxBIOSv3/mainboard/amd/norwich/Makefile
LinuxBIOSv3/mainboard/artecgroup/dbe61/Makefile
LinuxBIOSv3/mainboard/emulation/qemu-x86/Makefile
LinuxBIOSv3/mainboard/emulation/qemu-x86/initram.c
LinuxBIOSv3/mainboard/pcengines/alix1c/Makefile
Log:
Use the elf-parsing capabilities of LAR to parse the initram.o file,
and create a valid LAR header with an entry value. This will fix the
problems Ron is having on the ALIX 1C and probably allow it to boot.
It also sets the text base of the .o to 0, instead of whatever wacky
value gld is choosing, so all platforms will have the same value.
Get away from worrying about potential gld bugs, now and in the future.
As added benefit, we obsolete a lot of code without introducing
new code.
Qemu target entry point debugging has been added to be able to spot
problems with entry points in the future.
This patch is a joint work of Ron and Carl-Daniel.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006(a)gmx.net>
Acked-by: Ronald G. Minnich <rminnich(a)gmail.com>
Modified: LinuxBIOSv3/arch/x86/Makefile
===================================================================
--- LinuxBIOSv3/arch/x86/Makefile 2007-11-27 01:12:48 UTC (rev 522)
+++ LinuxBIOSv3/arch/x86/Makefile 2007-11-27 14:38:43 UTC (rev 523)
@@ -36,7 +36,7 @@
ROM_SIZE := $(shell expr $(CONFIG_LINUXBIOS_ROMSIZE_KB) \* 1024)
-LARFILES := nocompress:normal/initram normal/stage2 nocompress:normal/option_table
+LARFILES := nocompress:normal/initram.o normal/stage2 nocompress:normal/option_table
ifneq ($(CONFIG_PAYLOAD_NONE),y)
LARFILES += normal/payload
endif
@@ -57,11 +57,11 @@
COMPRESSFLAG := -C nrv2b
endif
-$(obj)/linuxbios.rom $(obj)/linuxbios.map: $(obj)/linuxbios.bootblock $(obj)/util/lar/lar lzma nrv2b $(obj)/linuxbios.initram $(obj)/linuxbios.stage2 $(obj)/option_table
+$(obj)/linuxbios.rom $(obj)/linuxbios.map: $(obj)/linuxbios.bootblock $(obj)/util/lar/lar lzma nrv2b $(obj)/linuxbios.initram.o $(obj)/linuxbios.stage2 $(obj)/option_table
$(Q)rm -rf $(obj)/lar.tmp
$(Q)mkdir $(obj)/lar.tmp
$(Q)mkdir $(obj)/lar.tmp/normal
- $(Q)cp $(obj)/linuxbios.initram $(obj)/lar.tmp/normal/initram
+ $(Q)cp $(obj)/linuxbios.initram.o $(obj)/lar.tmp/normal/initram.o
$(Q)cp $(obj)/linuxbios.stage2 $(obj)/lar.tmp/normal/stage2
$(Q)cp $(obj)/option_table $(obj)/lar.tmp/normal/option_table
ifeq ($(CONFIG_PAYLOAD_NONE),y)
@@ -122,10 +122,12 @@
endif
endif
+
+# We now parse initram as ELF, so we need PARSEELF enabled unconditionally.
ifeq ($(CONFIG_PAYLOAD_PREPARSE_ELF), y)
PARSEELF = -e
else
- PARSEELF =
+ PARSEELF = -e
endif
STAGE0_OBJ := $(patsubst %,$(obj)/lib/%,$(STAGE0_LIB_OBJ)) \
Modified: LinuxBIOSv3/arch/x86/stage1.c
===================================================================
--- LinuxBIOSv3/arch/x86/stage1.c 2007-11-27 01:12:48 UTC (rev 522)
+++ LinuxBIOSv3/arch/x86/stage1.c 2007-11-27 14:38:43 UTC (rev 523)
@@ -138,17 +138,17 @@
// find first initram
if (check_normal_boot_flag()) {
printk(BIOS_DEBUG, "Choosing normal boot.\n");
- ret = execute_in_place(&archive, "normal/initram");
+ ret = execute_in_place(&archive, "normal/initram.o/segment0");
} else {
printk(BIOS_DEBUG, "Choosing fallback boot.\n");
- ret = execute_in_place(&archive, "fallback/initram");
+ ret = execute_in_place(&archive, "fallback/initram.o/segment0");
/* Try a normal boot if fallback doesn't exist in the lar.
* TODO: There are other ways to do this.
* It could be ifdef or the boot flag could be forced.
*/
if (ret) {
printk(BIOS_DEBUG, "Fallback failed. Try normal boot\n");
- ret = execute_in_place(&archive, "normal/initram");
+ ret = execute_in_place(&archive, "normal/initram.o/segment0");
}
}
Modified: LinuxBIOSv3/lib/lar.c
===================================================================
--- LinuxBIOSv3/lib/lar.c 2007-11-27 01:12:48 UTC (rev 522)
+++ LinuxBIOSv3/lib/lar.c 2007-11-27 14:38:43 UTC (rev 523)
@@ -263,9 +263,9 @@
filename);
return 1;
}
- where = result.start;
+ where = result.start + (u32)result.entry;
}
- printk(BIOS_SPEW, "where is %p\n", where);
+ printk(BIOS_SPEW, "Entry point is %p\n", where);
ret = run_address(where);
printk(BIOS_SPEW, "run_file returns with %d\n", ret);
return ret;
Modified: LinuxBIOSv3/mainboard/adl/msm800sev/Makefile
===================================================================
--- LinuxBIOSv3/mainboard/adl/msm800sev/Makefile 2007-11-27 01:12:48 UTC (rev 522)
+++ LinuxBIOSv3/mainboard/adl/msm800sev/Makefile 2007-11-27 14:38:43 UTC (rev 523)
@@ -32,14 +32,11 @@
$(obj)/southbridge/amd/cs5536/smbus_initram.o \
$(obj)/arch/x86/geodelx/geodelx.o
-$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
+$(obj)/linuxbios.initram.o $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
$(Q)# initram links against stage0
$(Q)printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
+ $(Q)$(LD) -Ttext 0 --entry main -N -R $(obj)/stage0-prefixed.o \
$(patsubst %.o,%_xip.o,$(INITRAM_OBJ)) -o $(obj)/linuxbios.initram.o
- $(Q)printf " OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
- $(obj)/linuxbios.initram
$(Q)printf " NM $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(NM) $(obj)/linuxbios.initram.o | sort -u > $(obj)/linuxbios.initram.map
Modified: LinuxBIOSv3/mainboard/amd/norwich/Makefile
===================================================================
--- LinuxBIOSv3/mainboard/amd/norwich/Makefile 2007-11-27 01:12:48 UTC (rev 522)
+++ LinuxBIOSv3/mainboard/amd/norwich/Makefile 2007-11-27 14:38:43 UTC (rev 523)
@@ -32,14 +32,11 @@
$(Q)printf " BUILD DUMMY VPD\n"
$(Q)dd if=/dev/zero of=$(obj)/linuxbios.vpd bs=256 count=1 $(SILENT)
-$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
+$(obj)/linuxbios.initram.o $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
$(Q)# initram links against stage0
$(Q)printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
+ $(Q)$(LD) -Ttext 0 --entry main -N -R $(obj)/stage0-prefixed.o \
$(patsubst %.o,%_xip.o,$(INITRAM_OBJ)) -o $(obj)/linuxbios.initram.o
- $(Q)printf " OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
- $(obj)/linuxbios.initram
$(Q)printf " NM $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(NM) $(obj)/linuxbios.initram.o | sort -u > $(obj)/linuxbios.initram.map
Modified: LinuxBIOSv3/mainboard/artecgroup/dbe61/Makefile
===================================================================
--- LinuxBIOSv3/mainboard/artecgroup/dbe61/Makefile 2007-11-27 01:12:48 UTC (rev 522)
+++ LinuxBIOSv3/mainboard/artecgroup/dbe61/Makefile 2007-11-27 14:38:43 UTC (rev 523)
@@ -30,14 +30,11 @@
INITRAM_OBJ = $(obj)/mainboard/$(MAINBOARDDIR)/initram.o \
$(obj)/arch/x86/geodelx/geodelx.o
-$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
+$(obj)/linuxbios.initram.o $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
$(Q)# initram links against stage0
$(Q)printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
+ $(Q)$(LD) -Ttext 0 --entry main -N -R $(obj)/stage0-prefixed.o \
$(patsubst %.o,%_xip.o,$(INITRAM_OBJ)) -o $(obj)/linuxbios.initram.o
- $(Q)printf " OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
- $(obj)/linuxbios.initram
$(Q)printf " NM $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(NM) $(obj)/linuxbios.initram.o | sort -u > $(obj)/linuxbios.initram.map
Modified: LinuxBIOSv3/mainboard/emulation/qemu-x86/Makefile
===================================================================
--- LinuxBIOSv3/mainboard/emulation/qemu-x86/Makefile 2007-11-27 01:12:48 UTC (rev 522)
+++ LinuxBIOSv3/mainboard/emulation/qemu-x86/Makefile 2007-11-27 14:38:43 UTC (rev 523)
@@ -42,14 +42,11 @@
INITRAM_OBJ = $(obj)/mainboard/$(MAINBOARDDIR)/initram.o
-$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
+$(obj)/linuxbios.initram.o $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
$(Q)# initram links against stage0
$(Q)printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
+ $(Q)$(LD) -Ttext 0 --entry main -N -R $(obj)/stage0-prefixed.o \
$(patsubst %.o,%_xip.o,$(INITRAM_OBJ)) -o $(obj)/linuxbios.initram.o
- $(Q)printf " OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
- $(obj)/linuxbios.initram
$(Q)printf " NM $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(NM) $(obj)/linuxbios.initram.o | sort -u > $(obj)/linuxbios.initram.map
Modified: LinuxBIOSv3/mainboard/emulation/qemu-x86/initram.c
===================================================================
--- LinuxBIOSv3/mainboard/emulation/qemu-x86/initram.c 2007-11-27 01:12:48 UTC (rev 522)
+++ LinuxBIOSv3/mainboard/emulation/qemu-x86/initram.c 2007-11-27 14:38:43 UTC (rev 523)
@@ -21,10 +21,24 @@
#include <console.h>
+/* printktest1() is here to increase the likelihood of main() not ending up at
+ * the beginning of the file, so we can check whether the entry point at main()
+ * was honored.
+ */
+int printktest1(void)
+{
+ printk(BIOS_INFO, "printktest1: If the immediately preceding line does"
+ " not say \"Nothing to do.\", then execution did not start at"
+ " main()\n");
+
+ return 0;
+}
+
int main(void)
{
printk(BIOS_INFO, "RAM init code started.\n");
printk(BIOS_INFO, "Nothing to do.\n");
+ printktest1();
return 0;
}
Modified: LinuxBIOSv3/mainboard/pcengines/alix1c/Makefile
===================================================================
--- LinuxBIOSv3/mainboard/pcengines/alix1c/Makefile 2007-11-27 01:12:48 UTC (rev 522)
+++ LinuxBIOSv3/mainboard/pcengines/alix1c/Makefile 2007-11-27 14:38:43 UTC (rev 523)
@@ -32,14 +32,11 @@
$(Q)printf " BUILD DUMMY VPD\n"
$(Q)dd if=/dev/zero of=$(obj)/linuxbios.vpd bs=256 count=1 $(SILENT)
-$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
+$(obj)/linuxbios.initram.o $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(patsubst %.o,%_xip.o,$(INITRAM_OBJ))
$(Q)# initram links against stage0
$(Q)printf " LD $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(LD) --entry main -N -R $(obj)/stage0-prefixed.o \
+ $(Q)$(LD) -Ttext 0 --entry main -N -R $(obj)/stage0-prefixed.o \
$(patsubst %.o,%_xip.o,$(INITRAM_OBJ)) -o $(obj)/linuxbios.initram.o
- $(Q)printf " OBJCOPY $(subst $(shell pwd)/,,$(@))\n"
- $(Q)$(OBJCOPY) -O binary $(obj)/linuxbios.initram.o \
- $(obj)/linuxbios.initram
$(Q)printf " NM $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(NM) $(obj)/linuxbios.initram.o | sort -u > $(obj)/linuxbios.initram.map