amdfwtool: Upgrade "relative address" to four address modes

Address Mode 0: Physical Address, bit 63~56: 0x00
Address Mode 1: Relative Address to entire BIOS image, bit 63~56: 0x40
Address Mode 2: Relative Address to PSP/BIOS directory, bit 63~56: 0x80
Address Mode 3: Relative Address to slot N, bit 63~56: 0xC0

It is the expanding mode for simple relative address mode, for which
address_mode equals 1.

Only mode 2 is added. We need to record current table base address and
calculate the offset. The ctx.current_table is zero outside the
table. When it goes into the function to integrate the table, it
should backup the old value and get current table base. Before it goes
out the function, it should restore the value.

If the table address mode is 2, the address in each entry should be
also add address mode information. If not, the address mode in entry
is meanless.

The old mode 0,1 should be back compatible.

Change-Id: I29a03f4381cd0507e2b2e3b359111e3375a73de1
Signed-off-by: Zheng Bao <fishbaozi@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/59308
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Zheng Bao
2021-11-15 19:53:21 +08:00
committed by Felix Held
parent 8ad94770e2
commit 6fff2497b1
2 changed files with 99 additions and 22 deletions

View File

@@ -121,7 +121,16 @@ typedef struct _psp_directory_header {
uint32_t cookie;
uint32_t checksum;
uint32_t num_entries;
uint32_t additional_info;
union {
uint32_t additional_info;
struct {
uint32_t dir_size:10;
uint32_t spi_block_size:4;
uint32_t base_addr:15;
uint32_t address_mode:2;
uint32_t not_used:1;
} __attribute__((packed)) additional_info_fields;
};
} __attribute__((packed, aligned(16))) psp_directory_header;
typedef struct _psp_directory_entry {
@@ -129,7 +138,8 @@ typedef struct _psp_directory_entry {
uint8_t subprog;
uint16_t rsvd;
uint32_t size;
uint64_t addr; /* or a value in some cases */
uint64_t addr:62; /* or a value in some cases */
uint64_t address_mode:2;
} __attribute__((packed)) psp_directory_entry;
typedef struct _psp_directory_table {
@@ -164,7 +174,16 @@ typedef struct _bios_directory_hdr {
uint32_t cookie;
uint32_t checksum;
uint32_t num_entries;
uint32_t additional_info;
union {
uint32_t additional_info;
struct {
uint32_t dir_size:10;
uint32_t spi_block_size:4;
uint32_t base_addr:15;
uint32_t address_mode:2;
uint32_t not_used:1;
} __attribute__((packed)) additional_info_fields;
};
} __attribute__((packed, aligned(16))) bios_directory_hdr;
typedef struct _bios_directory_entry {
@@ -177,7 +196,8 @@ typedef struct _bios_directory_entry {
int inst:4;
uint8_t subprog; /* b[7:3] reserved */
uint32_t size;
uint64_t source;
uint64_t source:62;
uint64_t address_mode:2;
uint64_t dest;
} __attribute__((packed)) bios_directory_entry;