| 1 |
|
| 2 |
|
| 3 |
#include <spi_flash.h> |
| 4 |
#include <types.h> |
| 5 |
#include "psp_def.h" |
| 6 |
|
| 7 |
enum psp_spi_id_type { |
| 8 |
SMI_TARGET_NVRAM = 0, |
| 9 |
SMI_TARGET_RPMC_NVRAM = 5, |
| 10 |
}; |
| 11 |
|
| 12 |
struct psp_spi_info_request { |
| 13 |
#if CONFIG(SOC_AMD_COMMON_BLOCK_PSP_GEN2) |
| 14 |
uint64_t target_nv_id; |
| 15 |
#endif |
| 16 |
uint64_t lba; |
| 17 |
uint64_t block_size; |
| 18 |
uint64_t num_blocks; |
| 19 |
} __packed; |
| 20 |
|
| 21 |
struct mbox_psp_cmd_spi_info { |
| 22 |
struct mbox_buffer_header header; |
| 23 |
struct psp_spi_info_request req; |
| 24 |
} __packed; |
| 25 |
|
| 26 |
struct psp_spi_read_write_request { |
| 27 |
#if CONFIG(SOC_AMD_COMMON_BLOCK_PSP_GEN2) |
| 28 |
uint64_t target_nv_id; |
| 29 |
#endif |
| 30 |
uint64_t lba; |
| 31 |
uint64_t offset; |
| 32 |
uint64_t num_bytes; |
| 33 |
uint8_t buffer[]; |
| 34 |
} __packed; |
| 35 |
|
| 36 |
struct mbox_psp_cmd_spi_read_write { |
| 37 |
struct mbox_buffer_header header; |
| 38 |
struct psp_spi_read_write_request req; |
| 39 |
} __packed; |
| 40 |
|
| 41 |
struct psp_spi_erase_request { |
| 42 |
#if CONFIG(SOC_AMD_COMMON_BLOCK_PSP_GEN2) |
| 43 |
uint64_t target_nv_id; |
| 44 |
#endif |
| 45 |
uint64_t lba; |
| 46 |
uint64_t num_blocks; |
| 47 |
} __packed; |
| 48 |
|
| 49 |
struct mbox_psp_cmd_spi_erase { |
| 50 |
struct mbox_buffer_header header; |
| 51 |
struct psp_spi_erase_request req; |
| 52 |
} __packed; |
| 53 |
|
| 54 |
struct psp_spi_rpmc_inc_mc { |
| 55 |
uint32_t counter_address; |
| 56 |
uint8_t counter_data[SPI_RPMC_COUNTER_DATA_LEN]; |
| 57 |
uint8_t signature[SPI_RPMC_SIG_LEN]; |
| 58 |
} __packed; |
| 59 |
|
| 60 |
struct mbox_psp_cmd_spi_rpmc_inc_mc { |
| 61 |
struct mbox_buffer_header header; |
| 62 |
struct psp_spi_rpmc_inc_mc req; |
| 63 |
} __packed; |
| 64 |
|
| 65 |
struct psp_smi_rpmc_req_mc { |
| 66 |
uint32_t counter_address; |
| 67 |
uint8_t tag[SPI_RPMC_TAG_LEN]; |
| 68 |
uint8_t signature[SPI_RPMC_SIG_LEN]; |
| 69 |
uint8_t output_counter_data[SPI_RPMC_COUNTER_DATA_LEN]; |
| 70 |
uint8_t output_signature[SPI_RPMC_SIG_LEN]; |
| 71 |
} __packed; |
| 72 |
|
| 73 |
struct mbox_psp_cmd_spi_rpmc_req_mc { |
| 74 |
struct mbox_buffer_header header; |
| 75 |
struct psp_smi_rpmc_req_mc req; |
| 76 |
} __packed; |
| 77 |
|
| 78 |
bool is_valid_psp_spi_info(struct mbox_psp_cmd_spi_info *cmd_buf); |
| 79 |
bool is_valid_psp_spi_read_write(struct mbox_psp_cmd_spi_read_write *cmd_buf); |
| 80 |
bool is_valid_psp_spi_erase(struct mbox_psp_cmd_spi_erase *cmd_buf); |
| 81 |
uint64_t get_psp_spi_info_id(struct mbox_psp_cmd_spi_info *cmd_buf); |
| 82 |
void set_psp_spi_info(struct mbox_psp_cmd_spi_info *cmd_buf, uint64_t lba, uint64_t block_size, |
| 83 |
uint64_t num_blocks); |
| 84 |
void get_psp_spi_read_write(struct mbox_psp_cmd_spi_read_write *cmd_buf, |
| 85 |
uint64_t *target_nv_id, uint64_t *lba, uint64_t *offset, |
| 86 |
uint64_t *num_bytes, uint8_t **data); |
| 87 |
void get_psp_spi_erase(struct mbox_psp_cmd_spi_erase *cmd_buf, uint64_t *target_nv_id, |
| 88 |
uint64_t *lba, uint64_t *num_blocks); |
| 89 |
|
| 90 |
enum mbox_p2c_status psp_smi_spi_get_info(struct mbox_default_buffer *buffer); |
| 91 |
enum mbox_p2c_status psp_smi_spi_read(struct mbox_default_buffer *buffer); |
| 92 |
enum mbox_p2c_status psp_smi_spi_write(struct mbox_default_buffer *buffer); |
| 93 |
enum mbox_p2c_status psp_smi_spi_erase(struct mbox_default_buffer *buffer); |
| 94 |
enum mbox_p2c_status psp_smi_spi_rpmc_inc_mc(struct mbox_default_buffer *buffer); |
| 95 |
enum mbox_p2c_status psp_smi_spi_rpmc_req_mc(struct mbox_default_buffer *buffer); |