Debian Codegraph @

src/lib/Makefile.mk

raw symbols SCIP
1 # SPDX-License-Identifier: GPL-2.0-only
2
3 subdirs-y += gnat
4
5 ifeq ($(CONFIG_UBSAN),y)
6 ramstage-y += ubsan.c
7 CFLAGS_ramstage += -fsanitize=undefined
8 endif
9
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
15
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
23
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
30
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=
36
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
44
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
57
58 bootblock-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
59
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
66
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
76
77 verstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
78 verstage-y += boot_device.c
79 verstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
80
81 verstage-$(CONFIG_GENERIC_UDELAY) += timer.c
82 verstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
83
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))
92
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
113
114 romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
115 romstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
116
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
125
126 romstage-$(CONFIG_GENERIC_UDELAY) += timer.c
127
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_BMP_LOGO) += render_bmp.c
152 ramstage-$(CONFIG_BOOTSPLASH) += bootsplash.c
153 ramstage-$(CONFIG_BOOTSPLASH) += jpeg.c
154 ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
155 ramstage-$(CONFIG_COVERAGE) += libgcov.c
156 ramstage-y += dp_aux.c
157 ramstage-y += edid.c
158 ramstage-y += edid_fill_fb.c
159 ramstage-y += memrange.c
160 ramstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
161 ramstage-$(CONFIG_GENERIC_UDELAY) += timer.c
162 ramstage-y += b64_decode.c
163 ramstage-$(CONFIG_ACPI_NHLT) += nhlt.c
164 ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit.c
165 ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit_payload.c
166
167 romstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c
168 ramstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c
169
170 romstage-$(CONFIG_COOP_MULTITASKING) += thread.c
171 ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c
172
173 romstage-y += cbmem_common.c
174 romstage-y += imd_cbmem.c
175 romstage-y += imd.c
176
177 ramstage-y += cbmem_common.c
178 ramstage-y += imd_cbmem.c
179 ramstage-y += imd.c
180
181 postcar-$(CONFIG_PROBE_RAM) += ramdetect.c
182 postcar-y += cbmem_common.c
183 postcar-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
184 postcar-y += imd_cbmem.c
185 postcar-y += imd.c
186 postcar-y += romstage_handoff.c
187
188 bootblock-y += hexdump.c
189 postcar-y += hexdump.c
190 ramstage-y += hexdump.c
191 romstage-y += hexdump.c
192 verstage-y += hexdump.c
193 smm-y += hexdump.c
194
195 bootblock-$(CONFIG_FW_CONFIG) += fw_config.c
196 verstage-$(CONFIG_FW_CONFIG) += fw_config.c
197 romstage-$(CONFIG_FW_CONFIG) += fw_config.c
198 ramstage-$(CONFIG_FW_CONFIG) += fw_config.c
199
200 bootblock-$(CONFIG_ESPI_DEBUG) += espi_debug.c
201 verstage-$(CONFIG_ESPI_DEBUG) += espi_debug.c
202 romstage-$(CONFIG_ESPI_DEBUG) += espi_debug.c
203 ramstage-$(CONFIG_ESPI_DEBUG) += espi_debug.c
204
205 bootblock-$(CONFIG_REG_SCRIPT) += reg_script.c
206 verstage-$(CONFIG_REG_SCRIPT) += reg_script.c
207 romstage-$(CONFIG_REG_SCRIPT) += reg_script.c
208 ramstage-$(CONFIG_REG_SCRIPT) += reg_script.c
209
210 ramstage-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c
211 romstage-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c
212 postcar-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c
213
214 ramstage-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c
215 romstage-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c
216 postcar-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c
217
218 romstage-y += boot_device.c
219 ramstage-y += boot_device.c
220
221 smm-y += boot_device.c
222 smm-y += delay.c
223 smm-y += fmap.c
224 smm-y += cbfs.c memcmp.c
225 smm-$(CONFIG_GENERIC_UDELAY) += timer.c
226 ifeq ($(CONFIG_DEBUG_SMI),y)
227 smm-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
228 endif
229
230 all-y += identity.c version.c
231 smm-y += identity.c version.c
232
233 $(call src-to-obj,bootblock,$(dir)/version.c) : $(obj)/build.h
234 $(call src-to-obj,romstage,$(dir)/version.c) : $(obj)/build.h
235 $(call src-to-obj,ramstage,$(dir)/version.c) : $(obj)/build.h
236 $(call src-to-obj,smm,$(dir)/version.c) : $(obj)/build.h
237 $(call src-to-obj,verstage,$(dir)/version.c) : $(obj)/build.h
238 $(call src-to-obj,postcar,$(dir)/version.c) : $(obj)/build.h
239
240 bootblock-y += bootmode.c
241 romstage-y += bootmode.c
242 ramstage-y += bootmode.c
243 verstage-y += bootmode.c
244
245 decompressor-y += halt.c
246 bootblock-y += halt.c
247 romstage-y += halt.c
248 ramstage-y += halt.c
249 smm-y += halt.c
250
251 decompressor-y += reset.c
252 bootblock-y += reset.c
253 verstage-y += reset.c
254 romstage-y += reset.c
255 postcar-y += reset.c
256 ramstage-y += reset.c
257 smm-y += reset.c
258
259 decompressor-y += string.c
260 bootblock-y += string.c
261 verstage-y += string.c
262 romstage-y += string.c
263 postcar-y += string.c
264 ramstage-y += string.c
265 smm-y += string.c
266
267 decompressor-y += crc_byte.c
268 bootblock-y += crc_byte.c
269 verstage-y += crc_byte.c
270 romstage-y += crc_byte.c
271 postcar-y += crc_byte.c
272 ramstage-y += crc_byte.c
273 smm-y += crc_byte.c
274
275 romstage-y += xxhash.c
276 ramstage-y += xxhash.c
277
278 postcar-y += bootmode.c
279 postcar-y += boot_device.c
280 postcar-y += cbfs.c
281 postcar-y += delay.c
282 postcar-y += fmap.c
283 postcar-y += gcc.c
284 postcar-y += halt.c
285 postcar-y += libgcc.c
286 postcar-$(CONFIG_COMPRESS_RAMSTAGE_LZMA) += lzma.c lzmadecode.c
287 postcar-y += memchr.c
288 postcar-y += memcmp.c
289 postcar-y += prog_loaders.c
290 postcar-y += prog_ops.c
291 postcar-y += rmodule.c
292 postcar-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
293 postcar-$(CONFIG_GENERIC_UDELAY) += timer.c
294
295 all-$(CONFIG_ARCH_ARM) += io.c
296 all-$(CONFIG_ARCH_ARM64) += io.c
297 all-$(CONFIG_ARCH_RISCV) += io.c
298
299 # Use program.ld for all the platforms which use C fo the bootblock.
300 bootblock-y += program.ld
301
302 decompressor-y += program.ld
303 postcar-y += program.ld
304 romstage-y += program.ld
305 ramstage-y += program.ld
306 verstage-y += program.ld
307
308 ifeq ($(CONFIG_RELOCATABLE_MODULES),y)
309 ramstage-y += rmodule.c
310 romstage-y += rmodule.c
311
312 RMODULE_LDFLAGS := -z defs -Bsymbolic
313
314 # rmodule_link_rules is a function that should be called with:
315 # (1) the object name to link
316 # (2) the dependencies
317 # (3) arch for which the rmodules are to be linked
318 # It will create the necessary Make rules to create a rmodule. The resulting
319 # rmdoule is named $(1).rmod
320 define rmodule_link
321 $(strip $(1)): $(strip $(2)) $$(COMPILER_RT_rmodules_$(3)) $(call src-to-obj,rmodules_$(3),src/lib/rmodule.ld) | $$(RMODTOOL)
322 ifeq ($(CONFIG_LTO),y)
323 $$(CC_rmodules_$(3)) $$(CPPFLAGS_rmodules_$(3)) $$(CFLAGS_rmodules_$(3)) $$(LDFLAGS_rmodules_$(3):%=-Wl,%) $$(COMPILER_RT_FLAGS_rmodules_$(3):%=-Wl,%) $(RMODULE_LDFLAGS) $($(1)-ldflags:%=-Wl,%) -T $(call src-to-obj,rmodules_$(3),src/lib/rmodule.ld) -o $$@ -Wl,--whole-archive -Wl,--start-group $(filter-out %.ld,$(2)) -Wl,--no-whole-archive $$(COMPILER_RT_rmodules_$(3)) -Wl,--end-group
324 else
325 $$(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)) --no-whole-archive $$(COMPILER_RT_rmodules_$(3)) --end-group
326 endif
327 $$(NM_rmodules_$(3)) -n $$@ > $$(basename $$@).map
328 endef
329
330 endif
331
332 $(objcbfs)/%.debug.rmod: $(objcbfs)/%.debug | $(RMODTOOL)
333 $(RMODTOOL) -i $< -o $@
334
335 $(obj)/%.elf.rmod: $(obj)/%.elf | $(RMODTOOL)
336 $(RMODTOOL) -i $< -o $@
337
338 romstage-$(CONFIG_ROMSTAGE_ADA) += cb.ads
339 ramstage-$(CONFIG_RAMSTAGE_ADA) += cb.ads
340
341 ifneq (,$(filter y, $(CONFIG_RAMSTAGE_LIBHWBASE) $(CONFIG_ROMSTAGE_LIBHWBASE)))
342
343 to-ada-hex = $(eval $(1) := 16\\\#$(patsubst 0x%,%,$($(1)))\\\#)
344
345 $(call to-ada-hex,CONFIG_HWBASE_DEFAULT_MMCONF)
346
347 libhwbase-stages = $(foreach stage, romstage ramstage, \
348 $(if $(filter y,$(CONFIG_$(call toupper,$(stage))_LIBHWBASE)),$(stage)))
349
350 $(call add-special-class,hw)
351 hw-handler +=$(foreach stage, $(libhwbase-stages), \
352 $(eval $(stage)-srcs += $$(addprefix $(1),$(2))))
353
354 $(call add-special-class,hw-gen)
355 hw-gen-handler = \
356 $(eval additional-dirs += $(dir $(2))) \
357 $(foreach stage, $(libhwbase-stages), \
358 $(eval $(stage)-srcs += $(2)) \
359 $(eval $(stage)-ads-deps += $(2)) \
360 $(eval $(stage)-adb-deps += $(2))) \
361 $(eval $(2): $(obj)/config.h)
362
363 subdirs-y += ../../3rdparty/libhwbase
364
365 $(foreach stage,$(libhwbase-stages), \
366 $(eval $(stage)-$(CONFIG_HAVE_MONOTONIC_TIMER) += hw-time-timer.adb))
367
368 endif # CONFIG_ROMSTAGE_LIBHWBASE || CONFIG_RAMSTAGE_LIBHWBASE
369
370 romstage-y += spd_bin.c
371
372 ifeq ($(CONFIG_HAVE_SPD_IN_CBFS),y)
373 LIB_SPD_BIN = $(obj)/spd.bin
374
375 LIB_SPD_DEPS = $(foreach f, $(SPD_SOURCES), src/mainboard/$(MAINBOARDDIR)/spd/$(f).spd.hex)
376
377 # Include spd ROM data
378 $(LIB_SPD_BIN): $(LIB_SPD_DEPS)
379 test -n "$(SPD_SOURCES)" || \
380 (echo "HAVE_SPD_IN_CBFS is set but SPD_SOURCES is empty" && exit 1)
381 test -n "$(LIB_SPD_DEPS)" || \
382 (echo "SPD_SOURCES is set but no SPD file was found" && exit 1)
383 if [ "$(SPD_SOURCES)" = "placeholder" ]; then \
384 printf '\0'; \
385 else \
386 for f in $(LIB_SPD_DEPS); do \
387 if [ ! -f $$f ]; then \
388 echo "File not found: $$f" >&2; \
389 exit 1; \
390 fi; \
391 for c in $$(cat $$f | grep --binary-files=text -v ^#); \
392 do printf $$(printf '\\%o' 0x$$c); \
393 done; \
394 done; \
395 fi > $@
396
397 cbfs-files-y += spd.bin
398 spd.bin-file := $(LIB_SPD_BIN)
399 spd.bin-type := spd
400 endif
401
402 ramstage-y += uuid.c
403
404 romstage-$(CONFIG_SPD_CACHE_IN_FMAP) += spd_cache.c
405
406 cbfs-files-y += cbfs_master_header
407 cbfs_master_header-file := cbfs_master_header.c:struct
408 cbfs_master_header-type := "cbfs header"
409 cbfs_master_header-position := 0
410
411 bootblock-$(CONFIG_ARCH_X86) += master_header_pointer.c
412
413 NEED_CBFS_POINTER=
414
415 ifneq ($(CONFIG_ARCH_X86),y)
416 NEED_CBFS_POINTER=y
417 endif
418 ifneq ($(CONFIG_BOOTBLOCK_IN_CBFS),y)
419 NEED_CBFS_POINTER=y
420 endif
421
422 cbfs-files-$(NEED_CBFS_POINTER) += header_pointer
423 header_pointer-file := master_header_pointer.c:struct
424 header_pointer-position := -4
425 header_pointer-type := "cbfs header"
426
427 romstage-y += ux_locales.c
428
429 # Add logo to the cbfs image
430 BMP_LOGO_COMPRESS_FLAG := $(CBFS_COMPRESS_FLAG)
431 ifeq ($(CONFIG_BMP_LOGO_COMPRESS_LZMA),y)
432 BMP_LOGO_COMPRESS_FLAG := LZMA
433 else ifeq ($(CONFIG_BMP_LOGO_COMPRESS_LZ4),y)
434 BMP_LOGO_COMPRESS_FLAG := LZ4
435 endif
436
437 define add_bmp_logo_file_to_cbfs
438 cbfs-files-$$($(1)) += $(2)
439 $(2)-file := $$(call strip_quotes,$$($(3)))
440 $(2)-type := raw
441 $(2)-compression := $$(BMP_LOGO_COMPRESS_FLAG)
442 endef
443
444 ifneq ($(CONFIG_HAVE_CUSTOM_BMP_LOGO),y)
445 $(eval $(call add_bmp_logo_file_to_cbfs,CONFIG_BMP_LOGO,logo.bmp,CONFIG_BMP_LOGO_FILE_NAME))
446 endif
447
448 $(eval $(call add_bmp_logo_file_to_cbfs,CONFIG_PLATFORM_HAS_LOW_BATTERY_INDICATOR, \
449 low_battery.bmp,CONFIG_PLATFORM_LOW_BATTERY_INDICATOR_LOGO_PATH))
450 $(eval $(call add_bmp_logo_file_to_cbfs,CONFIG_SPLASH_SCREEN_FOOTER, \
451 footer_logo.bmp,CONFIG_SPLASH_SCREEN_FOOTER_LOGO_PATH))