Nicholas Chin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/85905?usp=email )
Change subject: drivers/option: Add CBFS file based option backend ......................................................................
drivers/option: Add CBFS file based option backend
Add a new option backend that uses values stored in CBFS files, similar to the SeaBIOS runtime config options stored in files with the etc/ prefix. Values can be set using `cbfstool coreboot.rom add-int -i value -n option_name`.
Change-Id: Ifc0439ee42f13f49ae54d4855d1d9333c39b01f5 Signed-off-by: Nicholas Chin nic.c3.14@gmail.com --- M src/Kconfig M src/drivers/option/Makefile.mk A src/drivers/option/cbfs_file_option.c 3 files changed, 33 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/05/85905/1
diff --git a/src/Kconfig b/src/Kconfig index 55fad95..0a0643e 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -164,6 +164,12 @@ Enable this option if coreboot shall read options from the "CMOS" NVRAM instead of using hard-coded values.
+config USE_CBFS_FILE_OPTION_BACKEND + bool "Use CBFS files for configuration values" + help + Enable this option if coreboot shall read options from files in CBFS. + Options can be set using `cbfstool add-int -n option-name -i value`. + config USE_UEFI_VARIABLE_STORE bool "Use UEFI variable-store in SPI flash as option backend" depends on DRIVERS_EFI_VARIABLE_STORE diff --git a/src/drivers/option/Makefile.mk b/src/drivers/option/Makefile.mk index 7ca439d..1d1c05e 100644 --- a/src/drivers/option/Makefile.mk +++ b/src/drivers/option/Makefile.mk @@ -1,3 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only
ramstage-$(CONFIG_DRIVERS_OPTION_CFR) += cfr.c + +all-$(CONFIG_USE_CBFS_FILE_OPTION_BACKEND) += cbfs_file_option.c +smm-$(CONFIG_USE_CBFS_FILE_OPTION_BACKEND) += cbfs_file_option.c diff --git a/src/drivers/option/cbfs_file_option.c b/src/drivers/option/cbfs_file_option.c new file mode 100644 index 0000000..7f7ade7 --- /dev/null +++ b/src/drivers/option/cbfs_file_option.c @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <cbfs.h> +#include <console/console.h> +#include <option.h> + +unsigned int get_uint_option(const char *name, const unsigned int fallback) +{ + unsigned int value; + size_t size; + unsigned int *p = cbfs_map(name, &size); + if (!p || size < sizeof(value)) { + value = fallback; + } else { + value = *p; + cbfs_unmap(p); + } + return value; +} + +enum cb_err set_uint_option(const char *name, unsigned int value) +{ + return CB_ERR_NOT_IMPLEMENTED; +}