1# SPDX-License-Identifier: GPL-2.0-only 2 3subdirs-y += gnat 4 5ifeq ($(CONFIG_UBSAN),y) 6ramstage-y += ubsan.c 7CFLAGS_ramstage += -fsanitize=undefined 8endif 9 10# Ensure that asan_shadow_offset_callback patch is applied to GCC before ASan is used. 11CFLAGS_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 16ifeq ($(CONFIG_ASAN_IN_ROMSTAGE),y) 17romstage-y += asan.c 18CFLAGS_asan += --param asan-globals=0 19CFLAGS_romstage += $(CFLAGS_asan) 20# Allow memory access without __asan_load and __asan_store checks. 21$(obj)/romstage/lib/asan.o: CFLAGS_asan = 22endif 23 24ifeq ($(CONFIG_ASAN_IN_RAMSTAGE),y) 25ramstage-y += asan.c 26CFLAGS_asan += --param asan-globals=1 27CFLAGS_ramstage += $(CFLAGS_asan) 28$(obj)/ramstage/lib/asan.o: CFLAGS_asan = 29endif 30 31decompressor-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 37decompressor-y += delay.c 38decompressor-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c 39decompressor-y += memchr.c 40decompressor-y += memcmp.c 41decompressor-$(CONFIG_CBFS_VERIFICATION) += metadata_hash.c 42decompressor-y += prog_ops.c 43decompressor-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c 44 45bootblock-y += bootblock.c 46bootblock-y += prog_loaders.c 47bootblock-y += prog_ops.c 48bootblock-y += cbfs.c 49bootblock-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c 50bootblock-y += libgcc.c 51ifneq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y) 52bootblock-$(CONFIG_CBFS_VERIFICATION) += metadata_hash.c 53else # ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y) 54verstage-$(CONFIG_CBFS_VERIFICATION) += metadata_hash.c 55endif # ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y) 56bootblock-$(CONFIG_GENERIC_UDELAY) += timer.c 57 58bootblock-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c 59 60bootblock-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c 61bootblock-y += delay.c 62bootblock-y += memchr.c 63bootblock-y += memcmp.c 64bootblock-y += boot_device.c 65bootblock-y += fmap.c 66 67verstage-y += prog_loaders.c 68verstage-y += prog_ops.c 69verstage-y += delay.c 70verstage-y += cbfs.c 71verstage-y += halt.c 72verstage-y += fmap.c 73verstage-y += libgcc.c 74verstage-y += memcmp.c 75verstage-y += string.c 76 77verstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c 78verstage-y += boot_device.c 79verstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c 80 81verstage-$(CONFIG_GENERIC_UDELAY) += timer.c 82verstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c 83 84romstage-$(CONFIG_PROBE_RAM) += ramdetect.c 85romstage-y += prog_loaders.c 86romstage-y += prog_ops.c 87romstage-y += memchr.c 88romstage-y += memcmp.c 89$(foreach arch,$(ARCH_SUPPORTED),\ 90 $(eval rmodules_$(arch)-y += memcmp.c) \ 91 $(eval rmodules_$(arch)-y += rmodule.ld)) 92 93romstage-y += fmap.c 94romstage-y += delay.c 95romstage-y += cbfs.c 96ifneq ($(CONFIG_COMPRESS_RAMSTAGE_LZMA)$(CONFIG_FSP_COMPRESS_FSP_M_LZMA),) 97romstage-y += lzma.c lzmadecode.c 98endif 99romstage-y += libgcc.c 100romstage-y += memrange.c 101romstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c 102ramstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c 103romstage-y += ramtest.c 104romstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c 105ramstage-y += region_file.c 106romstage-y += region_file.c 107ramstage-y += romstage_handoff.c 108romstage-y += romstage_handoff.c 109romstage-y += selfboot.c 110romstage-y += stack.c 111romstage-y += rtc.c 112ramstage-y += rtc.c 113 114romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c 115romstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c 116 117romstage-y += dimm_info_util.c 118ifeq ($(CONFIG_COMPILER_GCC),y) 119bootblock-$(CONFIG_ARCH_BOOTBLOCK_X86_32) += gcc.c 120verstage-$(CONFIG_ARCH_VERSTAGE_X86_32) += gcc.c 121romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += gcc.c 122ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += gcc.c 123smm-y += gcc.c 124endif 125 126romstage-$(CONFIG_GENERIC_UDELAY) += timer.c 127 128ramstage-$(CONFIG_PROBE_RAM) += ramdetect.c 129ramstage-y += prog_loaders.c 130ramstage-y += prog_ops.c 131ramstage-y += hardwaremain.c 132ramstage-y += selfboot.c 133ramstage-y += coreboot_table.c 134ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c 135ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios_defaults.c 136ramstage-y += bootmem.c 137ramstage-y += fmap.c 138ramstage-y += memchr.c 139ramstage-y += memcmp.c 140ramstage-y += malloc.c 141ramstage-y += dimm_info_util.c 142ramstage-y += delay.c 143ramstage-y += fallback_boot.c 144ramstage-y += cbfs.c 145ramstage-y += lzma.c lzmadecode.c 146ramstage-y += stack.c 147ramstage-y += hexstrtobin.c 148ramstage-y += wrdd.c 149ramstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c 150ramstage-$(CONFIG_BMP_LOGO) += bmp_logo.c 151ramstage-$(CONFIG_BOOTSPLASH) += bootsplash.c 152ramstage-$(CONFIG_BOOTSPLASH) += jpeg.c 153ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c 154ramstage-$(CONFIG_COVERAGE) += libgcov.c 155ramstage-y += dp_aux.c 156ramstage-y += edid.c 157ramstage-y += edid_fill_fb.c 158ramstage-y += memrange.c 159ramstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c 160ramstage-$(CONFIG_GENERIC_UDELAY) += timer.c 161ramstage-y += b64_decode.c 162ramstage-$(CONFIG_ACPI_NHLT) += nhlt.c 163ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit.c 164ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit_payload.c 165 166romstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c 167ramstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c 168 169romstage-$(CONFIG_COOP_MULTITASKING) += thread.c 170ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c 171 172romstage-y += cbmem_common.c 173romstage-y += imd_cbmem.c 174romstage-y += imd.c 175 176ramstage-y += cbmem_common.c 177ramstage-y += imd_cbmem.c 178ramstage-y += imd.c 179 180postcar-$(CONFIG_PROBE_RAM) += ramdetect.c 181postcar-y += cbmem_common.c 182postcar-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c 183postcar-y += imd_cbmem.c 184postcar-y += imd.c 185postcar-y += romstage_handoff.c 186 187bootblock-y += hexdump.c 188postcar-y += hexdump.c 189ramstage-y += hexdump.c 190romstage-y += hexdump.c 191verstage-y += hexdump.c 192smm-y += hexdump.c 193 194bootblock-$(CONFIG_FW_CONFIG) += fw_config.c 195verstage-$(CONFIG_FW_CONFIG) += fw_config.c 196romstage-$(CONFIG_FW_CONFIG) += fw_config.c 197ramstage-$(CONFIG_FW_CONFIG) += fw_config.c 198 199bootblock-$(CONFIG_ESPI_DEBUG) += espi_debug.c 200verstage-$(CONFIG_ESPI_DEBUG) += espi_debug.c 201romstage-$(CONFIG_ESPI_DEBUG) += espi_debug.c 202ramstage-$(CONFIG_ESPI_DEBUG) += espi_debug.c 203 204bootblock-$(CONFIG_REG_SCRIPT) += reg_script.c 205verstage-$(CONFIG_REG_SCRIPT) += reg_script.c 206romstage-$(CONFIG_REG_SCRIPT) += reg_script.c 207ramstage-$(CONFIG_REG_SCRIPT) += reg_script.c 208 209ramstage-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c 210romstage-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c 211postcar-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c 212 213ramstage-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c 214romstage-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c 215postcar-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c 216 217romstage-y += boot_device.c 218ramstage-y += boot_device.c 219 220smm-y += boot_device.c 221smm-y += delay.c 222smm-y += fmap.c 223smm-y += cbfs.c memcmp.c 224smm-$(CONFIG_GENERIC_UDELAY) += timer.c 225ifeq ($(CONFIG_DEBUG_SMI),y) 226smm-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c 227endif 228 229all-y += identity.c version.c 230smm-y += identity.c version.c 231 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 238 239bootblock-y += bootmode.c 240romstage-y += bootmode.c 241ramstage-y += bootmode.c 242verstage-y += bootmode.c 243 244decompressor-y += halt.c 245bootblock-y += halt.c 246romstage-y += halt.c 247ramstage-y += halt.c 248smm-y += halt.c 249 250decompressor-y += reset.c 251bootblock-y += reset.c 252verstage-y += reset.c 253romstage-y += reset.c 254postcar-y += reset.c 255ramstage-y += reset.c 256smm-y += reset.c 257 258decompressor-y += string.c 259bootblock-y += string.c 260verstage-y += string.c 261romstage-y += string.c 262postcar-y += string.c 263ramstage-y += string.c 264smm-y += string.c 265 266decompressor-y += crc_byte.c 267bootblock-y += crc_byte.c 268verstage-y += crc_byte.c 269romstage-y += crc_byte.c 270postcar-y += crc_byte.c 271ramstage-y += crc_byte.c 272smm-y += crc_byte.c 273 274romstage-y += xxhash.c 275ramstage-y += xxhash.c 276 277postcar-y += bootmode.c 278postcar-y += boot_device.c 279postcar-y += cbfs.c 280postcar-y += delay.c 281postcar-y += fmap.c 282postcar-y += gcc.c 283postcar-y += halt.c 284postcar-y += libgcc.c 285postcar-$(CONFIG_COMPRESS_RAMSTAGE_LZMA) += lzma.c lzmadecode.c 286postcar-y += memchr.c 287postcar-y += memcmp.c 288postcar-y += prog_loaders.c 289postcar-y += prog_ops.c 290postcar-y += rmodule.c 291postcar-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c 292postcar-$(CONFIG_GENERIC_UDELAY) += timer.c 293 294# Use program.ld for all the platforms which use C fo the bootblock. 295bootblock-y += program.ld 296 297decompressor-y += program.ld 298postcar-y += program.ld 299romstage-y += program.ld 300ramstage-y += program.ld 301verstage-y += program.ld 302 303ifeq ($(CONFIG_RELOCATABLE_MODULES),y) 304ramstage-y += rmodule.c 305romstage-y += rmodule.c 306 307RMODULE_LDFLAGS := -z defs -Bsymbolic 308 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 315define 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 319endef 320 321endif 322 323$(objcbfs)/%.debug.rmod: $(objcbfs)/%.debug | $(RMODTOOL) 324 $(RMODTOOL) -i $< -o $@ 325 326$(obj)/%.elf.rmod: $(obj)/%.elf | $(RMODTOOL) 327 $(RMODTOOL) -i $< -o $@ 328 329romstage-$(CONFIG_ROMSTAGE_ADA) += cb.ads 330ramstage-$(CONFIG_RAMSTAGE_ADA) += cb.ads 331 332ifneq (,$(filter y, $(CONFIG_RAMSTAGE_LIBHWBASE) $(CONFIG_ROMSTAGE_LIBHWBASE))) 333 334to-ada-hex = $(eval $(1) := 16\\\#$(patsubst 0x%,%,$($(1)))\\\#) 335 336$(call to-ada-hex,CONFIG_HWBASE_DEFAULT_MMCONF) 337 338libhwbase-stages = $(foreach stage, romstage ramstage, \ 339 $(if $(filter y,$(CONFIG_$(call toupper,$(stage))_LIBHWBASE)),$(stage))) 340 341$(call add-special-class,hw) 342hw-handler +=$(foreach stage, $(libhwbase-stages), \ 343 $(eval $(stage)-srcs += $$(addprefix $(1),$(2)))) 344 345$(call add-special-class,hw-gen) 346hw-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) 353 354subdirs-y += ../../3rdparty/libhwbase 355 356$(foreach stage,$(libhwbase-stages), \ 357 $(eval $(stage)-$(CONFIG_HAVE_MONOTONIC_TIMER) += hw-time-timer.adb)) 358 359endif # CONFIG_ROMSTAGE_LIBHWBASE || CONFIG_RAMSTAGE_LIBHWBASE 360 361romstage-y += spd_bin.c 362 363ifeq ($(CONFIG_HAVE_SPD_IN_CBFS),y) 364LIB_SPD_BIN = $(obj)/spd.bin 365 366LIB_SPD_DEPS = $(foreach f, $(SPD_SOURCES), src/mainboard/$(MAINBOARDDIR)/spd/$(f).spd.hex) 367 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 > $@ 387 388cbfs-files-y += spd.bin 389spd.bin-file := $(LIB_SPD_BIN) 390spd.bin-type := spd 391endif 392 393ramstage-y += uuid.c 394 395romstage-$(CONFIG_SPD_CACHE_IN_FMAP) += spd_cache.c 396 397cbfs-files-y += cbfs_master_header 398cbfs_master_header-file := cbfs_master_header.c:struct 399cbfs_master_header-type := "cbfs header" 400cbfs_master_header-position := 0 401 402bootblock-$(CONFIG_ARCH_X86) += master_header_pointer.c 403 404NEED_CBFS_POINTER= 405 406ifneq ($(CONFIG_ARCH_X86),y) 407NEED_CBFS_POINTER=y 408endif 409ifneq ($(CONFIG_BOOTBLOCK_IN_CBFS),y) 410NEED_CBFS_POINTER=y 411endif 412 413cbfs-files-$(NEED_CBFS_POINTER) += header_pointer 414header_pointer-file := master_header_pointer.c:struct 415header_pointer-position := -4 416header_pointer-type := "cbfs header" 417 418romstage-y += ux_locales.c 419