1 ## SPDX-License-Identifier: GPL-2.0-only
3 ifeq ($(CONFIG_POSTCAR_STAGE),y)
4 $(eval $(call init_standard_toolchain,postcar))
7 ################################################################################
9 NVRAMTOOL:=$(objutil)/nvramtool/nvramtool
12 ifeq ($(CONFIG_HAVE_OPTION_TABLE),y)
14 CMOS_LAYOUT_FILE := $(top)/$(call strip_quotes,$(CONFIG_CMOS_LAYOUT_FILE))
16 cbfs-files-y += cmos_layout.bin
17 cmos_layout.bin-file = $(obj)/cmos_layout.bin
18 cmos_layout.bin-type = cmos_layout
20 $(obj)/cmos_layout.bin: $(NVRAMTOOL) $(CMOS_LAYOUT_FILE)
21 @printf " OPTION $(subst $(obj)/,,$(@))\n"
22 $(NVRAMTOOL) -y $(CMOS_LAYOUT_FILE) -L $@
24 OPTION_TABLE_H:=$(obj)/option_table.h
26 $(OPTION_TABLE_H): $(NVRAMTOOL) $(CMOS_LAYOUT_FILE)
27 @printf " OPTION $(subst $(obj)/,,$(@))\n"
28 $(NVRAMTOOL) -y $(CMOS_LAYOUT_FILE) -H $@
29 endif # CONFIG_HAVE_OPTION_TABLE
31 stripped_vgabios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_ID))
32 cbfs-files-$(CONFIG_VGA_BIOS) += pci$(stripped_vgabios_id).rom
33 pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE))
34 pci$(stripped_vgabios_id).rom-type := optionrom
36 stripped_second_vbios_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_SECOND_ID))
37 cbfs-files-$(CONFIG_VGA_BIOS_SECOND) += pci$(stripped_second_vbios_id).rom
38 pci$(stripped_second_vbios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_SECOND_FILE))
39 pci$(stripped_second_vbios_id).rom-type := optionrom
41 stripped_vgabios_dgpu_id = $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_ID))
42 cbfs-files-$(CONFIG_VGA_BIOS_DGPU) += pci$(stripped_vgabios_dgpu_id).rom
43 pci$(stripped_vgabios_dgpu_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_FILE))
44 pci$(stripped_vgabios_dgpu_id).rom-type := optionrom
46 # The AMD LPC SPI DMA controller requires source files to be 64 byte aligned.
47 ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA),y)
48 pci$(stripped_vgabios_id).rom-align := 64
49 pci$(stripped_second_vbios_id).rom-align := 64
50 pci$(stripped_vgabios_dgpu_id).rom-align := 64
51 endif # CONFIG_SOC_AMD_COMMON_BLOCK_LPC_SPI_DMA
53 ###############################################################################
54 # common support for early assembly includes
55 ###############################################################################
57 define early_x86_stage
61 # The '.' include path is needed for the generated assembly.inc file.
64 $$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs)
65 @printf " LINK $$(subst $$(obj)/,,$$(@))\n"
66 $$(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)
67 -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; \
74 ###############################################################################
76 ###############################################################################
78 ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y)
82 bootblock-y += cpu_common.c
83 bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
84 bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
85 bootblock-y += memcpy.c
86 bootblock-y += memset.c
87 bootblock-y += memmove.c
88 bootblock-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
89 bootblock-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
90 bootblock-$(CONFIG_BOOTBLOCK_NORMAL) += bootblock_normal.c
91 bootblock-y += gdt_init.S
93 bootblock-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
95 $(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h
97 ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32),y)
98 $(eval $(call early_x86_stage,bootblock,elf32-i386))
100 $(eval $(call early_x86_stage,bootblock,elf64-x86-64))
103 $(call src-to-obj,bootblock,$(dir)/walkcbfs.S): $(obj)/fmap_config.h
104 bootblock-y += walkcbfs.S
106 endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64
108 ###############################################################################
110 ###############################################################################
112 ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32)$(CONFIG_ARCH_VERSTAGE_X86_64),y)
114 verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += assembly_entry.S
117 verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += gdt_init.S
118 verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
119 verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
120 verstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
122 verstage-y += cpu_common.c
123 verstage-y += memset.c
124 verstage-y += memcpy.c
125 verstage-y += memmove.c
126 verstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
127 # If verstage is a separate stage it means there's no need
128 # for a chipset-specific car_stage_entry() so use the generic one
129 # which just calls verstage().
130 verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += verstage.c
132 verstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
136 ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32),y)
137 $(eval $(call early_x86_stage,verstage,elf32-i386))
139 $(eval $(call early_x86_stage,verstage,elf64-x86-64))
142 endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64
144 ###############################################################################
146 ###############################################################################
148 ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)
150 romstage-y += assembly_entry.S
153 romstage-y += gdt_init.S
154 romstage-y += cpu_common.c
155 romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
156 romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
157 romstage-y += memcpy.c
158 romstage-y += memmove.c
159 romstage-y += memset.c
160 romstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
161 romstage-y += postcar_loader.c
162 romstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
163 romstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
164 romstage-$(CONFIG_COOP_MULTITASKING) += thread.c
165 romstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S
167 romstage-srcs += $(wildcard $(src)/mainboard/$(MAINBOARDDIR)/romstage.c)
170 ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
171 $(eval $(call early_x86_stage,romstage,elf32-i386))
173 $(eval $(call early_x86_stage,romstage,elf64-x86-64))
176 # Compiling crt0 with -g seems to trigger https://sourceware.org/bugzilla/show_bug.cgi?id=6428
177 romstage-S-ccopts += -g0
179 endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64
181 ###############################################################################
183 ###############################################################################
185 ifeq ($(CONFIG_ARCH_POSTCAR_X86_32),y)
186 $(eval $(call create_class_compiler,postcar,x86_32))
188 $(eval $(call create_class_compiler,postcar,x86_64))
190 postcar-generic-ccopts += -D__POSTCAR__
194 postcar-y += gdt_init.S
195 postcar-y += cpu_common.c
196 postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
197 postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
198 postcar-y += exit_car.S
199 postcar-y += memcpy.c
200 postcar-y += memmove.c
201 postcar-y += memset.c
202 postcar-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
203 postcar-y += postcar.c
204 postcar-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
205 postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
207 LDFLAGS_postcar += -Map $(objcbfs)/postcar.map
209 $(objcbfs)/postcar.debug: $$(postcar-objs)
210 @printf " LINK $(subst $(obj)/,,$(@))\n"
211 $(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))
213 $(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod
216 # Add postcar to CBFS
217 cbfs-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
222 ###############################################################################
224 ###############################################################################
226 ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y)
229 ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
230 ramstage-$(CONFIG_ACPI_BERT) += acpi_bert_storage.c
233 ramstage-y += c_start.S
234 ramstage-y += c_exit.S
236 ramstage-y += cpu_common.c
238 ramstage-y += exception.c
240 ramstage-$(CONFIG_IOAPIC) += ioapic.c
241 ramstage-y += memcpy.c
242 ramstage-y += memmove.c
243 ramstage-y += memset.c
244 ramstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
245 ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c
246 ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c
247 ramstage-y += rdrand.c
248 ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c
249 ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios_defaults.c
250 ramstage-y += tables.c
251 ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c
252 ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S
253 ramstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
254 ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S
255 ramstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
257 rmodules_x86_32-y += memcpy.c
258 rmodules_x86_32-y += memmove.c
259 rmodules_x86_32-y += memset.c
261 rmodules_x86_64-y += memcpy.c
262 rmodules_x86_64-y += memmove.c
263 rmodules_x86_64-y += memset.c
265 ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
266 target-objcopy=-O elf32-i386 -B i386
267 LD_MACHINE =-m elf_i386
269 ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y)
270 target-objcopy=-O elf64-x86-64 -B i386:x86-64
271 LD_MACHINE =-m elf_x86_64
274 ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
275 ifeq ($(CONFIG_GENERATE_MP_TABLE),y)
276 ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/mptable.c),)
277 ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mptable.c
280 ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y)
281 ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/irq_tables.c
286 # The rmodule_link definition creates an elf file with .rmod extension.
287 $(objcbfs)/ramstage.elf: $(objcbfs)/ramstage.debug.rmod
290 $(objcbfs)/ramstage.debug: $(objgenerated)/ramstage.o $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE))
291 @printf " CC $(subst $(obj)/,,$(@))\n"
292 $(LD_ramstage) $(CPPFLAGS) $(LDFLAGS_ramstage) -o $@ -L$(obj) $< -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE))
294 $(objgenerated)/ramstage.o: $$(ramstage-objs) $(COMPILER_RT_ramstage) $$(ramstage-libs)
295 @printf " CC $(subst $(obj)/,,$(@))\n"
296 $(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
298 endif # CONFIG_ARCH_RAMSTAGE_X86_32 / CONFIG_ARCH_RAMSTAGE_X86_64
300 smm-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
301 smm-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
305 smm-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
307 smm-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/smihandler.c)