soc/intel/alderlake/acpi.c: Don't look up coreboot CPU index
[coreboot.git] / src / lib / Makefile.inc
blob1c7bc22c1ef6fcf896a13f1da81b4244146a8859
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 all-y += list.c
33 decompressor-y += decompressor.c
34 $(call src-to-obj,decompressor,$(dir)/decompressor.c): $(objcbfs)/bootblock.lz4
35 $(call src-to-obj,decompressor,$(dir)/decompressor.c): CCACHE_EXTRAFILES=$(objcbfs)/bootblock.lz4
36 # Must reset CCACHE_EXTRAFILES or make applies it transitively to dependencies.
37 $(objcbfs)/bootblock.lz4: CCACHE_EXTRAFILES=
39 decompressor-y += delay.c
40 decompressor-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
41 decompressor-y += memchr.c
42 decompressor-y += memcmp.c
43 decompressor-$(CONFIG_CBFS_VERIFICATION) += metadata_hash.c
44 decompressor-y += prog_ops.c
45 decompressor-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
47 bootblock-y += bootblock.c
48 bootblock-y += prog_loaders.c
49 bootblock-y += prog_ops.c
50 bootblock-y += cbfs.c
51 bootblock-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
52 bootblock-y += libgcc.c
53 ifneq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y)
54 bootblock-$(CONFIG_CBFS_VERIFICATION) += metadata_hash.c
55 else # ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y)
56 verstage-$(CONFIG_CBFS_VERIFICATION) += metadata_hash.c
57 endif # ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y)
58 bootblock-$(CONFIG_GENERIC_UDELAY) += timer.c
60 bootblock-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
62 bootblock-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
63 bootblock-y += delay.c
64 bootblock-y += memchr.c
65 bootblock-y += memcmp.c
66 bootblock-y += boot_device.c
67 bootblock-y += fmap.c
69 verstage-y += prog_loaders.c
70 verstage-y += prog_ops.c
71 verstage-y += delay.c
72 verstage-y += cbfs.c
73 verstage-y += halt.c
74 verstage-y += fmap.c
75 verstage-y += libgcc.c
76 verstage-y += memcmp.c
77 verstage-y += string.c
79 verstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
80 verstage-y += boot_device.c
81 verstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
83 verstage-$(CONFIG_GENERIC_UDELAY) += timer.c
84 verstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
86 romstage-$(CONFIG_VENDOR_EMULATION) += ramdetect.c
87 romstage-y += prog_loaders.c
88 romstage-y += prog_ops.c
89 romstage-y += memchr.c
90 romstage-y += memcmp.c
91 $(foreach arch,$(ARCH_SUPPORTED),\
92             $(eval rmodules_$(arch)-y += memcmp.c) \
93             $(eval rmodules_$(arch)-y += rmodule.ld))
95 romstage-y += fmap.c
96 romstage-y += delay.c
97 romstage-y += cbfs.c
98 romstage-$(CONFIG_COMPRESS_RAMSTAGE) += lzma.c lzmadecode.c
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 += compute_ip_checksum.c
118 romstage-y += dimm_info_util.c
119 ifeq ($(CONFIG_COMPILER_GCC),y)
120 bootblock-$(CONFIG_ARCH_BOOTBLOCK_X86_32) += gcc.c
121 verstage-$(CONFIG_ARCH_VERSTAGE_X86_32) += gcc.c
122 romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += gcc.c
123 ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += gcc.c
124 smm-y += gcc.c
125 endif
127 romstage-$(CONFIG_GENERIC_UDELAY) += timer.c
129 ramstage-$(CONFIG_VENDOR_EMULATION) += ramdetect.c
130 ramstage-y += prog_loaders.c
131 ramstage-y += prog_ops.c
132 ramstage-y += hardwaremain.c
133 ramstage-y += selfboot.c
134 ramstage-y += coreboot_table.c
135 ramstage-y += bootmem.c
136 ramstage-y += fmap.c
137 ramstage-y += memchr.c
138 ramstage-y += memcmp.c
139 ramstage-y += malloc.c
140 ramstage-y += dimm_info_util.c
141 ramstage-y += delay.c
142 ramstage-y += fallback_boot.c
143 ramstage-y += compute_ip_checksum.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_FLATTENED_DEVICE_TREE) += device_tree.c
164 ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit.c
165 ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit_payload.c
167 romstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c
168 ramstage-$(CONFIG_TIMER_QUEUE) += timer_queue.c
170 romstage-$(CONFIG_COOP_MULTITASKING) += thread.c
171 ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c
173 romstage-y += cbmem_common.c
174 romstage-y += imd_cbmem.c
175 romstage-y += imd.c
177 ramstage-y += cbmem_common.c
178 ramstage-y += imd_cbmem.c
179 ramstage-y += imd.c
181 postcar-$(CONFIG_VENDOR_EMULATION) += 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
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
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
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
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
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
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
218 romstage-y += boot_device.c
219 ramstage-y += boot_device.c
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
230 bootblock-y += version.c
231 romstage-y += version.c
232 ramstage-y += version.c
233 smm-y += version.c
234 verstage-y += version.c
235 postcar-y += version.c
237 $(call src-to-obj,bootblock,$(dir)/version.c) : $(obj)/build.h
238 $(call src-to-obj,romstage,$(dir)/version.c) : $(obj)/build.h
239 $(call src-to-obj,ramstage,$(dir)/version.c) : $(obj)/build.h
240 $(call src-to-obj,smm,$(dir)/version.c) : $(obj)/build.h
241 $(call src-to-obj,verstage,$(dir)/version.c) : $(obj)/build.h
242 $(call src-to-obj,postcar,$(dir)/version.c) : $(obj)/build.h
244 $(call src-to-obj,bootblock,$(dir)/fmap.c) : $(obj)/fmap_config.h
245 $(call src-to-obj,romstage,$(dir)/fmap.c) : $(obj)/fmap_config.h
246 $(call src-to-obj,ramstage,$(dir)/fmap.c) : $(obj)/fmap_config.h
247 $(call src-to-obj,smm,$(dir)/fmap.c) : $(obj)/fmap_config.h
248 $(call src-to-obj,verstage,$(dir)/fmap.c) : $(obj)/fmap_config.h
249 $(call src-to-obj,postcar,$(dir)/fmap.c) : $(obj)/fmap_config.h
251 bootblock-y += bootmode.c
252 romstage-y += bootmode.c
253 ramstage-y += bootmode.c
254 verstage-y += bootmode.c
256 decompressor-y += halt.c
257 bootblock-y += halt.c
258 romstage-y += halt.c
259 ramstage-y += halt.c
260 smm-y += halt.c
262 decompressor-y += reset.c
263 bootblock-y += reset.c
264 verstage-y += reset.c
265 romstage-y += reset.c
266 postcar-y += reset.c
267 ramstage-y += reset.c
268 smm-y += reset.c
270 decompressor-y += string.c
271 bootblock-y += string.c
272 verstage-y += string.c
273 romstage-y += string.c
274 postcar-y += string.c
275 ramstage-y += string.c
276 smm-y += string.c
278 decompressor-y += crc_byte.c
279 bootblock-y += crc_byte.c
280 verstage-y += crc_byte.c
281 romstage-y += crc_byte.c
282 postcar-y += crc_byte.c
283 ramstage-y += crc_byte.c
284 smm-y += crc_byte.c
286 romstage-y += xxhash.c
287 ramstage-y += xxhash.c
289 postcar-y += bootmode.c
290 postcar-y += boot_device.c
291 postcar-y += cbfs.c
292 postcar-y += delay.c
293 postcar-y += fmap.c
294 postcar-y += gcc.c
295 postcar-y += halt.c
296 postcar-y += libgcc.c
297 postcar-$(CONFIG_COMPRESS_RAMSTAGE) += lzma.c lzmadecode.c
298 postcar-y += memchr.c
299 postcar-y += memcmp.c
300 postcar-y += prog_loaders.c
301 postcar-y += prog_ops.c
302 postcar-y += rmodule.c
303 postcar-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
304 postcar-$(CONFIG_GENERIC_UDELAY) += timer.c
306 # Use program.ld for all the platforms which use C fo the bootblock.
307 bootblock-y += program.ld
309 decompressor-y += program.ld
310 postcar-y += program.ld
311 romstage-y += program.ld
312 ramstage-y += program.ld
313 verstage-y += program.ld
315 ifeq ($(CONFIG_RELOCATABLE_MODULES),y)
316 ramstage-y += rmodule.c
317 romstage-y += rmodule.c
319 RMODULE_LDFLAGS  := -z defs -Bsymbolic
321 # rmodule_link_rules is a function that should be called with:
322 # (1) the object name to link
323 # (2) the dependencies
324 # (3) heap size of the relocatable module
325 # (4) arch for which the rmodules are to be linked
326 # It will create the necessary Make rules to create a rmodule. The resulting
327 # rmdoule is named $(1).rmod
328 define rmodule_link
329 $(strip $(1)): $(strip $(2)) $$(COMPILER_RT_rmodules_$(4)) $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) | $$(RMODTOOL)
330         $$(LD_rmodules_$(4)) $$(LDFLAGS_rmodules_$(4)) $(RMODULE_LDFLAGS) $($(1)-ldflags) -T $(call src-to-obj,rmodules_$(4),src/lib/rmodule.ld) --defsym=__heap_size=$(strip $(3)) -o $$@ --whole-archive --start-group $(filter-out %.ld,$(2)) --end-group
331         $$(NM_rmodules_$(4)) -n $$@ > $$(basename $$@).map
332 endef
334 endif
336 $(objcbfs)/%.debug.rmod: $(objcbfs)/%.debug | $(RMODTOOL)
337         $(RMODTOOL) -i $< -o $@
339 $(obj)/%.elf.rmod: $(obj)/%.elf | $(RMODTOOL)
340         $(RMODTOOL) -i $< -o $@
342 ramstage-$(CONFIG_RAMSTAGE_ADA) += cb.ads
344 ifeq ($(CONFIG_RAMSTAGE_LIBHWBASE),y)
346 to-ada-hex = $(eval $(1) := 16\\\#$(patsubst 0x%,%,$($(1)))\\\#)
348 $(call to-ada-hex,CONFIG_HWBASE_DEFAULT_MMCONF)
350 $(call add-special-class,hw)
351 hw-handler = $(eval ramstage-srcs += $$(addprefix $(1),$(2)))
353 $(call add-special-class,hw-gen)
354 hw-gen-handler = \
355         $(eval additional-dirs += $(dir $(2))) \
356         $(eval ramstage-srcs += $(2)) \
357         $(eval ramstage-ads-deps += $(2)) \
358         $(eval ramstage-adb-deps += $(2)) \
359         $(eval $(2): $(obj)/config.h)
361 subdirs-y += ../../3rdparty/libhwbase
363 ramstage-$(CONFIG_HAVE_MONOTONIC_TIMER) += hw-time-timer.adb
365 endif # CONFIG_RAMSTAGE_LIBHWBASE
367 romstage-y += spd_bin.c
369 ifeq ($(CONFIG_HAVE_SPD_IN_CBFS),y)
370 LIB_SPD_BIN = $(obj)/spd.bin
372 LIB_SPD_DEPS = $(foreach f, $(SPD_SOURCES), src/mainboard/$(MAINBOARDDIR)/spd/$(f).spd.hex)
374 # Include spd ROM data
375 $(LIB_SPD_BIN): $(LIB_SPD_DEPS)
376         test -n "$(SPD_SOURCES)" || \
377             (echo "HAVE_SPD_IN_CBFS is set but SPD_SOURCES is empty" && exit 1)
378         test -n "$(LIB_SPD_DEPS)" || \
379             (echo "SPD_SOURCES is set but no SPD file was found" && exit 1)
380         if [ "$(SPD_SOURCES)" = "placeholder" ]; then \
381             printf '\0'; \
382         else \
383             for f in $(LIB_SPD_DEPS); do \
384                 if [ ! -f $$f ]; then \
385                     echo "File not found: $$f" >&2; \
386                     exit 1; \
387                 fi; \
388                 for c in $$(cat $$f | grep --binary-files=text -v ^#); \
389                     do printf $$(printf '\\%o' 0x$$c); \
390                 done; \
391             done; \
392         fi > $@
394 cbfs-files-y += spd.bin
395 spd.bin-file := $(LIB_SPD_BIN)
396 spd.bin-type := spd
397 endif
399 ramstage-y += uuid.c
401 romstage-$(CONFIG_SPD_CACHE_IN_FMAP) += spd_cache.c
403 cbfs-files-y += cbfs_master_header
404 cbfs_master_header-file := cbfs_master_header.c:struct
405 cbfs_master_header-type := "cbfs header"
406 cbfs_master_header-position := 0
408 ifeq ($(CONFIG_ARCH_X86),y)
409 $(call src-to-obj,bootblock,$(dir)/master_header_pointer.c): $(obj)/fmap_config.h
410 bootblock-y += master_header_pointer.c
411 endif
413 NEED_CBFS_POINTER=
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
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"