Debian Codegraph @

src/soc/amd/glinda/Makefile.mk

raw symbols SCIP
1 # SPDX-License-Identifier: BSD-3-Clause
2
3 # TODO: Move as much as possible to common
4 # TODO: Update for Glinda
5
6 ifeq ($(CONFIG_SOC_AMD_GLINDA),y)
7
8 subdirs-$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK) += psp_verstage
9
10 # Beware that all-y also adds the compilation unit to verstage on PSP
11 all-y += aoac.c
12 all-y += config.c
13 all-y += i2c.c
14
15 # all_x86-y adds the compilation unit to all stages that run on the x86 cores
16 all_x86-y += gpio.c
17 all_x86-y += i3c.c
18 all_x86-y += uart.c
19
20 bootblock-y += early_fch.c
21 bootblock-y += espi_util.c
22
23 verstage-y += espi_util.c
24
25 romstage-y += fsp_m_params.c
26
27 ramstage-y += acpi.c
28 ramstage-y += chip.c
29 ramstage-y += cpu.c
30 ramstage-y += fch.c
31 ramstage-y += fsp_s_params.c
32 ramstage-y += mca.c
33 ramstage-y += memmap.c
34 ramstage-y += root_complex.c
35 ramstage-y += xhci.c
36
37 smm-y += gpio.c
38 smm-y += root_complex.c
39 smm-y += smihandler.c
40 smm-$(CONFIG_DEBUG_SMI) += uart.c
41
42 CPPFLAGS_common += -I$(src)/soc/amd/glinda/include
43 CPPFLAGS_common += -I$(src)/soc/amd/glinda/acpi
44 CPPFLAGS_common += -I$(src)/vendorcode/amd/fsp/glinda
45 CPPFLAGS_common += -I$(src)/vendorcode/amd/fsp/common
46
47 # Building the cbfs image will fail if the offset, aligned to 64 bytes, isn't large enough
48 ifeq ($(CONFIG_CBFS_VERIFICATION),y)
49 # 0x80 accounts for the cbfs_file struct + filename + metadata structs
50 AMD_FW_AB_POSITION := 0x80
51 else # ($(CONFIG_CBFS_VERIFICATION), y)
52 # 0x40 accounts for the cbfs_file struct + filename + metadata structs without hash attribute
53 AMD_FW_AB_POSITION := 0x40
54 endif # ($(CONFIG_CBFS_VERIFICATION), y)
55
56 GLINDA_FW_A_POSITION=$(call int-add, \
57 $(call get_fmap_value,FMAP_SECTION_FW_MAIN_A_START) $(AMD_FW_AB_POSITION))
58
59 GLINDA_FW_B_POSITION=$(call int-add, \
60 $(call get_fmap_value,FMAP_SECTION_FW_MAIN_B_START) $(AMD_FW_AB_POSITION))
61
62 #
63 # PSP Directory Table items
64 #
65 # Certain ordering requirements apply, however these are ensured by amdfwtool.
66 # For more information see "AMD Platform Security Processor BIOS Architecture
67 # Design Guide for AMD Family 17h Processors" (PID #55758, NDA only).
68 #
69
70 ifeq ($(CONFIG_PSP_DISABLE_POSTCODES),y)
71 PSP_SOFTFUSE_BITS += 7
72 endif
73
74 ifeq ($(CONFIG_PSP_UNLOCK_SECURE_DEBUG),y)
75 # Enable secure debug unlock
76 PSP_SOFTFUSE_BITS += 0
77 OPT_TOKEN_UNLOCK="--token-unlock"
78 endif
79
80 ifeq ($(CONFIG_PSP_LOAD_MP2_FW),y)
81 OPT_PSP_LOAD_MP2_FW="--load-mp2-fw"
82 else
83 # Disable MP2 firmware loading
84 PSP_SOFTFUSE_BITS += 29
85 endif
86
87 # Use additional Soft Fuse bits specified in Kconfig
88 PSP_SOFTFUSE_BITS += $(call strip_quotes, $(CONFIG_PSP_SOFTFUSE_BITS))
89
90 # type = 0x04
91 # The flashmap section used for this is expected to be named PSP_NVRAM
92 PSP_NVRAM_BASE=$(call get_fmap_value,FMAP_SECTION_PSP_NVRAM_START)
93 PSP_NVRAM_SIZE=$(call get_fmap_value,FMAP_SECTION_PSP_NVRAM_SIZE)
94
95 # type = 0x3a
96 ifeq ($(CONFIG_HAVE_PSP_WHITELIST_FILE),y)
97 PSP_WHITELIST_FILE=$(CONFIG_PSP_WHITELIST_FILE)
98 endif
99
100 # type = 0x54
101 # The flashmap section used for this is expected to be named PSP_RPMC_NVRAM
102 PSP_RPMC_NVRAM_BASE=$(call get_fmap_value,FMAP_SECTION_PSP_RPMC_NVRAM_START)
103 PSP_RPMC_NVRAM_SIZE=$(call get_fmap_value,FMAP_SECTION_PSP_RPMC_NVRAM_SIZE)
104
105 # type = 0x55
106 SPL_TABLE_FILE=$(CONFIG_SPL_TABLE_FILE)
107 ifeq ($(CONFIG_HAVE_SPL_RW_AB_FILE),y)
108 SPL_RW_AB_TABLE_FILE=$(CONFIG_SPL_RW_AB_TABLE_FILE)
109 else
110 SPL_RW_AB_TABLE_FILE=$(CONFIG_SPL_TABLE_FILE)
111 endif
112
113 #
114 # BIOS Directory Table items - proper ordering is managed by amdfwtool
115 #
116
117 # type = 0x60
118 PSP_APCB_FILES=$(APCB_SOURCES) $(APCB_SOURCES_RECOVERY)
119
120 # type = 0x61
121 PSP_APOB_BASE=$(CONFIG_PSP_APOB_DRAM_ADDRESS)
122
123 # type = 0x62
124 PSP_BIOSBIN_FILE=$(obj)/amd_biospsp.img
125 PSP_ELF_FILE=$(objcbfs)/bootblock_fixed_data.elf
126 PSP_BIOSBIN_SIZE=$(shell $(READELF_bootblock) -Wl $(PSP_ELF_FILE) | grep LOAD | awk '{print $$5}')
127 PSP_BIOSBIN_DEST=$(shell $(READELF_bootblock) -Wl $(PSP_ELF_FILE) | grep LOAD | awk '{print $$3}')
128
129 ifneq ($(CONFIG_SOC_AMD_COMMON_BLOCK_APOB_NV_DISABLE),y)
130 # type = 0x63 - construct APOB NV base/size from flash map
131 # The flashmap section used for this is expected to be named RW_MRC_CACHE
132 APOB_NV_SIZE=$(call get_fmap_value,FMAP_SECTION_RW_MRC_CACHE_SIZE)
133 APOB_NV_BASE=$(call get_fmap_value,FMAP_SECTION_RW_MRC_CACHE_START)
134 endif # !CONFIG_SOC_AMD_COMMON_BLOCK_APOB_NV_DISABLE
135
136 ifeq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y)
137 # type = 0x6B - PSP Shared memory location
138 ifneq ($(CONFIG_PSP_SHAREDMEM_SIZE),0x0)
139 PSP_SHAREDMEM_SIZE=$(CONFIG_PSP_SHAREDMEM_SIZE)
140 PSP_SHAREDMEM_BASE=$(shell awk '$$3 == "_psp_sharedmem_dram" {printf "0x" $$1}' $(objcbfs)/bootblock.map)
141 endif
142
143 # type = 0x52 - PSP Bootloader Userspace Application (verstage)
144 PSP_VERSTAGE_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_FILE))
145 PSP_VERSTAGE_SIG_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_SIGNING_TOKEN))
146 endif # CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK
147
148 ifeq ($(CONFIG_SEPARATE_SIGNED_PSPFW),y)
149 SIGNED_AMDFW_A_POSITION=$(call get_fmap_value,FMAP_SECTION_SIGNED_AMDFW_A_START)
150 SIGNED_AMDFW_B_POSITION=$(call get_fmap_value,FMAP_SECTION_SIGNED_AMDFW_B_START)
151 SIGNED_AMDFW_A_FILE=$(obj)/amdfw_a.rom.signed
152 SIGNED_AMDFW_B_FILE=$(obj)/amdfw_b.rom.signed
153 endif # CONFIG_SEPARATE_SIGNED_PSPFW
154
155 # Helper function to return a value with given bit set
156 # Soft Fuse type = 0xb - See #55758 (NDA) for bit definitions.
157 set-bit=$(call int-shift-left, 1 $(call _toint,$1))
158 PSP_SOFTFUSE=$(shell A=$(call int-add, \
159 $(foreach bit,$(sort $(PSP_SOFTFUSE_BITS)),$(call set-bit,$(bit)))); printf "0x%x" $$A)
160
161 #
162 # Build the arguments to amdfwtool (order is unimportant). Missing file names
163 # result in empty OPT_ variables, i.e. the argument is not passed to amdfwtool.
164 #
165
166 add_opt_prefix=$(if $(call strip_quotes, $(1)), $(2) $(call strip_quotes, $(1)), )
167
168 OPT_PSP_NVRAM_BASE=$(call add_opt_prefix, $(PSP_NVRAM_BASE), --nvram-base)
169 OPT_PSP_NVRAM_SIZE=$(call add_opt_prefix, $(PSP_NVRAM_SIZE), --nvram-size)
170
171 OPT_PSP_RPMC_NVRAM_BASE=$(call add_opt_prefix, $(PSP_RPMC_NVRAM_BASE), --rpmc-nvram-base)
172 OPT_PSP_RPMC_NVRAM_SIZE=$(call add_opt_prefix, $(PSP_RPMC_NVRAM_SIZE), --rpmc-nvram-size)
173
174 OPT_VERSTAGE_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_FILE), --verstage)
175 OPT_VERSTAGE_SIG_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_SIG_FILE), --verstage_sig)
176
177 OPT_PSP_APCB_FILES= $(if $(APCB_SOURCES), --instance 0 --apcb $(APCB_SOURCES)) \
178 $(if $(APCB_SOURCES_RECOVERY), --instance 10 --apcb $(APCB_SOURCES_RECOVERY)) \
179 $(if $(APCB_SOURCES_68), --instance 18 --apcb $(APCB_SOURCES_68))
180
181 OPT_APOB_ADDR=$(call add_opt_prefix, $(PSP_APOB_BASE), --apob-base)
182 OPT_PSP_BIOSBIN_FILE=$(call add_opt_prefix, $(PSP_BIOSBIN_FILE), --bios-bin)
183 OPT_PSP_BIOSBIN_DEST=$(call add_opt_prefix, $(PSP_BIOSBIN_DEST), --bios-bin-dest)
184 OPT_PSP_BIOSBIN_SIZE=$(call add_opt_prefix, $(PSP_BIOSBIN_SIZE), --bios-uncomp-size)
185
186 OPT_PSP_SHAREDMEM_BASE=$(call add_opt_prefix, $(PSP_SHAREDMEM_BASE), --sharedmem)
187 OPT_PSP_SHAREDMEM_SIZE=$(call add_opt_prefix, $(PSP_SHAREDMEM_SIZE), --sharedmem-size)
188 OPT_APOB_NV_SIZE=$(call add_opt_prefix, $(APOB_NV_SIZE), --apob-nv-size)
189 OPT_APOB_NV_BASE=$(call add_opt_prefix, $(APOB_NV_BASE),--apob-nv-base)
190 OPT_EFS_SPI_READ_MODE=$(call add_opt_prefix, $(CONFIG_EFS_SPI_READ_MODE), --spi-read-mode)
191 OPT_EFS_SPI_SPEED=$(call add_opt_prefix, $(CONFIG_EFS_SPI_SPEED), --spi-speed)
192 OPT_EFS_SPI_MICRON_FLAG=$(call add_opt_prefix, $(CONFIG_EFS_SPI_MICRON_FLAG), --spi-micron-flag)
193
194 OPT_SIGNED_AMDFW_A_POSITION=$(call add_opt_prefix, $(SIGNED_AMDFW_A_POSITION), --signed-addr)
195 OPT_SIGNED_AMDFW_A_FILE=$(call add_opt_prefix, $(SIGNED_AMDFW_A_FILE), --signed-output)
196 OPT_SIGNED_AMDFW_B_POSITION=$(call add_opt_prefix, $(SIGNED_AMDFW_B_POSITION), --signed-addr)
197 OPT_SIGNED_AMDFW_B_FILE=$(call add_opt_prefix, $(SIGNED_AMDFW_B_FILE), --signed-output)
198
199 OPT_PSP_SOFTFUSE=$(call add_opt_prefix, $(PSP_SOFTFUSE), --soft-fuse)
200
201 OPT_WHITELIST_FILE=$(call add_opt_prefix, $(PSP_WHITELIST_FILE), --whitelist)
202 OPT_SPL_TABLE_FILE=$(call add_opt_prefix, $(SPL_TABLE_FILE), --spl-table)
203 OPT_SPL_RW_AB_TABLE_FILE=$(call add_opt_prefix, $(SPL_RW_AB_TABLE_FILE), --spl-table)
204
205 # If vboot uses 2 RW slots, then 2 copies of PSP binaries are redundant
206 OPT_RECOVERY_AB_SINGLE_COPY=$(if $(CONFIG_VBOOT_SLOTS_RW_AB), --recovery-ab-single-copy)
207
208 AMDFW_COMMON_ARGS=$(OPT_PSP_APCB_FILES) \
209 $(OPT_PSP_NVRAM_BASE) \
210 $(OPT_PSP_NVRAM_SIZE) \
211 $(OPT_PSP_RPMC_NVRAM_BASE) \
212 $(OPT_PSP_RPMC_NVRAM_SIZE) \
213 $(OPT_APOB_ADDR) \
214 $(OPT_DEBUG_AMDFWTOOL) \
215 $(OPT_PSP_BIOSBIN_FILE) \
216 $(OPT_PSP_BIOSBIN_DEST) \
217 $(OPT_PSP_BIOSBIN_SIZE) \
218 $(OPT_PSP_SOFTFUSE) \
219 $(OPT_PSP_LOAD_MP2_FW) \
220 --use-pspsecureos \
221 --load-s0i3 \
222 $(OPT_TOKEN_UNLOCK) \
223 $(OPT_WHITELIST_FILE) \
224 $(OPT_PSP_SHAREDMEM_BASE) \
225 $(OPT_PSP_SHAREDMEM_SIZE) \
226 $(OPT_EFS_SPI_READ_MODE) \
227 $(OPT_EFS_SPI_SPEED) \
228 $(OPT_EFS_SPI_MICRON_FLAG) \
229 --config $(CONFIG_AMDFW_CONFIG_FILE) \
230 --flashsize $(CONFIG_ROM_SIZE) \
231 $(OPT_RECOVERY_AB_SINGLE_COPY)
232
233 $(obj)/amdfw.rom: $(call strip_quotes, $(PSP_BIOSBIN_FILE)) \
234 $(PSP_VERSTAGE_FILE) \
235 $(PSP_VERSTAGE_SIG_FILE) \
236 $$(PSP_APCB_FILES) \
237 $(DEP_FILES) \
238 $(AMDFWTOOL) \
239 $(obj)/fmap_config.h \
240 $(objcbfs)/bootblock_fixed_data.elf # this target also creates the .map file
241 rm -f $@
242 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
243 $(AMDFWTOOL) \
244 $(AMDFW_COMMON_ARGS) \
245 $(OPT_APOB_NV_SIZE) \
246 $(OPT_APOB_NV_BASE) \
247 $(OPT_VERSTAGE_FILE) \
248 $(OPT_VERSTAGE_SIG_FILE) \
249 $(OPT_SPL_TABLE_FILE) \
250 --location $(CONFIG_AMD_FWM_POSITION) \
251 --output $@
252
253 #
254 # Extracts everything from the ELF's first PT_LOAD area and compresses it.
255 # This discards everything before PT_LOAD, every symbol, debug information
256 # and relocations. The generated binary is expected to run at PSP_BIOSBIN_DEST
257 # with a maximum size of PSP_BIOSBIN_SIZE. The entrypoint is fixed at
258 # PSP_BIOSBIN_DEST + PSP_BIOSBIN_SIZE - 0x10.
259 #
260 $(PSP_BIOSBIN_FILE): $(PSP_ELF_FILE) $(AMDCOMPRESS)
261 rm -f $@
262 @printf " AMDCOMPRS $(subst $(obj)/,,$(@))\n"
263 $(AMDCOMPRESS) --infile $(PSP_ELF_FILE) --outfile $@ --compress \
264 --maxsize $(PSP_BIOSBIN_SIZE)
265
266 $(obj)/amdfw_a.rom: $(obj)/amdfw.rom
267 rm -f $@
268 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
269 $(AMDFWTOOL) \
270 $(AMDFW_COMMON_ARGS) \
271 $(OPT_APOB_NV_SIZE) \
272 $(OPT_APOB_NV_BASE) \
273 $(OPT_SPL_RW_AB_TABLE_FILE) \
274 $(OPT_SIGNED_AMDFW_A_POSITION) \
275 $(OPT_SIGNED_AMDFW_A_FILE) \
276 --location $(call _tohex,$(GLINDA_FW_A_POSITION)) \
277 --anywhere \
278 --output $@
279
280 $(obj)/amdfw_b.rom: $(obj)/amdfw.rom
281 rm -f $@
282 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
283 $(AMDFWTOOL) \
284 $(AMDFW_COMMON_ARGS) \
285 $(OPT_APOB_NV_SIZE) \
286 $(OPT_APOB_NV_BASE) \
287 $(OPT_SPL_RW_AB_TABLE_FILE) \
288 $(OPT_SIGNED_AMDFW_B_POSITION) \
289 $(OPT_SIGNED_AMDFW_B_FILE) \
290 --location $(call _tohex,$(GLINDA_FW_B_POSITION)) \
291 --anywhere \
292 --output $@
293
294
295 ifeq ($(CONFIG_VBOOT_SLOTS_RW_AB)$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),yy)
296 cbfs-files-y += apu/amdfw_a
297 apu/amdfw_a-file := $(obj)/amdfw_a.rom
298 apu/amdfw_a-position := $(AMD_FW_AB_POSITION)
299 apu/amdfw_a-type := raw
300
301 cbfs-files-y += apu/amdfw_b
302 apu/amdfw_b-file := $(obj)/amdfw_b.rom
303 apu/amdfw_b-position := $(AMD_FW_AB_POSITION)
304 apu/amdfw_b-type := raw
305
306 ifeq ($(CONFIG_SEPARATE_SIGNED_PSPFW),y)
307 build_complete:: $(obj)/amdfw_a.rom $(obj)/amdfw_b.rom
308 @printf " Adding Signed ROM and HASH\n"
309 $(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_A -i 0 -f $(obj)/amdfw_a.rom.signed
310 $(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_B -i 0 -f $(obj)/amdfw_b.rom.signed
311 $(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_A -f $(obj)/amdfw_a.rom.signed.hash \
312 -n apu/amdfw_a_hash -t raw
313 $(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_B -f $(obj)/amdfw_b.rom.signed.hash \
314 -n apu/amdfw_b_hash -t raw
315 endif # CONFIG_SEPARATE_SIGNED_PSPFW
316 endif
317
318 endif # ($(CONFIG_SOC_AMD_GLINDA),y)