Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/52856 )
Change subject: lib/option: Move CMOS option backend to choice ......................................................................
lib/option: Move CMOS option backend to choice
In order to add more option backend make the current one part of a Kconfig choice. Also remove the remaining 'select' directives which do not work with choice options.
Instead of inlining the option framework add a stub file in case no option backend is selected, which is the default.
Change-Id: Ibcbc3db01d35b933678e5d6a203b2a9e406092fe Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M payloads/Kconfig M src/Kconfig M src/drivers/pc80/rtc/option.c M src/include/option.h M src/lib/Makefile.inc A src/lib/option.c 6 files changed, 43 insertions(+), 21 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/56/52856/1
diff --git a/payloads/Kconfig b/payloads/Kconfig index 627bb95..386b207 100644 --- a/payloads/Kconfig +++ b/payloads/Kconfig @@ -133,7 +133,6 @@ bool "Load nvramcui as a secondary payload" default n depends on ARCH_X86 && HAVE_OPTION_TABLE - select USE_OPTION_TABLE help nvramcui can be loaded as a secondary payload under SeaBIOS, GRUB, or any other payload that can load additional payloads. diff --git a/src/Kconfig b/src/Kconfig index fe325e8..3877658 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -120,6 +120,14 @@
Otherwise, say N to use the provided pregenerated scanner/parser.
+choice + prompt "Option backend to use" + default USE_OPTION_TABLE if NVRAMCUI_SECONDARY_PAYLOAD + default USE_NO_OPTION_TABLE + +config USE_NO_OPTION_TABLE + bool "None" + config USE_OPTION_TABLE bool "Use CMOS for configuration values" depends on HAVE_OPTION_TABLE @@ -127,6 +135,9 @@ Enable this option if coreboot shall read options from the "CMOS" NVRAM instead of using hard-coded values.
+ +endchoice + config STATIC_OPTION_TABLE bool "Load default configuration values into CMOS on each boot" depends on USE_OPTION_TABLE diff --git a/src/drivers/pc80/rtc/option.c b/src/drivers/pc80/rtc/option.c index 5cc5ea5..de90822 100644 --- a/src/drivers/pc80/rtc/option.c +++ b/src/drivers/pc80/rtc/option.c @@ -205,3 +205,16 @@ cmos_restore_rtc(control_state); } } + +enum cb_err set_int_option(const char *name, int value) +{ + return cmos_set_option(name, &value); +} + +int get_int_option(const char *name, const int fallback) +{ + if (cmos_get_option(&value, name) == CB_SUCCESS) + return value; + + return fallback; +} diff --git a/src/include/option.h b/src/include/option.h index 4de032b..7c33cad 100644 --- a/src/include/option.h +++ b/src/include/option.h @@ -7,25 +7,7 @@
void sanitize_cmos(void);
-enum cb_err cmos_set_option(const char *name, void *val); -enum cb_err cmos_get_option(void *dest, const char *name); - -static inline enum cb_err set_int_option(const char *name, int value) -{ - if (CONFIG(USE_OPTION_TABLE)) - return cmos_set_option(name, &value); - - return CB_CMOS_OTABLE_DISABLED; -} - -static inline int get_int_option(const char *name, const int fallback) -{ - if (CONFIG(USE_OPTION_TABLE)) { - int value = 0; - if (cmos_get_option(&value, name) == CB_SUCCESS) - return value; - } - return fallback; -} +enum cb_err set_int_option(const char *name, int value); +int get_int_option(const char *name, const int fallback);
#endif /* _OPTION_H_ */ diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index 358035d..f36efbf 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -270,6 +270,9 @@ ramstage-y += crc_byte.c smm-y += crc_byte.c
+all-$(CONFIG_USE_NO_OPTION_TABLE) += option.c +smm-$(CONFIG_USE_NO_OPTION_TABLE) += option.c + postcar-y += bootmode.c postcar-y += boot_device.c postcar-y += cbfs.c diff --git a/src/lib/option.c b/src/lib/option.c new file mode 100644 index 0000000..0d3a498 --- /dev/null +++ b/src/lib/option.c @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <types.h> +#include <option.h> + +enum cb_err set_int_option(const char *name, int value) +{ + return CB_CMOS_OTABLE_DISABLED; +} + +int get_int_option(const char *name, const int fallback) +{ + return fallback; +}