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_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
176 ramstage-y
+= cbmem_common.c
177 ramstage-y
+= imd_cbmem.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
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
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
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
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
250 decompressor-y
+= reset.c
251 bootblock-y
+= reset.c
252 verstage-y
+= reset.c
253 romstage-y
+= reset.c
255 ramstage-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
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
274 romstage-y
+= xxhash.c
275 ramstage-y
+= xxhash.c
277 postcar-y
+= bootmode.c
278 postcar-y
+= boot_device.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
316 $(strip $(1)): $(strip $(2)) $$(COMPILER_RT_rmodules_
$(3)) $(call src-to-obj
,rmodules_
$(3),src
/lib
/rmodule.
ld) |
$$(RMODTOOL
)
317 ifeq ($(CONFIG_LTO
),y
)
318 $$(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
320 $$(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
322 $$(NM_rmodules_
$(3)) -n
$$@
> $$(basename $$@
).map
327 $(objcbfs
)/%.debug.rmod
: $(objcbfs
)/%.debug |
$(RMODTOOL
)
328 $(RMODTOOL
) -i
$< -o
$@
330 $(obj
)/%.elf.rmod
: $(obj
)/%.elf |
$(RMODTOOL
)
331 $(RMODTOOL
) -i
$< -o
$@
333 romstage-
$(CONFIG_ROMSTAGE_ADA
) += cb.ads
334 ramstage-
$(CONFIG_RAMSTAGE_ADA
) += cb.ads
336 ifneq (,$(filter y
, $(CONFIG_RAMSTAGE_LIBHWBASE
) $(CONFIG_ROMSTAGE_LIBHWBASE
)))
338 to-ada-hex
= $(eval
$(1) := 16\\\
#$(patsubst 0x%,%,$($(1)))\\\#)
340 $(call to-ada-hex
,CONFIG_HWBASE_DEFAULT_MMCONF
)
342 libhwbase-stages
= $(foreach stage
, romstage ramstage
, \
343 $(if
$(filter y
,$(CONFIG_
$(call toupper
,$(stage
))_LIBHWBASE
)),$(stage
)))
345 $(call add-special-class
,hw
)
346 hw-handler
+=$(foreach stage
, $(libhwbase-stages
), \
347 $(eval
$(stage
)-srcs
+= $$(addprefix $(1),$(2))))
349 $(call add-special-class
,hw-gen
)
351 $(eval additional-dirs
+= $(dir $(2))) \
352 $(foreach stage
, $(libhwbase-stages
), \
353 $(eval
$(stage
)-srcs
+= $(2)) \
354 $(eval
$(stage
)-ads-deps
+= $(2)) \
355 $(eval
$(stage
)-adb-deps
+= $(2))) \
356 $(eval
$(2): $(obj
)/config.h
)
358 subdirs-y
+= ..
/..
/3rdparty
/libhwbase
360 $(foreach stage
,$(libhwbase-stages
), \
361 $(eval
$(stage
)-$(CONFIG_HAVE_MONOTONIC_TIMER
) += hw-time-timer.adb
))
363 endif # CONFIG_ROMSTAGE_LIBHWBASE || CONFIG_RAMSTAGE_LIBHWBASE
365 romstage-y
+= spd_bin.c
367 ifeq ($(CONFIG_HAVE_SPD_IN_CBFS
),y
)
368 LIB_SPD_BIN
= $(obj
)/spd.bin
370 LIB_SPD_DEPS
= $(foreach f
, $(SPD_SOURCES
), src
/mainboard
/$(MAINBOARDDIR
)/spd
/$(f
).spd.hex
)
372 # Include spd ROM data
373 $(LIB_SPD_BIN
): $(LIB_SPD_DEPS
)
374 test -n
"$(SPD_SOURCES)" || \
375 (echo
"HAVE_SPD_IN_CBFS is set but SPD_SOURCES is empty" && exit
1)
376 test -n
"$(LIB_SPD_DEPS)" || \
377 (echo
"SPD_SOURCES is set but no SPD file was found" && exit
1)
378 if
[ "$(SPD_SOURCES)" = "placeholder" ]; then \
381 for f in
$(LIB_SPD_DEPS
); do \
382 if
[ ! -f
$$f ]; then \
383 echo
"File not found: $$f" >&2; \
386 for c in
$$(cat
$$f | grep
--binary-files
=text
-v ^
#); \
387 do printf
$$(printf
'\\%o' 0x
$$c); \
392 cbfs-files-y
+= spd.bin
393 spd.bin-file
:= $(LIB_SPD_BIN
)
399 romstage-
$(CONFIG_SPD_CACHE_IN_FMAP
) += spd_cache.c
401 cbfs-files-y
+= cbfs_master_header
402 cbfs_master_header-file
:= cbfs_master_header.c
:struct
403 cbfs_master_header-type
:= "cbfs header"
404 cbfs_master_header-position
:= 0
406 bootblock-
$(CONFIG_ARCH_X86
) += master_header_pointer.c
410 ifneq ($(CONFIG_ARCH_X86
),y
)
413 ifneq ($(CONFIG_BOOTBLOCK_IN_CBFS
),y
)
417 cbfs-files-
$(NEED_CBFS_POINTER
) += header_pointer
418 header_pointer-file
:= master_header_pointer.c
:struct
419 header_pointer-position
:= -4
420 header_pointer-type
:= "cbfs header"
422 romstage-y
+= ux_locales.c