From 8fc68816a96c6fdfc7a35ec1c68b681b03decc06 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Fri, 18 Aug 2023 16:28:29 -0600 Subject: [PATCH] soc/amd: Move psp_transfer.h out of each SOC into common The psp_transfer.h file was the same under all SoCs, and is really tied to the file common/vboot/transfer.c, not the SOC. This patch makes an include directory under vboot to put the header into and sets it to be included for all SoCs using SOC_AMD_COMMON. This makes the header file available to all platforms, so that new chips that don't use the psp_verstage don't have to make a psp_transfer.h file just to satisfy the compiler. Signed-off-by: Martin Roth Change-Id: I5b9f2adee3a1d4d8d32813ec0a850344b7d717b2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/77303 Reviewed-by: Fred Reitberger Tested-by: build bot (Jenkins) --- .../amd/cezanne/include/soc/psp_transfer.h | 62 ------------------ src/soc/amd/cezanne/smihandler.c | 2 +- src/soc/amd/common/Makefile.inc | 2 + .../amd/common/block/cpu/noncar/bootblock.c | 2 +- .../cpu/noncar/memlayout_psp_verstage.ld | 2 +- .../common/block/cpu/noncar/memlayout_x86.ld | 2 +- .../psp_verstage/include/psp_verstage.h | 2 +- .../amd/common/psp_verstage/psp_verstage.c | 2 +- .../include/psp_verstage}/psp_transfer.h | 6 +- src/soc/amd/common/vboot/transfer_buffer.c | 2 +- src/soc/amd/common/vboot/vboot_bootblock.c | 2 +- src/soc/amd/glinda/include/soc/psp_transfer.h | 64 ------------------- .../amd/mendocino/include/soc/psp_transfer.h | 64 ------------------- .../amd/phoenix/include/soc/psp_transfer.h | 64 ------------------- 14 files changed, 13 insertions(+), 265 deletions(-) delete mode 100644 src/soc/amd/cezanne/include/soc/psp_transfer.h rename src/soc/amd/{picasso/include/soc => common/vboot/include/psp_verstage}/psp_transfer.h (94%) delete mode 100644 src/soc/amd/glinda/include/soc/psp_transfer.h delete mode 100644 src/soc/amd/mendocino/include/soc/psp_transfer.h delete mode 100644 src/soc/amd/phoenix/include/soc/psp_transfer.h diff --git a/src/soc/amd/cezanne/include/soc/psp_transfer.h b/src/soc/amd/cezanne/include/soc/psp_transfer.h deleted file mode 100644 index f81785ec11e..00000000000 --- a/src/soc/amd/cezanne/include/soc/psp_transfer.h +++ /dev/null @@ -1,62 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#ifndef AMD_CEZANNE_PSP_TRANSFER_H -#define AMD_CEZANNE_PSP_TRANSFER_H - -# if (CONFIG_CMOS_RECOVERY_BYTE != 0) -# define CMOS_RECOVERY_BYTE CONFIG_CMOS_RECOVERY_BYTE -# elif CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK) -# error "Must set CONFIG_CMOS_RECOVERY_BYTE" -# endif - -#define CMOS_RECOVERY_MAGIC_VAL 0x96 - -#define TRANSFER_INFO_SIZE 64 -#define TIMESTAMP_BUFFER_SIZE 0x200 - -#define TRANSFER_MAGIC_VAL 0x50544953 - -/* Bit definitions for the psp_info field in the PSP transfer_info_struct */ -#define PSP_INFO_PRODUCTION_MODE 0x00000001UL -#define PSP_INFO_PRODUCTION_SILICON 0x00000002UL -#define PSP_INFO_VALID 0x80000000UL - -/* Area for things that would cause errors in a linker script */ -#if !defined(__ASSEMBLER__) -#include - -struct transfer_info_struct { - uint32_t magic_val; /* Identifier */ - uint32_t struct_bytes; /* Size of this structure */ - uint32_t buffer_size; /* Size of the transfer buffer area */ - - /* Offsets from start of transfer buffer */ - uint32_t workbuf_offset; - uint32_t console_offset; - uint32_t timestamp_offset; - uint32_t fmap_offset; - - uint32_t unused1[5]; - - /* Fields reserved for the PSP */ - uint64_t timestamp; /* Offset 0x30 */ - uint32_t psp_unused; /* Offset 0x38 */ - uint32_t psp_info; /* Offset 0x3C */ -}; - -_Static_assert(sizeof(struct transfer_info_struct) == TRANSFER_INFO_SIZE, - "TRANSFER_INFO_SIZE is incorrect"); - -/* Make sure the PSP transferred information over to x86 side. */ -int transfer_buffer_valid(const struct transfer_info_struct *ptr); -/* Verify vboot work buffer is valid in transfer buffer */ -void verify_psp_transfer_buf(void); -/* Display the transfer block's PSP_info data */ -void show_psp_transfer_info(void); -/* Replays the pre-x86 cbmem console into the x86 cbmem console */ -void replay_transfer_buffer_cbmemc(void); -/* Called by bootblock_c_entry in the VBOOT_STARTS_BEFORE_BOOTBLOCK case */ -void boot_with_psp_timestamp(uint64_t base_timestamp); - -#endif -#endif /* AMD_CEZANNE_PSP_TRANSFER_H */ diff --git a/src/soc/amd/cezanne/smihandler.c b/src/soc/amd/cezanne/smihandler.c index 61f5099362e..2c5489f03b7 100644 --- a/src/soc/amd/cezanne/smihandler.c +++ b/src/soc/amd/cezanne/smihandler.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/soc/amd/common/Makefile.inc b/src/soc/amd/common/Makefile.inc index 9f455135467..c5d952ff2d3 100644 --- a/src/soc/amd/common/Makefile.inc +++ b/src/soc/amd/common/Makefile.inc @@ -5,6 +5,8 @@ subdirs-y += fsp subdirs-y += pi subdirs-y += vboot +CPPFLAGS_common += -I$(src)/soc/amd/common/vboot/include + ifneq ($(V),) OPT_DEBUG_AMDFWTOOL = --debug endif diff --git a/src/soc/amd/common/block/cpu/noncar/bootblock.c b/src/soc/amd/common/block/cpu/noncar/bootblock.c index 9ef899e5ac4..e32499de045 100644 --- a/src/soc/amd/common/block/cpu/noncar/bootblock.c +++ b/src/soc/amd/common/block/cpu/noncar/bootblock.c @@ -6,8 +6,8 @@ #include #include #include +#include #include -#include #include asmlinkage void bootblock_c_entry(uint64_t base_timestamp) diff --git a/src/soc/amd/common/block/cpu/noncar/memlayout_psp_verstage.ld b/src/soc/amd/common/block/cpu/noncar/memlayout_psp_verstage.ld index e0278abfc88..cc1a1b5026f 100644 --- a/src/soc/amd/common/block/cpu/noncar/memlayout_psp_verstage.ld +++ b/src/soc/amd/common/block/cpu/noncar/memlayout_psp_verstage.ld @@ -1,8 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include -#include #include +#include #include ENTRY(_psp_vs_start) diff --git a/src/soc/amd/common/block/cpu/noncar/memlayout_x86.ld b/src/soc/amd/common/block/cpu/noncar/memlayout_x86.ld index 42323f51bf1..090d8b727f2 100644 --- a/src/soc/amd/common/block/cpu/noncar/memlayout_x86.ld +++ b/src/soc/amd/common/block/cpu/noncar/memlayout_x86.ld @@ -2,7 +2,7 @@ #include #include -#include +#include #define EARLY_RESERVED_DRAM_START(addr) REGION_START(early_reserved_dram, addr) #define EARLY_RESERVED_DRAM_END(addr) REGION_END(early_reserved_dram, addr) diff --git a/src/soc/amd/common/psp_verstage/include/psp_verstage.h b/src/soc/amd/common/psp_verstage/include/psp_verstage.h index 39059b8c5c7..c397b1e7781 100644 --- a/src/soc/amd/common/psp_verstage/include/psp_verstage.h +++ b/src/soc/amd/common/psp_verstage/include/psp_verstage.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #define EMBEDDED_FW_SIGNATURE 0x55aa55aa diff --git a/src/soc/amd/common/psp_verstage/psp_verstage.c b/src/soc/amd/common/psp_verstage/psp_verstage.c index e84ea06289f..cc710fae617 100644 --- a/src/soc/amd/common/psp_verstage/psp_verstage.c +++ b/src/soc/amd/common/psp_verstage/psp_verstage.c @@ -12,8 +12,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/src/soc/amd/picasso/include/soc/psp_transfer.h b/src/soc/amd/common/vboot/include/psp_verstage/psp_transfer.h similarity index 94% rename from src/soc/amd/picasso/include/soc/psp_transfer.h rename to src/soc/amd/common/vboot/include/psp_verstage/psp_transfer.h index 5b5169161dd..e2365168ed6 100644 --- a/src/soc/amd/picasso/include/soc/psp_transfer.h +++ b/src/soc/amd/common/vboot/include/psp_verstage/psp_transfer.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef AMD_PICASSO_PSP_TRANSFER_H -#define AMD_PICASSO_PSP_TRANSFER_H +#ifndef AMD_COMMON_PSP_TRANSFER_H +#define AMD_COMMON_PSP_TRANSFER_H # if (CONFIG_CMOS_RECOVERY_BYTE != 0) # define CMOS_RECOVERY_BYTE CONFIG_CMOS_RECOVERY_BYTE @@ -60,4 +60,4 @@ void boot_with_psp_timestamp(uint64_t base_timestamp); #endif -#endif /* AMD_PICASSO_PSP_TRANSFER_H */ +#endif /* AMD_COMMON_PSP_TRANSFER_H */ diff --git a/src/soc/amd/common/vboot/transfer_buffer.c b/src/soc/amd/common/vboot/transfer_buffer.c index e08847e8ca5..a9644d3a089 100644 --- a/src/soc/amd/common/vboot/transfer_buffer.c +++ b/src/soc/amd/common/vboot/transfer_buffer.c @@ -4,9 +4,9 @@ #include #include #include +#include #include #include -#include #include #include <2struct.h> diff --git a/src/soc/amd/common/vboot/vboot_bootblock.c b/src/soc/amd/common/vboot/vboot_bootblock.c index 07039fd3b5a..9b24232263b 100644 --- a/src/soc/amd/common/vboot/vboot_bootblock.c +++ b/src/soc/amd/common/vboot/vboot_bootblock.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/soc/amd/glinda/include/soc/psp_transfer.h b/src/soc/amd/glinda/include/soc/psp_transfer.h deleted file mode 100644 index 2c2b22abee3..00000000000 --- a/src/soc/amd/glinda/include/soc/psp_transfer.h +++ /dev/null @@ -1,64 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -/* TODO: Update for Glinda */ - -#ifndef AMD_GLINDA_PSP_TRANSFER_H -#define AMD_GLINDA_PSP_TRANSFER_H - -# if (CONFIG_CMOS_RECOVERY_BYTE != 0) -# define CMOS_RECOVERY_BYTE CONFIG_CMOS_RECOVERY_BYTE -# elif CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK) -# error "Must set CONFIG_CMOS_RECOVERY_BYTE" -# endif - -#define CMOS_RECOVERY_MAGIC_VAL 0x96 - -#define TRANSFER_INFO_SIZE 64 -#define TIMESTAMP_BUFFER_SIZE 0x200 - -#define TRANSFER_MAGIC_VAL 0x50544953 - -/* Bit definitions for the psp_info field in the PSP transfer_info_struct */ -#define PSP_INFO_PRODUCTION_MODE 0x00000001UL -#define PSP_INFO_PRODUCTION_SILICON 0x00000002UL -#define PSP_INFO_VALID 0x80000000UL - -/* Area for things that would cause errors in a linker script */ -#if !defined(__ASSEMBLER__) -#include - -struct transfer_info_struct { - uint32_t magic_val; /* Identifier */ - uint32_t struct_bytes; /* Size of this structure */ - uint32_t buffer_size; /* Size of the transfer buffer area */ - - /* Offsets from start of transfer buffer */ - uint32_t workbuf_offset; - uint32_t console_offset; - uint32_t timestamp_offset; - uint32_t fmap_offset; - - uint32_t unused1[5]; - - /* Fields reserved for the PSP */ - uint64_t timestamp; /* Offset 0x30 */ - uint32_t psp_unused; /* Offset 0x38 */ - uint32_t psp_info; /* Offset 0x3C */ -}; - -_Static_assert(sizeof(struct transfer_info_struct) == TRANSFER_INFO_SIZE, - "TRANSFER_INFO_SIZE is incorrect"); - -/* Make sure the PSP transferred information over to x86 side. */ -int transfer_buffer_valid(const struct transfer_info_struct *ptr); -/* Verify vboot work buffer is valid in transfer buffer */ -void verify_psp_transfer_buf(void); -/* Display the transfer block's PSP_info data */ -void show_psp_transfer_info(void); -/* Replays the pre-x86 cbmem console into the x86 cbmem console */ -void replay_transfer_buffer_cbmemc(void); -/* Called by bootblock_c_entry in the VBOOT_STARTS_BEFORE_BOOTBLOCK case */ -void boot_with_psp_timestamp(uint64_t base_timestamp); - -#endif -#endif /* AMD_GLINDA_PSP_TRANSFER_H */ diff --git a/src/soc/amd/mendocino/include/soc/psp_transfer.h b/src/soc/amd/mendocino/include/soc/psp_transfer.h deleted file mode 100644 index 3612f176b22..00000000000 --- a/src/soc/amd/mendocino/include/soc/psp_transfer.h +++ /dev/null @@ -1,64 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -/* TODO: Check if this is still correct */ - -#ifndef AMD_MENDOCINO_PSP_TRANSFER_H -#define AMD_MENDOCINO_PSP_TRANSFER_H - -# if (CONFIG_CMOS_RECOVERY_BYTE != 0) -# define CMOS_RECOVERY_BYTE CONFIG_CMOS_RECOVERY_BYTE -# elif CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK) -# error "Must set CONFIG_CMOS_RECOVERY_BYTE" -# endif - -#define CMOS_RECOVERY_MAGIC_VAL 0x96 - -#define TRANSFER_INFO_SIZE 64 -#define TIMESTAMP_BUFFER_SIZE 0x200 - -#define TRANSFER_MAGIC_VAL 0x50544953 - -/* Bit definitions for the psp_info field in the PSP transfer_info_struct */ -#define PSP_INFO_PRODUCTION_MODE 0x00000001UL -#define PSP_INFO_PRODUCTION_SILICON 0x00000002UL -#define PSP_INFO_VALID 0x80000000UL - -/* Area for things that would cause errors in a linker script */ -#if !defined(__ASSEMBLER__) -#include - -struct transfer_info_struct { - uint32_t magic_val; /* Identifier */ - uint32_t struct_bytes; /* Size of this structure */ - uint32_t buffer_size; /* Size of the transfer buffer area */ - - /* Offsets from start of transfer buffer */ - uint32_t workbuf_offset; - uint32_t console_offset; - uint32_t timestamp_offset; - uint32_t fmap_offset; - - uint32_t unused1[5]; - - /* Fields reserved for the PSP */ - uint64_t timestamp; /* Offset 0x30 */ - uint32_t psp_unused; /* Offset 0x38 */ - uint32_t psp_info; /* Offset 0x3C */ -}; - -_Static_assert(sizeof(struct transfer_info_struct) == TRANSFER_INFO_SIZE, - "TRANSFER_INFO_SIZE is incorrect"); - -/* Make sure the PSP transferred information over to x86 side. */ -int transfer_buffer_valid(const struct transfer_info_struct *ptr); -/* Verify vboot work buffer is valid in transfer buffer */ -void verify_psp_transfer_buf(void); -/* Display the transfer block's PSP_info data */ -void show_psp_transfer_info(void); -/* Replays the pre-x86 cbmem console into the x86 cbmem console */ -void replay_transfer_buffer_cbmemc(void); -/* Called by bootblock_c_entry in the VBOOT_STARTS_BEFORE_BOOTBLOCK case */ -void boot_with_psp_timestamp(uint64_t base_timestamp); - -#endif -#endif /* AMD_MENDOCINO_PSP_TRANSFER_H */ diff --git a/src/soc/amd/phoenix/include/soc/psp_transfer.h b/src/soc/amd/phoenix/include/soc/psp_transfer.h deleted file mode 100644 index a197bb8f83c..00000000000 --- a/src/soc/amd/phoenix/include/soc/psp_transfer.h +++ /dev/null @@ -1,64 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -/* TODO: Update for Phoenix */ - -#ifndef AMD_PHOENIX_PSP_TRANSFER_H -#define AMD_PHOENIX_PSP_TRANSFER_H - -# if (CONFIG_CMOS_RECOVERY_BYTE != 0) -# define CMOS_RECOVERY_BYTE CONFIG_CMOS_RECOVERY_BYTE -# elif CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK) -# error "Must set CONFIG_CMOS_RECOVERY_BYTE" -# endif - -#define CMOS_RECOVERY_MAGIC_VAL 0x96 - -#define TRANSFER_INFO_SIZE 64 -#define TIMESTAMP_BUFFER_SIZE 0x200 - -#define TRANSFER_MAGIC_VAL 0x50544953 - -/* Bit definitions for the psp_info field in the PSP transfer_info_struct */ -#define PSP_INFO_PRODUCTION_MODE 0x00000001UL -#define PSP_INFO_PRODUCTION_SILICON 0x00000002UL -#define PSP_INFO_VALID 0x80000000UL - -/* Area for things that would cause errors in a linker script */ -#if !defined(__ASSEMBLER__) -#include - -struct transfer_info_struct { - uint32_t magic_val; /* Identifier */ - uint32_t struct_bytes; /* Size of this structure */ - uint32_t buffer_size; /* Size of the transfer buffer area */ - - /* Offsets from start of transfer buffer */ - uint32_t workbuf_offset; - uint32_t console_offset; - uint32_t timestamp_offset; - uint32_t fmap_offset; - - uint32_t unused1[5]; - - /* Fields reserved for the PSP */ - uint64_t timestamp; /* Offset 0x30 */ - uint32_t psp_unused; /* Offset 0x38 */ - uint32_t psp_info; /* Offset 0x3C */ -}; - -_Static_assert(sizeof(struct transfer_info_struct) == TRANSFER_INFO_SIZE, - "TRANSFER_INFO_SIZE is incorrect"); - -/* Make sure the PSP transferred information over to x86 side. */ -int transfer_buffer_valid(const struct transfer_info_struct *ptr); -/* Verify vboot work buffer is valid in transfer buffer */ -void verify_psp_transfer_buf(void); -/* Display the transfer block's PSP_info data */ -void show_psp_transfer_info(void); -/* Replays the pre-x86 cbmem console into the x86 cbmem console */ -void replay_transfer_buffer_cbmemc(void); -/* Called by bootblock_c_entry in the VBOOT_STARTS_BEFORE_BOOTBLOCK case */ -void boot_with_psp_timestamp(uint64_t base_timestamp); - -#endif -#endif /* AMD_PHOENIX_PSP_TRANSFER_H */