blob: 788d7c7849ebeaf6661ea6a1ec2cd8408f064232 [file] [log] [blame]
Alexandru Gagniuc00b579a2012-07-20 00:11:21 -05001################################################################################
Stefan Reinauer30584912010-08-14 20:38:17 +00002##
3## This file is part of the coreboot project.
4##
Alexandru Gagniuc00b579a2012-07-20 00:11:21 -05005## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
Stefan Reinauer30584912010-08-14 20:38:17 +00006## Copyright (C) 2009-2010 coresystems GmbH
7## Copyright (C) 2009 Ronald G. Minnich
8##
9## This program is free software; you can redistribute it and/or modify
10## it under the terms of the GNU General Public License as published by
11## the Free Software Foundation; version 2 of the License.
12##
13## This program is distributed in the hope that it will be useful,
14## but WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16## GNU General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with this program; if not, write to the Free Software
Patrick Georgib890a122015-03-26 15:17:45 +010020## Foundation, Inc.
Stefan Reinauer30584912010-08-14 20:38:17 +000021##
Patrick Georgi0588d192009-08-12 15:00:51 +000022
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010023################################################################################
24# i386 specific tools
25NVRAMTOOL:=$(objutil)/nvramtool/nvramtool
26
Patrick Georgi8463dd92010-09-30 16:55:02 +000027OPTION_TABLE_H:=
28ifeq ($(CONFIG_HAVE_OPTION_TABLE),y)
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010029
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 Georgi70a6b4f2015-03-27 14:14:58 +010034$(obj)/cmos_layout.bin: $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
35 @printf " OPTION $(subst $(obj)/,,$(@))\n"
36 $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -L $@
37
Patrick Georgi8463dd92010-09-30 16:55:02 +000038OPTION_TABLE_H:=$(obj)/option_table.h
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010039
40$(OPTION_TABLE_H): $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
41 @printf " OPTION $(subst $(obj)/,,$(@))\n"
42 $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -H $@
43endif # CONFIG_HAVE_OPTION_TABLE
Patrick Georgi0588d192009-08-12 15:00:51 +000044
Patrick Georgiff9d78c2011-01-30 16:37:39 +000045stripped_vgabios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_ID))
46cbfs-files-$(CONFIG_VGA_BIOS) += pci$(stripped_vgabios_id).rom
47pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE))
48pci$(stripped_vgabios_id).rom-type := optionrom
49
50cbfs-files-$(CONFIG_INTEL_MBI) += mbi.bin
51mbi.bin-file := $(call strip_quotes,$(CONFIG_MBI_FILE))
52mbi.bin-type := mbi
53
Stefan Reinauer181b7732015-03-15 19:23:50 +010054ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
Julius Wernerf780c402014-11-10 13:11:50 -080055CBFSTOOL_PRE1_OPTS = -m x86 -s $(CONFIG_ROM_SIZE) \
56 -o $$(( $(CONFIG_ROM_SIZE) - $(CONFIG_CBFS_SIZE) ))
Furquan Shaikhb4ce4d42014-10-30 11:47:20 -070057# Make sure that segment for .car.data is ignored while adding romstage.
58CBFSTOOL_PRE_OPTS = -b $(shell cat $(objcbfs)/base_xip.txt) -S ".car.data"
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070059endif
Patrick Georgiff9d78c2011-01-30 16:37:39 +000060
Martin Roth16bc7e82015-06-28 13:49:16 -060061## Calculate the base address of CBFS for later comparisons
62CBFS_BASE_ADDRESS=$(call int-add, $(call int-subtract, 0xffffffff $(CONFIG_CBFS_SIZE)) 1)
63
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070064###############################################################################
65# bootblock
66###############################################################################
Patrick Georgi641dd712011-11-01 18:55:59 +010067
Stefan Reinauer181b7732015-03-15 19:23:50 +010068ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070069
Aaron Durbin3953e392015-09-03 00:41:29 -050070# Add the assembly file that pulls in the rest of the dependencies in
71# the right order. Make sure the auto generated bootblock.inc is a proper
72# dependency. Make the same true for the linker sript.
73bootblock-y += bootblock.S
74$(obj)/arch/x86/bootblock.bootblock.o: $(objgenerated)/bootblock.inc
Patrick Georgi641dd712011-11-01 18:55:59 +010075
Aaron Durbin3953e392015-09-03 00:41:29 -050076bootblock-y += bootblock.ld
77$(obj)/arch/x86/bootblock.bootblock.ld: $(objgenerated)/bootblock.ld
Patrick Georgi641dd712011-11-01 18:55:59 +010078
Patrick Georgi56b83092015-04-02 19:44:19 +020079bootblock_romccflags := -mcpu=i386 -O2 -D__PRE_RAM__ -D__BOOTBLOCK__
Patrick Georgi641dd712011-11-01 18:55:59 +010080ifeq ($(CONFIG_SSE),y)
Patrick Georgi56b83092015-04-02 19:44:19 +020081bootblock_romccflags := -mcpu=k7 -msse -O2 -D__PRE_RAM__ -D__BOOTBLOCK__
Patrick Georgi641dd712011-11-01 18:55:59 +010082endif
83
Aaron Durbin3953e392015-09-03 00:41:29 -050084# This is a hack in case there are no per chipset linker files.
85$(objgenerated)/empty:
86 touch $@
87
88$(objgenerated)/bootblock.ld: $$(filter-out $(obj)/arch/x86/bootblock.bootblock.ld, $$(filter %.ld,$$(bootblock-objs))) $(objgenerated)/empty
Patrick Georgi641dd712011-11-01 18:55:59 +010089 @printf " GEN $(subst $(obj)/,,$(@))\n"
Marc Jonesac630f72015-06-30 15:46:49 -060090 cat $^ >> $@.tmp
91 mv $@.tmp $@
Patrick Georgi641dd712011-11-01 18:55:59 +010092
Patrick Georgief0158e2015-07-27 17:47:55 +020093$(objgenerated)/bootblock.inc: $(src)/arch/x86/$(subst ",,$(CONFIG_BOOTBLOCK_SOURCE)) $(objutil)/romcc/romcc $(OPTION_TABLE_H) $(KCONFIG_AUTOHEADER)
Patrick Georgi641dd712011-11-01 18:55:59 +010094 @printf " ROMCC $(subst $(obj)/,,$(@))\n"
Patrick Georgi59307742014-05-19 09:23:57 +020095 $(CC_bootblock) $(CPPFLAGS_bootblock) -MM -MT$(objgenerated)/bootblock.inc \
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +030096 $< > $(objgenerated)/bootblock.inc.d
Patrick Georgi59307742014-05-19 09:23:57 +020097 $(ROMCC) -c -S $(bootblock_romccflags) -I. $(CPPFLAGS_bootblock) $< -o $@
Patrick Georgi641dd712011-11-01 18:55:59 +010098
Aaron Durbin3953e392015-09-03 00:41:29 -050099$(objcbfs)/bootblock.debug: $(obj)/arch/x86/bootblock.bootblock.o $(obj)/arch/x86/bootblock.bootblock.ld
Patrick Georgi641dd712011-11-01 18:55:59 +0100100 @printf " LINK $(subst $(obj)/,,$(@))\n"
Stefan Reinauer98749332015-06-23 12:57:06 -0700101ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
Aaron Durbin3953e392015-09-03 00:41:29 -0500102 $(LD_bootblock) -m elf_i386 --oformat elf32-i386 -static -o $@ -L$(obj) $< -T $(obj)/arch/x86/bootblock.bootblock.ld
Stefan Reinauer98749332015-06-23 12:57:06 -0700103else
Aaron Durbin3953e392015-09-03 00:41:29 -0500104 $(LD_bootblock) -m elf_x86_64 --oformat elf64-x86-64 -static -o $@ -L$(obj) $< -T $(obj)/arch/x86/bootblock.bootblock.ld
Stefan Reinauer98749332015-06-23 12:57:06 -0700105endif
Patrick Georgi641dd712011-11-01 18:55:59 +0100106
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700107
Stefan Reinauer181b7732015-03-15 19:23:50 +0100108endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700109
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700110###############################################################################
111# romstage
112###############################################################################
113
Stefan Reinauer181b7732015-03-15 19:23:50 +0100114ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700115
Aaron Durbin956c4f22015-09-05 13:31:14 -0500116romstage-y += memlayout.ld
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700117
Aaron Durbine581b062015-09-03 11:29:28 -0500118# Chipset specific assembly stubs in the romstage program flow. Certain
119# boards have more than one assembly stub so collect those and put them
120# into a single generated file.
121crt0s = $(cpu_incs-y)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700122
Aaron Durbine581b062015-09-03 11:29:28 -0500123$(objgenerated)/romstage.inc: $$(crt0s)
124 @printf " GEN $(subst $(obj)/,,$(@))\n"
125 printf '$(foreach crt0,$(crt0s),#include "$(crt0)"\n)' > $@
126
127# Add the assembly file that pulls in the rest of the dependencies in
128# the right order. Make sure the auto generated romstage.inc is a proper
129# dependency.
130romstage-y += romstage.S
131$(obj)/arch/x86/romstage.romstage.o: $(objgenerated)/romstage.inc
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700132
Aaron Durbin85982cd2015-09-03 11:01:17 -0500133ifneq ($(CONFIG_ROMCC),y)
134
135romstage-srcs += $(src)/mainboard/$(MAINBOARDDIR)/romstage.c
136
137else # CONFIG_ROMCC == y
138
139# This order matters. The mainboards requiring ROMCC need their mainboard
140# code to follow the prior crt0s files for program flow control. The
141# romstage.inc from the MAINBOARDDIR is implicitly main() for romstage
142# because of the instruction sequen fall-through.
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700143crt0s += $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc
Stefan Reinauer6cb3a592015-07-13 09:39:15 +0200144crt0s += $(src)/arch/x86/crt0_romcc_epilogue.inc
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700145
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700146ifeq ($(CONFIG_MMX),y)
147 ifeq ($(CONFIG_SSE),y)
148 ROMCCFLAGS := -mcpu=p4 -O2 # MMX, SSE
149 else
150 ROMCCFLAGS := -mcpu=p2 -O2 # MMX, !SSE
151 endif
152else
153 ROMCCFLAGS := -mcpu=i386 -O2 # !MMX, !SSE
154endif
155
Patrick Georgi24cca752014-11-29 11:51:25 +0100156$(objcbfs)/romstage%.bin: $(objcbfs)/romstage%.elf
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700157 @printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
158 $(OBJCOPY_romstage) -O binary $< $@
159
Patrick Georgi24cca752014-11-29 11:51:25 +0100160$(objcbfs)/romstage%.elf: $(objcbfs)/romstage%.debug
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700161 @printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
162 cp $< $@.tmp
163 $(OBJCOPY_romstage) --strip-debug $@.tmp
164 $(OBJCOPY_romstage) --add-gnu-debuglink=$< $@.tmp
165 mv $@.tmp $@
166
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700167$(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(objutil)/romcc/romcc $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h
168 printf " ROMCC romstage.inc\n"
Patrick Georgi815f4bf2015-04-28 22:43:31 +0200169 $(ROMCC) -c -S $(ROMCCFLAGS) -D__ROMSTAGE__ -D__PRE_RAM__ -I. $(CPPFLAGS_romstage) $< -o $@
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700170
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700171endif
172
Alexandru Gagniuceb3c9912014-03-29 13:01:11 -0500173romstage-libs ?=
174
Stefan Reinauer98749332015-06-23 12:57:06 -0700175ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
176romstage-oformat=elf32-i386
177else
178romstage-oformat=elf64-x86-64
179endif
180
Alexandru Gagniuceb3c9912014-03-29 13:01:11 -0500181$(objcbfs)/romstage_null.debug: $$(romstage-objs) $(objgenerated)/romstage_null.ld $$(romstage-libs)
Patrick Georgi641dd712011-11-01 18:55:59 +0100182 @printf " LINK $(subst $(obj)/,,$(@))\n"
Stefan Reinauer98749332015-06-23 12:57:06 -0700183 $(LD_romstage) --gc-sections -nostdlib -nostartfiles -static -o $@ -L$(obj) $(COMPILER_RT_FLAGS_romstage) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) $(romstage-libs) --no-whole-archive $(COMPILER_RT_romstage) --end-group -T $(objgenerated)/romstage_null.ld --oformat $(romstage-oformat)
Martin Rothdbb50c42015-08-22 10:37:39 -0600184 LANG=C LC_ALL= $(OBJCOPY_romstage) --only-section .illegal_globals $(@) $(objcbfs)/romstage_null.offenders 2>&1 | \
185 grep -v "Empty loadable segment detected" && \
Furquan Shaikh3cf6aea2014-10-30 11:53:38 -0700186 $(NM_romstage) $(objcbfs)/romstage_null.offenders | grep -q ""; if [ $$? -eq 0 ]; then \
Stefan Reinauerb6e12372012-07-31 14:52:04 -0700187 echo "Forbidden global variables in romstage:"; \
Furquan Shaikh3cf6aea2014-10-30 11:53:38 -0700188 $(NM_romstage) $(objcbfs)/romstage_null.offenders; false; \
Stefan Reinauerb6e12372012-07-31 14:52:04 -0700189 else true; fi
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300190
Patrick Georgi24cca752014-11-29 11:51:25 +0100191$(objcbfs)/romstage.debug: $$(romstage-objs) $(objgenerated)/romstage.ld $$(romstage-libs)
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300192 @printf " LINK $(subst $(obj)/,,$(@))\n"
Stefan Reinauer98749332015-06-23 12:57:06 -0700193 $(LD_romstage) --gc-sections -nostdlib -nostartfiles -static -o $@ -L$(obj) $(COMPILER_RT_FLAGS_romstage) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) $(romstage-libs) --no-whole-archive $(COMPILER_RT_romstage) --end-group -T $(objgenerated)/romstage.ld --oformat $(romstage-oformat)
Patrick Georgi641dd712011-11-01 18:55:59 +0100194
Aaron Durbin956c4f22015-09-05 13:31:14 -0500195$(objgenerated)/romstage_null.ld: $(obj)/arch/x86/memlayout.romstage.ld
Patrick Georgi641dd712011-11-01 18:55:59 +0100196 @printf " GEN $(subst $(obj)/,,$(@))\n"
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300197 rm -f $@
198 printf "ROMSTAGE_BASE = 0x0;\n" > $@.tmp
Aaron Durbin14714e12015-09-04 12:06:05 -0500199 cat $< >> $@.tmp
Marc Jonesac630f72015-06-30 15:46:49 -0600200 mv $@.tmp $@
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300201
Patrick Georgi24cca752014-11-29 11:51:25 +0100202$(objgenerated)/romstage.ld: $(objgenerated)/romstage_null.ld $(objcbfs)/base_xip.txt
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300203 @printf " GEN $(subst $(obj)/,,$(@))\n"
204 rm -f $@
Kyösti Mälkki1e9c1b32012-04-19 14:43:47 +0300205 sed -e 's/^/ROMSTAGE_BASE = /g' -e 's/$$/;/g' $(objcbfs)/base_xip.txt > $@.tmp
Patrick Georgi828e0e82015-04-04 15:50:20 +0200206 sed -e '/^ROMSTAGE_BASE/d' $(objgenerated)/romstage_null.ld >> $@.tmp
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300207 mv $@.tmp $@
208
Aaron Durbin4b349092015-09-07 23:05:28 -0500209# Use a '-a 64' option to cbfstool locate to provide a minimum alignment
210# requirement for the overall romstage. While the first object within
211# romstage could have a 4 byte minimum alignment that doesn't mean the linker
212# won't decide the entire section should be aligned to a larger value. In the
213# future cbfstool should add XIP files proper and honor the alignment
214# requirements of the program segment.
Kyösti Mälkki1e9c1b32012-04-19 14:43:47 +0300215$(objcbfs)/base_xip.txt: $(obj)/coreboot.pre1 $(objcbfs)/romstage_null.bin
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300216 rm -f $@
Aaron Durbin4b349092015-09-07 23:05:28 -0500217 $(CBFSTOOL) $(obj)/coreboot.pre1 locate -T -f $(objcbfs)/romstage_null.bin -n $(CONFIG_CBFS_PREFIX)/romstage -P $(CONFIG_XIP_ROM_SIZE) -a 64 > $@.tmp \
Kyösti Mälkkia01ec142012-03-31 10:21:29 +0300218 || { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; }
Hung-Te Lin657ea6a2013-01-28 23:00:47 +0800219 mv $@.tmp $@
Patrick Georgi641dd712011-11-01 18:55:59 +0100220
Patrick Georgid69839b2015-04-03 10:32:17 +0200221# Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428
222romstage-S-ccopts += -I. -g0
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700223
Stefan Reinauer181b7732015-03-15 19:23:50 +0100224endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64
Stefan Reinauerf1939bb2010-12-30 17:39:50 +0000225
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700226###############################################################################
227# ramstage
228###############################################################################
229
Stefan Reinauer181b7732015-03-15 19:23:50 +0100230ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700231
Patrick Georgic32a52c2015-06-22 21:10:34 +0200232ifeq ($(CONFIG_COMPILE_IN_DSDT),y)
233ramstage-srcs += $(obj)/dsdt.aml
234
235ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
236target-objcopy=-O elf32-i386 -B i386
237endif
238ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y)
239target-objcopy=-O elf64-x86_64 -B x86_64
240endif
241
242define ramstage-objs_aml_template
243$(call src-to-obj,ramstage,$(1).aml): $(1).aml
244 @printf " OBJCOPY $$(subst $$(obj)/,,$$(@))\n"
245 cd $$(dir $$@) && $$(OBJCOPY_ramstage) -I binary $$(target-objcopy) $$(notdir $$<) $$(notdir $$@)
246endef
247endif
248
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700249ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
250ifeq ($(CONFIG_GENERATE_MP_TABLE),y)
251ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),)
252ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c
253endif
254endif
255ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y)
256ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c
257endif
258ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/reset.c),)
259ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/reset.c
260endif
Vladimir Serbinenko822bc652014-01-03 15:55:40 +0100261ifeq ($(CONFIG_HAVE_ACPI_TABLES),y)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700262ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/acpi_tables.c
Aaron Durbinab454c62015-07-30 12:44:58 -0500263ifeq ($(CONFIG_COMPILE_IN_DSDT),y)
264$(eval $(call asl_template,dsdt,n))
265else
Vladimir Serbinenko36f8d272015-05-31 12:31:59 +0200266$(eval $(call asl_template,dsdt))
Aaron Durbinab454c62015-07-30 12:44:58 -0500267endif
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700268ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/fadt.c),)
269ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/fadt.c
270endif
Patrick Georgi990e7c92015-04-03 10:47:15 +0200271endif # CONFIG_GENERATE_ACPI_TABLES
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700272ifeq ($(CONFIG_HAVE_SMI_HANDLER),y)
273ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c),)
274smm-srcs += src/mainboard/$(MAINBOARDDIR)/smihandler.c
275endif
276endif
277ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/get_bus_conf.c),)
278ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/get_bus_conf.c
279endif
280
281ramstage-libs ?=
282
283ifeq ($(CONFIG_RELOCATABLE_RAMSTAGE),y)
284
Stefan Reinauer181b7732015-03-15 19:23:50 +0100285ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
Furquan Shaikh133096b2014-07-31 09:28:55 -0700286$(eval $(call rmodule_link,$(objcbfs)/ramstage.debug, $(objgenerated)/ramstage.o, $(CONFIG_HEAP_SIZE),x86_32))
Stefan Reinauer181b7732015-03-15 19:23:50 +0100287else
288$(eval $(call rmodule_link,$(objcbfs)/ramstage.debug, $(objgenerated)/ramstage.o, $(CONFIG_HEAP_SIZE),x86_64))
289endif
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700290
291# The rmodule_link defintion creates an elf file with .rmod extension.
292$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
293 cp $< $@
294
295else
296
Aaron Durbin956c4f22015-09-05 13:31:14 -0500297ramstage-y += memlayout.ld
Patrick Georgi828e0e82015-04-04 15:50:20 +0200298
Aaron Durbin956c4f22015-09-05 13:31:14 -0500299$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(obj)/arch/x86/memlayout.ramstage.ld
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700300 @printf " CC $(subst $(obj)/,,$(@))\n"
Aaron Durbin956c4f22015-09-05 13:31:14 -0500301 $(LD_ramstage) $(CPPFLAGS) --gc-sections -o $@ -L$(obj) $< -T $(obj)/arch/x86/memlayout.ramstage.ld
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700302
303endif
304
Patrick Georgi3ce96bd2014-11-22 17:42:58 +0100305$(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700306 @printf " CC $(subst $(obj)/,,$(@))\n"
Stefan Reinauer181b7732015-03-15 19:23:50 +0100307ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
Patrick Georgieec8dfb2015-05-07 22:24:41 +0200308 $(LD_ramstage) -m elf_i386 -r -o $@ $(COMPILER_RT_FLAGS_ramstage) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) --no-whole-archive $(COMPILER_RT_ramstage) --end-group
Stefan Reinauer181b7732015-03-15 19:23:50 +0100309else
310 $(LD_ramstage) -m elf_x86_64 -r -o $@ $(COMPILER_RT_FLAGS_ramstage) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) $(ramstage-libs) --no-whole-archive $(COMPILER_RT_ramstage) --end-group
311endif
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700312
Stefan Reinauer181b7732015-03-15 19:23:50 +0100313endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700314
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700315
Stefan Reinauer6cb3a592015-07-13 09:39:15 +0200316ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
317
318romstage-y += cbmem.c
319romstage-y += boot.c
320
321romstage-y += cbfs_and_run.c
322romstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += cpu_common.c
323romstage-y += memset.c
324romstage-y += memcpy.c
325romstage-y += memmove.c
326romstage-y += mmap_boot.c
327
328romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
329
330endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64
331
332ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y)
333
334ramstage-y += boot.c
335ramstage-y += gdt.c
336ramstage-y += tables.c
337ramstage-y += cbmem.c
338ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c
339ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c
340ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c
341ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c
342ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen.c
343ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S
344
345ramstage-y += c_start.S
346ramstage-y += cpu.c
347ramstage-y += cpu_common.c
348ramstage-y += pci_ops_conf1.c
349ramstage-$(CONFIG_MMCONF_SUPPORT) += pci_ops_mmconf.c
350ramstage-y += exception.c
351ramstage-$(CONFIG_IOAPIC) += ioapic.c
352ramstage-y += memset.c
353ramstage-y += memcpy.c
354ramstage-y += memmove.c
355ramstage-y += ebda.c
356ramstage-y += mmap_boot.c
357ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c
358ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S
359ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
360
361smm-y += memset.c
362smm-y += memcpy.c
363smm-y += memmove.c
364smm-y += mmap_boot.c
365
366ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
367rmodules_x86_32-y += memset.c
368rmodules_x86_32-y += memcpy.c
369rmodules_x86_32-y += memmove.c
370else
371rmodules_x86_64-y += memset.c
372rmodules_x86_64-y += memcpy.c
373rmodules_x86_64-y += memmove.c
374endif
375
376endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64