amdfwtool: Set entry address mode based on current table header

The address field of each PSP or BIOS entry defines the location of
the entry.
For the family newer than Cezanne, the upper 2 bits define the address
mode. In table header, the address mode of the table is set. They have
the same definition.
  Address Mode 0: Physical Address
  Address Mode 1: Relative Address to entire BIOS image
  Address Mode 2: Relative Address to PSP/BIOS directory
  Address Mode 3: Relative Address to slot N

In common case, the address mode of entry should be the same as its
table. In spec, it says, "attribute is ignored if the directory
address mode is not 2 or 3",
In the old code, if the header defines address mode as relative BIOS(1),
the entry address mode is not set. That meets the spec. PSP doesn't
use, but amdfwtool can use it to record the address mode and transfer
it to table. That can reduce the code complexity.

Identidal binary test passes on platforms which are not based on
Cezanne, V2000A, Genoa. Booting test passes on Majolica/Cezanne.

Change-Id: I156b315d350d9e7217afc7442ca80277bb7f9095
Signed-off-by: Zheng Bao <fishbaozi@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84530
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
This commit is contained in:
Zheng Bao 2024-09-23 11:14:57 +08:00 committed by Felix Held
commit 8a0d68d804

View file

@ -382,10 +382,15 @@ amd_bios_entry amd_bios_table[] = {
#define BUFF_TO_RUN_MODE(ctx, ptr, mode) RUN_OFFSET_MODE((ctx), ((char *)(ptr) - (ctx).rom), \
(ctx).address_mode < (mode) ? (ctx).address_mode : (mode))
#define BUFF_ROOM(ctx) ((ctx).rom_size - (ctx).current)
/* Only set the address mode in entry if the table is mode 2. */
/* AMD PSP Spec: Only set the address mode in entry if the table is mode 2 or 3. */
/* For address mode 3, it is not be used in any SOC family yet.
For address mode 1, we can use it to store and transfer the address mode.
It can reduce the complexity. */
#define SET_ADDR_MODE(table, mode) \
((table)->header.additional_info_fields.address_mode == \
AMD_ADDR_REL_TAB ? (mode) : 0)
((table)->header.additional_info_fields.address_mode == AMD_ADDR_REL_TAB || \
(table)->header.additional_info_fields.address_mode == AMD_ADDR_REL_BIOS || \
(table)->header.additional_info_fields.address_mode == AMD_ADDR_REL_SLOT \
? (mode) : 0)
#define SET_ADDR_MODE_BY_TABLE(table) \
SET_ADDR_MODE((table), (table)->header.additional_info_fields.address_mode)