Xeon-SP boards: Factor out OCP VPD `get_cxl_mode()` impl
[coreboot2.git] / src / lib / Makefile.mk
blob59e2116e300f76d23c3783922fdbf07b03fc0853
1 # SPDX-License-Identifier: GPL-2.0-only
3 subdirs-y += gnat
5 ifeq ($(CONFIG_UBSAN),y)
6 ramstage-y += ubsan.c
7 CFLAGS_ramstage += -fsanitize=undefined
8 endif
10 # Ensure that asan_shadow_offset_callback patch is applied to GCC before ASan is used.
11 CFLAGS_asan += -fsanitize=kernel-address --param asan-use-shadow-offset-callback=1 \
12 --param asan-stack=1 -fsanitize-address-use-after-scope \
13 --param asan-instrumentation-with-call-threshold=0 \
14 --param use-after-scope-direct-emission-threshold=0
16 ifeq ($(CONFIG_ASAN_IN_ROMSTAGE),y)
17 romstage-y += asan.c
18 CFLAGS_asan += --param asan-globals=0
19 CFLAGS_romstage += $(CFLAGS_asan)
20 # Allow memory access without __asan_load and __asan_store checks.
21 $(obj)/romstage/lib/asan.o: CFLAGS_asan =
22 endif
24 ifeq ($(CONFIG_ASAN_IN_RAMSTAGE),y)
25 ramstage-y += asan.c
26 CFLAGS_asan += --param asan-globals=1
27 CFLAGS_ramstage += $(CFLAGS_asan)
28 $(obj)/ramstage/lib/asan.o: CFLAGS_asan =
29 endif
31 decompressor-y += decompressor.c
32 $(call src-to-obj,decompressor,$(dir)/decompressor.c): $(objcbfs)/bootblock.lz4
33 $(call src-to-obj,decompressor,$(dir)/decompressor.c): CCACHE_EXTRAFILES=$(objcbfs)/bootblock.lz4
34 # Must reset CCACHE_EXTRAFILES or make applies it transitively to dependencies.
35 $(objcbfs)/bootblock.lz4: CCACHE_EXTRAFILES=
37 decompressor-y += delay.c
38 decompressor-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
39 decompressor-y += memchr.c
40 decompressor-y += memcmp.c
41 decompressor-$(CONFIG_CBFS_VERIFICATION) += metadata_hash.c
42 decompressor-y += prog_ops.c
43 decompressor-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
45 bootblock-y += bootblock.c
46 bootblock-y += prog_loaders.c
47 bootblock-y += prog_ops.c
48 bootblock-y += cbfs.c
49 bootblock-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
50 bootblock-y += libgcc.c
51 ifneq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y)
52 bootblock-$(CONFIG_CBFS_VERIFICATION) += metadata_hash.c
53 else # ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y)
54 verstage-$(CONFIG_CBFS_VERIFICATION) += metadata_hash.c
55 endif # ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y)
56 bootblock-$(CONFIG_GENERIC_UDELAY) += timer.c
58 bootblock-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
60 bootblock-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
61 bootblock-y += delay.c
62 bootblock-y += memchr.c
63 bootblock-y += memcmp.c
64 bootblock-y += boot_device.c
65 bootblock-y += fmap.c
67 verstage-y += prog_loaders.c
68 verstage-y += prog_ops.c
69 verstage-y += delay.c
70 verstage-y += cbfs.c
71 verstage-y += halt.c
72 verstage-y += fmap.c
73 verstage-y += libgcc.c
74 verstage-y += memcmp.c
75 verstage-y += string.c
77 verstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
78 verstage-y += boot_device.c
79 verstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
81 verstage-$(CONFIG_GENERIC_UDELAY) += timer.c
82 verstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
84 romstage-$(CONFIG_PROBE_RAM) += ramdetect.c
85 romstage-y += prog_loaders.c
86 romstage-y += prog_ops.c
87 romstage-y += memchr.c
88 romstage-y += memcmp.c
89 $(foreach arch,$(ARCH_SUPPORTED),\
90 $(eval rmodules_$(arch)-y += memcmp.c) \
91 $(eval rmodules_$(arch)-y += rmodule.ld))
93 romstage-y += fmap.c
94 romstage-y += delay.c
95 romstage-y += cbfs.c
96 ifneq ($(CONFIG_COMPRESS_RAMSTAGE_LZMA)$(CONFIG_FSP_COMPRESS_FSP_M_LZMA),)
97 romstage-y += lzma.c lzmadecode.c
98 endif
99 romstage-y += libgcc.c
100 romstage-y += memrange.c
101 romstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c
102 ramstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c
103 romstage-y += ramtest.c
104 romstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
105 ramstage-y += region_file.c
106 romstage-y += region_file.c
107 ramstage-y += romstage_handoff.c
108 romstage-y += romstage_handoff.c
109 romstage-y += selfboot.c
110 romstage-y += stack.c
111 romstage-y += rtc.c
112 ramstage-y += rtc.c
114 romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
115 romstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
117 romstage-y += dimm_info_util.c
118 ifeq ($(CONFIG_COMPILER_GCC),y)
119 bootblock-$(CONFIG_ARCH_BOOTBLOCK_X86_32) += gcc.c
120 verstage-$(CONFIG_ARCH_VERSTAGE_X86_32) += gcc.c
121 romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += gcc.c
122 ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += gcc.c
123 smm-y += gcc.c
124 endif
126 romstage-$(CONFIG_GENERIC_UDELAY) += timer.c
128 ramstage-$(CONFIG_PROBE_RAM) += ramdetect.c
129 ramstage-y += prog_loaders.c
130 ramstage-y += prog_ops.c
131 ramstage-y += hardwaremain.c
132 ramstage-y += selfboot.c
133 ramstage-y += coreboot_table.c
134 ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c
135 ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios_defaults.c
136 ramstage-y += bootmem.c
137 ramstage-y += fmap.c
138 ramstage-y += memchr.c
139 ramstage-y += memcmp.c
140 ramstage-y += malloc.c
141 ramstage-y += dimm_info_util.c
142 ramstage-y += delay.c
143 ramstage-y += fallback_boot.c
144 ramstage-y += cbfs.c
145 ramstage-y += lzma.c lzmadecode.c
146 ramstage-y += stack.c
147 ramstage-y += hexstrtobin.c
148 ramstage-y += wrdd.c
149 ramstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
150 ramstage-$(CONFIG_BMP_LOGO) += bmp_logo.c
151 ramstage-$(CONFIG_BOOTSPLASH) += bootsplash.c
152 ramstage-$(CONFIG_BOOTSPLASH) += jpeg.c
153 ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
154 ramstage-$(CONFIG_COVERAGE) += libgcov.c
155 ramstage-y += dp_aux.c
156 ramstage-y += edid.c
157 ramstage-y += edid_fill_fb.c
158 ramstage-y += memrange.c
159 ramstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
160 ramstage-$(CONFIG_GENERIC_UDELAY) += timer.c
161 ramstage-y += b64_decode.c
162 ramstage-$(CONFIG_ACPI_NHLT) += nhlt.c
163 ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit.c
164 ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit_payload.c
166 romstage-$(CONFIG_FLATTENED_DEVICE_TREE) += device_tree.c
167 ramstage-$(CONFIG_FLATTENED_DEVICE_TREE) += device_tree.c
169 romstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c
170 ramstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c
172 romstage-$(CONFIG_COOP_MULTITASKING) += thread.c
173 ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c
175 romstage-y += cbmem_common.c
176 romstage-y += imd_cbmem.c
177 romstage-y += imd.c
179 ramstage-y += cbmem_common.c
180 ramstage-y += imd_cbmem.c
181 ramstage-y += imd.c
183 postcar-$(CONFIG_PROBE_RAM) += ramdetect.c
184 postcar-y += cbmem_common.c
185 postcar-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
186 postcar-y += imd_cbmem.c
187 postcar-y += imd.c
188 postcar-y += romstage_handoff.c
190 bootblock-y += hexdump.c
191 postcar-y += hexdump.c
192 ramstage-y += hexdump.c
193 romstage-y += hexdump.c
194 verstage-y += hexdump.c
195 smm-y += hexdump.c
197 bootblock-$(CONFIG_FW_CONFIG) += fw_config.c
198 verstage-$(CONFIG_FW_CONFIG) += fw_config.c
199 romstage-$(CONFIG_FW_CONFIG) += fw_config.c
200 ramstage-$(CONFIG_FW_CONFIG) += fw_config.c
202 bootblock-$(CONFIG_ESPI_DEBUG) += espi_debug.c
203 verstage-$(CONFIG_ESPI_DEBUG) += espi_debug.c
204 romstage-$(CONFIG_ESPI_DEBUG) += espi_debug.c
205 ramstage-$(CONFIG_ESPI_DEBUG) += espi_debug.c
207 bootblock-$(CONFIG_REG_SCRIPT) += reg_script.c
208 verstage-$(CONFIG_REG_SCRIPT) += reg_script.c
209 romstage-$(CONFIG_REG_SCRIPT) += reg_script.c
210 ramstage-$(CONFIG_REG_SCRIPT) += reg_script.c
212 ramstage-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c
213 romstage-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c
214 postcar-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c
216 ramstage-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c
217 romstage-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c
218 postcar-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c
220 romstage-y += boot_device.c
221 ramstage-y += boot_device.c
223 smm-y += boot_device.c
224 smm-y += delay.c
225 smm-y += fmap.c
226 smm-y += cbfs.c memcmp.c
227 smm-$(CONFIG_GENERIC_UDELAY) += timer.c
228 ifeq ($(CONFIG_DEBUG_SMI),y)
229 smm-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
230 endif
232 all-y += identity.c version.c
233 smm-y += identity.c version.c
235 $(call src-to-obj,bootblock,$(dir)/version.c) : $(obj)/build.h
236 $(call src-to-obj,romstage,$(dir)/version.c) : $(obj)/build.h
237 $(call src-to-obj,ramstage,$(dir)/version.c) : $(obj)/build.h
238 $(call src-to-obj,smm,$(dir)/version.c) : $(obj)/build.h
239 $(call src-to-obj,verstage,$(dir)/version.c) : $(obj)/build.h
240 $(call src-to-obj,postcar,$(dir)/version.c) : $(obj)/build.h
242 bootblock-y += bootmode.c
243 romstage-y += bootmode.c
244 ramstage-y += bootmode.c
245 verstage-y += bootmode.c
247 decompressor-y += halt.c
248 bootblock-y += halt.c
249 romstage-y += halt.c
250 ramstage-y += halt.c
251 smm-y += halt.c
253 decompressor-y += reset.c
254 bootblock-y += reset.c
255 verstage-y += reset.c
256 romstage-y += reset.c
257 postcar-y += reset.c
258 ramstage-y += reset.c
259 smm-y += reset.c
261 decompressor-y += string.c
262 bootblock-y += string.c
263 verstage-y += string.c
264 romstage-y += string.c
265 postcar-y += string.c
266 ramstage-y += string.c
267 smm-y += string.c
269 decompressor-y += crc_byte.c
270 bootblock-y += crc_byte.c
271 verstage-y += crc_byte.c
272 romstage-y += crc_byte.c
273 postcar-y += crc_byte.c
274 ramstage-y += crc_byte.c
275 smm-y += crc_byte.c
277 romstage-y += xxhash.c
278 ramstage-y += xxhash.c
280 postcar-y += bootmode.c
281 postcar-y += boot_device.c
282 postcar-y += cbfs.c
283 postcar-y += delay.c
284 postcar-y += fmap.c
285 postcar-y += gcc.c
286 postcar-y += halt.c
287 postcar-y += libgcc.c
288 postcar-$(CONFIG_COMPRESS_RAMSTAGE_LZMA) += lzma.c lzmadecode.c
289 postcar-y += memchr.c
290 postcar-y += memcmp.c
291 postcar-y += prog_loaders.c
292 postcar-y += prog_ops.c
293 postcar-y += rmodule.c
294 postcar-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
295 postcar-$(CONFIG_GENERIC_UDELAY) += timer.c
297 # Use program.ld for all the platforms which use C fo the bootblock.
298 bootblock-y += program.ld
300 decompressor-y += program.ld
301 postcar-y += program.ld
302 romstage-y += program.ld
303 ramstage-y += program.ld
304 verstage-y += program.ld
306 ifeq ($(CONFIG_RELOCATABLE_MODULES),y)
307 ramstage-y += rmodule.c
308 romstage-y += rmodule.c
310 RMODULE_LDFLAGS := -z defs -Bsymbolic
312 # rmodule_link_rules is a function that should be called with:
313 # (1) the object name to link
314 # (2) the dependencies
315 # (3) arch for which the rmodules are to be linked
316 # It will create the necessary Make rules to create a rmodule. The resulting
317 # rmdoule is named $(1).rmod
318 define rmodule_link
319 $(strip $(1)): $(strip $(2)) $$(COMPILER_RT_rmodules_$(3)) $(call src-to-obj,rmodules_$(3),src/lib/rmodule.ld) | $$(RMODTOOL)
320 $$(LD_rmodules_$(3)) $$(LDFLAGS_rmodules_$(3)) $(RMODULE_LDFLAGS) $($(1)-ldflags) -T $(call src-to-obj,rmodules_$(3),src/lib/rmodule.ld) -o $$@ --whole-archive --start-group $(filter-out %.ld,$(2)) --end-group
321 $$(NM_rmodules_$(3)) -n $$@ > $$(basename $$@).map
322 endef
324 endif
326 $(objcbfs)/%.debug.rmod: $(objcbfs)/%.debug | $(RMODTOOL)
327 $(RMODTOOL) -i $< -o $@
329 $(obj)/%.elf.rmod: $(obj)/%.elf | $(RMODTOOL)
330 $(RMODTOOL) -i $< -o $@
332 romstage-$(CONFIG_ROMSTAGE_ADA) += cb.ads
333 ramstage-$(CONFIG_RAMSTAGE_ADA) += cb.ads
335 ifneq (,$(filter y, $(CONFIG_RAMSTAGE_LIBHWBASE) $(CONFIG_ROMSTAGE_LIBHWBASE)))
337 to-ada-hex = $(eval $(1) := 16\\\#$(patsubst 0x%,%,$($(1)))\\\#)
339 $(call to-ada-hex,CONFIG_HWBASE_DEFAULT_MMCONF)
341 libhwbase-stages = $(foreach stage, romstage ramstage, \
342 $(if $(filter y,$(CONFIG_$(call toupper,$(stage))_LIBHWBASE)),$(stage)))
344 $(call add-special-class,hw)
345 hw-handler +=$(foreach stage, $(libhwbase-stages), \
346 $(eval $(stage)-srcs += $$(addprefix $(1),$(2))))
348 $(call add-special-class,hw-gen)
349 hw-gen-handler = \
350 $(eval additional-dirs += $(dir $(2))) \
351 $(foreach stage, $(libhwbase-stages), \
352 $(eval $(stage)-srcs += $(2)) \
353 $(eval $(stage)-ads-deps += $(2)) \
354 $(eval $(stage)-adb-deps += $(2))) \
355 $(eval $(2): $(obj)/config.h)
357 subdirs-y += ../../3rdparty/libhwbase
359 $(foreach stage,$(libhwbase-stages), \
360 $(eval $(stage)-$(CONFIG_HAVE_MONOTONIC_TIMER) += hw-time-timer.adb))
362 endif # CONFIG_ROMSTAGE_LIBHWBASE || CONFIG_RAMSTAGE_LIBHWBASE
364 romstage-y += spd_bin.c
366 ifeq ($(CONFIG_HAVE_SPD_IN_CBFS),y)
367 LIB_SPD_BIN = $(obj)/spd.bin
369 LIB_SPD_DEPS = $(foreach f, $(SPD_SOURCES), src/mainboard/$(MAINBOARDDIR)/spd/$(f).spd.hex)
371 # Include spd ROM data
372 $(LIB_SPD_BIN): $(LIB_SPD_DEPS)
373 test -n "$(SPD_SOURCES)" || \
374 (echo "HAVE_SPD_IN_CBFS is set but SPD_SOURCES is empty" && exit 1)
375 test -n "$(LIB_SPD_DEPS)" || \
376 (echo "SPD_SOURCES is set but no SPD file was found" && exit 1)
377 if [ "$(SPD_SOURCES)" = "placeholder" ]; then \
378 printf '\0'; \
379 else \
380 for f in $(LIB_SPD_DEPS); do \
381 if [ ! -f $$f ]; then \
382 echo "File not found: $$f" >&2; \
383 exit 1; \
384 fi; \
385 for c in $$(cat $$f | grep --binary-files=text -v ^#); \
386 do printf $$(printf '\\%o' 0x$$c); \
387 done; \
388 done; \
389 fi > $@
391 cbfs-files-y += spd.bin
392 spd.bin-file := $(LIB_SPD_BIN)
393 spd.bin-type := spd
394 endif
396 ramstage-y += uuid.c
398 romstage-$(CONFIG_SPD_CACHE_IN_FMAP) += spd_cache.c
400 cbfs-files-y += cbfs_master_header
401 cbfs_master_header-file := cbfs_master_header.c:struct
402 cbfs_master_header-type := "cbfs header"
403 cbfs_master_header-position := 0
405 bootblock-$(CONFIG_ARCH_X86) += master_header_pointer.c
407 NEED_CBFS_POINTER=
409 ifneq ($(CONFIG_ARCH_X86),y)
410 NEED_CBFS_POINTER=y
411 endif
412 ifneq ($(CONFIG_BOOTBLOCK_IN_CBFS),y)
413 NEED_CBFS_POINTER=y
414 endif
416 cbfs-files-$(NEED_CBFS_POINTER) += header_pointer
417 header_pointer-file := master_header_pointer.c:struct
418 header_pointer-position := -4
419 header_pointer-type := "cbfs header"
421 romstage-y += ux_locales.c