blob: 51575648473575038f18a8b05acbdfc1a2c09353 [file] [log] [blame]
Patrick Georgi11f00792020-03-04 15:10:45 +01001## SPDX-License-Identifier: GPL-2.0-only
Patrick Georgi0588d192009-08-12 15:00:51 +00002
Patrick Georgi29eeece2018-10-31 14:24:47 +01003ifeq ($(CONFIG_POSTCAR_STAGE),y)
4$(eval $(call init_standard_toolchain,postcar))
5endif
6
Patrick Georgi70a6b4f2015-03-27 14:14:58 +01007################################################################################
8# i386 specific tools
9NVRAMTOOL:=$(objutil)/nvramtool/nvramtool
10
Patrick Georgi8463dd92010-09-30 16:55:02 +000011OPTION_TABLE_H:=
12ifeq ($(CONFIG_HAVE_OPTION_TABLE),y)
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010013
Patrick Georgi5c0bca22011-01-30 16:31:15 +000014cbfs-files-y += cmos_layout.bin
15cmos_layout.bin-file = $(obj)/cmos_layout.bin
Martin Roth8ea06512016-09-19 13:58:01 -060016cmos_layout.bin-type = cmos_layout
Patrick Georgi24479372011-01-18 13:56:36 +000017
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010018$(obj)/cmos_layout.bin: $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
19 @printf " OPTION $(subst $(obj)/,,$(@))\n"
20 $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -L $@
21
Patrick Georgi8463dd92010-09-30 16:55:02 +000022OPTION_TABLE_H:=$(obj)/option_table.h
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010023
24$(OPTION_TABLE_H): $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
25 @printf " OPTION $(subst $(obj)/,,$(@))\n"
26 $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -H $@
27endif # CONFIG_HAVE_OPTION_TABLE
Patrick Georgi0588d192009-08-12 15:00:51 +000028
Patrick Georgiff9d78c2011-01-30 16:37:39 +000029stripped_vgabios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_ID))
30cbfs-files-$(CONFIG_VGA_BIOS) += pci$(stripped_vgabios_id).rom
31pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE))
32pci$(stripped_vgabios_id).rom-type := optionrom
33
Martin Roth4cc2cac2019-12-06 19:11:08 -070034stripped_second_vbios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_SECOND_ID))
35cbfs-files-$(CONFIG_VGA_BIOS_SECOND) += pci$(stripped_second_vbios_id).rom
36pci$(stripped_second_vbios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_SECOND_FILE))
37pci$(stripped_second_vbios_id).rom-type := optionrom
38
Mike Banon0f8547e2019-02-17 19:51:53 +030039stripped_vgabios_dgpu_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_ID))
40cbfs-files-$(CONFIG_VGA_BIOS_DGPU) += pci$(stripped_vgabios_dgpu_id).rom
41pci$(stripped_vgabios_dgpu_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_FILE))
42pci$(stripped_vgabios_dgpu_id).rom-type := optionrom
43
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070044###############################################################################
Aaron Durbineb907b32016-01-21 00:08:17 -060045# common support for early assembly includes
46###############################################################################
47
48# Chipset specific assembly stubs in the romstage program flow. Certain
49# boards have more than one assembly stub so collect those and put them
50# into a single generated file.
51crt0s = $(cpu_incs-y)
52
Patrick Georgi6f5e5e52020-06-29 22:28:18 +020053$(objgenerated)/assembly.inc: build-dirs $$(crt0s)
Aaron Durbineb907b32016-01-21 00:08:17 -060054 @printf " GEN $(subst $(obj)/,,$(@))\n"
55 printf '$(foreach crt0,$(crt0s),#include "$(crt0)"\n)' > $@
56
57
58define early_x86_assembly_entry_rule
59# $1 stage name
60# Add the assembly file that pulls in the rest of the dependencies in
61# the right order. Make sure the auto generated assembly.inc is a proper
62# dependency.
63$(1)-y += assembly_entry.S
Nico Huber81b09f42016-01-23 00:50:00 +010064$(call src-to-obj,$(1),$(dir)/assembly_entry.S): $(objgenerated)/assembly.inc
Aaron Durbineb907b32016-01-21 00:08:17 -060065endef
66
67define early_x86_stage
68# $1 stage name
69# $2 oformat
Aaron Durbineb907b32016-01-21 00:08:17 -060070
71# The '.' include path is needed for the generated assembly.inc file.
72$(1)-S-ccopts += -I.
73
74$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs)
75 @printf " LINK $$(subst $$(obj)/,,$$(@))\n"
Furquan Shaikh46514c22020-06-11 11:59:07 -070076 $$(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),$(CONFIG_MEMLAYOUT_LD_FILE)) --oformat $(2)
Aaron Durbineb907b32016-01-21 00:08:17 -060077 -LANG=C LC_ALL= $$(OBJCOPY_$(1)) --only-section .illegal_globals $$(@) $$(objcbfs)/$(1)_null.offenders >/dev/null 2>&1
78 if [ -z "$$$$($$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders 2>&1 | grep 'no symbols')" ];then \
79 echo "Forbidden global variables in $(1):"; \
80 $$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders; false; \
81 fi
82endef
83
84###############################################################################
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070085# bootblock
86###############################################################################
Patrick Georgi641dd712011-11-01 18:55:59 +010087
Stefan Reinauer181b7732015-03-15 19:23:50 +010088ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070089
Martin Rothcbf6e6b2020-06-06 09:45:20 -060090bootblock-y += boot.c
91bootblock-y += post.c
92bootblock-y += cpu_common.c
Aaron Durbin4b032e42018-04-20 01:39:30 -060093bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
94bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -060095bootblock-y += memcpy.c
96bootblock-y += memset.c
Martin Roth00b37d32020-06-25 14:34:46 -060097bootblock-y += memmove.c
Aaron Durbinf49ddb62018-01-24 17:35:58 -070098bootblock-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Alexandru Gagniuc6a622312015-10-27 10:27:30 -070099bootblock-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Kyösti Mälkkib8d575c2019-12-16 16:00:49 +0200100bootblock-$(CONFIG_BOOTBLOCK_NORMAL) += bootblock_normal.c
Alexandru Gagniucee2740b2015-10-04 17:47:36 -0700101bootblock-y += id.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600102bootblock-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
103
Nico Huber81b09f42016-01-23 00:50:00 +0100104$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h
Patrick Georgiab355752015-10-15 11:07:07 +0200105
Alexandru Gagniuc6be6c8f2016-01-26 18:22:43 -0800106bootblock-y += bootblock_crt0.S
Aaron Durbineb907b32016-01-21 00:08:17 -0600107
108ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
109$(eval $(call early_x86_stage,bootblock,elf32-i386))
110else
111$(eval $(call early_x86_stage,bootblock,elf64-x86-64))
112endif
113
Kyösti Mälkkid60e9ab2019-12-21 10:14:15 +0200114bootblock-$(CONFIG_MICROCODE_UPDATE_PRE_RAM) += walkcbfs.S
Arthur Heymans0eb9c572019-01-05 18:21:47 +0100115
Stefan Reinauer181b7732015-03-15 19:23:50 +0100116endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700117
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700118###############################################################################
Aaron Durbin75c51d92015-09-29 16:31:20 -0500119# verstage
120###############################################################################
121
122ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32)$(CONFIG_ARCH_VERSTAGE_X86_64),y)
123
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600124verstage-y += boot.c
125verstage-y += post.c
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -0700126verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += gdt_init.S
Aaron Durbin4b032e42018-04-20 01:39:30 -0600127verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
128verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600129verstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500130
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600131verstage-y += cpu_common.c
132verstage-y += memset.c
133verstage-y += memcpy.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500134verstage-y += memmove.c
Aaron Durbin57dbbbb2016-03-18 13:12:41 -0500135verstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Arthur Heymans7bea0842018-06-06 18:19:56 +0200136# If verstage is a separate stage it means there's no need
Aaron Durbin10221a02016-05-26 10:55:48 -0500137# for a chipset-specific car_stage_entry() so use the generic one
138# which just calls verstage().
Arthur Heymans7bea0842018-06-06 18:19:56 +0200139verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += verstage.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500140
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700141verstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500142
Julius Wernere91d1702017-03-20 15:32:15 -0700143verstage-libs ?=
Aaron Durbin75c51d92015-09-29 16:31:20 -0500144
Aaron Durbineb907b32016-01-21 00:08:17 -0600145$(eval $(call early_x86_assembly_entry_rule,verstage))
146
Aaron Durbin75c51d92015-09-29 16:31:20 -0500147ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y)
148$(eval $(call early_x86_stage,verstage,elf32-i386))
149else
150$(eval $(call early_x86_stage,verstage,elf64-x86-64))
151endif
152
Aaron Durbin75c51d92015-09-29 16:31:20 -0500153endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64
154
155###############################################################################
Aaron Durbin1bc6a792015-09-29 14:54:25 -0500156# romstage
157###############################################################################
158
159ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700160
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600161romstage-y += boot.c
162romstage-y += post.c
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -0700163# gdt_init.S is included by entry32.inc when romstage is the first C
164# environment.
Arthur Heymansc05b1a62019-11-22 21:01:30 +0100165romstage-y += gdt_init.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600166romstage-y += cpu_common.c
Aaron Durbin4b032e42018-04-20 01:39:30 -0600167romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
168romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600169romstage-y += memcpy.c
Lee Leahye82b5052016-07-25 17:07:53 -0700170romstage-y += memmove.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600171romstage-y += memset.c
Lee Leahye82b5052016-07-25 17:07:53 -0700172romstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Rizwan Qureshib1b44d32016-08-26 21:08:50 +0530173romstage-y += postcar_loader.c
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700174romstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600175romstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
Lee Leahye82b5052016-07-25 17:07:53 -0700176
Rizwan Qureshi8e8ca5c2018-10-01 14:35:25 +0530177romstage-srcs += $(wildcard $(src)/mainboard/$(MAINBOARDDIR)/romstage.c)
Alexandru Gagniuceb3c9912014-03-29 13:01:11 -0500178romstage-libs ?=
179
Aaron Durbineb907b32016-01-21 00:08:17 -0600180$(eval $(call early_x86_assembly_entry_rule,romstage))
181
Stefan Reinauer98749332015-06-23 12:57:06 -0700182ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
Aaron Durbin1bc6a792015-09-29 14:54:25 -0500183$(eval $(call early_x86_stage,romstage,elf32-i386))
Stefan Reinauer98749332015-06-23 12:57:06 -0700184else
Aaron Durbin1bc6a792015-09-29 14:54:25 -0500185$(eval $(call early_x86_stage,romstage,elf64-x86-64))
Stefan Reinauer98749332015-06-23 12:57:06 -0700186endif
187
Patrick Georgid69839b2015-04-03 10:32:17 +0200188# Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428
Aaron Durbin75c51d92015-09-29 16:31:20 -0500189romstage-S-ccopts += -g0
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700190
Stefan Reinauer181b7732015-03-15 19:23:50 +0100191endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64
Stefan Reinauerf1939bb2010-12-30 17:39:50 +0000192
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700193###############################################################################
Lee Leahya7491502016-07-24 07:43:23 -0700194# postcar
195###############################################################################
196
Patrick Rudolph8daa12f2018-12-26 15:12:32 +0100197ifeq ($(CONFIG_ARCH_POSTCAR_X86_32),y)
Lee Leahya7491502016-07-24 07:43:23 -0700198$(eval $(call create_class_compiler,postcar,x86_32))
Patrick Rudolph8daa12f2018-12-26 15:12:32 +0100199else
200$(eval $(call create_class_compiler,postcar,x86_64))
201endif
Lee Leahya7491502016-07-24 07:43:23 -0700202postcar-generic-ccopts += -D__POSTCAR__
203
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600204postcar-y += boot.c
205postcar-y += post.c
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -0700206postcar-y += gdt_init.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600207postcar-y += cpu_common.c
Aaron Durbin4b032e42018-04-20 01:39:30 -0600208postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
209postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Lee Leahya7491502016-07-24 07:43:23 -0700210postcar-y += exit_car.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600211postcar-y += memcpy.c
Lee Leahya7491502016-07-24 07:43:23 -0700212postcar-y += memmove.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600213postcar-y += memset.c
Lee Leahya7491502016-07-24 07:43:23 -0700214postcar-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Aaron Durbin6b0cebc2016-09-16 16:15:14 -0500215postcar-y += postcar.c
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700216postcar-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600217postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
Lee Leahya7491502016-07-24 07:43:23 -0700218
Lee Leahy4cfde2a2016-07-24 07:51:24 -0700219LDFLAGS_postcar += -Map $(objcbfs)/postcar.map
220
Lee Leahya7491502016-07-24 07:43:23 -0700221$(objcbfs)/postcar.debug: $$(postcar-objs)
222 @printf " LINK $(subst $(obj)/,,$(@))\n"
Furquan Shaikh46514c22020-06-11 11:59:07 -0700223 $(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,$(CONFIG_MEMLAYOUT_LD_FILE))
Lee Leahya7491502016-07-24 07:43:23 -0700224
225$(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod
226 cp $< $@
227
228# Add postcar to CBFS
229cbfs-files-$(CONFIG_POSTCAR_STAGE) += $(CONFIG_CBFS_PREFIX)/postcar
230$(CONFIG_CBFS_PREFIX)/postcar-file := $(objcbfs)/postcar.elf
231$(CONFIG_CBFS_PREFIX)/postcar-type := stage
232$(CONFIG_CBFS_PREFIX)/postcar-compression := none
233
234###############################################################################
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700235# ramstage
236###############################################################################
237
Stefan Reinauer181b7732015-03-15 19:23:50 +0100238ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700239
Angel Pons79572e42020-07-13 00:17:43 +0200240ramstage-y += acpi.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700241ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
Marshall Dawson991467d2018-09-04 12:32:56 -0600242ramstage-$(CONFIG_ACPI_BERT) += acpi_bert_storage.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600243ramstage-y += boot.c
244ramstage-y += post.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700245ramstage-y += c_start.S
Patrick Rudolphe5638152018-12-09 10:48:59 +0100246ramstage-y += c_exit.S
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700247ramstage-y += cpu.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600248ramstage-y += cpu_common.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700249ramstage-y += ebda.c
250ramstage-y += exception.c
Aaron Durbin7a7c70b2018-04-20 00:56:57 -0600251ramstage-y += idt.S
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700252ramstage-$(CONFIG_IOAPIC) += ioapic.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600253ramstage-y += memcpy.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700254ramstage-y += memmove.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600255ramstage-y += memset.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700256ramstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
257ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700258ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c
Robbie Zhang18792312017-02-13 13:44:14 -0800259ramstage-y += rdrand.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700260ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c
Angel Ponsbea5ce72020-07-29 18:40:00 +0200261ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios_defaults.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700262ramstage-y += tables.c
263ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c
264ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700265ramstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700266ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600267ramstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700268
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700269rmodules_x86_32-y += memcpy.c
270rmodules_x86_32-y += memmove.c
271rmodules_x86_32-y += memset.c
Kyösti Mälkki67a537c2020-06-04 09:21:40 +0300272
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700273rmodules_x86_64-y += memcpy.c
274rmodules_x86_64-y += memmove.c
275rmodules_x86_64-y += memset.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700276
Patrick Georgic32a52c2015-06-22 21:10:34 +0200277ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
278target-objcopy=-O elf32-i386 -B i386
Kyösti Mälkki67a537c2020-06-04 09:21:40 +0300279LD_MACHINE =-m elf_i386
Patrick Georgic32a52c2015-06-22 21:10:34 +0200280endif
281ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y)
Stefan Reinauer593f5c82015-07-30 18:03:18 -0700282target-objcopy=-O elf64-x86-64 -B i386:x86-64
Kyösti Mälkki67a537c2020-06-04 09:21:40 +0300283LD_MACHINE =-m elf_x86_64
Patrick Georgic32a52c2015-06-22 21:10:34 +0200284endif
285
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700286ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
287ifeq ($(CONFIG_GENERATE_MP_TABLE),y)
288ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),)
289ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c
290endif
291endif
292ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y)
293ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c
294endif
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700295
296ramstage-libs ?=
297
Elyes HAOUAS2f79eb32018-08-07 12:24:42 +0200298# The rmodule_link definition creates an elf file with .rmod extension.
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700299$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
300 cp $< $@
301
Furquan Shaikh46514c22020-06-11 11:59:07 -0700302$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE))
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700303 @printf " CC $(subst $(obj)/,,$(@))\n"
Furquan Shaikh46514c22020-06-11 11:59:07 -0700304 $(LD_ramstage) $(CPPFLAGS) $(LDFLAGS_ramstage) -o $@ -L$(obj) $< -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE))
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700305
Patrick Georgi3ce96bd2014-11-22 17:42:58 +0100306$(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700307 @printf " CC $(subst $(obj)/,,$(@))\n"
Kyösti Mälkki67a537c2020-06-04 09:21:40 +0300308 $(LD_ramstage) $(LD_MACHINE) -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
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700309
Stefan Reinauer181b7732015-03-15 19:23:50 +0100310endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64
Subrata Banikeb5b0d02019-06-04 16:46:41 +0530311
312smm-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
313smm-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
314smm-y += memcpy.c
315smm-y += memmove.c
316smm-y += memset.c
317smm-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
318
Subrata Banikeb5b0d02019-06-04 16:46:41 +0530319ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c),)
320smm-srcs += src/mainboard/$(MAINBOARDDIR)/smihandler.c
321endif