1 # SPDX-License-Identifier: GPL-2.0-only
5 ifeq ($(CONFIG_UBSAN
),y
)
7 CFLAGS_ramstage
+= -fsanitize
=undefined
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
)
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
=
24 ifeq ($(CONFIG_ASAN_IN_RAMSTAGE
),y
)
26 CFLAGS_asan
+= --param asan-globals
=1
27 CFLAGS_ramstage
+= $(CFLAGS_asan
)
28 $(obj
)/ramstage
/lib
/asan.o
: CFLAGS_asan
=
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
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
67 verstage-y
+= prog_loaders.c
68 verstage-y
+= prog_ops.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))
96 ifneq ($(CONFIG_COMPRESS_RAMSTAGE_LZMA
)$(CONFIG_FSP_COMPRESS_FSP_M_LZMA
),)
97 romstage-y
+= 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
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
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
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
145 ramstage-y
+= lzma.c lzmadecode.c
146 ramstage-y
+= stack.c
147 ramstage-y
+= hexstrtobin.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
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
177 ramstage-y
+= cbmem_common.c
178 ramstage-y
+= imd_cbmem.c
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
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
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
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
230 all-y
+= identity.c version.c
231 smm-y
+= identity.c version.c
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
240 bootblock-y
+= bootmode.c
241 romstage-y
+= bootmode.c
242 ramstage-y
+= bootmode.c
243 verstage-y
+= bootmode.c
245 decompressor-y
+= halt.c
246 bootblock-y
+= halt.c
251 decompressor-y
+= reset.c
252 bootblock-y
+= reset.c
253 verstage-y
+= reset.c
254 romstage-y
+= reset.c
256 ramstage-y
+= reset.c
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
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
275 romstage-y
+= xxhash.c
276 ramstage-y
+= xxhash.c
278 postcar-y
+= bootmode.c
279 postcar-y
+= boot_device.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
295 # Use program.ld for all the platforms which use C fo the bootblock.
296 bootblock-y
+= program.
ld
298 decompressor-y
+= program.
ld
299 postcar-y
+= program.
ld
300 romstage-y
+= program.
ld
301 ramstage-y
+= program.
ld
302 verstage-y
+= program.
ld
304 ifeq ($(CONFIG_RELOCATABLE_MODULES
),y
)
305 ramstage-y
+= rmodule.c
306 romstage-y
+= rmodule.c
308 RMODULE_LDFLAGS
:= -z defs
-Bsymbolic
310 # rmodule_link_rules is a function that should be called with:
311 # (1) the object name to link
312 # (2) the dependencies
313 # (3) arch for which the rmodules are to be linked
314 # It will create the necessary Make rules to create a rmodule. The resulting
315 # rmdoule is named $(1).rmod
317 $(strip $(1)): $(strip $(2)) $$(COMPILER_RT_rmodules_
$(3)) $(call src-to-obj
,rmodules_
$(3),src
/lib
/rmodule.
ld) |
$$(RMODTOOL
)
318 $$(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
319 $$(NM_rmodules_
$(3)) -n
$$@
> $$(basename $$@
).map
324 $(objcbfs
)/%.debug.rmod
: $(objcbfs
)/%.debug |
$(RMODTOOL
)
325 $(RMODTOOL
) -i
$< -o
$@
327 $(obj
)/%.elf.rmod
: $(obj
)/%.elf |
$(RMODTOOL
)
328 $(RMODTOOL
) -i
$< -o
$@
330 romstage-
$(CONFIG_ROMSTAGE_ADA
) += cb.ads
331 ramstage-
$(CONFIG_RAMSTAGE_ADA
) += cb.ads
333 ifneq (,$(filter y
, $(CONFIG_RAMSTAGE_LIBHWBASE
) $(CONFIG_ROMSTAGE_LIBHWBASE
)))
335 to-ada-hex
= $(eval
$(1) := 16\\\
#$(patsubst 0x%,%,$($(1)))\\\#)
337 $(call to-ada-hex
,CONFIG_HWBASE_DEFAULT_MMCONF
)
339 libhwbase-stages
= $(foreach stage
, romstage ramstage
, \
340 $(if
$(filter y
,$(CONFIG_
$(call toupper
,$(stage
))_LIBHWBASE
)),$(stage
)))
342 $(call add-special-class
,hw
)
343 hw-handler
+=$(foreach stage
, $(libhwbase-stages
), \
344 $(eval
$(stage
)-srcs
+= $$(addprefix $(1),$(2))))
346 $(call add-special-class
,hw-gen
)
348 $(eval additional-dirs
+= $(dir $(2))) \
349 $(foreach stage
, $(libhwbase-stages
), \
350 $(eval
$(stage
)-srcs
+= $(2)) \
351 $(eval
$(stage
)-ads-deps
+= $(2)) \
352 $(eval
$(stage
)-adb-deps
+= $(2))) \
353 $(eval
$(2): $(obj
)/config.h
)
355 subdirs-y
+= ..
/..
/3rdparty
/libhwbase
357 $(foreach stage
,$(libhwbase-stages
), \
358 $(eval
$(stage
)-$(CONFIG_HAVE_MONOTONIC_TIMER
) += hw-time-timer.adb
))
360 endif # CONFIG_ROMSTAGE_LIBHWBASE || CONFIG_RAMSTAGE_LIBHWBASE
362 romstage-y
+= spd_bin.c
364 ifeq ($(CONFIG_HAVE_SPD_IN_CBFS
),y
)
365 LIB_SPD_BIN
= $(obj
)/spd.bin
367 LIB_SPD_DEPS
= $(foreach f
, $(SPD_SOURCES
), src
/mainboard
/$(MAINBOARDDIR
)/spd
/$(f
).spd.hex
)
369 # Include spd ROM data
370 $(LIB_SPD_BIN
): $(LIB_SPD_DEPS
)
371 test -n
"$(SPD_SOURCES)" || \
372 (echo
"HAVE_SPD_IN_CBFS is set but SPD_SOURCES is empty" && exit
1)
373 test -n
"$(LIB_SPD_DEPS)" || \
374 (echo
"SPD_SOURCES is set but no SPD file was found" && exit
1)
375 if
[ "$(SPD_SOURCES)" = "placeholder" ]; then \
378 for f in
$(LIB_SPD_DEPS
); do \
379 if
[ ! -f
$$f ]; then \
380 echo
"File not found: $$f" >&2; \
383 for c in
$$(cat
$$f | grep
--binary-files
=text
-v ^
#); \
384 do printf
$$(printf
'\\%o' 0x
$$c); \
389 cbfs-files-y
+= spd.bin
390 spd.bin-file
:= $(LIB_SPD_BIN
)
396 romstage-
$(CONFIG_SPD_CACHE_IN_FMAP
) += spd_cache.c
398 cbfs-files-y
+= cbfs_master_header
399 cbfs_master_header-file
:= cbfs_master_header.c
:struct
400 cbfs_master_header-type
:= "cbfs header"
401 cbfs_master_header-position
:= 0
403 bootblock-
$(CONFIG_ARCH_X86
) += master_header_pointer.c
407 ifneq ($(CONFIG_ARCH_X86
),y
)
410 ifneq ($(CONFIG_BOOTBLOCK_IN_CBFS
),y
)
414 cbfs-files-
$(NEED_CBFS_POINTER
) += header_pointer
415 header_pointer-file
:= master_header_pointer.c
:struct
416 header_pointer-position
:= -4
417 header_pointer-type
:= "cbfs header"
419 romstage-y
+= ux_locales.c