blob: 4570e070863141eb948a3e13b0daca5bbeaa8574 [file] [log] [blame]
Martin Rothf95a11e2022-10-21 16:43:08 -06001# SPDX-License-Identifier: BSD-3-Clause
2
3# TODO: Move as much as possible to common
4# TODO: Update for Glinda
5
6ifeq ($(CONFIG_SOC_AMD_GLINDA),y)
7
8subdirs-$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK) += psp_verstage
9
10# Beware that all-y also adds the compilation unit to verstage on PSP
Martin Rothf95a11e2022-10-21 16:43:08 -060011all-y += aoac.c
Felix Held46cd1b52023-04-01 01:21:27 +020012all-y += config.c
13all-y += i2c.c
Martin Rothf95a11e2022-10-21 16:43:08 -060014
Felix Heldf008e0a2023-04-01 01:31:24 +020015# all_x86-y adds the compilation unit to all stages that run on the x86 cores
16all_x86-y += gpio.c
17all_x86-y += uart.c
18
Martin Rothf95a11e2022-10-21 16:43:08 -060019bootblock-y += early_fch.c
20bootblock-y += espi_util.c
Martin Rothf95a11e2022-10-21 16:43:08 -060021
Martin Rothf95a11e2022-10-21 16:43:08 -060022verstage-y += espi_util.c
Martin Rothf95a11e2022-10-21 16:43:08 -060023
24romstage-y += fsp_m_params.c
Martin Rothf95a11e2022-10-21 16:43:08 -060025
26ramstage-y += acpi.c
Martin Rothf95a11e2022-10-21 16:43:08 -060027ramstage-y += chip.c
28ramstage-y += cpu.c
Martin Rothf95a11e2022-10-21 16:43:08 -060029ramstage-y += fch.c
30ramstage-y += fsp_s_params.c
Martin Rothf95a11e2022-10-21 16:43:08 -060031ramstage-y += mca.c
Martin Rothf95a11e2022-10-21 16:43:08 -060032ramstage-y += root_complex.c
Martin Rothf95a11e2022-10-21 16:43:08 -060033ramstage-y += xhci.c
34
35smm-y += gpio.c
36smm-y += smihandler.c
Martin Rothf95a11e2022-10-21 16:43:08 -060037smm-$(CONFIG_DEBUG_SMI) += uart.c
38
39CPPFLAGS_common += -I$(src)/soc/amd/glinda/include
40CPPFLAGS_common += -I$(src)/soc/amd/glinda/acpi
41CPPFLAGS_common += -I$(src)/vendorcode/amd/fsp/glinda
42CPPFLAGS_common += -I$(src)/vendorcode/amd/fsp/common
43
Karthikeyan Ramasubramanian3167fb72023-10-16 14:53:57 -060044# Building the cbfs image will fail if the offset, aligned to 64 bytes, isn't large enough
45ifeq ($(CONFIG_CBFS_VERIFICATION),y)
46# 0x80 accounts for the cbfs_file struct + filename + metadata structs
47AMD_FW_AB_POSITION := 0x80
48else # ($(CONFIG_CBFS_VERIFICATION), y)
49# 0x40 accounts for the cbfs_file struct + filename + metadata structs without hash attribute
Martin Rothf95a11e2022-10-21 16:43:08 -060050AMD_FW_AB_POSITION := 0x40
Karthikeyan Ramasubramanian3167fb72023-10-16 14:53:57 -060051endif # ($(CONFIG_CBFS_VERIFICATION), y)
Martin Rothf95a11e2022-10-21 16:43:08 -060052
53GLINDA_FW_A_POSITION=$(call int-add, \
Matt DeVillier163dbdd2023-06-29 16:56:09 -050054 $(call get_fmap_value,FMAP_SECTION_FW_MAIN_A_START) $(AMD_FW_AB_POSITION))
Martin Rothf95a11e2022-10-21 16:43:08 -060055
56GLINDA_FW_B_POSITION=$(call int-add, \
Matt DeVillier163dbdd2023-06-29 16:56:09 -050057 $(call get_fmap_value,FMAP_SECTION_FW_MAIN_B_START) $(AMD_FW_AB_POSITION))
Martin Rothf95a11e2022-10-21 16:43:08 -060058#
59# PSP Directory Table items
60#
61# Certain ordering requirements apply, however these are ensured by amdfwtool.
62# For more information see "AMD Platform Security Processor BIOS Architecture
63# Design Guide for AMD Family 17h Processors" (PID #55758, NDA only).
64#
65
66ifeq ($(CONFIG_PSP_DISABLE_POSTCODES),y)
67PSP_SOFTFUSE_BITS += 7
68endif
69
70ifeq ($(CONFIG_PSP_UNLOCK_SECURE_DEBUG),y)
71# Enable secure debug unlock
72PSP_SOFTFUSE_BITS += 0
73OPT_TOKEN_UNLOCK="--token-unlock"
74endif
75
76ifeq ($(CONFIG_PSP_LOAD_MP2_FW),y)
77OPT_PSP_LOAD_MP2_FW="--load-mp2-fw"
78else
79# Disable MP2 firmware loading
80PSP_SOFTFUSE_BITS += 29
81endif
82
83# Use additional Soft Fuse bits specified in Kconfig
84PSP_SOFTFUSE_BITS += $(call strip_quotes, $(CONFIG_PSP_SOFTFUSE_BITS))
85
86# type = 0x3a
87ifeq ($(CONFIG_HAVE_PSP_WHITELIST_FILE),y)
88PSP_WHITELIST_FILE=$(CONFIG_PSP_WHITELIST_FILE)
89endif
90
91# type = 0x55
Martin Rothf95a11e2022-10-21 16:43:08 -060092SPL_TABLE_FILE=$(CONFIG_SPL_TABLE_FILE)
93ifeq ($(CONFIG_HAVE_SPL_RW_AB_FILE),y)
94SPL_RW_AB_TABLE_FILE=$(CONFIG_SPL_RW_AB_TABLE_FILE)
95else
96SPL_RW_AB_TABLE_FILE=$(CONFIG_SPL_TABLE_FILE)
97endif
Martin Rothf95a11e2022-10-21 16:43:08 -060098
99#
100# BIOS Directory Table items - proper ordering is managed by amdfwtool
101#
102
103# type = 0x60
104PSP_APCB_FILES=$(APCB_SOURCES) $(APCB_SOURCES_RECOVERY)
105
106# type = 0x61
107PSP_APOB_BASE=$(CONFIG_PSP_APOB_DRAM_ADDRESS)
108
109# type = 0x62
110PSP_BIOSBIN_FILE=$(obj)/amd_biospsp.img
111PSP_ELF_FILE=$(objcbfs)/bootblock.elf
Felix Held3b89c952022-11-22 20:02:46 +0100112PSP_BIOSBIN_SIZE=$(shell $(READELF_bootblock) -Wl $(PSP_ELF_FILE) | grep LOAD | awk '{print $$5}')
113PSP_BIOSBIN_DEST=$(shell $(READELF_bootblock) -Wl $(PSP_ELF_FILE) | grep LOAD | awk '{print $$3}')
Martin Rothf95a11e2022-10-21 16:43:08 -0600114
Fred Reitberger2a1fc732023-07-17 09:09:42 -0400115ifneq ($(CONFIG_SOC_AMD_COMMON_BLOCK_APOB_NV_DISABLE),y)
Martin Rothf95a11e2022-10-21 16:43:08 -0600116# type = 0x63 - construct APOB NV base/size from flash map
117# The flashmap section used for this is expected to be named RW_MRC_CACHE
Matt DeVillier163dbdd2023-06-29 16:56:09 -0500118APOB_NV_SIZE=$(call get_fmap_value,FMAP_SECTION_RW_MRC_CACHE_SIZE)
119APOB_NV_BASE=$(call get_fmap_value,FMAP_SECTION_RW_MRC_CACHE_START)
Fred Reitberger2a1fc732023-07-17 09:09:42 -0400120endif # !CONFIG_SOC_AMD_COMMON_BLOCK_APOB_NV_DISABLE
Martin Rothf95a11e2022-10-21 16:43:08 -0600121
122ifeq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y)
123# type = 0x6B - PSP Shared memory location
124ifneq ($(CONFIG_PSP_SHAREDMEM_SIZE),0x0)
125PSP_SHAREDMEM_SIZE=$(CONFIG_PSP_SHAREDMEM_SIZE)
126PSP_SHAREDMEM_BASE=$(shell awk '$$3 == "_psp_sharedmem_dram" {printf "0x" $$1}' $(objcbfs)/bootblock.map)
127endif
128
129# type = 0x52 - PSP Bootloader Userspace Application (verstage)
130PSP_VERSTAGE_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_FILE))
131PSP_VERSTAGE_SIG_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_SIGNING_TOKEN))
132endif # CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK
133
134ifeq ($(CONFIG_SEPARATE_SIGNED_PSPFW),y)
135SIGNED_AMDFW_A_POSITION=$(call int-subtract, \
Matt DeVillier163dbdd2023-06-29 16:56:09 -0500136 $(call get_fmap_value,FMAP_SECTION_SIGNED_AMDFW_A_START) \
137 $(call get_fmap_value,FMAP_SECTION_FLASH_START))
Martin Rothf95a11e2022-10-21 16:43:08 -0600138SIGNED_AMDFW_B_POSITION=$(call int-subtract, \
Matt DeVillier163dbdd2023-06-29 16:56:09 -0500139 $(call get_fmap_value,FMAP_SECTION_SIGNED_AMDFW_B_START) \
140 $(call get_fmap_value,FMAP_SECTION_FLASH_START))
Martin Rothf95a11e2022-10-21 16:43:08 -0600141SIGNED_AMDFW_A_FILE=$(obj)/amdfw_a.rom.signed
142SIGNED_AMDFW_B_FILE=$(obj)/amdfw_b.rom.signed
143endif # CONFIG_SEPARATE_SIGNED_PSPFW
144
145# Helper function to return a value with given bit set
146# Soft Fuse type = 0xb - See #55758 (NDA) for bit definitions.
147set-bit=$(call int-shift-left, 1 $(call _toint,$1))
148PSP_SOFTFUSE=$(shell A=$(call int-add, \
Matt DeVillier0daefa52023-10-30 20:58:41 -0500149 $(foreach bit,$(sort $(PSP_SOFTFUSE_BITS)),$(call set-bit,$(bit)))); printf "0x%x" $$A)
Martin Rothf95a11e2022-10-21 16:43:08 -0600150
151#
152# Build the arguments to amdfwtool (order is unimportant). Missing file names
153# result in empty OPT_ variables, i.e. the argument is not passed to amdfwtool.
154#
155
156add_opt_prefix=$(if $(call strip_quotes, $(1)), $(2) $(call strip_quotes, $(1)), )
157
158OPT_VERSTAGE_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_FILE), --verstage)
159OPT_VERSTAGE_SIG_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_SIG_FILE), --verstage_sig)
160
161OPT_PSP_APCB_FILES= $(if $(APCB_SOURCES), --instance 0 --apcb $(APCB_SOURCES)) \
162 $(if $(APCB_SOURCES_RECOVERY), --instance 10 --apcb $(APCB_SOURCES_RECOVERY)) \
163 $(if $(APCB_SOURCES_68), --instance 18 --apcb $(APCB_SOURCES_68))
164
165OPT_APOB_ADDR=$(call add_opt_prefix, $(PSP_APOB_BASE), --apob-base)
166OPT_PSP_BIOSBIN_FILE=$(call add_opt_prefix, $(PSP_BIOSBIN_FILE), --bios-bin)
167OPT_PSP_BIOSBIN_DEST=$(call add_opt_prefix, $(PSP_BIOSBIN_DEST), --bios-bin-dest)
168OPT_PSP_BIOSBIN_SIZE=$(call add_opt_prefix, $(PSP_BIOSBIN_SIZE), --bios-uncomp-size)
169
170OPT_PSP_SHAREDMEM_BASE=$(call add_opt_prefix, $(PSP_SHAREDMEM_BASE), --sharedmem)
171OPT_PSP_SHAREDMEM_SIZE=$(call add_opt_prefix, $(PSP_SHAREDMEM_SIZE), --sharedmem-size)
172OPT_APOB_NV_SIZE=$(call add_opt_prefix, $(APOB_NV_SIZE), --apob-nv-size)
173OPT_APOB_NV_BASE=$(call add_opt_prefix, $(APOB_NV_BASE),--apob-nv-base)
174OPT_EFS_SPI_READ_MODE=$(call add_opt_prefix, $(CONFIG_EFS_SPI_READ_MODE), --spi-read-mode)
175OPT_EFS_SPI_SPEED=$(call add_opt_prefix, $(CONFIG_EFS_SPI_SPEED), --spi-speed)
176OPT_EFS_SPI_MICRON_FLAG=$(call add_opt_prefix, $(CONFIG_EFS_SPI_MICRON_FLAG), --spi-micron-flag)
177
178OPT_SIGNED_AMDFW_A_POSITION=$(call add_opt_prefix, $(SIGNED_AMDFW_A_POSITION), --signed-addr)
179OPT_SIGNED_AMDFW_A_FILE=$(call add_opt_prefix, $(SIGNED_AMDFW_A_FILE), --signed-output)
180OPT_SIGNED_AMDFW_B_POSITION=$(call add_opt_prefix, $(SIGNED_AMDFW_B_POSITION), --signed-addr)
181OPT_SIGNED_AMDFW_B_FILE=$(call add_opt_prefix, $(SIGNED_AMDFW_B_FILE), --signed-output)
182
183OPT_PSP_SOFTFUSE=$(call add_opt_prefix, $(PSP_SOFTFUSE), --soft-fuse)
184
185OPT_WHITELIST_FILE=$(call add_opt_prefix, $(PSP_WHITELIST_FILE), --whitelist)
186OPT_SPL_TABLE_FILE=$(call add_opt_prefix, $(SPL_TABLE_FILE), --spl-table)
187OPT_SPL_RW_AB_TABLE_FILE=$(call add_opt_prefix, $(SPL_RW_AB_TABLE_FILE), --spl-table)
188
189# If vboot uses 2 RW slots, then 2 copies of PSP binaries are redundant
190OPT_RECOVERY_AB_SINGLE_COPY=$(if $(CONFIG_VBOOT_SLOTS_RW_AB), --recovery-ab-single-copy)
191
192AMDFW_COMMON_ARGS=$(OPT_PSP_APCB_FILES) \
193 $(OPT_APOB_ADDR) \
Martin Roth0acf59d2023-03-08 15:18:24 -0700194 $(OPT_DEBUG_AMDFWTOOL) \
Martin Rothf95a11e2022-10-21 16:43:08 -0600195 $(OPT_PSP_BIOSBIN_FILE) \
196 $(OPT_PSP_BIOSBIN_DEST) \
197 $(OPT_PSP_BIOSBIN_SIZE) \
198 $(OPT_PSP_SOFTFUSE) \
199 $(OPT_PSP_LOAD_MP2_FW) \
200 --use-pspsecureos \
201 --load-s0i3 \
Martin Rothf95a11e2022-10-21 16:43:08 -0600202 $(OPT_TOKEN_UNLOCK) \
203 $(OPT_WHITELIST_FILE) \
204 $(OPT_PSP_SHAREDMEM_BASE) \
205 $(OPT_PSP_SHAREDMEM_SIZE) \
206 $(OPT_EFS_SPI_READ_MODE) \
207 $(OPT_EFS_SPI_SPEED) \
208 $(OPT_EFS_SPI_MICRON_FLAG) \
209 --config $(CONFIG_AMDFW_CONFIG_FILE) \
Martin Rothf95a11e2022-10-21 16:43:08 -0600210 --flashsize $(CONFIG_ROM_SIZE) \
211 $(OPT_RECOVERY_AB_SINGLE_COPY)
212
213$(obj)/amdfw.rom: $(call strip_quotes, $(PSP_BIOSBIN_FILE)) \
214 $(PSP_VERSTAGE_FILE) \
215 $(PSP_VERSTAGE_SIG_FILE) \
216 $$(PSP_APCB_FILES) \
217 $(DEP_FILES) \
218 $(AMDFWTOOL) \
219 $(obj)/fmap_config.h \
220 $(objcbfs)/bootblock.elf # this target also creates the .map file
Martin Rothf95a11e2022-10-21 16:43:08 -0600221 rm -f $@
222 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
223 $(AMDFWTOOL) \
224 $(AMDFW_COMMON_ARGS) \
225 $(OPT_APOB_NV_SIZE) \
226 $(OPT_APOB_NV_BASE) \
227 $(OPT_VERSTAGE_FILE) \
228 $(OPT_VERSTAGE_SIG_FILE) \
229 $(OPT_SPL_TABLE_FILE) \
Zheng Bao6bc06982023-02-14 13:26:31 +0800230 --location $(CONFIG_AMD_FWM_POSITION) \
Martin Rothf95a11e2022-10-21 16:43:08 -0600231 --output $@
232
233$(PSP_BIOSBIN_FILE): $(PSP_ELF_FILE) $(AMDCOMPRESS)
234 rm -f $@
235 @printf " AMDCOMPRS $(subst $(obj)/,,$(@))\n"
236 $(AMDCOMPRESS) --infile $(PSP_ELF_FILE) --outfile $@ --compress \
237 --maxsize $(PSP_BIOSBIN_SIZE)
238
239$(obj)/amdfw_a.rom: $(obj)/amdfw.rom
240 rm -f $@
241 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
242 $(AMDFWTOOL) \
243 $(AMDFW_COMMON_ARGS) \
244 $(OPT_APOB_NV_SIZE) \
245 $(OPT_APOB_NV_BASE) \
246 $(OPT_SPL_RW_AB_TABLE_FILE) \
247 $(OPT_SIGNED_AMDFW_A_POSITION) \
248 $(OPT_SIGNED_AMDFW_A_FILE) \
Fred Reitbergere66ce2f2023-07-05 15:43:19 -0400249 --location $(call _tohex,$(GLINDA_FW_A_POSITION)) \
Martin Rothf95a11e2022-10-21 16:43:08 -0600250 --anywhere \
251 --output $@
252
253$(obj)/amdfw_b.rom: $(obj)/amdfw.rom
254 rm -f $@
255 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
256 $(AMDFWTOOL) \
257 $(AMDFW_COMMON_ARGS) \
258 $(OPT_APOB_NV_SIZE) \
259 $(OPT_APOB_NV_BASE) \
260 $(OPT_SPL_RW_AB_TABLE_FILE) \
261 $(OPT_SIGNED_AMDFW_B_POSITION) \
262 $(OPT_SIGNED_AMDFW_B_FILE) \
Fred Reitbergere66ce2f2023-07-05 15:43:19 -0400263 --location $(call _tohex,$(GLINDA_FW_B_POSITION)) \
Martin Rothf95a11e2022-10-21 16:43:08 -0600264 --anywhere \
265 --output $@
266
267
Martin Rothf95a11e2022-10-21 16:43:08 -0600268ifeq ($(CONFIG_VBOOT_SLOTS_RW_AB)$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),yy)
269cbfs-files-y += apu/amdfw_a
270apu/amdfw_a-file := $(obj)/amdfw_a.rom
271apu/amdfw_a-position := $(AMD_FW_AB_POSITION)
272apu/amdfw_a-type := raw
273
274cbfs-files-y += apu/amdfw_b
275apu/amdfw_b-file := $(obj)/amdfw_b.rom
276apu/amdfw_b-position := $(AMD_FW_AB_POSITION)
277apu/amdfw_b-type := raw
278
279ifeq ($(CONFIG_SEPARATE_SIGNED_PSPFW),y)
280build_complete:: $(obj)/amdfw_a.rom $(obj)/amdfw_b.rom
281 @printf " Adding Signed ROM and HASH\n"
282 $(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_A -i 0 -f $(obj)/amdfw_a.rom.signed
283 $(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_B -i 0 -f $(obj)/amdfw_b.rom.signed
284 $(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_A -f $(obj)/amdfw_a.rom.signed.hash \
285 -n apu/amdfw_a_hash -t raw
286 $(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_B -f $(obj)/amdfw_b.rom.signed.hash \
287 -n apu/amdfw_b_hash -t raw
288endif # CONFIG_SEPARATE_SIGNED_PSPFW
289endif
290
291endif # ($(CONFIG_SOC_AMD_GLINDA),y)