blob: c15f8292094c688f06a0d5f948e5fd4d64eefab1 [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 Georgi70a6b4f2015-03-27 14:14:58 +010019################################################################################
20# i386 specific tools
21NVRAMTOOL:=$(objutil)/nvramtool/nvramtool
22
Patrick Georgi8463dd92010-09-30 16:55:02 +000023OPTION_TABLE_H:=
24ifeq ($(CONFIG_HAVE_OPTION_TABLE),y)
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010025
Patrick Georgi5c0bca22011-01-30 16:31:15 +000026cbfs-files-y += cmos_layout.bin
27cmos_layout.bin-file = $(obj)/cmos_layout.bin
Martin Roth8ea06512016-09-19 13:58:01 -060028cmos_layout.bin-type = cmos_layout
Patrick Georgi24479372011-01-18 13:56:36 +000029
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010030$(obj)/cmos_layout.bin: $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
31 @printf " OPTION $(subst $(obj)/,,$(@))\n"
32 $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -L $@
33
Patrick Georgi8463dd92010-09-30 16:55:02 +000034OPTION_TABLE_H:=$(obj)/option_table.h
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010035
36$(OPTION_TABLE_H): $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
37 @printf " OPTION $(subst $(obj)/,,$(@))\n"
38 $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -H $@
39endif # CONFIG_HAVE_OPTION_TABLE
Patrick Georgi0588d192009-08-12 15:00:51 +000040
Patrick Georgiff9d78c2011-01-30 16:37:39 +000041stripped_vgabios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_ID))
42cbfs-files-$(CONFIG_VGA_BIOS) += pci$(stripped_vgabios_id).rom
43pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE))
44pci$(stripped_vgabios_id).rom-type := optionrom
45
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070046###############################################################################
Aaron Durbineb907b32016-01-21 00:08:17 -060047# common support for early assembly includes
48###############################################################################
49
50# Chipset specific assembly stubs in the romstage program flow. Certain
51# boards have more than one assembly stub so collect those and put them
52# into a single generated file.
53crt0s = $(cpu_incs-y)
54
55$(objgenerated)/assembly.inc: $$(crt0s)
56 @printf " GEN $(subst $(obj)/,,$(@))\n"
57 printf '$(foreach crt0,$(crt0s),#include "$(crt0)"\n)' > $@
58
59
60define early_x86_assembly_entry_rule
61# $1 stage name
62# Add the assembly file that pulls in the rest of the dependencies in
63# the right order. Make sure the auto generated assembly.inc is a proper
64# dependency.
65$(1)-y += assembly_entry.S
Nico Huber81b09f42016-01-23 00:50:00 +010066$(call src-to-obj,$(1),$(dir)/assembly_entry.S): $(objgenerated)/assembly.inc
Aaron Durbineb907b32016-01-21 00:08:17 -060067endef
68
69define early_x86_stage
70# $1 stage name
71# $2 oformat
72$(1)-y += memlayout.ld
73
74# The '.' include path is needed for the generated assembly.inc file.
75$(1)-S-ccopts += -I.
76
77$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs)
78 @printf " LINK $$(subst $$(obj)/,,$$(@))\n"
Nico Huber81b09f42016-01-23 00:50:00 +010079 $$(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 -060080 -LANG=C LC_ALL= $$(OBJCOPY_$(1)) --only-section .illegal_globals $$(@) $$(objcbfs)/$(1)_null.offenders >/dev/null 2>&1
81 if [ -z "$$$$($$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders 2>&1 | grep 'no symbols')" ];then \
82 echo "Forbidden global variables in $(1):"; \
83 $$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders; false; \
84 fi
85endef
86
87###############################################################################
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070088# bootblock
89###############################################################################
Patrick Georgi641dd712011-11-01 18:55:59 +010090
Stefan Reinauer181b7732015-03-15 19:23:50 +010091ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070092
Alexandru Gagniuc4e153d62016-01-08 23:05:00 -080093bootblock-y += boot.c
Lee Leahy5f4b4c42016-07-24 08:09:40 -070094bootblock-y += cpu_common.c
Aaron Durbin4b032e42018-04-20 01:39:30 -060095bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
96bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Alexandru Gagniuc4e153d62016-01-08 23:05:00 -080097bootblock-y += memcpy.c
98bootblock-y += memset.c
Aaron Durbinf49ddb62018-01-24 17:35:58 -070099bootblock-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Alexandru Gagniuc6a622312015-10-27 10:27:30 -0700100bootblock-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Alexandru Gagniuc4e153d62016-01-08 23:05:00 -0800101
Alexandru Gagniucee2740b2015-10-04 17:47:36 -0700102bootblock-y += id.S
Nico Huber81b09f42016-01-23 00:50:00 +0100103$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h
Patrick Georgiab355752015-10-15 11:07:07 +0200104
Aaron Durbineb907b32016-01-21 00:08:17 -0600105ifeq ($(CONFIG_C_ENVIRONMENT_BOOTBLOCK),y)
106
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -0800107bootblock-y += bootblock_crt0.S
Aaron Durbineb907b32016-01-21 00:08:17 -0600108
109ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
110$(eval $(call early_x86_stage,bootblock,elf32-i386))
111else
112$(eval $(call early_x86_stage,bootblock,elf64-x86-64))
113endif
114
115else # !C_ENVIRONMENT_BOOTBLOCK
116
117# x86-specific linker flags
118ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
119LDFLAGS_bootblock += -m elf_i386 --oformat elf32-i386
120else
121LDFLAGS_bootblock += -m elf_x86_64 --oformat elf64-x86-64
122endif
123
Alexandru Gagniucf8e49132015-10-02 12:42:26 -0700124# Add the assembly file that pulls in the rest of the dependencies in
125# the right order. Make sure the auto generated bootblock.inc is a proper
126# dependency. Make the same true for the linker sript.
127bootblock-y += bootblock_romcc.S
Alexandru Gagniucc46a3922015-10-02 16:17:41 -0700128bootblock-y += walkcbfs.S
Alexandru Gagniucf8e49132015-10-02 12:42:26 -0700129$(call src-to-obj,bootblock,$(dir)/bootblock_romcc.S): $(objgenerated)/bootblock.inc
Patrick Georgi641dd712011-11-01 18:55:59 +0100130
Aaron Durbin3953e392015-09-03 00:41:29 -0500131bootblock-y += bootblock.ld
Nico Huber81b09f42016-01-23 00:50:00 +0100132$(call src-to-obj,bootblock,$(dir)/bootblock.ld): $(objgenerated)/bootblock.ld
Patrick Georgi641dd712011-11-01 18:55:59 +0100133
Patrick Georgi56b83092015-04-02 19:44:19 +0200134bootblock_romccflags := -mcpu=i386 -O2 -D__PRE_RAM__ -D__BOOTBLOCK__
Patrick Georgi641dd712011-11-01 18:55:59 +0100135ifeq ($(CONFIG_SSE),y)
Patrick Georgi56b83092015-04-02 19:44:19 +0200136bootblock_romccflags := -mcpu=k7 -msse -O2 -D__PRE_RAM__ -D__BOOTBLOCK__
Patrick Georgi641dd712011-11-01 18:55:59 +0100137endif
138
Aaron Durbin3953e392015-09-03 00:41:29 -0500139# This is a hack in case there are no per chipset linker files.
Alexander Couzensb619f442015-12-14 22:04:54 +0100140$(objgenerated)/empty: build-dirs
Aaron Durbin3953e392015-09-03 00:41:29 -0500141 touch $@
142
Nico Huber81b09f42016-01-23 00:50:00 +0100143$(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 +0100144 @printf " GEN $(subst $(obj)/,,$(@))\n"
Marc Jonesac630f72015-06-30 15:46:49 -0600145 cat $^ >> $@.tmp
146 mv $@.tmp $@
Patrick Georgi641dd712011-11-01 18:55:59 +0100147
Patrick Georgief0158e2015-07-27 17:47:55 +0200148$(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 -0700149# The open quote in the subst messes with syntax highlighting. Fix it - ")
Patrick Georgi641dd712011-11-01 18:55:59 +0100150 @printf " ROMCC $(subst $(obj)/,,$(@))\n"
Patrick Georgi59307742014-05-19 09:23:57 +0200151 $(CC_bootblock) $(CPPFLAGS_bootblock) -MM -MT$(objgenerated)/bootblock.inc \
Kyösti Mälkkif775b8c2012-04-19 12:14:53 +0300152 $< > $(objgenerated)/bootblock.inc.d
Patrick Georgi59307742014-05-19 09:23:57 +0200153 $(ROMCC) -c -S $(bootblock_romccflags) -I. $(CPPFLAGS_bootblock) $< -o $@
Patrick Georgi641dd712011-11-01 18:55:59 +0100154
Nico Huber81b09f42016-01-23 00:50:00 +0100155# bootblock.ld is part of $(bootblock-objs)
Alexandru Gagniucdbeedbe2015-10-02 12:17:56 -0700156$(objcbfs)/bootblock.debug: $$(bootblock-objs)
Patrick Georgi641dd712011-11-01 18:55:59 +0100157 @printf " LINK $(subst $(obj)/,,$(@))\n"
Alexandru Gagniucdbeedbe2015-10-02 12:17:56 -0700158 $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \
159 $(filter-out %.ld,$(bootblock-objs)) \
Nico Huber81b09f42016-01-23 00:50:00 +0100160 -T $(call src-to-obj,bootblock,src/arch/x86/bootblock.ld)
Patrick Georgi641dd712011-11-01 18:55:59 +0100161
Aaron Durbineb907b32016-01-21 00:08:17 -0600162endif # C_ENVIRONMENT_BOOTBLOCK
163
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700164
Stefan Reinauer181b7732015-03-15 19:23:50 +0100165endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700166
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700167###############################################################################
Aaron Durbin75c51d92015-09-29 16:31:20 -0500168# verstage
169###############################################################################
170
171ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32)$(CONFIG_ARCH_VERSTAGE_X86_64),y)
172
173verstage-y += boot.c
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -0700174verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += gdt_init.S
Aaron Durbin4b032e42018-04-20 01:39:30 -0600175verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
176verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Aaron Durbin75c51d92015-09-29 16:31:20 -0500177
178verstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += cpu_common.c
179verstage-y += memset.c
180verstage-y += memcpy.c
181verstage-y += memmove.c
Aaron Durbin57dbbbb2016-03-18 13:12:41 -0500182verstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Aaron Durbin10221a02016-05-26 10:55:48 -0500183# If C environment is used for bootblock it means there's no need
184# for a chipset-specific car_stage_entry() so use the generic one
185# which just calls verstage().
186verstage-$(CONFIG_C_ENVIRONMENT_BOOTBLOCK) += verstage.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500187
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700188verstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500189
Julius Wernere91d1702017-03-20 15:32:15 -0700190verstage-libs ?=
Aaron Durbin75c51d92015-09-29 16:31:20 -0500191
Aaron Durbineb907b32016-01-21 00:08:17 -0600192$(eval $(call early_x86_assembly_entry_rule,verstage))
193
Aaron Durbin75c51d92015-09-29 16:31:20 -0500194ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y)
195$(eval $(call early_x86_stage,verstage,elf32-i386))
196else
197$(eval $(call early_x86_stage,verstage,elf64-x86-64))
198endif
199
Aaron Durbin75c51d92015-09-29 16:31:20 -0500200endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64
201
202###############################################################################
Aaron Durbin1bc6a792015-09-29 14:54:25 -0500203# romstage
204###############################################################################
205
206ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700207
Lee Leahye82b5052016-07-25 17:07:53 -0700208romstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
209romstage-y += boot.c
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -0700210# gdt_init.S is included by entry32.inc when romstage is the first C
211# environment.
212romstage-$(CONFIG_C_ENVIRONMENT_BOOTBLOCK) += gdt_init.S
Lee Leahye82b5052016-07-25 17:07:53 -0700213romstage-y += cbmem.c
214romstage-y += cbfs_and_run.c
215romstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += cpu_common.c
Subrata Banikc7590cd2017-09-04 18:44:38 +0530216romstage-$(CONFIG_EARLY_EBDA_INIT) += ebda.c
Aaron Durbin4b032e42018-04-20 01:39:30 -0600217romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
218romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Lee Leahye82b5052016-07-25 17:07:53 -0700219romstage-y += memcpy.c
220romstage-y += memmove.c
221romstage-y += memset.c
222romstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Rizwan Qureshib1b44d32016-08-26 21:08:50 +0530223romstage-y += postcar_loader.c
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700224romstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Lee Leahye82b5052016-07-25 17:07:53 -0700225
Aaron Durbin85982cd2015-09-03 11:01:17 -0500226romstage-srcs += $(src)/mainboard/$(MAINBOARDDIR)/romstage.c
Alexandru Gagniuceb3c9912014-03-29 13:01:11 -0500227romstage-libs ?=
228
Aaron Durbineb907b32016-01-21 00:08:17 -0600229$(eval $(call early_x86_assembly_entry_rule,romstage))
230
Stefan Reinauer98749332015-06-23 12:57:06 -0700231ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
Aaron Durbin1bc6a792015-09-29 14:54:25 -0500232$(eval $(call early_x86_stage,romstage,elf32-i386))
Stefan Reinauer98749332015-06-23 12:57:06 -0700233else
Aaron Durbin1bc6a792015-09-29 14:54:25 -0500234$(eval $(call early_x86_stage,romstage,elf64-x86-64))
Stefan Reinauer98749332015-06-23 12:57:06 -0700235endif
236
Patrick Georgid69839b2015-04-03 10:32:17 +0200237# Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428
Aaron Durbin75c51d92015-09-29 16:31:20 -0500238romstage-S-ccopts += -g0
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700239
Stefan Reinauer181b7732015-03-15 19:23:50 +0100240endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64
Stefan Reinauerf1939bb2010-12-30 17:39:50 +0000241
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700242###############################################################################
Lee Leahya7491502016-07-24 07:43:23 -0700243# postcar
244###############################################################################
245
246$(eval $(call create_class_compiler,postcar,x86_32))
247postcar-generic-ccopts += -D__POSTCAR__
248
Subrata Banik5d2928c2017-09-21 19:17:33 +0530249postcar-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
Lee Leahya7491502016-07-24 07:43:23 -0700250postcar-y += boot.c
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -0700251postcar-y += gdt_init.S
Lee Leahya7491502016-07-24 07:43:23 -0700252postcar-y += cbfs_and_run.c
Kyösti Mälkki740afc42017-09-07 08:13:19 +0300253postcar-y += cbmem.c
Lee Leahy5f4b4c42016-07-24 08:09:40 -0700254postcar-y += cpu_common.c
Subrata Banikc7590cd2017-09-04 18:44:38 +0530255postcar-$(CONFIG_EARLY_EBDA_INIT) += ebda.c
Aaron Durbin4b032e42018-04-20 01:39:30 -0600256postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
257postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Lee Leahya7491502016-07-24 07:43:23 -0700258postcar-y += exit_car.S
259postcar-y += memcpy.c
260postcar-y += memmove.c
261postcar-y += memset.c
262postcar-y += memlayout.ld
263postcar-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Aaron Durbin6b0cebc2016-09-16 16:15:14 -0500264postcar-y += postcar.c
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700265postcar-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Lee Leahya7491502016-07-24 07:43:23 -0700266
Lee Leahy4cfde2a2016-07-24 07:51:24 -0700267LDFLAGS_postcar += -Map $(objcbfs)/postcar.map
268
Lee Leahya7491502016-07-24 07:43:23 -0700269$(objcbfs)/postcar.debug: $$(postcar-objs)
270 @printf " LINK $(subst $(obj)/,,$(@))\n"
271 $(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)
272
273$(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod
274 cp $< $@
275
276# Add postcar to CBFS
277cbfs-files-$(CONFIG_POSTCAR_STAGE) += $(CONFIG_CBFS_PREFIX)/postcar
278$(CONFIG_CBFS_PREFIX)/postcar-file := $(objcbfs)/postcar.elf
279$(CONFIG_CBFS_PREFIX)/postcar-type := stage
280$(CONFIG_CBFS_PREFIX)/postcar-compression := none
281
282###############################################################################
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700283# ramstage
284###############################################################################
285
Stefan Reinauer181b7732015-03-15 19:23:50 +0100286ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700287
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700288ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c
289ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen.c
Furquan Shaikh4a2cfad2016-10-21 16:40:17 -0700290ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen_dsm.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700291ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi_device.c
Duncan Laurie3e7197a2018-05-07 14:18:13 -0700292ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi_pld.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700293ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
294ramstage-y += boot.c
295ramstage-y += c_start.S
296ramstage-y += cbmem.c
297ramstage-y += cpu.c
298ramstage-y += cpu_common.c
299ramstage-y += ebda.c
300ramstage-y += exception.c
Aaron Durbin7a7c70b2018-04-20 00:56:57 -0600301ramstage-y += idt.S
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700302ramstage-y += gdt.c
303ramstage-$(CONFIG_IOAPIC) += ioapic.c
304ramstage-y += memcpy.c
305ramstage-y += memlayout.ld
306ramstage-y += memmove.c
307ramstage-y += memset.c
308ramstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
309ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c
310ramstage-y += pci_ops_conf1.c
Nico Huberd4ac11f2018-05-04 16:29:13 +0200311ramstage-$(CONFIG_NO_MMCONF_SUPPORT) += pci_ops.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700312ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c
Robbie Zhang18792312017-02-13 13:44:14 -0800313ramstage-y += rdrand.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700314ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c
315ramstage-y += tables.c
316ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c
317ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700318ramstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700319ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S
320
Aaron Durbin4b032e42018-04-20 01:39:30 -0600321smm-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
322smm-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700323smm-y += memcpy.c
324smm-y += memmove.c
325smm-y += memset.c
326smm-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
327
328ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
329rmodules_x86_32-y += memcpy.c
330rmodules_x86_32-y += memmove.c
331rmodules_x86_32-y += memset.c
332else
333rmodules_x86_64-y += memcpy.c
334rmodules_x86_64-y += memmove.c
335rmodules_x86_64-y += memset.c
336endif
337
Patrick Georgic32a52c2015-06-22 21:10:34 +0200338ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
339target-objcopy=-O elf32-i386 -B i386
340endif
341ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y)
Stefan Reinauer593f5c82015-07-30 18:03:18 -0700342target-objcopy=-O elf64-x86-64 -B i386:x86-64
Patrick Georgic32a52c2015-06-22 21:10:34 +0200343endif
344
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700345ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
346ifeq ($(CONFIG_GENERATE_MP_TABLE),y)
347ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),)
348ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c
349endif
350endif
351ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y)
352ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c
353endif
354ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/reset.c),)
355ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/reset.c
356endif
Vladimir Serbinenko822bc652014-01-03 15:55:40 +0100357ifeq ($(CONFIG_HAVE_ACPI_TABLES),y)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700358ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/acpi_tables.c
Vladimir Serbinenko36f8d272015-05-31 12:31:59 +0200359$(eval $(call asl_template,dsdt))
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700360ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/fadt.c),)
361ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/fadt.c
362endif
Patrick Georgi990e7c92015-04-03 10:47:15 +0200363endif # CONFIG_GENERATE_ACPI_TABLES
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700364ifeq ($(CONFIG_HAVE_SMI_HANDLER),y)
365ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c),)
366smm-srcs += src/mainboard/$(MAINBOARDDIR)/smihandler.c
367endif
368endif
369ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/get_bus_conf.c),)
370ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/get_bus_conf.c
371endif
372
373ramstage-libs ?=
374
375ifeq ($(CONFIG_RELOCATABLE_RAMSTAGE),y)
376
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700377# The rmodule_link defintion creates an elf file with .rmod extension.
378$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
379 cp $< $@
380
Aaron Durbin83bc0db2015-09-06 10:45:18 -0500381endif
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700382
Nico Huber81b09f42016-01-23 00:50:00 +0100383$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(call src-to-obj,ramstage,src/arch/x86/memlayout.ld)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700384 @printf " CC $(subst $(obj)/,,$(@))\n"
Nico Huber81b09f42016-01-23 00:50:00 +0100385 $(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 -0700386
Patrick Georgi3ce96bd2014-11-22 17:42:58 +0100387$(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700388 @printf " CC $(subst $(obj)/,,$(@))\n"
Stefan Reinauer181b7732015-03-15 19:23:50 +0100389ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
Patrick Georgieec8dfb2015-05-07 22:24:41 +0200390 $(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 +0100391else
392 $(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
393endif
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700394
Stefan Reinauer181b7732015-03-15 19:23:50 +0100395endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64