Attention is currently required from: Fred Reitberger, Jason Glenesk, Matt DeVillier.
Felix Held has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/84063?usp=email )
Change subject: soc/amd/common/psp/psp_smi_flash: introduce common data structures ......................................................................
soc/amd/common/psp/psp_smi_flash: introduce common data structures
The request buffer data structures differ between the PSP generation 1 and 2 in the way that the generation 2 added the 64 bit target NV ID field right at the beginning of the request buffer data structures. In order to make the data structure definitions common, remove the target_nv_id struct element via the preprocessor in case the SOC_AMD_COMMON_BLOCK_PSP_GEN2 option isn't selected. Since the request buffer data structures are now common for both generations, also remove the 'v2' from the struct names.
Signed-off-by: Felix Held felix-coreboot@felixheld.de Change-Id: Ibe0bd2d8e6a5c39cc67a49e7bb3a51ce0900a39a --- M src/soc/amd/common/block/psp/psp_smi_flash.c M src/soc/amd/common/block/psp/psp_smi_flash.h M src/soc/amd/common/block/psp/psp_smi_flash_gen2.c 3 files changed, 40 insertions(+), 34 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/84063/1
diff --git a/src/soc/amd/common/block/psp/psp_smi_flash.c b/src/soc/amd/common/block/psp/psp_smi_flash.c index 8a62296..e9b906b 100644 --- a/src/soc/amd/common/block/psp/psp_smi_flash.c +++ b/src/soc/amd/common/block/psp/psp_smi_flash.c @@ -11,13 +11,13 @@ #include "psp_def.h" #include "psp_smi_flash.h"
-static bool is_valid_rw_byte_count(struct mbox_pspv2_cmd_spi_read_write *cmd_buf, +static bool is_valid_rw_byte_count(struct mbox_psp_cmd_spi_read_write *cmd_buf, u64 num_bytes) { const u32 cmd_buf_size = read32(&cmd_buf->header.size); const size_t payload_buffer_offset = - offsetof(struct mbox_pspv2_cmd_spi_read_write, req) + - offsetof(struct pspv2_spi_read_write_request, buffer); + offsetof(struct mbox_psp_cmd_spi_read_write, req) + + offsetof(struct psp_spi_read_write_request, buffer); return num_bytes <= cmd_buf_size - payload_buffer_offset; }
@@ -91,8 +91,8 @@
enum mbox_p2c_status psp_smi_spi_get_info(struct mbox_default_buffer *buffer) { - struct mbox_pspv2_cmd_spi_info *const cmd_buf = - (struct mbox_pspv2_cmd_spi_info *)buffer; + struct mbox_psp_cmd_spi_info *const cmd_buf = + (struct mbox_psp_cmd_spi_info *)buffer; const struct spi_flash *flash; struct region_device store; u64 target_nv_id; @@ -131,8 +131,8 @@
enum mbox_p2c_status psp_smi_spi_read(struct mbox_default_buffer *buffer) { - struct mbox_pspv2_cmd_spi_read_write *const cmd_buf = - (struct mbox_pspv2_cmd_spi_read_write *)buffer; + struct mbox_psp_cmd_spi_read_write *const cmd_buf = + (struct mbox_psp_cmd_spi_read_write *)buffer; enum mbox_p2c_status ret; u64 target_nv_id; u64 lba; @@ -180,8 +180,8 @@
enum mbox_p2c_status psp_smi_spi_write(struct mbox_default_buffer *buffer) { - struct mbox_pspv2_cmd_spi_read_write *const cmd_buf = - (struct mbox_pspv2_cmd_spi_read_write *)buffer; + struct mbox_psp_cmd_spi_read_write *const cmd_buf = + (struct mbox_psp_cmd_spi_read_write *)buffer; enum mbox_p2c_status ret; u64 target_nv_id; u64 lba; @@ -229,8 +229,8 @@
enum mbox_p2c_status psp_smi_spi_erase(struct mbox_default_buffer *buffer) { - struct mbox_pspv2_cmd_spi_erase *const cmd_buf = - (struct mbox_pspv2_cmd_spi_erase *)buffer; + struct mbox_psp_cmd_spi_erase *const cmd_buf = + (struct mbox_psp_cmd_spi_erase *)buffer; enum mbox_p2c_status ret; u64 target_nv_id; u64 lba; diff --git a/src/soc/amd/common/block/psp/psp_smi_flash.h b/src/soc/amd/common/block/psp/psp_smi_flash.h index 077cc3b..52144f8 100644 --- a/src/soc/amd/common/block/psp/psp_smi_flash.h +++ b/src/soc/amd/common/block/psp/psp_smi_flash.h @@ -8,49 +8,55 @@ SMI_TARGET_RPMC_NVRAM = 5, };
-struct pspv2_spi_info_request { +struct psp_spi_info_request { +#if CONFIG(SOC_AMD_COMMON_BLOCK_PSP_GEN2) u64 target_nv_id; +#endif u64 lba; u64 block_size; u64 num_blocks; } __packed;
-struct mbox_pspv2_cmd_spi_info { +struct mbox_psp_cmd_spi_info { struct mbox_buffer_header header; - struct pspv2_spi_info_request req; + struct psp_spi_info_request req; } __packed;
-struct pspv2_spi_read_write_request { +struct psp_spi_read_write_request { +#if CONFIG(SOC_AMD_COMMON_BLOCK_PSP_GEN2) u64 target_nv_id; +#endif u64 lba; u64 offset; u64 num_bytes; u8 buffer[]; } __packed;
-struct mbox_pspv2_cmd_spi_read_write { +struct mbox_psp_cmd_spi_read_write { struct mbox_buffer_header header; - struct pspv2_spi_read_write_request req; + struct psp_spi_read_write_request req; } __packed;
-struct pspv2_spi_erase_request { +struct psp_spi_erase_request { +#if CONFIG(SOC_AMD_COMMON_BLOCK_PSP_GEN2) u64 target_nv_id; +#endif u64 lba; u64 num_blocks; } __packed;
-struct mbox_pspv2_cmd_spi_erase { +struct mbox_psp_cmd_spi_erase { struct mbox_buffer_header header; - struct pspv2_spi_erase_request req; + struct psp_spi_erase_request req; } __packed;
-bool is_valid_psp_spi_info(struct mbox_pspv2_cmd_spi_info *cmd_buf); -bool is_valid_psp_spi_read_write(struct mbox_pspv2_cmd_spi_read_write *cmd_buf); -bool is_valid_psp_spi_erase(struct mbox_pspv2_cmd_spi_erase *cmd_buf); -u64 get_psp_spi_info_id(struct mbox_pspv2_cmd_spi_info *cmd_buf); -void set_psp_spi_info(struct mbox_pspv2_cmd_spi_info *cmd_buf, u64 lba, u64 block_size, +bool is_valid_psp_spi_info(struct mbox_psp_cmd_spi_info *cmd_buf); +bool is_valid_psp_spi_read_write(struct mbox_psp_cmd_spi_read_write *cmd_buf); +bool is_valid_psp_spi_erase(struct mbox_psp_cmd_spi_erase *cmd_buf); +u64 get_psp_spi_info_id(struct mbox_psp_cmd_spi_info *cmd_buf); +void set_psp_spi_info(struct mbox_psp_cmd_spi_info *cmd_buf, u64 lba, u64 block_size, u64 num_blocks); -void get_psp_spi_read_write(struct mbox_pspv2_cmd_spi_read_write *cmd_buf, u64 *target_nv_id, +void get_psp_spi_read_write(struct mbox_psp_cmd_spi_read_write *cmd_buf, u64 *target_nv_id, u64 *lba, u64 *offset, u64 *num_bytes, u8 **data); -void get_psp_spi_erase(struct mbox_pspv2_cmd_spi_erase *cmd_buf, u64 *target_nv_id, u64 *lba, +void get_psp_spi_erase(struct mbox_psp_cmd_spi_erase *cmd_buf, u64 *target_nv_id, u64 *lba, u64 *num_blocks); diff --git a/src/soc/amd/common/block/psp/psp_smi_flash_gen2.c b/src/soc/amd/common/block/psp/psp_smi_flash_gen2.c index 99ea030..f62cdd2 100644 --- a/src/soc/amd/common/block/psp/psp_smi_flash_gen2.c +++ b/src/soc/amd/common/block/psp/psp_smi_flash_gen2.c @@ -11,27 +11,27 @@ target_nv_id == SMI_TARGET_RPMC_NVRAM; }
-bool is_valid_psp_spi_info(struct mbox_pspv2_cmd_spi_info *cmd_buf) +bool is_valid_psp_spi_info(struct mbox_psp_cmd_spi_info *cmd_buf) { return is_valid_psp_spi_id(read64(&cmd_buf->req.target_nv_id)); }
-bool is_valid_psp_spi_read_write(struct mbox_pspv2_cmd_spi_read_write *cmd_buf) +bool is_valid_psp_spi_read_write(struct mbox_psp_cmd_spi_read_write *cmd_buf) { return is_valid_psp_spi_id(read64(&cmd_buf->req.target_nv_id)); }
-bool is_valid_psp_spi_erase(struct mbox_pspv2_cmd_spi_erase *cmd_buf) +bool is_valid_psp_spi_erase(struct mbox_psp_cmd_spi_erase *cmd_buf) { return is_valid_psp_spi_id(read64(&cmd_buf->req.target_nv_id)); }
-u64 get_psp_spi_info_id(struct mbox_pspv2_cmd_spi_info *cmd_buf) +u64 get_psp_spi_info_id(struct mbox_psp_cmd_spi_info *cmd_buf) { return read64(&cmd_buf->req.target_nv_id); }
-void set_psp_spi_info(struct mbox_pspv2_cmd_spi_info *cmd_buf, u64 lba, u64 block_size, +void set_psp_spi_info(struct mbox_psp_cmd_spi_info *cmd_buf, u64 lba, u64 block_size, u64 num_blocks) { write64(&cmd_buf->req.lba, lba); @@ -39,7 +39,7 @@ write64(&cmd_buf->req.num_blocks, num_blocks); }
-void get_psp_spi_read_write(struct mbox_pspv2_cmd_spi_read_write *cmd_buf, u64 *target_nv_id, +void get_psp_spi_read_write(struct mbox_psp_cmd_spi_read_write *cmd_buf, u64 *target_nv_id, u64 *lba, u64 *offset, u64 *num_bytes, u8 **data) { *target_nv_id = read64(&cmd_buf->req.target_nv_id); @@ -49,7 +49,7 @@ *data = cmd_buf->req.buffer; }
-void get_psp_spi_erase(struct mbox_pspv2_cmd_spi_erase *cmd_buf, u64 *target_nv_id, u64 *lba, +void get_psp_spi_erase(struct mbox_psp_cmd_spi_erase *cmd_buf, u64 *target_nv_id, u64 *lba, u64 *num_blocks) { *target_nv_id = read64(&cmd_buf->req.target_nv_id);