blob: 9c048006bbf0daee56df1356b933f31dd586e66b [file] [log] [blame]
Patrick Georgi9341acd2009-12-23 12:52:56 +00001ifdef POST_EVALUATION
2
3#######################################################################
4# Build the final rom image
5
Patrick Georgi967952a2010-02-09 19:41:11 +00006ifneq ($(CONFIG_UPDATE_IMAGE),y)
Patrick Georgi9341acd2009-12-23 12:52:56 +00007$(obj)/coreboot.pre1: $(obj)/coreboot.bootblock $(CBFSTOOL)
8 rm -f $@
9 $(CBFSTOOL) $@ create $(CONFIG_COREBOOT_ROMSIZE_KB)K $(obj)/coreboot.bootblock
Patrick Georgi967952a2010-02-09 19:41:11 +000010else
11$(obj)/coreboot.pre1: $(CBFSTOOL)
12 mv $(obj)/coreboot.rom $@
13endif
Patrick Georgi9341acd2009-12-23 12:52:56 +000014
15$(obj)/coreboot.pre: $(obj)/coreboot.romstage $(obj)/coreboot.pre1 $(CBFSTOOL)
16 rm -f $@
17 cp $(obj)/coreboot.pre1 $@
Patrick Georgi4b8a2412010-02-09 19:35:16 +000018 $(CBFSTOOL) $@ add-stage $(obj)/romstage.elf $(CONFIG_CBFS_PREFIX)/romstage x 0x$(shell cat $(obj)/location.txt)
Patrick Georgi9341acd2009-12-23 12:52:56 +000019#FIXME: location.txt might require an offset of header size
20
21#######################################################################
22# Build the bootblock
23
24$(obj)/coreboot.bootblock: $(obj)/bootblock.elf
25 @printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
26 $(OBJCOPY) -O binary $< $@
27
28bootblock_lds := $(src)/arch/i386/init/ldscript_failover.lb
29bootblock_lds += $(src)/cpu/x86/16bit/entry16.lds
30bootblock_lds += $(src)/cpu/x86/16bit/reset16.lds
31bootblock_lds += $(src)/arch/i386/lib/id.lds
Patrick Georgi753169d2010-01-06 09:14:08 +000032bootblock_lds += $(chipset_bootblock_lds)
Patrick Georgi9341acd2009-12-23 12:52:56 +000033
34bootblock_inc := $(src)/arch/i386/init/bootblock_prologue.c
35bootblock_inc += $(src)/cpu/x86/16bit/entry16.inc
36bootblock_inc += $(src)/cpu/x86/16bit/reset16.inc
37bootblock_inc += $(src)/cpu/x86/32bit/entry32.inc
38bootblock_inc += $(src)/arch/i386/lib/id.inc
Patrick Georgi753169d2010-01-06 09:14:08 +000039bootblock_inc += $(chipset_bootblock_inc)
Rudolf Marek95c50c62010-01-05 17:35:44 +000040
Patrick Georgi1bb68282009-12-31 12:56:53 +000041ifeq ($(CONFIG_SSE),y)
42bootblock_inc += $(src)/cpu/x86/sse_enable.inc
43endif
Patrick Georgi9341acd2009-12-23 12:52:56 +000044bootblock_inc += $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc
45bootblock_inc += $(src)/arch/i386/lib/walkcbfs.S
46
Patrick Georgi1bb68282009-12-31 12:56:53 +000047bootblock_romccflags := -mcpu=i386
48ifeq ($(CONFIG_SSE),y)
49bootblock_romccflags := -mcpu=k7 -msse
50endif
51
Patrick Georgi9341acd2009-12-23 12:52:56 +000052$(obj)/bootblock/ldscript.ld: $(bootblock_ldscripts) $(obj)/ldoptions
53 mkdir -p $(obj)/bootblock
54 printf '$(foreach ldscript,ldoptions $(bootblock_lds),INCLUDE "$(ldscript)"\n)' > $@
55
56$(obj)/bootblock/bootblock.c: $(bootblock_inc)
57 mkdir -p $(obj)/bootblock
58 printf '$(foreach crt0,config.h $(bootblock_inc),#include "$(crt0)"\n)' > $@
59
60$(obj)/mainboard/$(MAINBOARDDIR)/bootblock.o: $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.s
61 $(CC) -I$(obj) -Wa,-acdlns -c -o $@ $< > $(dir $@)/crt0.disasm
62
63$(obj)/mainboard/$(MAINBOARDDIR)/bootblock.s: $(obj)/bootblock/bootblock.c
64 $(CC) -x assembler-with-cpp -DASSEMBLY -E -I$(src)/include -I$(src)/arch/i386/include -I$(obj) -I$(obj)/bootblock -include $(obj)/config.h -I. -I$(src) $< > $@.new && mv $@.new $@
65
Patrick Georgif60a2562010-02-09 20:02:32 +000066$(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc: $(src)/arch/i386/init/bootblock.c $(obj)/romcc
Patrick Georgi4b8a2412010-02-09 19:35:16 +000067 $(obj)/romcc $(bootblock_romccflags) -O2 $(ROMCCFLAGS) $(INCLUDES) $< -o $@
Patrick Georgi9341acd2009-12-23 12:52:56 +000068
69$(obj)/bootblock.elf: $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.o $(obj)/bootblock/ldscript.ld
70 @printf " LINK $(subst $(obj)/,,$(@))\n"
71 $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(obj)/bootblock/ldscript.ld $<
72 $(NM) -n $(obj)/bootblock.elf | sort > $(obj)/bootblock.map
73
74#######################################################################
75# Build the romstage
76$(obj)/coreboot.romstage: $(obj)/coreboot.pre1 $(initobjs) $(obj)/romstage/ldscript.ld
77 @printf " LINK $(subst $(obj)/,,$(@))\n"
Patrick Georgi1f807fd2010-01-04 20:09:27 +000078 printf "CONFIG_ROMBASE = 0x0;\nAUTO_XIP_ROM_BASE = 0x0;\n" > $(obj)/location.ld
Patrick Georgi9341acd2009-12-23 12:52:56 +000079 $(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/ldscript.ld $(initobjs)
80 $(OBJCOPY) -O binary $(obj)/romstage.elf $(obj)/romstage.bin
81 printf "CONFIG_ROMBASE = 0x" > $(obj)/location.ld
Patrick Georgi4b8a2412010-02-09 19:35:16 +000082 $(CBFSTOOL) $(obj)/coreboot.pre1 locate $(obj)/romstage.bin $(CONFIG_CBFS_PREFIX)/romstage $(CONFIG_XIP_ROM_SIZE) > $(obj)/location.txt
Patrick Georgi9341acd2009-12-23 12:52:56 +000083 cat $(obj)/location.txt >> $(obj)/location.ld
Patrick Georgi1f807fd2010-01-04 20:09:27 +000084 printf ';\nAUTO_XIP_ROM_BASE = CONFIG_ROMBASE & ~(CONFIG_XIP_ROM_SIZE - 1);\n' >> $(obj)/location.ld
Patrick Georgi9341acd2009-12-23 12:52:56 +000085 $(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/ldscript.ld $(initobjs)
86 $(NM) -n $(obj)/romstage.elf | sort > $(obj)/romstage.map
87 $(OBJCOPY) -O binary $(obj)/romstage.elf $@
88
89$(obj)/romstage/ldscript.ld: $(ldscripts) $(obj)/ldoptions
90 mkdir -p $(obj)/romstage
91 printf '$(foreach ldscript,ldoptions location.ld $(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' > $@
92
93$(obj)/romstage/crt0_includes.h: $(crt0s)
Stefan Reinauere3778572010-01-30 09:47:18 +000094 @printf " GEN $(subst $(obj)/,,$(@))\n"
Patrick Georgi9341acd2009-12-23 12:52:56 +000095 mkdir -p $(obj)/romstage
96 printf '$(foreach crt0,config.h $(crt0s),#include "$(crt0:$(obj)/%=%)"\n)' > $@
97
98$(obj)/mainboard/$(MAINBOARDDIR)/crt0.o: $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s
99 $(CC) -I$(obj) -Wa,-acdlns -c -o $@ $< > $(dir $@)/crt0.disasm
100
101$(obj)/mainboard/$(MAINBOARDDIR)/crt0.s: $(src)/arch/i386/init/crt0.S.lb $(obj)/romstage/crt0_includes.h
102 $(CC) -x assembler-with-cpp -DASSEMBLY -E -I$(src)/include -I$(src)/arch/i386/include -I$(obj) -I$(obj)/romstage -include $(obj)/config.h -I. -I$(src) $< > $@.new && mv $@.new $@
103
104endif