Fill out ChromeOS specific coreboot table extensions
[coreboot.git] / src / arch / x86 / Makefile.inc
index 54f0f82da58a7ab42d27f2c33b26599c312a4a3b..8783d4bc027c7b8296a68d8dc31c1b4e3dc616cc 100755 (executable)
@@ -58,13 +58,15 @@ extract_nth=$(word $(1), $(subst |, ,$(2)))
 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)
@@ -144,11 +146,12 @@ $(objutil)/options/build_opt_tbl: $(top)/util/options/build_opt_tbl.c $(top)/src
 
 $(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"
@@ -166,12 +169,12 @@ ifeq ($(CONFIG_AP_CODE_IN_CAR),y)
 
 $(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
 
@@ -190,13 +193,7 @@ crt0s += $(src)/cpu/x86/sse_enable.inc
 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
@@ -204,13 +201,6 @@ endif
 
 crt0s += $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc
 
-ifeq ($(CONFIG_SSE),y)
-crt0s += $(src)/cpu/x86/sse_disable.inc
-endif
-ifeq ($(CONFIG_MMX),y)
-crt0s += $(src)/cpu/x86/mmx_disable.inc
-endif
-
 ifeq ($(CONFIG_ROMCC),y)
 crt0s += $(src)/arch/x86/init/crt0_romcc_epilogue.inc
 endif
@@ -276,11 +266,10 @@ endif
 
 $(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
@@ -325,7 +314,7 @@ $(obj)/bootblock/bootblock.S: $$(bootblock_inc)
 
 $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.o: $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.s
        @printf "    CC         $(subst $(obj)/,,$(@))\n"
-       $(CC) -I$(obj) -Wa,-acdlns -c -o $@ $<  > $(dir $@)/crt0.disasm
+       $(CC) -Wa,-acdlns -c -o $@ $<  > $(dir $@)/crt0.disasm
 
 $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.s: $(obj)/bootblock/bootblock.S $(obj)/config.h $(obj)/build.h
        @printf "    CC         $(subst $(obj)/,,$(@))\n"
@@ -333,40 +322,57 @@ $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.s: $(obj)/bootblock/bootblock.S $(obj
 
 $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc: $(src)/arch/x86/init/$(subst ",,$(CONFIG_BOOTBLOCK_SOURCE)) $(objutil)/romcc/romcc $(OPTION_TABLE_H)
        @printf "    ROMCC      $(subst $(obj)/,,$(@))\n"
-       $(CC) -MM -MT$(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc \
+       $(CC) $(INCLUDES) -MM -MT$(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc \
                $< > $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc.d
        $(ROMCC) -c -S $(bootblock_romccflags) $(ROMCCFLAGS) -I. $(INCLUDES) $< -o $@
 
 $(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"
+       $(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"
-       printf "CONFIG_ROMBASE = 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 "CONFIG_ROMBASE = 0x" > $(obj)/location.ld
-       $(CBFSTOOL) $(obj)/coreboot.pre1 locate $(obj)/romstage.bin $(CONFIG_CBFS_PREFIX)/romstage $(CONFIG_XIP_ROM_SIZE) > $(obj)/location.txt
-       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_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"
@@ -375,7 +381,7 @@ $(obj)/romstage/crt0.S: $$(crt0s)
 
 $(obj)/mainboard/$(MAINBOARDDIR)/crt0.romstage.o: $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s
        @printf "    CC         $(subst $(obj)/,,$(@))\n"
-       $(CC) -I$(obj) -Wa,-acdlns -c -o $@ $<  > $(dir $@)/crt0.disasm
+       $(CC) -Wa,-acdlns -c -o $@ $<  > $(dir $@)/crt0.disasm
 
 $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s: $(obj)/romstage/crt0.S $(obj)/config.h $(obj)/build.h
        @printf "    CC         $(subst $(obj)/,,$(@))\n"
@@ -387,7 +393,9 @@ seabios:
                        CC="$(CC)" LD="$(LD)" OBJDUMP="$(OBJDUMP)" \
                        OBJCOPY="$(OBJCOPY)" STRIP="$(STRIP)" \
                        CONFIG_SEABIOS_MASTER=$(CONFIG_SEABIOS_MASTER) \
-                       CONFIG_SEABIOS_STABLE=$(CONFIG_SEABIOS_STABLE)
+                       CONFIG_SEABIOS_STABLE=$(CONFIG_SEABIOS_STABLE) \
+                       OUT=$(abspath $(obj))
+
 filo:
        $(MAKE) -C payloads/external/FILO -f Makefile.inc \
                        HOSTCC="$(HOSTCC)" \