blob: 675712f6b422a2b208a32ad610f370d7ad5750b0 [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 -060025romstage-y += romstage.c
Martin Rothf95a11e2022-10-21 16:43:08 -060026
27ramstage-y += acpi.c
28ramstage-y += agesa_acpi.c
29ramstage-y += chip.c
30ramstage-y += cpu.c
Martin Rothf95a11e2022-10-21 16:43:08 -060031ramstage-y += fch.c
32ramstage-y += fsp_s_params.c
Martin Rothf95a11e2022-10-21 16:43:08 -060033ramstage-y += mca.c
Martin Rothf95a11e2022-10-21 16:43:08 -060034ramstage-y += root_complex.c
Martin Rothf95a11e2022-10-21 16:43:08 -060035ramstage-y += xhci.c
36
37smm-y += gpio.c
38smm-y += smihandler.c
Martin Rothf95a11e2022-10-21 16:43:08 -060039smm-$(CONFIG_DEBUG_SMI) += uart.c
40
41CPPFLAGS_common += -I$(src)/soc/amd/glinda/include
42CPPFLAGS_common += -I$(src)/soc/amd/glinda/acpi
43CPPFLAGS_common += -I$(src)/vendorcode/amd/fsp/glinda
44CPPFLAGS_common += -I$(src)/vendorcode/amd/fsp/common
45
Karthikeyan Ramasubramanian3167fb72023-10-16 14:53:57 -060046# Building the cbfs image will fail if the offset, aligned to 64 bytes, isn't large enough
47ifeq ($(CONFIG_CBFS_VERIFICATION),y)
48# 0x80 accounts for the cbfs_file struct + filename + metadata structs
49AMD_FW_AB_POSITION := 0x80
50else # ($(CONFIG_CBFS_VERIFICATION), y)
51# 0x40 accounts for the cbfs_file struct + filename + metadata structs without hash attribute
Martin Rothf95a11e2022-10-21 16:43:08 -060052AMD_FW_AB_POSITION := 0x40
Karthikeyan Ramasubramanian3167fb72023-10-16 14:53:57 -060053endif # ($(CONFIG_CBFS_VERIFICATION), y)
Martin Rothf95a11e2022-10-21 16:43:08 -060054
55GLINDA_FW_A_POSITION=$(call int-add, \
Matt DeVillier163dbdd2023-06-29 16:56:09 -050056 $(call get_fmap_value,FMAP_SECTION_FW_MAIN_A_START) $(AMD_FW_AB_POSITION))
Martin Rothf95a11e2022-10-21 16:43:08 -060057
58GLINDA_FW_B_POSITION=$(call int-add, \
Matt DeVillier163dbdd2023-06-29 16:56:09 -050059 $(call get_fmap_value,FMAP_SECTION_FW_MAIN_B_START) $(AMD_FW_AB_POSITION))
Martin Rothf95a11e2022-10-21 16:43:08 -060060#
61# PSP Directory Table items
62#
63# Certain ordering requirements apply, however these are ensured by amdfwtool.
64# For more information see "AMD Platform Security Processor BIOS Architecture
65# Design Guide for AMD Family 17h Processors" (PID #55758, NDA only).
66#
67
68ifeq ($(CONFIG_PSP_DISABLE_POSTCODES),y)
69PSP_SOFTFUSE_BITS += 7
70endif
71
72ifeq ($(CONFIG_PSP_UNLOCK_SECURE_DEBUG),y)
73# Enable secure debug unlock
74PSP_SOFTFUSE_BITS += 0
75OPT_TOKEN_UNLOCK="--token-unlock"
76endif
77
78ifeq ($(CONFIG_PSP_LOAD_MP2_FW),y)
79OPT_PSP_LOAD_MP2_FW="--load-mp2-fw"
80else
81# Disable MP2 firmware loading
82PSP_SOFTFUSE_BITS += 29
83endif
84
85# Use additional Soft Fuse bits specified in Kconfig
86PSP_SOFTFUSE_BITS += $(call strip_quotes, $(CONFIG_PSP_SOFTFUSE_BITS))
87
88# type = 0x3a
89ifeq ($(CONFIG_HAVE_PSP_WHITELIST_FILE),y)
90PSP_WHITELIST_FILE=$(CONFIG_PSP_WHITELIST_FILE)
91endif
92
93# type = 0x55
Martin Rothf95a11e2022-10-21 16:43:08 -060094SPL_TABLE_FILE=$(CONFIG_SPL_TABLE_FILE)
95ifeq ($(CONFIG_HAVE_SPL_RW_AB_FILE),y)
96SPL_RW_AB_TABLE_FILE=$(CONFIG_SPL_RW_AB_TABLE_FILE)
97else
98SPL_RW_AB_TABLE_FILE=$(CONFIG_SPL_TABLE_FILE)
99endif
Martin Rothf95a11e2022-10-21 16:43:08 -0600100
101#
102# BIOS Directory Table items - proper ordering is managed by amdfwtool
103#
104
105# type = 0x60
106PSP_APCB_FILES=$(APCB_SOURCES) $(APCB_SOURCES_RECOVERY)
107
108# type = 0x61
109PSP_APOB_BASE=$(CONFIG_PSP_APOB_DRAM_ADDRESS)
110
111# type = 0x62
112PSP_BIOSBIN_FILE=$(obj)/amd_biospsp.img
113PSP_ELF_FILE=$(objcbfs)/bootblock.elf
Felix Held3b89c952022-11-22 20:02:46 +0100114PSP_BIOSBIN_SIZE=$(shell $(READELF_bootblock) -Wl $(PSP_ELF_FILE) | grep LOAD | awk '{print $$5}')
115PSP_BIOSBIN_DEST=$(shell $(READELF_bootblock) -Wl $(PSP_ELF_FILE) | grep LOAD | awk '{print $$3}')
Martin Rothf95a11e2022-10-21 16:43:08 -0600116
Fred Reitberger2a1fc732023-07-17 09:09:42 -0400117ifneq ($(CONFIG_SOC_AMD_COMMON_BLOCK_APOB_NV_DISABLE),y)
Martin Rothf95a11e2022-10-21 16:43:08 -0600118# type = 0x63 - construct APOB NV base/size from flash map
119# The flashmap section used for this is expected to be named RW_MRC_CACHE
Matt DeVillier163dbdd2023-06-29 16:56:09 -0500120APOB_NV_SIZE=$(call get_fmap_value,FMAP_SECTION_RW_MRC_CACHE_SIZE)
121APOB_NV_BASE=$(call get_fmap_value,FMAP_SECTION_RW_MRC_CACHE_START)
Fred Reitberger2a1fc732023-07-17 09:09:42 -0400122endif # !CONFIG_SOC_AMD_COMMON_BLOCK_APOB_NV_DISABLE
Martin Rothf95a11e2022-10-21 16:43:08 -0600123
124ifeq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y)
125# type = 0x6B - PSP Shared memory location
126ifneq ($(CONFIG_PSP_SHAREDMEM_SIZE),0x0)
127PSP_SHAREDMEM_SIZE=$(CONFIG_PSP_SHAREDMEM_SIZE)
128PSP_SHAREDMEM_BASE=$(shell awk '$$3 == "_psp_sharedmem_dram" {printf "0x" $$1}' $(objcbfs)/bootblock.map)
129endif
130
131# type = 0x52 - PSP Bootloader Userspace Application (verstage)
132PSP_VERSTAGE_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_FILE))
133PSP_VERSTAGE_SIG_FILE=$(call strip_quotes,$(CONFIG_PSP_VERSTAGE_SIGNING_TOKEN))
134endif # CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK
135
136ifeq ($(CONFIG_SEPARATE_SIGNED_PSPFW),y)
137SIGNED_AMDFW_A_POSITION=$(call int-subtract, \
Matt DeVillier163dbdd2023-06-29 16:56:09 -0500138 $(call get_fmap_value,FMAP_SECTION_SIGNED_AMDFW_A_START) \
139 $(call get_fmap_value,FMAP_SECTION_FLASH_START))
Martin Rothf95a11e2022-10-21 16:43:08 -0600140SIGNED_AMDFW_B_POSITION=$(call int-subtract, \
Matt DeVillier163dbdd2023-06-29 16:56:09 -0500141 $(call get_fmap_value,FMAP_SECTION_SIGNED_AMDFW_B_START) \
142 $(call get_fmap_value,FMAP_SECTION_FLASH_START))
Martin Rothf95a11e2022-10-21 16:43:08 -0600143SIGNED_AMDFW_A_FILE=$(obj)/amdfw_a.rom.signed
144SIGNED_AMDFW_B_FILE=$(obj)/amdfw_b.rom.signed
145endif # CONFIG_SEPARATE_SIGNED_PSPFW
146
147# Helper function to return a value with given bit set
148# Soft Fuse type = 0xb - See #55758 (NDA) for bit definitions.
149set-bit=$(call int-shift-left, 1 $(call _toint,$1))
150PSP_SOFTFUSE=$(shell A=$(call int-add, \
Matt DeVillier0daefa52023-10-30 20:58:41 -0500151 $(foreach bit,$(sort $(PSP_SOFTFUSE_BITS)),$(call set-bit,$(bit)))); printf "0x%x" $$A)
Martin Rothf95a11e2022-10-21 16:43:08 -0600152
153#
154# Build the arguments to amdfwtool (order is unimportant). Missing file names
155# result in empty OPT_ variables, i.e. the argument is not passed to amdfwtool.
156#
157
158add_opt_prefix=$(if $(call strip_quotes, $(1)), $(2) $(call strip_quotes, $(1)), )
159
160OPT_VERSTAGE_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_FILE), --verstage)
161OPT_VERSTAGE_SIG_FILE=$(call add_opt_prefix, $(PSP_VERSTAGE_SIG_FILE), --verstage_sig)
162
163OPT_PSP_APCB_FILES= $(if $(APCB_SOURCES), --instance 0 --apcb $(APCB_SOURCES)) \
164 $(if $(APCB_SOURCES_RECOVERY), --instance 10 --apcb $(APCB_SOURCES_RECOVERY)) \
165 $(if $(APCB_SOURCES_68), --instance 18 --apcb $(APCB_SOURCES_68))
166
167OPT_APOB_ADDR=$(call add_opt_prefix, $(PSP_APOB_BASE), --apob-base)
168OPT_PSP_BIOSBIN_FILE=$(call add_opt_prefix, $(PSP_BIOSBIN_FILE), --bios-bin)
169OPT_PSP_BIOSBIN_DEST=$(call add_opt_prefix, $(PSP_BIOSBIN_DEST), --bios-bin-dest)
170OPT_PSP_BIOSBIN_SIZE=$(call add_opt_prefix, $(PSP_BIOSBIN_SIZE), --bios-uncomp-size)
171
172OPT_PSP_SHAREDMEM_BASE=$(call add_opt_prefix, $(PSP_SHAREDMEM_BASE), --sharedmem)
173OPT_PSP_SHAREDMEM_SIZE=$(call add_opt_prefix, $(PSP_SHAREDMEM_SIZE), --sharedmem-size)
174OPT_APOB_NV_SIZE=$(call add_opt_prefix, $(APOB_NV_SIZE), --apob-nv-size)
175OPT_APOB_NV_BASE=$(call add_opt_prefix, $(APOB_NV_BASE),--apob-nv-base)
176OPT_EFS_SPI_READ_MODE=$(call add_opt_prefix, $(CONFIG_EFS_SPI_READ_MODE), --spi-read-mode)
177OPT_EFS_SPI_SPEED=$(call add_opt_prefix, $(CONFIG_EFS_SPI_SPEED), --spi-speed)
178OPT_EFS_SPI_MICRON_FLAG=$(call add_opt_prefix, $(CONFIG_EFS_SPI_MICRON_FLAG), --spi-micron-flag)
179
180OPT_SIGNED_AMDFW_A_POSITION=$(call add_opt_prefix, $(SIGNED_AMDFW_A_POSITION), --signed-addr)
181OPT_SIGNED_AMDFW_A_FILE=$(call add_opt_prefix, $(SIGNED_AMDFW_A_FILE), --signed-output)
182OPT_SIGNED_AMDFW_B_POSITION=$(call add_opt_prefix, $(SIGNED_AMDFW_B_POSITION), --signed-addr)
183OPT_SIGNED_AMDFW_B_FILE=$(call add_opt_prefix, $(SIGNED_AMDFW_B_FILE), --signed-output)
184
185OPT_PSP_SOFTFUSE=$(call add_opt_prefix, $(PSP_SOFTFUSE), --soft-fuse)
186
187OPT_WHITELIST_FILE=$(call add_opt_prefix, $(PSP_WHITELIST_FILE), --whitelist)
188OPT_SPL_TABLE_FILE=$(call add_opt_prefix, $(SPL_TABLE_FILE), --spl-table)
189OPT_SPL_RW_AB_TABLE_FILE=$(call add_opt_prefix, $(SPL_RW_AB_TABLE_FILE), --spl-table)
190
191# If vboot uses 2 RW slots, then 2 copies of PSP binaries are redundant
192OPT_RECOVERY_AB_SINGLE_COPY=$(if $(CONFIG_VBOOT_SLOTS_RW_AB), --recovery-ab-single-copy)
193
194AMDFW_COMMON_ARGS=$(OPT_PSP_APCB_FILES) \
195 $(OPT_APOB_ADDR) \
Martin Roth0acf59d2023-03-08 15:18:24 -0700196 $(OPT_DEBUG_AMDFWTOOL) \
Martin Rothf95a11e2022-10-21 16:43:08 -0600197 $(OPT_PSP_BIOSBIN_FILE) \
198 $(OPT_PSP_BIOSBIN_DEST) \
199 $(OPT_PSP_BIOSBIN_SIZE) \
200 $(OPT_PSP_SOFTFUSE) \
201 $(OPT_PSP_LOAD_MP2_FW) \
202 --use-pspsecureos \
203 --load-s0i3 \
Martin Rothf95a11e2022-10-21 16:43:08 -0600204 $(OPT_TOKEN_UNLOCK) \
205 $(OPT_WHITELIST_FILE) \
206 $(OPT_PSP_SHAREDMEM_BASE) \
207 $(OPT_PSP_SHAREDMEM_SIZE) \
208 $(OPT_EFS_SPI_READ_MODE) \
209 $(OPT_EFS_SPI_SPEED) \
210 $(OPT_EFS_SPI_MICRON_FLAG) \
211 --config $(CONFIG_AMDFW_CONFIG_FILE) \
Martin Rothf95a11e2022-10-21 16:43:08 -0600212 --flashsize $(CONFIG_ROM_SIZE) \
213 $(OPT_RECOVERY_AB_SINGLE_COPY)
214
215$(obj)/amdfw.rom: $(call strip_quotes, $(PSP_BIOSBIN_FILE)) \
216 $(PSP_VERSTAGE_FILE) \
217 $(PSP_VERSTAGE_SIG_FILE) \
218 $$(PSP_APCB_FILES) \
219 $(DEP_FILES) \
220 $(AMDFWTOOL) \
221 $(obj)/fmap_config.h \
222 $(objcbfs)/bootblock.elf # this target also creates the .map file
Martin Rothf95a11e2022-10-21 16:43:08 -0600223 rm -f $@
224 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
225 $(AMDFWTOOL) \
226 $(AMDFW_COMMON_ARGS) \
227 $(OPT_APOB_NV_SIZE) \
228 $(OPT_APOB_NV_BASE) \
229 $(OPT_VERSTAGE_FILE) \
230 $(OPT_VERSTAGE_SIG_FILE) \
231 $(OPT_SPL_TABLE_FILE) \
Zheng Bao6bc06982023-02-14 13:26:31 +0800232 --location $(CONFIG_AMD_FWM_POSITION) \
Martin Rothf95a11e2022-10-21 16:43:08 -0600233 --output $@
234
235$(PSP_BIOSBIN_FILE): $(PSP_ELF_FILE) $(AMDCOMPRESS)
236 rm -f $@
237 @printf " AMDCOMPRS $(subst $(obj)/,,$(@))\n"
238 $(AMDCOMPRESS) --infile $(PSP_ELF_FILE) --outfile $@ --compress \
239 --maxsize $(PSP_BIOSBIN_SIZE)
240
241$(obj)/amdfw_a.rom: $(obj)/amdfw.rom
242 rm -f $@
243 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
244 $(AMDFWTOOL) \
245 $(AMDFW_COMMON_ARGS) \
246 $(OPT_APOB_NV_SIZE) \
247 $(OPT_APOB_NV_BASE) \
248 $(OPT_SPL_RW_AB_TABLE_FILE) \
249 $(OPT_SIGNED_AMDFW_A_POSITION) \
250 $(OPT_SIGNED_AMDFW_A_FILE) \
Fred Reitbergere66ce2f2023-07-05 15:43:19 -0400251 --location $(call _tohex,$(GLINDA_FW_A_POSITION)) \
Martin Rothf95a11e2022-10-21 16:43:08 -0600252 --anywhere \
253 --output $@
254
255$(obj)/amdfw_b.rom: $(obj)/amdfw.rom
256 rm -f $@
257 @printf " AMDFWTOOL $(subst $(obj)/,,$(@))\n"
258 $(AMDFWTOOL) \
259 $(AMDFW_COMMON_ARGS) \
260 $(OPT_APOB_NV_SIZE) \
261 $(OPT_APOB_NV_BASE) \
262 $(OPT_SPL_RW_AB_TABLE_FILE) \
263 $(OPT_SIGNED_AMDFW_B_POSITION) \
264 $(OPT_SIGNED_AMDFW_B_FILE) \
Fred Reitbergere66ce2f2023-07-05 15:43:19 -0400265 --location $(call _tohex,$(GLINDA_FW_B_POSITION)) \
Martin Rothf95a11e2022-10-21 16:43:08 -0600266 --anywhere \
267 --output $@
268
269
Martin Rothf95a11e2022-10-21 16:43:08 -0600270ifeq ($(CONFIG_VBOOT_SLOTS_RW_AB)$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),yy)
271cbfs-files-y += apu/amdfw_a
272apu/amdfw_a-file := $(obj)/amdfw_a.rom
273apu/amdfw_a-position := $(AMD_FW_AB_POSITION)
274apu/amdfw_a-type := raw
275
276cbfs-files-y += apu/amdfw_b
277apu/amdfw_b-file := $(obj)/amdfw_b.rom
278apu/amdfw_b-position := $(AMD_FW_AB_POSITION)
279apu/amdfw_b-type := raw
280
281ifeq ($(CONFIG_SEPARATE_SIGNED_PSPFW),y)
282build_complete:: $(obj)/amdfw_a.rom $(obj)/amdfw_b.rom
283 @printf " Adding Signed ROM and HASH\n"
284 $(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_A -i 0 -f $(obj)/amdfw_a.rom.signed
285 $(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_B -i 0 -f $(obj)/amdfw_b.rom.signed
286 $(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_A -f $(obj)/amdfw_a.rom.signed.hash \
287 -n apu/amdfw_a_hash -t raw
288 $(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_B -f $(obj)/amdfw_b.rom.signed.hash \
289 -n apu/amdfw_b_hash -t raw
290endif # CONFIG_SEPARATE_SIGNED_PSPFW
291endif
292
293endif # ($(CONFIG_SOC_AMD_GLINDA),y)