blob: 32e01738044a3feef31ec86cc77890d7c1bb61fa [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##
Patrick Georgi0588d192009-08-12 15:00:51 +000018
Patrick Georgi29eeece2018-10-31 14:24:47 +010019ifeq ($(CONFIG_POSTCAR_STAGE),y)
20$(eval $(call init_standard_toolchain,postcar))
21endif
22
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
Martin Roth8ea06512016-09-19 13:58:01 -060032cmos_layout.bin-type = cmos_layout
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
Mike Banon0f8547e2019-02-17 19:51:53 +030050stripped_vgabios_dgpu_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_ID))
51cbfs-files-$(CONFIG_VGA_BIOS_DGPU) += pci$(stripped_vgabios_dgpu_id).rom
52pci$(stripped_vgabios_dgpu_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_FILE))
53pci$(stripped_vgabios_dgpu_id).rom-type := optionrom
54
Nico Huber33fcaf92018-10-10 22:44:20 +020055verstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
56bootblock-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
57romstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
58ramstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
59postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
60
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070061###############################################################################
Aaron Durbineb907b32016-01-21 00:08:17 -060062# common support for early assembly includes
63###############################################################################
64
65# Chipset specific assembly stubs in the romstage program flow. Certain
66# boards have more than one assembly stub so collect those and put them
67# into a single generated file.
68crt0s = $(cpu_incs-y)
69
70$(objgenerated)/assembly.inc: $$(crt0s)
71 @printf " GEN $(subst $(obj)/,,$(@))\n"
72 printf '$(foreach crt0,$(crt0s),#include "$(crt0)"\n)' > $@
73
74
75define early_x86_assembly_entry_rule
76# $1 stage name
77# Add the assembly file that pulls in the rest of the dependencies in
78# the right order. Make sure the auto generated assembly.inc is a proper
79# dependency.
80$(1)-y += assembly_entry.S
Nico Huber81b09f42016-01-23 00:50:00 +010081$(call src-to-obj,$(1),$(dir)/assembly_entry.S): $(objgenerated)/assembly.inc
Aaron Durbineb907b32016-01-21 00:08:17 -060082endef
83
84define early_x86_stage
85# $1 stage name
86# $2 oformat
87$(1)-y += memlayout.ld
88
89# The '.' include path is needed for the generated assembly.inc file.
90$(1)-S-ccopts += -I.
91
92$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs)
93 @printf " LINK $$(subst $$(obj)/,,$$(@))\n"
Nico Huber81b09f42016-01-23 00:50:00 +010094 $$(LD_$(1)) $$(LDFLAGS_$(1)) -o $$@ -L$$(obj) $$(COMPILER_RT_FLAGS_$(1)) --whole-archive --start-group $$(filter-out %.ld,$$($(1)-objs)) $$($(1)-libs) --no-whole-archive $$(COMPILER_RT_$(1)) --end-group -T $(call src-to-obj,$(1),$(dir)/memlayout.ld) --oformat $(2)
Aaron Durbineb907b32016-01-21 00:08:17 -060095 -LANG=C LC_ALL= $$(OBJCOPY_$(1)) --only-section .illegal_globals $$(@) $$(objcbfs)/$(1)_null.offenders >/dev/null 2>&1
96 if [ -z "$$$$($$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders 2>&1 | grep 'no symbols')" ];then \
97 echo "Forbidden global variables in $(1):"; \
98 $$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders; false; \
99 fi
100endef
101
102###############################################################################
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700103# bootblock
104###############################################################################
Patrick Georgi641dd712011-11-01 18:55:59 +0100105
Stefan Reinauer181b7732015-03-15 19:23:50 +0100106ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700107
Alexandru Gagniuc4e153d62016-01-08 23:05:00 -0800108bootblock-y += boot.c
Lee Leahy5f4b4c42016-07-24 08:09:40 -0700109bootblock-y += cpu_common.c
Aaron Durbin4b032e42018-04-20 01:39:30 -0600110bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
111bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Alexandru Gagniuc4e153d62016-01-08 23:05:00 -0800112bootblock-y += memcpy.c
113bootblock-y += memset.c
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700114bootblock-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Alexandru Gagniuc6a622312015-10-27 10:27:30 -0700115bootblock-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Alexandru Gagniuc4e153d62016-01-08 23:05:00 -0800116
Alexandru Gagniucee2740b2015-10-04 17:47:36 -0700117bootblock-y += id.S
Nico Huber81b09f42016-01-23 00:50:00 +0100118$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h
Patrick Georgiab355752015-10-15 11:07:07 +0200119
Aaron Durbineb907b32016-01-21 00:08:17 -0600120ifeq ($(CONFIG_C_ENVIRONMENT_BOOTBLOCK),y)
121
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -0800122bootblock-y += bootblock_crt0.S
Aaron Durbineb907b32016-01-21 00:08:17 -0600123
124ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
125$(eval $(call early_x86_stage,bootblock,elf32-i386))
126else
127$(eval $(call early_x86_stage,bootblock,elf64-x86-64))
128endif
129
Patrick Rudolph4d60d962019-02-10 13:56:29 +0100130bootblock-$(CONFIG_ARCH_BOOTBLOCK_X86_32) += walkcbfs.S
Arthur Heymans0eb9c572019-01-05 18:21:47 +0100131
Aaron Durbineb907b32016-01-21 00:08:17 -0600132else # !C_ENVIRONMENT_BOOTBLOCK
133
134# x86-specific linker flags
135ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
136LDFLAGS_bootblock += -m elf_i386 --oformat elf32-i386
137else
138LDFLAGS_bootblock += -m elf_x86_64 --oformat elf64-x86-64
139endif
140
Alexandru Gagniucf8e49132015-10-02 12:42:26 -0700141# Add the assembly file that pulls in the rest of the dependencies in
142# the right order. Make sure the auto generated bootblock.inc is a proper
143# dependency. Make the same true for the linker sript.
144bootblock-y += bootblock_romcc.S
Alexandru Gagniucc46a3922015-10-02 16:17:41 -0700145bootblock-y += walkcbfs.S
Alexandru Gagniucf8e49132015-10-02 12:42:26 -0700146$(call src-to-obj,bootblock,$(dir)/bootblock_romcc.S): $(objgenerated)/bootblock.inc
Patrick Georgi641dd712011-11-01 18:55:59 +0100147
Aaron Durbin3953e392015-09-03 00:41:29 -0500148bootblock-y += bootblock.ld
Nico Huber81b09f42016-01-23 00:50:00 +0100149$(call src-to-obj,bootblock,$(dir)/bootblock.ld): $(objgenerated)/bootblock.ld
Patrick Georgi641dd712011-11-01 18:55:59 +0100150
Patrick Georgi56b83092015-04-02 19:44:19 +0200151bootblock_romccflags := -mcpu=i386 -O2 -D__PRE_RAM__ -D__BOOTBLOCK__
Patrick Georgi641dd712011-11-01 18:55:59 +0100152ifeq ($(CONFIG_SSE),y)
Kyösti Mälkki3ba79b32018-12-23 07:22:56 +0200153bootblock_romccflags := -mcpu=k7 -mno-mmx -msse -O2 -D__PRE_RAM__ -D__BOOTBLOCK__
Patrick Georgi641dd712011-11-01 18:55:59 +0100154endif
155
Aaron Durbin3953e392015-09-03 00:41:29 -0500156# This is a hack in case there are no per chipset linker files.
Alexander Couzensb619f442015-12-14 22:04:54 +0100157$(objgenerated)/empty: build-dirs
Aaron Durbin3953e392015-09-03 00:41:29 -0500158 touch $@
159
Nico Huber81b09f42016-01-23 00:50:00 +0100160$(objgenerated)/bootblock.ld: $$(filter-out $(call src-to-obj,bootblock,src/arch/x86/bootblock.ld), $$(filter %.ld,$$(bootblock-objs))) $(objgenerated)/empty
Patrick Georgi641dd712011-11-01 18:55:59 +0100161 @printf " GEN $(subst $(obj)/,,$(@))\n"
Marc Jonesac630f72015-06-30 15:46:49 -0600162 cat $^ >> $@.tmp
163 mv $@.tmp $@
Patrick Georgi641dd712011-11-01 18:55:59 +0100164
Nico Huber4ba7b262018-09-03 15:39:33 +0200165-include $(objgenerated)/bootblock.inc.d
Patrick Georgief0158e2015-07-27 17:47:55 +0200166$(objgenerated)/bootblock.inc: $(src)/arch/x86/$(subst ",,$(CONFIG_BOOTBLOCK_SOURCE)) $(objutil)/romcc/romcc $(OPTION_TABLE_H) $(KCONFIG_AUTOHEADER)
Martin Roth6313bc72016-01-15 11:12:04 -0700167# The open quote in the subst messes with syntax highlighting. Fix it - ")
Patrick Georgi641dd712011-11-01 18:55:59 +0100168 @printf " ROMCC $(subst $(obj)/,,$(@))\n"
Patrick Georgi59307742014-05-19 09:23:57 +0200169 $(CC_bootblock) $(CPPFLAGS_bootblock) -MM -MT$(objgenerated)/bootblock.inc \
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300170 $< > $(objgenerated)/bootblock.inc.d
Patrick Georgi59307742014-05-19 09:23:57 +0200171 $(ROMCC) -c -S $(bootblock_romccflags) -I. $(CPPFLAGS_bootblock) $< -o $@
Patrick Georgi641dd712011-11-01 18:55:59 +0100172
Nico Huber81b09f42016-01-23 00:50:00 +0100173# bootblock.ld is part of $(bootblock-objs)
Alexandru Gagniucdbeedbe2015-10-02 12:17:56 -0700174$(objcbfs)/bootblock.debug: $$(bootblock-objs)
Patrick Georgi641dd712011-11-01 18:55:59 +0100175 @printf " LINK $(subst $(obj)/,,$(@))\n"
Alexandru Gagniucdbeedbe2015-10-02 12:17:56 -0700176 $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \
177 $(filter-out %.ld,$(bootblock-objs)) \
Nico Huber81b09f42016-01-23 00:50:00 +0100178 -T $(call src-to-obj,bootblock,src/arch/x86/bootblock.ld)
Patrick Georgi641dd712011-11-01 18:55:59 +0100179
Aaron Durbineb907b32016-01-21 00:08:17 -0600180endif # C_ENVIRONMENT_BOOTBLOCK
181
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700182
Stefan Reinauer181b7732015-03-15 19:23:50 +0100183endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700184
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700185###############################################################################
Aaron Durbin75c51d92015-09-29 16:31:20 -0500186# verstage
187###############################################################################
188
189ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32)$(CONFIG_ARCH_VERSTAGE_X86_64),y)
190
191verstage-y += boot.c
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -0700192verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += gdt_init.S
Aaron Durbin4b032e42018-04-20 01:39:30 -0600193verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
194verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Aaron Durbin75c51d92015-09-29 16:31:20 -0500195
Subrata Banik27618472019-05-30 18:28:59 +0530196verstage-y += cpu_common.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500197verstage-y += memset.c
198verstage-y += memcpy.c
199verstage-y += memmove.c
Aaron Durbin57dbbbb2016-03-18 13:12:41 -0500200verstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Arthur Heymans7bea0842018-06-06 18:19:56 +0200201# If verstage is a separate stage it means there's no need
Aaron Durbin10221a02016-05-26 10:55:48 -0500202# for a chipset-specific car_stage_entry() so use the generic one
203# which just calls verstage().
Arthur Heymans7bea0842018-06-06 18:19:56 +0200204verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += verstage.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500205
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700206verstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500207
Julius Wernere91d1702017-03-20 15:32:15 -0700208verstage-libs ?=
Aaron Durbin75c51d92015-09-29 16:31:20 -0500209
Aaron Durbineb907b32016-01-21 00:08:17 -0600210$(eval $(call early_x86_assembly_entry_rule,verstage))
211
Aaron Durbin75c51d92015-09-29 16:31:20 -0500212ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y)
213$(eval $(call early_x86_stage,verstage,elf32-i386))
214else
215$(eval $(call early_x86_stage,verstage,elf64-x86-64))
216endif
217
Aaron Durbin75c51d92015-09-29 16:31:20 -0500218endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64
219
220###############################################################################
Aaron Durbin1bc6a792015-09-29 14:54:25 -0500221# romstage
222###############################################################################
223
224ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700225
Lee Leahye82b5052016-07-25 17:07:53 -0700226romstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
227romstage-y += boot.c
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -0700228# gdt_init.S is included by entry32.inc when romstage is the first C
229# environment.
230romstage-$(CONFIG_C_ENVIRONMENT_BOOTBLOCK) += gdt_init.S
Lee Leahye82b5052016-07-25 17:07:53 -0700231romstage-y += cbmem.c
232romstage-y += cbfs_and_run.c
Subrata Banik27618472019-05-30 18:28:59 +0530233romstage-y += cpu_common.c
Subrata Banikc7590cd2017-09-04 18:44:38 +0530234romstage-$(CONFIG_EARLY_EBDA_INIT) += ebda.c
Aaron Durbin4b032e42018-04-20 01:39:30 -0600235romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
236romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Lee Leahye82b5052016-07-25 17:07:53 -0700237romstage-y += memcpy.c
238romstage-y += memmove.c
239romstage-y += memset.c
240romstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Rizwan Qureshib1b44d32016-08-26 21:08:50 +0530241romstage-y += postcar_loader.c
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700242romstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Patrick Rudolph4d60d962019-02-10 13:56:29 +0100243romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += walkcbfs.S
Lee Leahye82b5052016-07-25 17:07:53 -0700244
Rizwan Qureshi8e8ca5c2018-10-01 14:35:25 +0530245romstage-srcs += $(wildcard $(src)/mainboard/$(MAINBOARDDIR)/romstage.c)
Alexandru Gagniuceb3c9912014-03-29 13:01:11 -0500246romstage-libs ?=
247
Aaron Durbineb907b32016-01-21 00:08:17 -0600248$(eval $(call early_x86_assembly_entry_rule,romstage))
249
Stefan Reinauer98749332015-06-23 12:57:06 -0700250ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
Aaron Durbin1bc6a792015-09-29 14:54:25 -0500251$(eval $(call early_x86_stage,romstage,elf32-i386))
Stefan Reinauer98749332015-06-23 12:57:06 -0700252else
Aaron Durbin1bc6a792015-09-29 14:54:25 -0500253$(eval $(call early_x86_stage,romstage,elf64-x86-64))
Stefan Reinauer98749332015-06-23 12:57:06 -0700254endif
255
Patrick Georgid69839b2015-04-03 10:32:17 +0200256# Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428
Aaron Durbin75c51d92015-09-29 16:31:20 -0500257romstage-S-ccopts += -g0
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700258
Stefan Reinauer181b7732015-03-15 19:23:50 +0100259endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64
Stefan Reinauerf1939bb2010-12-30 17:39:50 +0000260
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700261###############################################################################
Lee Leahya7491502016-07-24 07:43:23 -0700262# postcar
263###############################################################################
264
265$(eval $(call create_class_compiler,postcar,x86_32))
266postcar-generic-ccopts += -D__POSTCAR__
267
Subrata Banik5d2928c2017-09-21 19:17:33 +0530268postcar-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
Lee Leahya7491502016-07-24 07:43:23 -0700269postcar-y += boot.c
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -0700270postcar-y += gdt_init.S
Lee Leahya7491502016-07-24 07:43:23 -0700271postcar-y += cbfs_and_run.c
Kyösti Mälkki740afc42017-09-07 08:13:19 +0300272postcar-y += cbmem.c
Lee Leahy5f4b4c42016-07-24 08:09:40 -0700273postcar-y += cpu_common.c
Subrata Banikc7590cd2017-09-04 18:44:38 +0530274postcar-$(CONFIG_EARLY_EBDA_INIT) += ebda.c
Aaron Durbin4b032e42018-04-20 01:39:30 -0600275postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
276postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Lee Leahya7491502016-07-24 07:43:23 -0700277postcar-y += exit_car.S
278postcar-y += memcpy.c
279postcar-y += memmove.c
280postcar-y += memset.c
281postcar-y += memlayout.ld
282postcar-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Aaron Durbin6b0cebc2016-09-16 16:15:14 -0500283postcar-y += postcar.c
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700284postcar-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Lee Leahya7491502016-07-24 07:43:23 -0700285
Lee Leahy4cfde2a2016-07-24 07:51:24 -0700286LDFLAGS_postcar += -Map $(objcbfs)/postcar.map
287
Lee Leahya7491502016-07-24 07:43:23 -0700288$(objcbfs)/postcar.debug: $$(postcar-objs)
289 @printf " LINK $(subst $(obj)/,,$(@))\n"
290 $(LD_postcar) $(LDFLAGS_postcar) -o $@ -L$(obj) $(COMPILER_RT_FLAGS_postcar) --whole-archive --start-group $(filter-out %.ld,$^) --no-whole-archive $(COMPILER_RT_postcar) --end-group -T $(call src-to-obj,postcar,src/arch/x86/memlayout.ld)
291
292$(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod
293 cp $< $@
294
295# Add postcar to CBFS
296cbfs-files-$(CONFIG_POSTCAR_STAGE) += $(CONFIG_CBFS_PREFIX)/postcar
297$(CONFIG_CBFS_PREFIX)/postcar-file := $(objcbfs)/postcar.elf
298$(CONFIG_CBFS_PREFIX)/postcar-type := stage
299$(CONFIG_CBFS_PREFIX)/postcar-compression := none
300
301###############################################################################
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700302# ramstage
303###############################################################################
304
Stefan Reinauer181b7732015-03-15 19:23:50 +0100305ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700306
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700307ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c
308ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen.c
Furquan Shaikh4a2cfad2016-10-21 16:40:17 -0700309ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen_dsm.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700310ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi_device.c
Duncan Laurie3e7197a2018-05-07 14:18:13 -0700311ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi_pld.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700312ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
Marshall Dawson991467d2018-09-04 12:32:56 -0600313ramstage-$(CONFIG_ACPI_BERT) += acpi_bert_storage.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700314ramstage-y += boot.c
315ramstage-y += c_start.S
316ramstage-y += cbmem.c
317ramstage-y += cpu.c
318ramstage-y += cpu_common.c
319ramstage-y += ebda.c
320ramstage-y += exception.c
Aaron Durbin7a7c70b2018-04-20 00:56:57 -0600321ramstage-y += idt.S
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700322ramstage-y += gdt.c
323ramstage-$(CONFIG_IOAPIC) += ioapic.c
324ramstage-y += memcpy.c
325ramstage-y += memlayout.ld
326ramstage-y += memmove.c
327ramstage-y += memset.c
328ramstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
329ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700330ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c
Robbie Zhang18792312017-02-13 13:44:14 -0800331ramstage-y += rdrand.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700332ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c
333ramstage-y += tables.c
334ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c
335ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700336ramstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700337ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S
338
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700339ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
340rmodules_x86_32-y += memcpy.c
341rmodules_x86_32-y += memmove.c
342rmodules_x86_32-y += memset.c
343else
344rmodules_x86_64-y += memcpy.c
345rmodules_x86_64-y += memmove.c
346rmodules_x86_64-y += memset.c
347endif
348
Patrick Georgic32a52c2015-06-22 21:10:34 +0200349ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
350target-objcopy=-O elf32-i386 -B i386
351endif
352ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y)
Stefan Reinauer593f5c82015-07-30 18:03:18 -0700353target-objcopy=-O elf64-x86-64 -B i386:x86-64
Patrick Georgic32a52c2015-06-22 21:10:34 +0200354endif
355
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700356ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
357ifeq ($(CONFIG_GENERATE_MP_TABLE),y)
358ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),)
359ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c
360endif
361endif
362ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y)
363ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c
364endif
365ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/reset.c),)
366ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/reset.c
367endif
Vladimir Serbinenko822bc652014-01-03 15:55:40 +0100368ifeq ($(CONFIG_HAVE_ACPI_TABLES),y)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700369ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/acpi_tables.c
Vladimir Serbinenko36f8d272015-05-31 12:31:59 +0200370$(eval $(call asl_template,dsdt))
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700371ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/fadt.c),)
372ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/fadt.c
373endif
Patrick Georgi990e7c92015-04-03 10:47:15 +0200374endif # CONFIG_GENERATE_ACPI_TABLES
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700375
376ramstage-libs ?=
377
378ifeq ($(CONFIG_RELOCATABLE_RAMSTAGE),y)
379
Elyes HAOUAS2f79eb32018-08-07 12:24:42 +0200380# The rmodule_link definition creates an elf file with .rmod extension.
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700381$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
382 cp $< $@
383
Aaron Durbin83bc0db2015-09-06 10:45:18 -0500384endif
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700385
Nico Huber81b09f42016-01-23 00:50:00 +0100386$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(call src-to-obj,ramstage,src/arch/x86/memlayout.ld)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700387 @printf " CC $(subst $(obj)/,,$(@))\n"
Nico Huber81b09f42016-01-23 00:50:00 +0100388 $(LD_ramstage) $(CPPFLAGS) $(LDFLAGS_ramstage) -o $@ -L$(obj) $< -T $(call src-to-obj,ramstage,src/arch/x86/memlayout.ld)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700389
Patrick Georgi3ce96bd2014-11-22 17:42:58 +0100390$(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700391 @printf " CC $(subst $(obj)/,,$(@))\n"
Patrick Rudolph5407e892018-11-28 07:36:55 +0100392ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
Patrick Georgieec8dfb2015-05-07 22:24:41 +0200393 $(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 +0100394else
395 $(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
396endif
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700397
Stefan Reinauer181b7732015-03-15 19:23:50 +0100398endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64
Subrata Banikeb5b0d02019-06-04 16:46:41 +0530399
400smm-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
401smm-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
402smm-y += memcpy.c
403smm-y += memmove.c
404smm-y += memset.c
405smm-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
406
Subrata Banikeb5b0d02019-06-04 16:46:41 +0530407ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c),)
408smm-srcs += src/mainboard/$(MAINBOARDDIR)/smihandler.c
409endif