drivers/smmstore: Allow using raw FMAP regions

Use a raw fmap region SMMSTORE for the SMMSTORE mechanism, while
keeping the initial option to use a cbfsfile.

TESTED on Asus P5QC, (although it looks like the tianocore patches
using it might need some love as they can't seem to save properly).

Change-Id: I8c2b9b3a0ed16b2d37e6a97e33c671fb54df8de0
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/29991
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Arthur Heymans 2018-12-01 15:28:03 +01:00 committed by Patrick Georgi
parent dbcf293211
commit 8b04dc730d
2 changed files with 31 additions and 12 deletions

View File

@ -19,14 +19,22 @@ config SMMSTORE
depends on BOOT_DEVICE_SUPPORTS_WRITES depends on BOOT_DEVICE_SUPPORTS_WRITES
select SPI_FLASH_SMM if BOOT_DEVICE_SPI_FLASH_RW_NOMMAP select SPI_FLASH_SMM if BOOT_DEVICE_SPI_FLASH_RW_NOMMAP
config SMMSTORE_IN_CBFS
bool
default n
help
Select this if you want to the SMMSTORE region in a
cbfsfile in a cbfs FMAP region
if SMMSTORE if SMMSTORE
config SMMSTORE_REGION config SMMSTORE_REGION
string "fmap region in which SMM store file is kept" string "fmap region in which SMM store file is kept" if SMMSTORE_IN_CBFS
default "RW_LEGACY" if CHROMEOS default "RW_LEGACY" if CHROMEOS && SMMSTORE_IN_CBFS
default "COREBOOT" default "COREBOOT" if SMMSTORE_IN_CBFS
default "SMMSTORE"
config SMMSTORE_FILENAME config SMMSTORE_FILENAME
string "SMM store file name" string "SMM store file name" if SMMSTORE_IN_CBFS
default "smm_store" default "smm_store"
endif endif

View File

@ -15,6 +15,7 @@
#include <boot_device.h> #include <boot_device.h>
#include <cbfs.h> #include <cbfs.h>
#include <fmap.h>
#include <commonlib/region.h> #include <commonlib/region.h>
#include <console/console.h> #include <console/console.h>
#include <smmstore.h> #include <smmstore.h>
@ -57,15 +58,25 @@
static int lookup_store(struct region_device *rstore) static int lookup_store(struct region_device *rstore)
{ {
struct cbfsf file; struct cbfsf file;
if (cbfs_locate_file_in_region(&file, if (IS_ENABLED(CONFIG_SMMSTORE_IN_CBFS)) {
CONFIG_SMMSTORE_REGION, CONFIG_SMMSTORE_FILENAME, NULL) < 0) { if (cbfs_locate_file_in_region(&file,
printk(BIOS_WARNING, "smm store: " CONFIG_SMMSTORE_REGION,
"Unable to find SMM store file in region '%s'\n", CONFIG_SMMSTORE_FILENAME, NULL) < 0) {
CONFIG_SMMSTORE_REGION); printk(BIOS_WARNING, "smm store: "
return -1; "Unable to find SMM store file in region '%s'\n",
} CONFIG_SMMSTORE_REGION);
return -1;
}
cbfs_file_data(rstore, &file); cbfs_file_data(rstore, &file);
} else {
if (fmap_locate_area_as_rdev_rw(CONFIG_SMMSTORE_REGION, rstore)) {
printk(BIOS_WARNING,
"smm store: Unable to find SMM store FMAP region '%s'\n",
CONFIG_SMMSTORE_REGION);
return -1;
}
}
return 0; return 0;
} }