mb/google/byra: Add VBTs for variants missing them
[coreboot.git] / src / lib / Makefile.mk
blob56d8b1afd57de8c7dd1a2f870c09389d52827f31
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_TIMER_QUEUE) += timer_queue.c
167 ramstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c
169 romstage-$(CONFIG_COOP_MULTITASKING) += thread.c
170 ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c
172 romstage-y += cbmem_common.c
173 romstage-y += imd_cbmem.c
174 romstage-y += imd.c
176 ramstage-y += cbmem_common.c
177 ramstage-y += imd_cbmem.c
178 ramstage-y += imd.c
180 postcar-$(CONFIG_PROBE_RAM) += ramdetect.c
181 postcar-y += cbmem_common.c
182 postcar-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
183 postcar-y += imd_cbmem.c
184 postcar-y += imd.c
185 postcar-y += romstage_handoff.c
187 bootblock-y += hexdump.c
188 postcar-y += hexdump.c
189 ramstage-y += hexdump.c
190 romstage-y += hexdump.c
191 verstage-y += hexdump.c
192 smm-y += hexdump.c
194 bootblock-$(CONFIG_FW_CONFIG) += fw_config.c
195 verstage-$(CONFIG_FW_CONFIG) += fw_config.c
196 romstage-$(CONFIG_FW_CONFIG) += fw_config.c
197 ramstage-$(CONFIG_FW_CONFIG) += fw_config.c
199 bootblock-$(CONFIG_ESPI_DEBUG) += espi_debug.c
200 verstage-$(CONFIG_ESPI_DEBUG) += espi_debug.c
201 romstage-$(CONFIG_ESPI_DEBUG) += espi_debug.c
202 ramstage-$(CONFIG_ESPI_DEBUG) += espi_debug.c
204 bootblock-$(CONFIG_REG_SCRIPT) += reg_script.c
205 verstage-$(CONFIG_REG_SCRIPT) += reg_script.c
206 romstage-$(CONFIG_REG_SCRIPT) += reg_script.c
207 ramstage-$(CONFIG_REG_SCRIPT) += reg_script.c
209 ramstage-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c
210 romstage-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c
211 postcar-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c
213 ramstage-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c
214 romstage-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c
215 postcar-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c
217 romstage-y += boot_device.c
218 ramstage-y += boot_device.c
220 smm-y += boot_device.c
221 smm-y += delay.c
222 smm-y += fmap.c
223 smm-y += cbfs.c memcmp.c
224 smm-$(CONFIG_GENERIC_UDELAY) += timer.c
225 ifeq ($(CONFIG_DEBUG_SMI),y)
226 smm-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
227 endif
229 all-y += identity.c version.c
230 smm-y += identity.c version.c
232 $(call src-to-obj,bootblock,$(dir)/version.c) : $(obj)/build.h
233 $(call src-to-obj,romstage,$(dir)/version.c) : $(obj)/build.h
234 $(call src-to-obj,ramstage,$(dir)/version.c) : $(obj)/build.h
235 $(call src-to-obj,smm,$(dir)/version.c) : $(obj)/build.h
236 $(call src-to-obj,verstage,$(dir)/version.c) : $(obj)/build.h
237 $(call src-to-obj,postcar,$(dir)/version.c) : $(obj)/build.h
239 bootblock-y += bootmode.c
240 romstage-y += bootmode.c
241 ramstage-y += bootmode.c
242 verstage-y += bootmode.c
244 decompressor-y += halt.c
245 bootblock-y += halt.c
246 romstage-y += halt.c
247 ramstage-y += halt.c
248 smm-y += halt.c
250 decompressor-y += reset.c
251 bootblock-y += reset.c
252 verstage-y += reset.c
253 romstage-y += reset.c
254 postcar-y += reset.c
255 ramstage-y += reset.c
256 smm-y += reset.c
258 decompressor-y += string.c
259 bootblock-y += string.c
260 verstage-y += string.c
261 romstage-y += string.c
262 postcar-y += string.c
263 ramstage-y += string.c
264 smm-y += string.c
266 decompressor-y += crc_byte.c
267 bootblock-y += crc_byte.c
268 verstage-y += crc_byte.c
269 romstage-y += crc_byte.c
270 postcar-y += crc_byte.c
271 ramstage-y += crc_byte.c
272 smm-y += crc_byte.c
274 romstage-y += xxhash.c
275 ramstage-y += xxhash.c
277 postcar-y += bootmode.c
278 postcar-y += boot_device.c
279 postcar-y += cbfs.c
280 postcar-y += delay.c
281 postcar-y += fmap.c
282 postcar-y += gcc.c
283 postcar-y += halt.c
284 postcar-y += libgcc.c
285 postcar-$(CONFIG_COMPRESS_RAMSTAGE_LZMA) += lzma.c lzmadecode.c
286 postcar-y += memchr.c
287 postcar-y += memcmp.c
288 postcar-y += prog_loaders.c
289 postcar-y += prog_ops.c
290 postcar-y += rmodule.c
291 postcar-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
292 postcar-$(CONFIG_GENERIC_UDELAY) += timer.c
294 # Use program.ld for all the platforms which use C fo the bootblock.
295 bootblock-y += program.ld
297 decompressor-y += program.ld
298 postcar-y += program.ld
299 romstage-y += program.ld
300 ramstage-y += program.ld
301 verstage-y += program.ld
303 ifeq ($(CONFIG_RELOCATABLE_MODULES),y)
304 ramstage-y += rmodule.c
305 romstage-y += rmodule.c
307 RMODULE_LDFLAGS := -z defs -Bsymbolic
309 # rmodule_link_rules is a function that should be called with:
310 # (1) the object name to link
311 # (2) the dependencies
312 # (3) arch for which the rmodules are to be linked
313 # It will create the necessary Make rules to create a rmodule. The resulting
314 # rmdoule is named $(1).rmod
315 define rmodule_link
316 $(strip $(1)): $(strip $(2)) $$(COMPILER_RT_rmodules_$(3)) $(call src-to-obj,rmodules_$(3),src/lib/rmodule.ld) | $$(RMODTOOL)
317 $$(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
318 $$(NM_rmodules_$(3)) -n $$@ > $$(basename $$@).map
319 endef
321 endif
323 $(objcbfs)/%.debug.rmod: $(objcbfs)/%.debug | $(RMODTOOL)
324 $(RMODTOOL) -i $< -o $@
326 $(obj)/%.elf.rmod: $(obj)/%.elf | $(RMODTOOL)
327 $(RMODTOOL) -i $< -o $@
329 romstage-$(CONFIG_ROMSTAGE_ADA) += cb.ads
330 ramstage-$(CONFIG_RAMSTAGE_ADA) += cb.ads
332 ifneq (,$(filter y, $(CONFIG_RAMSTAGE_LIBHWBASE) $(CONFIG_ROMSTAGE_LIBHWBASE)))
334 to-ada-hex = $(eval $(1) := 16\\\#$(patsubst 0x%,%,$($(1)))\\\#)
336 $(call to-ada-hex,CONFIG_HWBASE_DEFAULT_MMCONF)
338 libhwbase-stages = $(foreach stage, romstage ramstage, \
339 $(if $(filter y,$(CONFIG_$(call toupper,$(stage))_LIBHWBASE)),$(stage)))
341 $(call add-special-class,hw)
342 hw-handler +=$(foreach stage, $(libhwbase-stages), \
343 $(eval $(stage)-srcs += $$(addprefix $(1),$(2))))
345 $(call add-special-class,hw-gen)
346 hw-gen-handler = \
347 $(eval additional-dirs += $(dir $(2))) \
348 $(foreach stage, $(libhwbase-stages), \
349 $(eval $(stage)-srcs += $(2)) \
350 $(eval $(stage)-ads-deps += $(2)) \
351 $(eval $(stage)-adb-deps += $(2))) \
352 $(eval $(2): $(obj)/config.h)
354 subdirs-y += ../../3rdparty/libhwbase
356 $(foreach stage,$(libhwbase-stages), \
357 $(eval $(stage)-$(CONFIG_HAVE_MONOTONIC_TIMER) += hw-time-timer.adb))
359 endif # CONFIG_ROMSTAGE_LIBHWBASE || CONFIG_RAMSTAGE_LIBHWBASE
361 romstage-y += spd_bin.c
363 ifeq ($(CONFIG_HAVE_SPD_IN_CBFS),y)
364 LIB_SPD_BIN = $(obj)/spd.bin
366 LIB_SPD_DEPS = $(foreach f, $(SPD_SOURCES), src/mainboard/$(MAINBOARDDIR)/spd/$(f).spd.hex)
368 # Include spd ROM data
369 $(LIB_SPD_BIN): $(LIB_SPD_DEPS)
370 test -n "$(SPD_SOURCES)" || \
371 (echo "HAVE_SPD_IN_CBFS is set but SPD_SOURCES is empty" && exit 1)
372 test -n "$(LIB_SPD_DEPS)" || \
373 (echo "SPD_SOURCES is set but no SPD file was found" && exit 1)
374 if [ "$(SPD_SOURCES)" = "placeholder" ]; then \
375 printf '\0'; \
376 else \
377 for f in $(LIB_SPD_DEPS); do \
378 if [ ! -f $$f ]; then \
379 echo "File not found: $$f" >&2; \
380 exit 1; \
381 fi; \
382 for c in $$(cat $$f | grep --binary-files=text -v ^#); \
383 do printf $$(printf '\\%o' 0x$$c); \
384 done; \
385 done; \
386 fi > $@
388 cbfs-files-y += spd.bin
389 spd.bin-file := $(LIB_SPD_BIN)
390 spd.bin-type := spd
391 endif
393 ramstage-y += uuid.c
395 romstage-$(CONFIG_SPD_CACHE_IN_FMAP) += spd_cache.c
397 cbfs-files-y += cbfs_master_header
398 cbfs_master_header-file := cbfs_master_header.c:struct
399 cbfs_master_header-type := "cbfs header"
400 cbfs_master_header-position := 0
402 bootblock-$(CONFIG_ARCH_X86) += master_header_pointer.c
404 NEED_CBFS_POINTER=
406 ifneq ($(CONFIG_ARCH_X86),y)
407 NEED_CBFS_POINTER=y
408 endif
409 ifneq ($(CONFIG_BOOTBLOCK_IN_CBFS),y)
410 NEED_CBFS_POINTER=y
411 endif
413 cbfs-files-$(NEED_CBFS_POINTER) += header_pointer
414 header_pointer-file := master_header_pointer.c:struct
415 header_pointer-position := -4
416 header_pointer-type := "cbfs header"
418 romstage-y += ux_locales.c