1 ## SPDX-License-Identifier: GPL-2.0-only
3 ################################################################################
4 # Take care of subdirectories
5 ################################################################################
9 ################################################################################
10 # ARM specific options
11 ################################################################################
13 ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM64),y)
14 check-ramstage-overlap-regions += postram_cbfs_cache stack ttb
17 ################################################################################
19 ################################################################################
21 ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARM64),y)
23 decompressor-y += boot.c
25 decompressor-y += div0.c
27 decompressor-y += eabi_compat.c
28 bootblock-y += eabi_compat.c
30 decompressor-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
31 bootblock-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
32 bootblock-y += transition.c transition_asm.S
34 decompressor-y += memset.S
35 bootblock-y += memset.S
36 decompressor-y += memcpy.S
37 bootblock-y += memcpy.S
38 decompressor-y += memmove.S
39 bootblock-y += memmove.S
43 $(objcbfs)/bootblock.debug: $$(bootblock-objs) $(obj)/config.h
44 @printf " LINK $(subst $(obj)/,,$(@))\n"
45 $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) --end-group -T $(call src-to-obj,bootblock,$(CONFIG_MEMLAYOUT_LD_FILE))
47 $(objcbfs)/decompressor.debug: $$(decompressor-objs) $(obj)/config.h
48 @printf " LINK $(subst $(obj)/,,$(@))\n"
49 $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(decompressor-objs)) --end-group -T $(call src-to-obj,decompressor,$(CONFIG_MEMLAYOUT_LD_FILE))
51 endif # CONFIG_ARCH_BOOTBLOCK_ARM64
53 ###############################################################################
55 ###############################################################################
57 ifeq ($(CONFIG_ARCH_VERSTAGE_ARM64),y)
59 $(objcbfs)/verstage.debug: $$(verstage-objs)
60 @printf " LINK $(subst $(obj)/,,$(@))\n"
61 $(LD_verstage) $(LDFLAGS_verstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(verstage-objs)) --end-group -T $(call src-to-obj,verstage,$(CONFIG_MEMLAYOUT_LD_FILE))
65 verstage-y += eabi_compat.c
66 verstage-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
67 verstage-y += memset.S
68 verstage-y += memcpy.S
69 verstage-y += memmove.S
71 verstage-y += transition.c transition_asm.S
73 endif # CONFIG_ARCH_VERSTAGE_ARM64
75 ################################################################################
77 ################################################################################
79 ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM64),y)
83 romstage-y += eabi_compat.c
84 romstage-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
85 romstage-y += memset.S
86 romstage-y += memcpy.S
87 romstage-y += memmove.S
88 romstage-y += ramdetect.c
89 romstage-y += romstage.c
90 romstage-y += transition.c transition_asm.S
92 rmodules_arm64-y += memset.S
93 rmodules_arm64-y += memcpy.S
94 rmodules_arm64-y += memmove.S
95 rmodules_arm64-y += eabi_compat.c
97 $(objcbfs)/romstage.debug: $$(romstage-objs)
98 @printf " LINK $(subst $(obj)/,,$(@))\n"
99 $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group -T $(call src-to-obj,romstage,$(CONFIG_MEMLAYOUT_LD_FILE))
101 endif # CONFIG_ARCH_ROMSTAGE_ARM64
103 ################################################################################
105 ################################################################################
107 ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM64),y)
110 ramstage-y += eabi_compat.c
112 ramstage-y += tables.c
113 ramstage-y += ramdetect.c
114 ramstage-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
115 ramstage-y += memset.S
116 ramstage-y += memcpy.S
117 ramstage-y += memmove.S
118 ramstage-$(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE) += bl31.c
119 ramstage-y += transition.c transition_asm.S
120 ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit_payload.c
122 rmodules_arm64-y += memset.S
123 rmodules_arm64-y += memcpy.S
124 rmodules_arm64-y += memmove.S
125 rmodules_arm64-y += eabi_compat.c
126 rmodules_arm64-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
128 ramstage-srcs += $(wildcard src/mainboard/$(MAINBOARDDIR)/mainboard.c)
132 $(objcbfs)/ramstage.debug: $$(ramstage-objs)
133 @printf " CC $(subst $(obj)/,,$(@))\n"
134 $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group -T $(call src-to-obj,ramstage,$(CONFIG_MEMLAYOUT_LD_FILE))
136 # Build ARM Trusted Firmware (BL31)
138 ifeq ($(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE),y)
140 ifeq ($(CONFIG_ARM64_BL31_EXTERNAL_FILE),"")
142 BL31_SOURCE := $(top)/3rdparty/arm-trusted-firmware
143 BL31_BUILD := $(abspath $(obj)/3rdparty/arm-trusted-firmware)
144 BL31_TARGET := $(BL31_BUILD)/bl31/bl31.elf
150 # Build ARM TF in debug mode (with assertions) if coreboot has hard assertions
151 ifeq ($(CONFIG_FATAL_ASSERTS),y)
152 BL31_MAKEARGS += DEBUG=1
153 endif # CONFIG_FATAL_ASSERTS
155 # ARM TF's VERBOSE (50) is *very* spammy, so default to INFO (40)
156 BL31_MAKEARGS += LOG_LEVEL=40
158 # Always enable crash reporting, even on a release build
159 BL31_MAKEARGS += CRASH_REPORTING=1
161 # Enable coreboot-specific features like CBMEM console support
162 BL31_MAKEARGS += COREBOOT=1
164 # Avoid build/release|build/debug distinction by overriding BUILD_PLAT directly
165 BL31_MAKEARGS += BUILD_PLAT="$(BL31_BUILD)"
167 # Force making .d files and output directories even though target is not 'bl31'
168 BL31_MAKEARGS += IS_ANYTHING_TO_BUILD=1
170 # Set a consistent build timestamp: the same coreboot has
171 BL31_MAKEARGS += BUILD_MESSAGE_TIMESTAMP='"$(shell sed -n 's/^.define COREBOOT_BUILD\>.*"\(.*\)".*/\1/p' $(obj)/build.h)"'
173 BL31_CFLAGS := -fno-pic -fno-stack-protector -Wno-deprecated-declarations -Wno-unused-function
174 BL31_LDFLAGS := --emit-relocs
176 BL31 := $(obj)/bl31.elf
178 $(BL31): $(obj)/build.h
179 printf " MAKE $(subst $(obj)/,,$(@))\n"
180 +CROSS_COMPILE="$(CROSS_COMPILE_arm64)" \
181 CFLAGS="$(BL31_CFLAGS)" \
182 LDFLAGS="$(BL31_LDFLAGS)" \
183 $(MAKE) -C $(BL31_SOURCE) $(BL31_MAKEARGS) $(BL31_TARGET) DISABLE_PEDANTIC=1
190 BL31 := $(call strip_quotes,$(CONFIG_ARM64_BL31_EXTERNAL_FILE))
192 endif # CONFIG_ARM64_BUILD_ARM_TRUSTED_FIRMWARE
195 BL31_CBFS := $(CONFIG_CBFS_PREFIX)/bl31
196 $(BL31_CBFS)-file := $(BL31)
197 $(BL31_CBFS)-type := payload
198 $(BL31_CBFS)-compression := $(CBFS_COMPRESS_FLAG)
199 cbfs-files-y += $(BL31_CBFS)
201 check-ramstage-overlap-files += $(BL31_CBFS)
203 ifeq ($(CONFIG_ARM64_USE_SECURE_OS),y)
205 SECURE_OS_FILE := $(CONFIG_ARM64_SECURE_OS_FILE)
206 SECURE_OS_FILE_CBFS := $(CONFIG_CBFS_PREFIX)/secure_os
207 $(SECURE_OS_FILE_CBFS)-file := $(SECURE_OS_FILE)
208 $(SECURE_OS_FILE_CBFS)-type := stage
209 cbfs-files-y += $(SECURE_OS_FILE_CBFS)
211 check-ramstage-overlap-files += $(SECURE_OS_FILE_CBFS)
213 endif # CONFIG_ARM64_USE_SECURE_OS
215 endif # CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE
217 endif # CONFIG_ARCH_RAMSTAGE_ARM64