ifneq ($(CONFIG_UPDATE_IMAGE),y)
prebuild-files = \
$(foreach file,$(cbfs-files), \
- $(CBFSTOOL) $@ add $(call extract_nth,1,$(file)) $(call extract_nth,2,$(file)) $(call extract_nth,3,$(file)) $(call extract_nth,4,$(file)); )
+ $(CBFSTOOL) $@.tmp add $(call extract_nth,1,$(file)) \
+ $(call extract_nth,2,$(file)) $(call extract_nth,3,$(file)) \
+ $(call extract_nth,4,$(file)) &&)
prebuilt-files = $(foreach file,$(cbfs-files), $(call extract_nth,1,$(file)))
$(obj)/coreboot.pre1: $(obj)/coreboot.bootblock $$(prebuilt-files) $(CBFSTOOL)
- rm -f $@
- $(CBFSTOOL) $@ create $(CONFIG_COREBOOT_ROMSIZE_KB)K $(obj)/coreboot.bootblock
- $(prebuild-files)
+ $(CBFSTOOL) $@.tmp create $(CONFIG_COREBOOT_ROMSIZE_KB)K $(obj)/coreboot.bootblock
+ $(prebuild-files) true
+ mv $@.tmp $@
else
.PHONY: $(obj)/coreboot.pre1
$(obj)/coreboot.pre1: $(CBFSTOOL)
$(obj)/coreboot_ram: $(obj)/coreboot_ram.o $(src)/arch/x86/coreboot_ram.ld #ldoptions
@printf " CC $(subst $(obj)/,,$(@))\n"
- $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(src)/arch/x86/coreboot_ram.ld $(obj)/coreboot_ram.o
- $(NM) -n $(obj)/coreboot_ram | sort > $(obj)/coreboot_ram.map
- $(OBJCOPY) --only-keep-debug $@ $(obj)/coreboot_ram.debug
- $(OBJCOPY) --strip-debug $@
- $(OBJCOPY) --add-gnu-debuglink=$(obj)/coreboot_ram.debug $@
+ $(CC) -nostdlib -nostartfiles -static -o $@.tmp -L$(obj) -T $(src)/arch/x86/coreboot_ram.ld $(obj)/coreboot_ram.o
+ $(NM) -n $@.tmp | sort > $@.map
+ $(OBJCOPY) --only-keep-debug $@.tmp $@.debug
+ $(OBJCOPY) --strip-debug $@.tmp
+ $(OBJCOPY) --add-gnu-debuglink=$@.debug $@.tmp
+ mv $@.tmp $@
$(obj)/coreboot_ram.o: $(obj)/arch/x86/lib/c_start.ramstage.o $$(driver-objs) $(obj)/coreboot.a $(LIBGCC_FILE_NAME)
@printf " CC $(subst $(obj)/,,$(@))\n"
$(obj)/coreboot_ap: $(obj)/mainboard/$(MAINBOARDDIR)/ap_romstage.o
@printf " CC $(subst $(obj)/,,$(@))\n"
- $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(src)/arch/x86/init/ldscript_apc.lb $^
- $(OBJCOPY) --only-keep-debug $@ $(obj)/coreboot_ap.debug
- $(OBJCOPY) --strip-debug $@
- $(OBJCOPY) --add-gnu-debuglink=$(obj)/coreboot_ap.debug $@
- $(NM) -n $(obj)/coreboot_ap | sort > $(obj)/coreboot_ap.map
-
+ $(CC) -nostdlib -nostartfiles -static -o $@.tmp -L$(obj) -T $(src)/arch/x86/init/ldscript_apc.lb $^
+ $(OBJCOPY) --only-keep-debug $@.tmp $@.debug
+ $(OBJCOPY) --strip-debug $@.tmp
+ $(OBJCOPY) --add-gnu-debuglink=$@.debug $@.tmp
+ $(NM) -n $@.tmp | sort > $@.map
+ mv $@.tmp $@
endif
endif
crt0s += $(cpu_incs)
-
-#
-# FIXME move to CPU_INTEL_SOCKET_MPGA604
-#
-ifeq ($(CONFIG_BOARD_TYAN_S2735),y)
-crt0s += $(src)/cpu/intel/car/cache_as_ram.inc
-endif
+crt0s += $(cpu_incs-y)
ifeq ($(CONFIG_LLSHELL),y)
crt0s += $(src)/arch/x86/llshell/llshell.inc
$(obj)/coreboot.pre: $(obj)/coreboot.romstage $(obj)/coreboot.pre1 $(CBFSTOOL)
@printf " CBFS $(subst $(obj)/,,$(@))\n"
- rm -f $@
- cp $(obj)/coreboot.pre1 $@
- $(CBFSTOOL) $@ add-stage $(obj)/romstage.elf \
- $(CONFIG_CBFS_PREFIX)/romstage x 0x$(shell cat $(obj)/location.txt)
-#FIXME: location.txt might require an offset of header size
+ cp $(obj)/coreboot.pre1 $@.tmp
+ $(CBFSTOOL) $@.tmp add-stage $(obj)/romstage.elf \
+ $(CONFIG_CBFS_PREFIX)/romstage x $(shell cat $(obj)/romstage/base_xip.txt)
+ mv $@.tmp $@
#######################################################################
# Build the bootblock
$(obj)/bootblock.elf: $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.o $(obj)/bootblock/ldscript.ld
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(obj)/bootblock/ldscript.ld $<
- $(NM) -n $(obj)/bootblock.elf | sort > $(obj)/bootblock.map
- $(OBJCOPY) --only-keep-debug $@ $(obj)/bootblock.debug
- $(OBJCOPY) --strip-debug $@
- $(OBJCOPY) --add-gnu-debuglink=$(obj)/bootblock.debug $@
+ $(CC) -nostdlib -nostartfiles -static -o $@.tmp -L$(obj) -T $(obj)/bootblock/ldscript.ld $<
+ $(NM) -n $@.tmp | sort > $(obj)/bootblock.map
+ $(OBJCOPY) --only-keep-debug $@.tmp $(obj)/bootblock.debug
+ $(OBJCOPY) --strip-debug $@.tmp
+ $(OBJCOPY) --add-gnu-debuglink=$(obj)/bootblock.debug $@.tmp
+ mv $@.tmp $@
#######################################################################
# Build the romstage
-$(obj)/coreboot.romstage: $(obj)/coreboot.pre1 $$(romstage-objs) $(obj)/romstage/ldscript.ld
+
+$(obj)/romstage.bin: $$(romstage-objs) $(obj)/romstage/link_null.ld
@printf " LINK $(subst $(obj)/,,$(@))\n"
- printf "ROMSTAGE_BASE = 0x0;\n" > $(obj)/location.ld
- $(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/ldscript.ld $(romstage-objs)
- $(OBJCOPY) -O binary $(obj)/romstage.elf $(obj)/romstage.bin
- printf "ROMSTAGE_BASE = 0x" > $(obj)/location.ld
- $(CBFSTOOL) $(obj)/coreboot.pre1 locate $(obj)/romstage.bin $(CONFIG_CBFS_PREFIX)/romstage $(CONFIG_XIP_ROM_SIZE) > $(obj)/location.txt || { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; }
- cat $(obj)/location.txt >> $(obj)/location.ld
- printf ';\n' >> $(obj)/location.ld
- $(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/ldscript.ld $(romstage-objs)
+ $(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/link_null.ld $(romstage-objs)
+ $(OBJCOPY) -O binary $(obj)/romstage.elf $@
+
+$(obj)/coreboot.romstage: $$(romstage-objs) $(obj)/romstage/link_xip.ld
+ @printf " LINK $(subst $(obj)/,,$(@))\n"
+ $(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/link_xip.ld $(romstage-objs)
$(NM) -n $(obj)/romstage.elf | sort > $(obj)/romstage.map
$(OBJCOPY) --only-keep-debug $(obj)/romstage.elf $(obj)/romstage.debug
$(OBJCOPY) --strip-debug $(obj)/romstage.elf
$(OBJCOPY) --add-gnu-debuglink=$(obj)/romstage.debug $(obj)/romstage.elf
$(OBJCOPY) -O binary $(obj)/romstage.elf $@
-$(obj)/romstage/ldscript.ld: $$(ldscripts) $(obj)/ldoptions
+$(obj)/romstage/link_null.ld: $$(ldscripts) $(obj)/ldoptions
@printf " GEN $(subst $(obj)/,,$(@))\n"
mkdir -p $(obj)/romstage
- printf '$(foreach ldscript,ldoptions location.ld $(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' > $@
+ rm -f $@
+ printf "ROMSTAGE_BASE = 0x0;\n" > $@.tmp
+ printf '$(foreach ldscript,ldoptions $(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' >> $@.tmp
+ mv $@.tmp $@
+
+$(obj)/romstage/link_xip.ld: $(obj)/romstage/link_null.ld $(obj)/romstage/base_xip.txt
+ @printf " GEN $(subst $(obj)/,,$(@))\n"
+ rm -f $@
+ sed -e 's/^/ROMSTAGE_BASE = /g' -e 's/$$/;/g' $(obj)/romstage/base_xip.txt > $@.tmp
+ sed -e '/ROMSTAGE_BASE/d' $(obj)/romstage/link_null.ld >> $@.tmp
+ mv $@.tmp $@
+
+$(obj)/romstage/base_xip.txt: $(obj)/coreboot.pre1 $(obj)/romstage.bin
+ rm -f $@
+ $(CBFSTOOL) $(obj)/coreboot.pre1 locate $(obj)/romstage.bin $(CONFIG_CBFS_PREFIX)/romstage $(CONFIG_XIP_ROM_SIZE) > $@.tmp \
+ || { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; }
+ sed -i -e 's/^/0x/g' $@.tmp
+ mv $@.tmp $@
$(obj)/romstage/crt0.S: $$(crt0s)
@printf " GEN $(subst $(obj)/,,$(@))\n"