mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
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@gmx.net> Acked-by: Ronald G. Minnich <rminnich@gmail.com> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@523 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
d3a96b3f67
commit
7eb899b0bb
9 changed files with 35 additions and 34 deletions
|
@ -36,7 +36,7 @@ SILENT := >/dev/null 2>&1
|
|||
|
||||
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 @@ ifeq ($(CONFIG_DEFAULT_COMPRESSION_NRV2B),y)
|
|||
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 @@ else
|
|||
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)) \
|
||||
|
|
|
@ -138,17 +138,17 @@ void __attribute__((stdcall)) stage1_main(u32 bist)
|
|||
// 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -263,9 +263,9 @@ int run_file(struct mem_file *archive, const char *filename, void *where)
|
|||
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;
|
||||
|
|
|
@ -32,14 +32,11 @@ INITRAM_OBJ = $(obj)/mainboard/$(MAINBOARDDIR)/initram.o \
|
|||
$(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
|
||||
|
||||
|
|
|
@ -32,14 +32,11 @@ $(obj)/linuxbios.vpd:
|
|||
$(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
|
||||
|
||||
|
|
|
@ -30,14 +30,11 @@ $(obj)/linuxbios.vpd:
|
|||
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
|
||||
|
||||
|
|
|
@ -42,14 +42,11 @@ $(obj)/linuxbios.vpd:
|
|||
|
||||
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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -32,14 +32,11 @@ $(obj)/linuxbios.vpd:
|
|||
$(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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue