blob: 186e6e2b35adedb73831f7351eca47321c8f8595 [file] [log] [blame]
Stefan Reinauer30584912010-08-14 20:38:17 +00001##
2## This file is part of the coreboot project.
3##
4## Copyright (C) 2009-2010 coresystems GmbH
5## Copyright (C) 2009 Ronald G. Minnich
6##
7## This program is free software; you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation; version 2 of the License.
10##
11## This program is distributed in the hope that it will be useful,
12## but WITHOUT ANY WARRANTY; without even the implied warranty of
13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14## GNU General Public License for more details.
15##
16## You should have received a copy of the GNU General Public License
17## along with this program; if not, write to the Free Software
18## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19##
20
Patrick Georgi0588d192009-08-12 15:00:51 +000021#######################################################################
22# Take care of subdirectories
23subdirs-y += boot
Stefan Reinauere3778572010-01-30 09:47:18 +000024# subdirs-y += init
Patrick Georgi0588d192009-08-12 15:00:51 +000025subdirs-y += lib
26subdirs-y += smp
27
Patrick Georgi8463dd92010-09-30 16:55:02 +000028OPTION_TABLE_H:=
29ifeq ($(CONFIG_HAVE_OPTION_TABLE),y)
Patrick Georgi5c0bca22011-01-30 16:31:15 +000030cbfs-files-y += cmos_layout.bin
31cmos_layout.bin-file = $(obj)/cmos_layout.bin
32cmos_layout.bin-type = 0x01aa
Patrick Georgi24479372011-01-18 13:56:36 +000033
Patrick Georgi8463dd92010-09-30 16:55:02 +000034OPTION_TABLE_H:=$(obj)/option_table.h
35endif
Patrick Georgi0588d192009-08-12 15:00:51 +000036
Patrick Georgi0588d192009-08-12 15:00:51 +000037#######################################################################
38# Build the final rom image
Patrick Georgi182b09e2010-03-16 16:59:03 +000039COREBOOT_ROM_DEPENDENCIES:=
Stefan Reinauerf1939bb2010-12-30 17:39:50 +000040ifeq ($(CONFIG_PAYLOAD_ELF),y)
Stefan Reinauerbccbbe62010-12-19 21:20:14 +000041COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_PAYLOAD_FILE)
Peter Stuge87f95142009-10-23 12:14:15 +000042endif
Stefan Reinauerf1939bb2010-12-30 17:39:50 +000043ifeq ($(CONFIG_PAYLOAD_SEABIOS),y)
44COREBOOT_ROM_DEPENDENCIES+=seabios
45endif
Stefan Reinauere50952f2011-04-15 03:34:05 +000046ifeq ($(CONFIG_PAYLOAD_FILO),y)
47COREBOOT_ROM_DEPENDENCIES+=filo
48endif
Stefan Reinauercca62682010-03-30 21:52:05 +000049ifeq ($(CONFIG_AP_CODE_IN_CAR),y)
50COREBOOT_ROM_DEPENDENCIES+=$(obj)/coreboot_ap
51endif
Stefan Reinauerf94a97b2010-04-21 20:55:38 +000052ifeq ($(CONFIG_GEODE_VSA_FILE),y)
53COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_VSA_FILENAME)
Stefan Reinauerbda29312010-04-20 18:35:33 +000054endif
Stefan Reinauercca62682010-03-30 21:52:05 +000055
Patrick Georgic2c23dc2010-12-16 07:36:28 +000056extract_nth=$(word $(1), $(subst |, ,$(2)))
57
58ifneq ($(CONFIG_UPDATE_IMAGE),y)
59prebuild-files = \
60 $(foreach file,$(cbfs-files), \
Vadim Bendebury10fea922011-11-05 02:07:01 +000061 $(CBFSTOOL) $@.tmp add $(call extract_nth,1,$(file)) \
62 $(call extract_nth,2,$(file)) $(call extract_nth,3,$(file)) \
63 $(call extract_nth,4,$(file)) &&)
Patrick Georgic2c23dc2010-12-16 07:36:28 +000064prebuilt-files = $(foreach file,$(cbfs-files), $(call extract_nth,1,$(file)))
65
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +030066$(obj)/coreboot.pre1: $(objcbfs)/bootblock.bin $$(prebuilt-files) $(CBFSTOOL)
67 $(CBFSTOOL) $@.tmp create $(CONFIG_COREBOOT_ROMSIZE_KB)K $(objcbfs)/bootblock.bin
Vadim Bendebury10fea922011-11-05 02:07:01 +000068 $(prebuild-files) true
69 mv $@.tmp $@
Patrick Georgic2c23dc2010-12-16 07:36:28 +000070else
Patrick Georgi3954b0a2011-10-28 22:52:11 +020071.PHONY: $(obj)/coreboot.pre1
Patrick Georgic2c23dc2010-12-16 07:36:28 +000072$(obj)/coreboot.pre1: $(CBFSTOOL)
73 mv $(obj)/coreboot.rom $@
74endif
75
Patrick Georgia84e98b2010-03-16 19:01:32 +000076$(obj)/coreboot.rom: $(obj)/coreboot.pre $(obj)/coreboot_ram $(CBFSTOOL) $(call strip_quotes,$(COREBOOT_ROM_DEPENDENCIES))
Patrick Georgi1cd76e72010-04-19 20:39:22 +000077 @printf " CBFS $(subst $(obj)/,,$(@))\n"
Patrick Georgi182b09e2010-03-16 16:59:03 +000078 cp $(obj)/coreboot.pre $@.tmp
Stefan Reinauercca62682010-03-30 21:52:05 +000079 if [ -f $(obj)/coreboot_ap ]; \
Patrick Georgi182b09e2010-03-16 16:59:03 +000080 then \
Stefan Reinauercca62682010-03-30 21:52:05 +000081 $(CBFSTOOL) $@.tmp add-stage $(obj)/coreboot_ap $(CONFIG_CBFS_PREFIX)/coreboot_ap $(CBFS_COMPRESS_FLAG); \
Patrick Georgi182b09e2010-03-16 16:59:03 +000082 fi
83 $(CBFSTOOL) $@.tmp add-stage $(obj)/coreboot_ram $(CONFIG_CBFS_PREFIX)/coreboot_ram $(CBFS_COMPRESS_FLAG)
84ifeq ($(CONFIG_PAYLOAD_NONE),y)
Patrick Georgi1cd76e72010-04-19 20:39:22 +000085 @printf " PAYLOAD \e[1;31mnone (as specified by user)\e[0m\n"
Stefan Reinauerf1939bb2010-12-30 17:39:50 +000086endif
87ifeq ($(CONFIG_PAYLOAD_ELF),y)
Stefan Reinauerbccbbe62010-12-19 21:20:14 +000088 @printf " PAYLOAD $(CONFIG_PAYLOAD_FILE) (compression: $(CBFS_PAYLOAD_COMPRESS_NAME))\n"
89 $(CBFSTOOL) $@.tmp add-payload $(CONFIG_PAYLOAD_FILE) $(CONFIG_CBFS_PREFIX)/payload $(CBFS_PAYLOAD_COMPRESS_FLAG)
Patrick Georgi182b09e2010-03-16 16:59:03 +000090endif
Stefan Reinauerf1939bb2010-12-30 17:39:50 +000091ifeq ($(CONFIG_PAYLOAD_SEABIOS),y)
92 @printf " PAYLOAD SeaBIOS (internal, compression: $(CBFS_PAYLOAD_COMPRESS_NAME))\n"
93 $(CBFSTOOL) $@.tmp add-payload $(CONFIG_PAYLOAD_FILE) $(CONFIG_CBFS_PREFIX)/payload $(CBFS_PAYLOAD_COMPRESS_FLAG)
94endif
Stefan Reinauere50952f2011-04-15 03:34:05 +000095ifeq ($(CONFIG_PAYLOAD_FILO),y)
96 @printf " PAYLOAD FILO (internal, compression: $(CBFS_PAYLOAD_COMPRESS_NAME))\n"
97 $(CBFSTOOL) $@.tmp add-payload $(CONFIG_PAYLOAD_FILE) $(CONFIG_CBFS_PREFIX)/payload $(CBFS_PAYLOAD_COMPRESS_FLAG)
98endif
Stefan Reinauerf94a97b2010-04-21 20:55:38 +000099ifeq ($(CONFIG_GEODE_VSA_FILE),y)
100 @printf " VSA $(CONFIG_VSA_FILENAME)\n"
101 $(OBJCOPY) --set-start 0x20 --adjust-vma 0x60000 -I binary -O elf32-i386 -B i386 $(CONFIG_VSA_FILENAME) $(obj)/vsa.o
Patrick Georgi7923c492010-06-07 14:09:41 +0000102 $(LD) -m elf_i386 -e 0x60020 --section-start .data=0x60000 $(obj)/vsa.o -o $(obj)/vsa.elf
Stefan Reinauerbda29312010-04-20 18:35:33 +0000103 $(CBFSTOOL) $@.tmp add-stage $(obj)/vsa.elf vsa
104endif
Cristian Măgherușan-Stanciud367b002011-06-19 03:03:28 +0200105ifeq ($(CONFIG_INCLUDE_CONFIG_FILE),y)
106 @printf " CONFIG $(DOTCONFIG)\n"
107 if [ -f $(DOTCONFIG) ]; then \
108 echo "# This image was built using git revision" `git rev-parse HEAD` > $(obj)/config.tmp ; \
109 sed -e '/^#/d' -e '/^ *$$/d' $(DOTCONFIG) >> $(obj)/config.tmp ; \
110 $(CBFSTOOL) $@.tmp add $(obj)/config.tmp config raw; rm -f $(obj)/config.tmp ; fi
111endif
Patrick Georgi182b09e2010-03-16 16:59:03 +0000112 mv $@.tmp $@
Patrick Georgi1cd76e72010-04-19 20:39:22 +0000113 @printf " CBFSPRINT $(subst $(obj)/,,$(@))\n\n"
Patrick Georgi182b09e2010-03-16 16:59:03 +0000114 $(CBFSTOOL) $@ print
Patrick Georgi0588d192009-08-12 15:00:51 +0000115
Patrick Georgiff9d78c2011-01-30 16:37:39 +0000116stripped_vgabios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_ID))
117cbfs-files-$(CONFIG_VGA_BIOS) += pci$(stripped_vgabios_id).rom
118pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE))
119pci$(stripped_vgabios_id).rom-type := optionrom
120
121cbfs-files-$(CONFIG_INTEL_MBI) += mbi.bin
122mbi.bin-file := $(call strip_quotes,$(CONFIG_MBI_FILE))
123mbi.bin-type := mbi
124
125cbfs-files-$(CONFIG_BOOTSPLASH) += bootsplash.jpg
126bootsplash.jpg-file := $(call strip_quotes,$(CONFIG_BOOTSPLASH_FILE))
127bootsplash.jpg-type := bootsplash
128
Patrick Georgi0588d192009-08-12 15:00:51 +0000129#######################################################################
130# i386 specific tools
Vikram Narayanana8111cf2012-04-14 15:25:13 +0530131NVRAMTOOL:=$(objutil)/nvramtool/nvramtool
Patrick Georgi0588d192009-08-12 15:00:51 +0000132
Vikram Narayanana8111cf2012-04-14 15:25:13 +0530133$(OPTION_TABLE_H): $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000134 @printf " OPTION $(subst $(obj)/,,$(@))\n"
Vikram Narayanana8111cf2012-04-14 15:25:13 +0530135 $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -H $@
Patrick Georgi1c797a12010-04-15 14:32:17 +0000136
Vikram Narayanana8111cf2012-04-14 15:25:13 +0530137$(obj)/cmos_layout.bin: $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
Patrick Georgi1c797a12010-04-15 14:32:17 +0000138 @printf " OPTION $(subst $(obj)/,,$(@))\n"
Vikram Narayanana8111cf2012-04-14 15:25:13 +0530139 $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -L $@
Patrick Georgi0588d192009-08-12 15:00:51 +0000140
141#######################################################################
Kyösti Mälkki0db2ae3a2012-04-19 12:00:06 +0300142# Common recipes for all stages
143
144$(objcbfs)/%.bin: $(objcbfs)/%.elf
145 @printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
146 $(OBJCOPY) -O binary $< $@
147
148$(objcbfs)/%.elf: $(objcbfs)/%.debug
149 @printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
150 cp $< $@.tmp
151 $(NM) -n $@.tmp | sort > $(basename $@).map
152 $(OBJCOPY) --strip-debug $@.tmp
153 $(OBJCOPY) --add-gnu-debuglink=$< $@.tmp
154 mv $@.tmp $@
155
156#######################################################################
Patrick Georgi0588d192009-08-12 15:00:51 +0000157# Build the coreboot_ram (stage 2)
158
Stefan Reinauer8677a232010-12-11 20:33:41 +0000159$(obj)/coreboot_ram: $(obj)/coreboot_ram.o $(src)/arch/x86/coreboot_ram.ld #ldoptions
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000160 @printf " CC $(subst $(obj)/,,$(@))\n"
Kyösti Mälkki608d15b2012-03-31 09:48:11 +0300161 $(CC) -nostdlib -nostartfiles -static -o $@.tmp -L$(obj) -T $(src)/arch/x86/coreboot_ram.ld $(obj)/coreboot_ram.o
162 $(NM) -n $@.tmp | sort > $@.map
163 $(OBJCOPY) --only-keep-debug $@.tmp $@.debug
164 $(OBJCOPY) --strip-debug $@.tmp
165 $(OBJCOPY) --add-gnu-debuglink=$@.debug $@.tmp
166 mv $@.tmp $@
Patrick Georgi0588d192009-08-12 15:00:51 +0000167
Stefan Reinauer8677a232010-12-11 20:33:41 +0000168$(obj)/coreboot_ram.o: $(obj)/arch/x86/lib/c_start.ramstage.o $$(driver-objs) $(obj)/coreboot.a $(LIBGCC_FILE_NAME)
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000169 @printf " CC $(subst $(obj)/,,$(@))\n"
Stefan Reinauer8677a232010-12-11 20:33:41 +0000170 $(CC) -nostdlib -r -o $@ $(obj)/arch/x86/lib/c_start.ramstage.o $(driver-objs) -Wl,--wrap,__divdi3 -Wl,--wrap,__udivdi3 -Wl,--wrap,__moddi3 -Wl,--wrap,__umoddi3 -Wl,--start-group $(obj)/coreboot.a $(LIBGCC_FILE_NAME) -Wl,--end-group
Patrick Georgi0588d192009-08-12 15:00:51 +0000171
Patrick Georgi8463dd92010-09-30 16:55:02 +0000172$(obj)/coreboot.a: $$(ramstage-objs)
Uwe Hermann6c73b4412009-10-28 17:10:51 +0000173 @printf " AR $(subst $(obj)/,,$(@))\n"
Patrick Georgi2b7418e2009-08-25 19:38:46 +0000174 rm -f $(obj)/coreboot.a
Patrick Georgi51e142f2010-03-27 17:18:39 +0000175 $(AR) cr $(obj)/coreboot.a $^
Patrick Georgi0588d192009-08-12 15:00:51 +0000176
Patrick Georgi0588d192009-08-12 15:00:51 +0000177#######################################################################
Stefan Reinauercca62682010-03-30 21:52:05 +0000178# coreboot_ap.rom
179
180ifeq ($(CONFIG_AP_CODE_IN_CAR),y)
181
182$(obj)/coreboot_ap: $(obj)/mainboard/$(MAINBOARDDIR)/ap_romstage.o
183 @printf " CC $(subst $(obj)/,,$(@))\n"
Kyösti Mälkki608d15b2012-03-31 09:48:11 +0300184 $(CC) -nostdlib -nostartfiles -static -o $@.tmp -L$(obj) -T $(src)/arch/x86/init/ldscript_apc.lb $^
185 $(OBJCOPY) --only-keep-debug $@.tmp $@.debug
186 $(OBJCOPY) --strip-debug $@.tmp
187 $(OBJCOPY) --add-gnu-debuglink=$@.debug $@.tmp
188 $(NM) -n $@.tmp | sort > $@.map
189 mv $@.tmp $@
Stefan Reinauercca62682010-03-30 21:52:05 +0000190
191endif
192
193#######################################################################
Patrick Georgi0588d192009-08-12 15:00:51 +0000194# done
195
Stefan Reinauer8677a232010-12-11 20:33:41 +0000196crt0s = $(src)/arch/x86/init/prologue.inc
Stefan Reinaueracdd52f2010-03-30 20:32:01 +0000197ldscripts =
Stefan Reinauer31853d82011-04-14 20:30:21 +0000198ldscripts += $(src)/arch/x86/init/bootblock.ld
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000199crt0s += $(src)/cpu/x86/32bit/entry32.inc
Patrick Georgi31b0bea2010-02-25 21:50:26 +0000200ldscripts += $(src)/cpu/x86/32bit/entry32.lds
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000201
202crt0s += $(src)/cpu/x86/fpu_enable.inc
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000203ifeq ($(CONFIG_SSE),y)
204crt0s += $(src)/cpu/x86/sse_enable.inc
205endif
206
Patrick Georgi5934b502010-04-12 15:28:34 +0000207crt0s += $(cpu_incs)
Kyösti Mälkkiabdf15f2012-02-28 14:01:34 +0200208crt0s += $(cpu_incs-y)
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000209
Stefan Reinauer5c503922010-03-13 22:07:15 +0000210ifeq ($(CONFIG_LLSHELL),y)
Stefan Reinauer8677a232010-12-11 20:33:41 +0000211crt0s += $(src)/arch/x86/llshell/llshell.inc
Stefan Reinauer5c503922010-03-13 22:07:15 +0000212endif
213
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000214crt0s += $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc
215
Patrick Georgie64b6372010-04-08 21:04:45 +0000216ifeq ($(CONFIG_ROMCC),y)
Stefan Reinauer8677a232010-12-11 20:33:41 +0000217crt0s += $(src)/arch/x86/init/crt0_romcc_epilogue.inc
Patrick Georgie64b6372010-04-08 21:04:45 +0000218endif
219
Patrick Georgi2063197a2010-02-09 12:21:10 +0000220ifeq ($(CONFIG_ROMCC),y)
221ROMCCFLAGS ?= -mcpu=p2 -O2
222
Patrick Georgib111ba42010-04-16 23:01:34 +0000223$(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(objutil)/romcc/romcc $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h
Patrick Georgi patrick.georgic5f773d2010-03-16 12:01:13 +0000224 printf " ROMCC romstage.inc\n"
Stefan Reinauere9f32582010-03-29 13:04:13 +0000225 $(ROMCC) -c -S $(ROMCCFLAGS) -D__PRE_RAM__ -I. $(INCLUDES) $< -o $@
Patrick Georgi2063197a2010-02-09 12:21:10 +0000226else
Stefan Reinauer18476182010-02-11 08:44:20 +0000227
Stefan Reinauer86554122010-03-29 21:50:53 +0000228$(obj)/mainboard/$(MAINBOARDDIR)/ap_romstage.o: $(src)/mainboard/$(MAINBOARDDIR)/ap_romstage.c $(OPTION_TABLE_H)
Stefan Reinauer6bee9512010-03-24 15:51:48 +0000229 @printf " CC $(subst $(obj)/,,$(@))\n"
Stefan Reinauer61aee5f2011-04-10 04:15:23 +0000230 $(CC) -MMD $(CFLAGS) -I$(src) -D__PRE_RAM__ -I. -I$(obj) -c $< -o $@
Stefan Reinauer18476182010-02-11 08:44:20 +0000231
Sven Schnelled69438e2011-03-29 09:01:10 +0000232$(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h
Patrick Georgi1cd76e72010-04-19 20:39:22 +0000233 @printf " CC romstage.inc\n"
Stefan Reinauer10ec0fe2010-09-25 10:40:47 +0000234 $(CC) -MMD $(CFLAGS) -D__PRE_RAM__ -I$(src) -I. -I$(obj) -c -S $< -o $@
Stefan Reinauer6bee9512010-03-24 15:51:48 +0000235
236$(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc
Patrick Georgi1cd76e72010-04-19 20:39:22 +0000237 @printf " POST romstage.inc\n"
Stefan Reinauer8d427ec2011-10-12 12:54:08 -0700238 sed -e 's/\.rodata/.rom.data/g' -e 's/\^\.text/.section .rom.text/g' \
239 -e 's/\^\.section \.text/.section .rom.text/g' $^ > $@.tmp
Patrick Georgi68882a32010-02-10 18:08:22 +0000240 mv $@.tmp $@
Patrick Georgi2063197a2010-02-09 12:21:10 +0000241endif
Patrick Georgi37bdb872010-02-27 08:39:04 +0000242
Patrick Georgi37bdb872010-02-27 08:39:04 +0000243# Things that appear in every board
Patrick Georgi8463dd92010-09-30 16:55:02 +0000244romstage-srcs += $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s
245ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mainboard.c
Patrick Georgi37bdb872010-02-27 08:39:04 +0000246ifeq ($(CONFIG_GENERATE_MP_TABLE),y)
Patrick Georgi8463dd92010-09-30 16:55:02 +0000247ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c
Patrick Georgi37bdb872010-02-27 08:39:04 +0000248endif
249ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y)
Patrick Georgi8463dd92010-09-30 16:55:02 +0000250ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c
Patrick Georgi37bdb872010-02-27 08:39:04 +0000251endif
252ifeq ($(CONFIG_BOARD_HAS_HARD_RESET),y)
Patrick Georgi8463dd92010-09-30 16:55:02 +0000253ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/reset.c
Patrick Georgi37bdb872010-02-27 08:39:04 +0000254endif
Patrick Georgi9ea7bff2010-02-28 18:23:00 +0000255ifeq ($(CONFIG_GENERATE_ACPI_TABLES),y)
Patrick Georgi8463dd92010-09-30 16:55:02 +0000256ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/acpi_tables.c
257ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/dsdt.asl
Patrick Georgi75bf0532010-03-01 07:42:02 +0000258# make doesn't have arithmetic operators or greater-than comparisons
259ifeq ($(subst 5,4,$(CONFIG_ACPI_SSDTX_NUM)),4)
Patrick Georgi8463dd92010-09-30 16:55:02 +0000260ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/ssdt2.asl
261ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/ssdt3.asl
262ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/ssdt4.asl
Patrick Georgi75bf0532010-03-01 07:42:02 +0000263endif
264ifeq ($(CONFIG_ACPI_SSDTX_NUM),5)
Patrick Georgi8463dd92010-09-30 16:55:02 +0000265ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/ssdt5.asl
Patrick Georgi75bf0532010-03-01 07:42:02 +0000266endif
Patrick Georgi9ea7bff2010-02-28 18:23:00 +0000267ifeq ($(CONFIG_BOARD_HAS_FADT),y)
Patrick Georgi8463dd92010-09-30 16:55:02 +0000268ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/fadt.c
Patrick Georgi9ea7bff2010-02-28 18:23:00 +0000269endif
270endif
271
272ifeq ($(CONFIG_HAVE_BUS_CONFIG),y)
Patrick Georgi8463dd92010-09-30 16:55:02 +0000273ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/get_bus_conf.c
Patrick Georgi9ea7bff2010-02-28 18:23:00 +0000274endif
Patrick Georgi37bdb872010-02-27 08:39:04 +0000275
Patrick Georgi641dd712011-11-01 18:55:59 +0100276#######################################################################
277# Build the final rom image
278
279$(obj)/coreboot.pre: $(obj)/coreboot.romstage $(obj)/coreboot.pre1 $(CBFSTOOL)
280 @printf " CBFS $(subst $(obj)/,,$(@))\n"
Vadim Bendebury10fea922011-11-05 02:07:01 +0000281 cp $(obj)/coreboot.pre1 $@.tmp
282 $(CBFSTOOL) $@.tmp add-stage $(obj)/romstage.elf \
Kyösti Mälkkid842f1f2012-03-26 19:03:44 +0300283 $(CONFIG_CBFS_PREFIX)/romstage x $(shell cat $(obj)/romstage/base_xip.txt)
Vadim Bendebury10fea922011-11-05 02:07:01 +0000284 mv $@.tmp $@
Patrick Georgi641dd712011-11-01 18:55:59 +0100285
286#######################################################################
287# Build the bootblock
288
Patrick Georgi641dd712011-11-01 18:55:59 +0100289bootblock_lds = $(src)/arch/x86/init/ldscript_failover.lb
290bootblock_lds += $(src)/cpu/x86/16bit/entry16.lds
291bootblock_lds += $(src)/cpu/x86/16bit/reset16.lds
292bootblock_lds += $(src)/arch/x86/lib/id.lds
293bootblock_lds += $(chipset_bootblock_lds)
294
295bootblock_inc = $(src)/arch/x86/init/prologue.inc
296bootblock_inc += $(src)/cpu/x86/16bit/entry16.inc
297bootblock_inc += $(src)/cpu/x86/16bit/reset16.inc
298bootblock_inc += $(src)/cpu/x86/32bit/entry32.inc
299bootblock_inc += $(src)/arch/x86/lib/id.inc
300bootblock_inc += $(chipset_bootblock_inc)
301
302ifeq ($(CONFIG_SSE),y)
303bootblock_inc += $(src)/cpu/x86/sse_enable.inc
304endif
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300305bootblock_inc += $(objgenerated)/bootblock.inc
Patrick Georgi641dd712011-11-01 18:55:59 +0100306bootblock_inc += $(src)/arch/x86/lib/walkcbfs.S
307
308bootblock_romccflags := -mcpu=i386 -O2 -D__PRE_RAM__
309ifeq ($(CONFIG_SSE),y)
310bootblock_romccflags := -mcpu=k7 -msse -O2 -D__PRE_RAM__
311endif
312
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300313$(objgenerated)/bootblock.ld: $$(bootblock_lds) $(obj)/ldoptions
Patrick Georgi641dd712011-11-01 18:55:59 +0100314 @printf " GEN $(subst $(obj)/,,$(@))\n"
Patrick Georgi641dd712011-11-01 18:55:59 +0100315 printf '$(foreach ldscript,ldoptions $(bootblock_lds),INCLUDE "$(ldscript)"\n)' > $@
316
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300317$(objgenerated)/bootblock.S: $$(bootblock_inc)
Patrick Georgi641dd712011-11-01 18:55:59 +0100318 @printf " GEN $(subst $(obj)/,,$(@))\n"
Patrick Georgi950f20a2012-01-17 13:13:59 +0100319 printf '$(foreach crt0,$(bootblock_inc),#include "$(crt0)"\n)' > $@
Patrick Georgi641dd712011-11-01 18:55:59 +0100320
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300321$(objgenerated)/bootblock.o: $(objgenerated)/bootblock.s
Patrick Georgi641dd712011-11-01 18:55:59 +0100322 @printf " CC $(subst $(obj)/,,$(@))\n"
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300323 $(CC) -Wa,-acdlns -c -o $@ $< > $(basename $@).disasm
Patrick Georgi641dd712011-11-01 18:55:59 +0100324
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300325$(objgenerated)/bootblock.s: $(objgenerated)/bootblock.S $(obj)/config.h $(obj)/build.h
Patrick Georgi641dd712011-11-01 18:55:59 +0100326 @printf " CC $(subst $(obj)/,,$(@))\n"
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300327 $(CC) -MMD -x assembler-with-cpp -E -I$(src)/include -I$(src)/arch/x86/include -I$(obj) -include $(obj)/build.h -include $(obj)/config.h -I. -I$(src) $< -o $@
Patrick Georgi641dd712011-11-01 18:55:59 +0100328
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300329$(objgenerated)/bootblock.inc: $(src)/arch/x86/init/$(subst ",,$(CONFIG_BOOTBLOCK_SOURCE)) $(objutil)/romcc/romcc $(OPTION_TABLE_H)
Patrick Georgi641dd712011-11-01 18:55:59 +0100330 @printf " ROMCC $(subst $(obj)/,,$(@))\n"
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300331 $(CC) $(INCLUDES) -MM -MT$(objgenerated)/bootblock.inc \
332 $< > $(objgenerated)/bootblock.inc.d
Patrick Georgi641dd712011-11-01 18:55:59 +0100333 $(ROMCC) -c -S $(bootblock_romccflags) $(ROMCCFLAGS) -I. $(INCLUDES) $< -o $@
334
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300335$(objcbfs)/bootblock.debug: $(objgenerated)/bootblock.o $(objgenerated)/bootblock.ld
Patrick Georgi641dd712011-11-01 18:55:59 +0100336 @printf " LINK $(subst $(obj)/,,$(@))\n"
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300337 $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(objgenerated)/bootblock.ld $<
Patrick Georgi641dd712011-11-01 18:55:59 +0100338
339#######################################################################
340# Build the romstage
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300341
Kyösti Mälkkid842f1f2012-03-26 19:03:44 +0300342$(obj)/romstage.bin: $$(romstage-objs) $(obj)/romstage/link_null.ld
Patrick Georgi641dd712011-11-01 18:55:59 +0100343 @printf " LINK $(subst $(obj)/,,$(@))\n"
Kyösti Mälkkid842f1f2012-03-26 19:03:44 +0300344 $(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/link_null.ld $(romstage-objs)
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300345 $(OBJCOPY) -O binary $(obj)/romstage.elf $@
346
Kyösti Mälkkid842f1f2012-03-26 19:03:44 +0300347$(obj)/coreboot.romstage: $$(romstage-objs) $(obj)/romstage/link_xip.ld
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300348 @printf " LINK $(subst $(obj)/,,$(@))\n"
Kyösti Mälkkid842f1f2012-03-26 19:03:44 +0300349 $(CC) -nostdlib -nostartfiles -static -o $(obj)/romstage.elf -L$(obj) -T $(obj)/romstage/link_xip.ld $(romstage-objs)
Patrick Georgi641dd712011-11-01 18:55:59 +0100350 $(NM) -n $(obj)/romstage.elf | sort > $(obj)/romstage.map
351 $(OBJCOPY) --only-keep-debug $(obj)/romstage.elf $(obj)/romstage.debug
352 $(OBJCOPY) --strip-debug $(obj)/romstage.elf
353 $(OBJCOPY) --add-gnu-debuglink=$(obj)/romstage.debug $(obj)/romstage.elf
354 $(OBJCOPY) -O binary $(obj)/romstage.elf $@
355
Kyösti Mälkkid842f1f2012-03-26 19:03:44 +0300356$(obj)/romstage/link_null.ld: $$(ldscripts) $(obj)/ldoptions
Patrick Georgi641dd712011-11-01 18:55:59 +0100357 @printf " GEN $(subst $(obj)/,,$(@))\n"
358 mkdir -p $(obj)/romstage
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300359 rm -f $@
360 printf "ROMSTAGE_BASE = 0x0;\n" > $@.tmp
361 printf '$(foreach ldscript,ldoptions $(ldscripts),INCLUDE "$(ldscript:$(obj)/%=%)"\n)' >> $@.tmp
362 mv $@.tmp $@
363
Kyösti Mälkkid842f1f2012-03-26 19:03:44 +0300364$(obj)/romstage/link_xip.ld: $(obj)/romstage/link_null.ld $(obj)/romstage/base_xip.txt
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300365 @printf " GEN $(subst $(obj)/,,$(@))\n"
366 rm -f $@
Kyösti Mälkkid842f1f2012-03-26 19:03:44 +0300367 sed -e 's/^/ROMSTAGE_BASE = /g' -e 's/$$/;/g' $(obj)/romstage/base_xip.txt > $@.tmp
368 sed -e '/ROMSTAGE_BASE/d' $(obj)/romstage/link_null.ld >> $@.tmp
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300369 mv $@.tmp $@
370
Kyösti Mälkkid842f1f2012-03-26 19:03:44 +0300371$(obj)/romstage/base_xip.txt: $(obj)/coreboot.pre1 $(obj)/romstage.bin
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300372 rm -f $@
373 $(CBFSTOOL) $(obj)/coreboot.pre1 locate $(obj)/romstage.bin $(CONFIG_CBFS_PREFIX)/romstage $(CONFIG_XIP_ROM_SIZE) > $@.tmp \
374 || { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; }
375 sed -i -e 's/^/0x/g' $@.tmp
376 mv $@.tmp $@
Patrick Georgi641dd712011-11-01 18:55:59 +0100377
378$(obj)/romstage/crt0.S: $$(crt0s)
379 @printf " GEN $(subst $(obj)/,,$(@))\n"
380 mkdir -p $(obj)/romstage
Patrick Georgi950f20a2012-01-17 13:13:59 +0100381 printf '$(foreach crt0,$(crt0s),#include "$(crt0:$(obj)/%=%)"\n)' > $@
Patrick Georgi641dd712011-11-01 18:55:59 +0100382
383$(obj)/mainboard/$(MAINBOARDDIR)/crt0.romstage.o: $(obj)/mainboard/$(MAINBOARDDIR)/crt0.s
384 @printf " CC $(subst $(obj)/,,$(@))\n"
Patrick Georgi30cc4802012-03-11 19:34:12 +0100385 $(CC) -Wa,-acdlns -c -o $@ $< > $(dir $@)/crt0.disasm
Patrick Georgi641dd712011-11-01 18:55:59 +0100386
Patrick Georgi950f20a2012-01-17 13:13:59 +0100387$(obj)/mainboard/$(MAINBOARDDIR)/crt0.s: $(obj)/romstage/crt0.S $(obj)/config.h $(obj)/build.h
Patrick Georgi641dd712011-11-01 18:55:59 +0100388 @printf " CC $(subst $(obj)/,,$(@))\n"
Patrick Georgi950f20a2012-01-17 13:13:59 +0100389 $(CC) -MMD -x assembler-with-cpp -E -I$(src)/include -I$(src)/arch/x86/include -I$(obj) -I$(obj)/romstage -include $(obj)/config.h -include $(obj)/build.h -I. -I$(src) $< -o $@
Stefan Reinauerf1939bb2010-12-30 17:39:50 +0000390
391seabios:
392 $(MAKE) -C payloads/external/SeaBIOS -f Makefile.inc \
Peter Stugeb1d1c4d2011-02-07 20:16:40 +0000393 HOSTCC="$(HOSTCC)" \
Stefan Reinauere3509fd2011-01-29 05:51:54 +0000394 CC="$(CC)" LD="$(LD)" OBJDUMP="$(OBJDUMP)" \
395 OBJCOPY="$(OBJCOPY)" STRIP="$(STRIP)" \
Stefan Reinauerf1939bb2010-12-30 17:39:50 +0000396 CONFIG_SEABIOS_MASTER=$(CONFIG_SEABIOS_MASTER) \
Stefan Reinaueraff6dc22012-01-21 10:34:22 -0800397 CONFIG_SEABIOS_STABLE=$(CONFIG_SEABIOS_STABLE) \
398 OUT=$(abspath $(obj))
399
Stefan Reinauere50952f2011-04-15 03:34:05 +0000400filo:
401 $(MAKE) -C payloads/external/FILO -f Makefile.inc \
402 HOSTCC="$(HOSTCC)" \
403 CC="$(CC)" LD="$(LD)" OBJDUMP="$(OBJDUMP)" \
404 OBJCOPY="$(OBJCOPY)" STRIP="$(STRIP)" \
405 CONFIG_FILO_MASTER=$(CONFIG_FILO_MASTER) \
406 CONFIG_FILO_STABLE=$(CONFIG_FILO_STABLE)
Stefan Reinauerf1939bb2010-12-30 17:39:50 +0000407