intel: mma: Use new CBFS API

This patch changes the Intel MMA driver to use the new CBFS API.

Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: Icc11d0c2a9ec1bd7a1d6af362f849dac16375433
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52282
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Julius Werner 2021-04-12 17:23:55 -07:00
parent 43c9d709c7
commit 62fa9f3cf9
4 changed files with 24 additions and 45 deletions

View File

@ -23,7 +23,7 @@ void setup_mma(FSP_M_CONFIG *memory_cfg)
{
struct mma_config_param mma_cfg;
if (mma_locate_param(&mma_cfg)) {
if (mma_map_param(&mma_cfg)) {
printk(BIOS_DEBUG, "MMA: set up failed\n");
return;
}

View File

@ -14,7 +14,6 @@
#define TEST_PARAM_MAX_SIZE 100
#define MMA_DATA_SIGNATURE (('M' << 0) | ('M' << 8) | \
('A' << 16) | ('D' << 24))
#define MMA_CBFS_REGION "COREBOOT"
struct mma_data_container {
uint32_t mma_signature; /* "MMAD" */
@ -99,31 +98,20 @@ static int label_value(const char *haystack, size_t haystack_sz,
return 0;
}
int mma_locate_param(struct mma_config_param *mma_cfg)
int mma_map_param(struct mma_config_param *mma_cfg)
{
void *mma_test_metadata;
size_t mma_test_metadata_file_len;
char test_filename[TEST_NAME_MAX_SIZE],
test_param_filename[TEST_PARAM_MAX_SIZE];
struct cbfsf metadata_fh, test_content_fh, test_param_fh;
uint32_t mma_type = CBFS_TYPE_MMA;
uint32_t efi_type = CBFS_TYPE_EFI;
bool metadata_parse_flag = true;
printk(BIOS_DEBUG, "MMA: Entry %s\n", __func__);
if (cbfs_locate_file_in_region(&metadata_fh, MMA_CBFS_REGION,
MMA_TEST_METADATA_FILENAME)) {
printk(BIOS_DEBUG, "MMA: Failed to locate %s\n",
MMA_TEST_METADATA_FILENAME);
return -1;
}
mma_test_metadata = rdev_mmap_full(&metadata_fh.data);
mma_test_metadata_file_len = region_device_sz(&metadata_fh.data);
if (!mma_test_metadata || !mma_test_metadata_file_len) {
printk(BIOS_DEBUG, "MMA: Failed to read %s\n",
mma_test_metadata = cbfs_ro_map(MMA_TEST_METADATA_FILENAME,
&mma_test_metadata_file_len);
if (!mma_test_metadata) {
printk(BIOS_DEBUG, "MMA: Failed to map %s\n",
MMA_TEST_METADATA_FILENAME);
return -1;
}
@ -145,7 +133,7 @@ int mma_locate_param(struct mma_config_param *mma_cfg)
metadata_parse_flag = false;
}
rdev_munmap(&metadata_fh.data, mma_test_metadata);
cbfs_unmap(mma_test_metadata);
if (!metadata_parse_flag)
return -1;
@ -153,24 +141,18 @@ int mma_locate_param(struct mma_config_param *mma_cfg)
printk(BIOS_DEBUG, "MMA: Got MMA_TEST_NAME=%s MMA_TEST_PARAM=%s\n",
test_filename, test_param_filename);
if (cbfs_locate_file_in_region(&test_content_fh, MMA_CBFS_REGION,
test_filename)) {
printk(BIOS_DEBUG, "MMA: Failed to locate %s\n",
test_filename);
mma_cfg->test_content = cbfs_ro_map(test_filename, &mma_cfg->test_content_size);
if (!mma_cfg->test_content) {
printk(BIOS_DEBUG, "MMA: Failed to map %s\n", test_filename);
return -1;
}
cbfs_file_data(&mma_cfg->test_content, &test_content_fh);
if (cbfs_locate_file_in_region(&test_param_fh, MMA_CBFS_REGION,
test_param_filename)) {
printk(BIOS_DEBUG, "MMA: Failed to locate %s\n",
test_param_filename);
mma_cfg->test_param = cbfs_ro_map(test_param_filename, &mma_cfg->test_param_size);
if (!mma_cfg->test_param) {
printk(BIOS_DEBUG, "MMA: Failed to map %s\n", test_param);
return -1;
}
cbfs_file_data(&mma_cfg->test_param, &test_param_fh);
printk(BIOS_DEBUG, "MMA: %s exit success\n", __func__);
return 0;

View File

@ -3,18 +3,19 @@
#ifndef _SOC_MMA_H_
#define _SOC_MMA_H_
#include <commonlib/region.h>
#include <types.h>
struct mma_config_param {
struct region_device test_content;
struct region_device test_param;
void *test_content;
size_t test_content_size;
void *test_param;
size_t test_param_size;
};
/* Locate mma metadata in CBFS, parse, find and fill rdev for
* mma test content and test param.
/* Locate mma metadata in CBFS, parse, find and map mma test content and test param.
* Returns 0 on success, < 0 on failure.
*/
int mma_locate_param(struct mma_config_param *mma_cfg);
int mma_map_param(struct mma_config_param *mma_cfg);
/* Locate the MMA hob from the FSP Hob list, This is implemented
* specific to FSP version.
* Returns 0 on success, < 0 on failure.

View File

@ -176,14 +176,10 @@ void soc_update_memory_params_for_mma(FSP_M_CONFIG *memory_cfg,
/* Boot media is memory mapped for Skylake and Kabylake (SPI). */
assert(CONFIG(BOOT_DEVICE_MEMORY_MAPPED));
memory_cfg->MmaTestContentPtr =
(uintptr_t) rdev_mmap_full(&mma_cfg->test_content);
memory_cfg->MmaTestContentSize =
region_device_sz(&mma_cfg->test_content);
memory_cfg->MmaTestConfigPtr =
(uintptr_t) rdev_mmap_full(&mma_cfg->test_param);
memory_cfg->MmaTestConfigSize =
region_device_sz(&mma_cfg->test_param);
memory_cfg->MmaTestContentPtr = (uintptr_t)mma_cfg->test_content;
memory_cfg->MmaTestContentSize = mma_cfg->test_content_size;
memory_cfg->MmaTestConfigPtr = (uintptr_t)mma_cfg->test_param;
memory_cfg->MmaTestConfigSize = mma_cfg->test_param_size;
memory_cfg->MrcFastBoot = 0x00;
memory_cfg->SaGv = 0x02;
}