blob: 458bcc637e5d7da648a1e6ee8057a3527452f68c [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
Angel Ponsf206cda2021-05-17 12:12:39 +020014CMOS_LAYOUT_FILE := $(top)/$(call strip_quotes,$(CONFIG_CMOS_LAYOUT_FILE))
15
Patrick Georgi5c0bca22011-01-30 16:31:15 +000016cbfs-files-y += cmos_layout.bin
17cmos_layout.bin-file = $(obj)/cmos_layout.bin
Martin Roth8ea06512016-09-19 13:58:01 -060018cmos_layout.bin-type = cmos_layout
Patrick Georgi24479372011-01-18 13:56:36 +000019
Angel Ponsf206cda2021-05-17 12:12:39 +020020$(obj)/cmos_layout.bin: $(NVRAMTOOL) $(CMOS_LAYOUT_FILE)
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010021 @printf " OPTION $(subst $(obj)/,,$(@))\n"
Angel Ponsf206cda2021-05-17 12:12:39 +020022 $(NVRAMTOOL) -y $(CMOS_LAYOUT_FILE) -L $@
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010023
Patrick Georgi8463dd92010-09-30 16:55:02 +000024OPTION_TABLE_H:=$(obj)/option_table.h
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010025
Angel Ponsf206cda2021-05-17 12:12:39 +020026$(OPTION_TABLE_H): $(NVRAMTOOL) $(CMOS_LAYOUT_FILE)
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010027 @printf " OPTION $(subst $(obj)/,,$(@))\n"
Angel Ponsf206cda2021-05-17 12:12:39 +020028 $(NVRAMTOOL) -y $(CMOS_LAYOUT_FILE) -H $@
Patrick Georgi70a6b4f2015-03-27 14:14:58 +010029endif # CONFIG_HAVE_OPTION_TABLE
Patrick Georgi0588d192009-08-12 15:00:51 +000030
Patrick Georgiff9d78c2011-01-30 16:37:39 +000031stripped_vgabios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_ID))
32cbfs-files-$(CONFIG_VGA_BIOS) += pci$(stripped_vgabios_id).rom
33pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE))
34pci$(stripped_vgabios_id).rom-type := optionrom
35
Martin Roth4cc2cac2019-12-06 19:11:08 -070036stripped_second_vbios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_SECOND_ID))
37cbfs-files-$(CONFIG_VGA_BIOS_SECOND) += pci$(stripped_second_vbios_id).rom
38pci$(stripped_second_vbios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_SECOND_FILE))
39pci$(stripped_second_vbios_id).rom-type := optionrom
40
Mike Banon0f8547e2019-02-17 19:51:53 +030041stripped_vgabios_dgpu_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_ID))
42cbfs-files-$(CONFIG_VGA_BIOS_DGPU) += pci$(stripped_vgabios_dgpu_id).rom
43pci$(stripped_vgabios_dgpu_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_FILE))
44pci$(stripped_vgabios_dgpu_id).rom-type := optionrom
45
Raul E Rangel90cec2d2021-07-23 16:43:18 -060046# The AMD LPC SPI DMA controller requires source files to be 64 byte aligned.
47ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA),y)
48pci$(stripped_vgabios_id).rom-align := 64
49pci$(stripped_second_vbios_id).rom-align := 64
50pci$(stripped_vgabios_dgpu_id).rom-align := 64
51endif # CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA
52
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070053###############################################################################
Aaron Durbineb907b32016-01-21 00:08:17 -060054# common support for early assembly includes
55###############################################################################
56
Aaron Durbineb907b32016-01-21 00:08:17 -060057define early_x86_stage
58# $1 stage name
59# $2 oformat
Aaron Durbineb907b32016-01-21 00:08:17 -060060
61# The '.' include path is needed for the generated assembly.inc file.
62$(1)-S-ccopts += -I.
63
64$$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs)
65 @printf " LINK $$(subst $$(obj)/,,$$(@))\n"
Furquan Shaikh46514c22020-06-11 11:59:07 -070066 $$(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 -060067 -LANG=C LC_ALL= $$(OBJCOPY_$(1)) --only-section .illegal_globals $$(@) $$(objcbfs)/$(1)_null.offenders >/dev/null 2>&1
68 if [ -z "$$$$($$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders 2>&1 | grep 'no symbols')" ];then \
69 echo "Forbidden global variables in $(1):"; \
70 $$(NM_$(1)) $$(objcbfs)/$(1)_null.offenders; false; \
71 fi
72endef
73
74###############################################################################
Furquan Shaikh88ca81a2014-04-22 16:33:22 -070075# bootblock
76###############################################################################
Patrick Georgi641dd712011-11-01 18:55:59 +010077
Stefan Reinauer181b7732015-03-15 19:23:50 +010078ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070079
Martin Rothcbf6e6b2020-06-06 09:45:20 -060080bootblock-y += boot.c
81bootblock-y += post.c
82bootblock-y += cpu_common.c
Aaron Durbin4b032e42018-04-20 01:39:30 -060083bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
84bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -060085bootblock-y += memcpy.c
86bootblock-y += memset.c
Martin Roth00b37d32020-06-25 14:34:46 -060087bootblock-y += memmove.c
Aaron Durbinf49ddb62018-01-24 17:35:58 -070088bootblock-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Alexandru Gagniuc6a622312015-10-27 10:27:30 -070089bootblock-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Kyösti Mälkkib8d575c2019-12-16 16:00:49 +020090bootblock-$(CONFIG_BOOTBLOCK_NORMAL) += bootblock_normal.c
Kyösti Mälkki97b76f72020-11-19 16:41:28 +020091bootblock-y += gdt_init.S
Alexandru Gagniucee2740b2015-10-04 17:47:36 -070092bootblock-y += id.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -060093bootblock-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
94
Nico Huber81b09f42016-01-23 00:50:00 +010095$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h
Patrick Georgiab355752015-10-15 11:07:07 +020096
Aaron Durbineb907b32016-01-21 00:08:17 -060097ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
98$(eval $(call early_x86_stage,bootblock,elf32-i386))
99else
100$(eval $(call early_x86_stage,bootblock,elf64-x86-64))
101endif
102
Arthur Heymans50ece622021-05-04 08:46:58 +0200103$(call src-to-obj,bootblock,$(dir)/walkcbfs.S): $(obj)/fmap_config.h
Arthur Heymansa033d8c2021-05-05 14:20:03 +0200104bootblock-y += walkcbfs.S
Arthur Heymans0eb9c572019-01-05 18:21:47 +0100105
Stefan Reinauer181b7732015-03-15 19:23:50 +0100106endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700107
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700108###############################################################################
Aaron Durbin75c51d92015-09-29 16:31:20 -0500109# verstage
110###############################################################################
111
112ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32)$(CONFIG_ARCH_VERSTAGE_X86_64),y)
113
Arthur Heymansf25f0952021-04-30 14:45:19 +0200114verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += assembly_entry.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600115verstage-y += boot.c
116verstage-y += post.c
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -0700117verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += gdt_init.S
Aaron Durbin4b032e42018-04-20 01:39:30 -0600118verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
119verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600120verstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500121
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600122verstage-y += cpu_common.c
123verstage-y += memset.c
124verstage-y += memcpy.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500125verstage-y += memmove.c
Aaron Durbin57dbbbb2016-03-18 13:12:41 -0500126verstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Arthur Heymans7bea0842018-06-06 18:19:56 +0200127# If verstage is a separate stage it means there's no need
Aaron Durbin10221a02016-05-26 10:55:48 -0500128# for a chipset-specific car_stage_entry() so use the generic one
129# which just calls verstage().
Arthur Heymans7bea0842018-06-06 18:19:56 +0200130verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += verstage.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500131
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700132verstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Aaron Durbin75c51d92015-09-29 16:31:20 -0500133
Julius Wernere91d1702017-03-20 15:32:15 -0700134verstage-libs ?=
Aaron Durbin75c51d92015-09-29 16:31:20 -0500135
136ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y)
137$(eval $(call early_x86_stage,verstage,elf32-i386))
138else
139$(eval $(call early_x86_stage,verstage,elf64-x86-64))
140endif
141
Aaron Durbin75c51d92015-09-29 16:31:20 -0500142endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64
143
144###############################################################################
Aaron Durbin1bc6a792015-09-29 14:54:25 -0500145# romstage
146###############################################################################
147
148ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700149
Arthur Heymans08cb80e2020-12-24 12:25:06 +0100150romstage-y += assembly_entry.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600151romstage-y += boot.c
152romstage-y += post.c
Arthur Heymansc05b1a62019-11-22 21:01:30 +0100153romstage-y += gdt_init.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600154romstage-y += cpu_common.c
Aaron Durbin4b032e42018-04-20 01:39:30 -0600155romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
156romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600157romstage-y += memcpy.c
Lee Leahye82b5052016-07-25 17:07:53 -0700158romstage-y += memmove.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600159romstage-y += memset.c
Lee Leahye82b5052016-07-25 17:07:53 -0700160romstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Rizwan Qureshib1b44d32016-08-26 21:08:50 +0530161romstage-y += postcar_loader.c
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700162romstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600163romstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
Raul E Rangelca0606e2021-07-21 14:34:00 -0600164romstage-$(CONFIG_COOP_MULTITASKING) += thread.c
165romstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S
Lee Leahye82b5052016-07-25 17:07:53 -0700166
Rizwan Qureshi8e8ca5c2018-10-01 14:35:25 +0530167romstage-srcs += $(wildcard $(src)/mainboard/$(MAINBOARDDIR)/romstage.c)
Alexandru Gagniuceb3c9912014-03-29 13:01:11 -0500168romstage-libs ?=
169
Stefan Reinauer98749332015-06-23 12:57:06 -0700170ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
Aaron Durbin1bc6a792015-09-29 14:54:25 -0500171$(eval $(call early_x86_stage,romstage,elf32-i386))
Stefan Reinauer98749332015-06-23 12:57:06 -0700172else
Aaron Durbin1bc6a792015-09-29 14:54:25 -0500173$(eval $(call early_x86_stage,romstage,elf64-x86-64))
Stefan Reinauer98749332015-06-23 12:57:06 -0700174endif
175
Patrick Georgid69839b2015-04-03 10:32:17 +0200176# Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428
Aaron Durbin75c51d92015-09-29 16:31:20 -0500177romstage-S-ccopts += -g0
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700178
Stefan Reinauer181b7732015-03-15 19:23:50 +0100179endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64
Stefan Reinauerf1939bb2010-12-30 17:39:50 +0000180
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700181###############################################################################
Lee Leahya7491502016-07-24 07:43:23 -0700182# postcar
183###############################################################################
184
Patrick Rudolph8daa12f2018-12-26 15:12:32 +0100185ifeq ($(CONFIG_ARCH_POSTCAR_X86_32),y)
Lee Leahya7491502016-07-24 07:43:23 -0700186$(eval $(call create_class_compiler,postcar,x86_32))
Patrick Rudolph8daa12f2018-12-26 15:12:32 +0100187else
188$(eval $(call create_class_compiler,postcar,x86_64))
189endif
Lee Leahya7491502016-07-24 07:43:23 -0700190postcar-generic-ccopts += -D__POSTCAR__
191
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600192postcar-y += boot.c
193postcar-y += post.c
Hannah Williamsd3c0c0c2018-04-27 09:09:04 -0700194postcar-y += gdt_init.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600195postcar-y += cpu_common.c
Aaron Durbin4b032e42018-04-20 01:39:30 -0600196postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
197postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
Lee Leahya7491502016-07-24 07:43:23 -0700198postcar-y += exit_car.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600199postcar-y += memcpy.c
Lee Leahya7491502016-07-24 07:43:23 -0700200postcar-y += memmove.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600201postcar-y += memset.c
Lee Leahya7491502016-07-24 07:43:23 -0700202postcar-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
Aaron Durbin6b0cebc2016-09-16 16:15:14 -0500203postcar-y += postcar.c
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700204postcar-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600205postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
Lee Leahya7491502016-07-24 07:43:23 -0700206
Lee Leahy4cfde2a2016-07-24 07:51:24 -0700207LDFLAGS_postcar += -Map $(objcbfs)/postcar.map
208
Lee Leahya7491502016-07-24 07:43:23 -0700209$(objcbfs)/postcar.debug: $$(postcar-objs)
210 @printf " LINK $(subst $(obj)/,,$(@))\n"
Furquan Shaikh46514c22020-06-11 11:59:07 -0700211 $(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 -0700212
213$(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod
214 cp $< $@
215
216# Add postcar to CBFS
217cbfs-files-$(CONFIG_POSTCAR_STAGE) += $(CONFIG_CBFS_PREFIX)/postcar
218$(CONFIG_CBFS_PREFIX)/postcar-file := $(objcbfs)/postcar.elf
219$(CONFIG_CBFS_PREFIX)/postcar-type := stage
220$(CONFIG_CBFS_PREFIX)/postcar-compression := none
221
222###############################################################################
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700223# ramstage
224###############################################################################
225
Stefan Reinauer181b7732015-03-15 19:23:50 +0100226ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y)
Furquan Shaikh99ac98f2014-04-23 10:18:48 -0700227
Angel Pons79572e42020-07-13 00:17:43 +0200228ramstage-y += acpi.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700229ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
Marshall Dawson991467d2018-09-04 12:32:56 -0600230ramstage-$(CONFIG_ACPI_BERT) += acpi_bert_storage.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600231ramstage-y += boot.c
232ramstage-y += post.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700233ramstage-y += c_start.S
Patrick Rudolphe5638152018-12-09 10:48:59 +0100234ramstage-y += c_exit.S
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700235ramstage-y += cpu.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600236ramstage-y += cpu_common.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700237ramstage-y += ebda.c
238ramstage-y += exception.c
Aaron Durbin7a7c70b2018-04-20 00:56:57 -0600239ramstage-y += idt.S
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700240ramstage-$(CONFIG_IOAPIC) += ioapic.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600241ramstage-y += memcpy.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700242ramstage-y += memmove.c
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600243ramstage-y += memset.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700244ramstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
245ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700246ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c
Robbie Zhang18792312017-02-13 13:44:14 -0800247ramstage-y += rdrand.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700248ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c
Angel Ponsbea5ce72020-07-29 18:40:00 +0200249ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios_defaults.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700250ramstage-y += tables.c
251ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c
252ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S
Aaron Durbinf49ddb62018-01-24 17:35:58 -0700253ramstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700254ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S
Martin Rothcbf6e6b2020-06-06 09:45:20 -0600255ramstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700256
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700257rmodules_x86_32-y += memcpy.c
258rmodules_x86_32-y += memmove.c
259rmodules_x86_32-y += memset.c
Kyösti Mälkki67a537c2020-06-04 09:21:40 +0300260
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700261rmodules_x86_64-y += memcpy.c
262rmodules_x86_64-y += memmove.c
263rmodules_x86_64-y += memset.c
Lee Leahy99f1b2f2016-07-25 17:18:50 -0700264
Patrick Georgic32a52c2015-06-22 21:10:34 +0200265ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
266target-objcopy=-O elf32-i386 -B i386
Kyösti Mälkki67a537c2020-06-04 09:21:40 +0300267LD_MACHINE =-m elf_i386
Patrick Georgic32a52c2015-06-22 21:10:34 +0200268endif
269ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y)
Stefan Reinauer593f5c82015-07-30 18:03:18 -0700270target-objcopy=-O elf64-x86-64 -B i386:x86-64
Kyösti Mälkki67a537c2020-06-04 09:21:40 +0300271LD_MACHINE =-m elf_x86_64
Patrick Georgic32a52c2015-06-22 21:10:34 +0200272endif
273
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700274ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
275ifeq ($(CONFIG_GENERATE_MP_TABLE),y)
276ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),)
277ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c
278endif
279endif
280ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y)
281ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c
282endif
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700283
284ramstage-libs ?=
285
Elyes HAOUAS2f79eb32018-08-07 12:24:42 +0200286# The rmodule_link definition creates an elf file with .rmod extension.
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700287$(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
288 cp $< $@
289
Furquan Shaikh46514c22020-06-11 11:59:07 -0700290$(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE))
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700291 @printf " CC $(subst $(obj)/,,$(@))\n"
Furquan Shaikh46514c22020-06-11 11:59:07 -0700292 $(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 -0700293
Patrick Georgi3ce96bd2014-11-22 17:42:58 +0100294$(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs)
Furquan Shaikh88ca81a2014-04-22 16:33:22 -0700295 @printf " CC $(subst $(obj)/,,$(@))\n"
Kyösti Mälkki67a537c2020-06-04 09:21:40 +0300296 $(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 -0700297
Stefan Reinauer181b7732015-03-15 19:23:50 +0100298endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64
Subrata Banikeb5b0d02019-06-04 16:46:41 +0530299
300smm-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
301smm-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
302smm-y += memcpy.c
303smm-y += memmove.c
304smm-y += memset.c
305smm-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
306
Kyösti Mälkki0be41992021-01-08 13:58:10 +0200307smm-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c)