Angel Pons has submitted this change. ( https://review.coreboot.org/c/coreboot/+/54729 )
Change subject: option: Allow mainboards to implement the API
......................................................................
option: Allow mainboards to implement the API
Some mainboards need a mainboard-specific mechanism to access option
values. Allow mainboards to implement the option API. Also, add some
documentation about the current option API, and describe when should
one reimplement the option API in mainboard code: only when the code
is mainboard-specific to comply with externally-imposed constraints.
Change-Id: Idccdb9a008b1ebb89821961659f27b1c0b17d29c
Signed-off-by: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Signed-off-by: Angel Pons <th3fanbus(a)gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/54729
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
Reviewed-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M Documentation/index.md
A Documentation/lib/option.md
M src/Kconfig
3 files changed, 47 insertions(+), 0 deletions(-)
Approvals:
build bot (Jenkins): Verified
Arthur Heymans: Looks good to me, approved
diff --git a/Documentation/index.md b/Documentation/index.md
index 9870cf3..c518c50 100644
--- a/Documentation/index.md
+++ b/Documentation/index.md
@@ -183,6 +183,7 @@
* [Mainboard](mainboard/index.md)
* [Payloads](lib/payloads/index.md)
* [Libraries](lib/index.md)
+* [Options](lib/option.md)
* [Security](security/index.md)
* [SuperIO](superio/index.md)
* [Vendorcode](vendorcode/index.md)
diff --git a/Documentation/lib/option.md b/Documentation/lib/option.md
new file mode 100644
index 0000000..eb63390
--- /dev/null
+++ b/Documentation/lib/option.md
@@ -0,0 +1,31 @@
+# Option API
+
+The option API around the `set_option(const char *name, void *val)` and
+`get_option(void *dest, const char *name)` functions deprecated in favor
+of a type-safe API.
+
+Historically, options were stored in RTC battery-backed CMOS RAM inside
+the chipset on PC platforms. Nowadays, options can also be stored in the
+same flash chip as the boot firmware or through some BMC interface.
+
+The new type-safe option framework can be used by calling
+`enum cb_err set_uint_option(const char *name, unsigned int value)` and
+`unsigned int get_uint_option(const char *name, const unsigned int fallback)`.
+
+The default setting is `OPTION_BACKEND_NONE`, which disables any runtime
+configurable options. If supported by a mainboard, the `USE_OPTION_TABLE`
+and `USE_MAINBOARD_SPECIFIC_OPTION_BACKEND` choices are visible, and can
+be selected to enable runtime configurability.
+
+# Mainboard-specific option backend
+
+Mainboards with a mainboard-specific (vendor-defined) method to access
+options can select `HAVE_MAINBOARD_SPECIFIC_OPTION_BACKEND` to provide
+implementations of the option API accessors. To allow choosing between
+multiple option backends, the mainboard-specific implementation should
+only be built when `USE_MAINBOARD_SPECIFIC_OPTION_BACKEND` is selected.
+
+Where possible, using a generic, mainboard-independent mechanism should
+be preferred over reinventing the wheel in mainboard-specific code. The
+mainboard-specific approach should only be used when the option storage
+mechanism has to satisfy externally-imposed, vendor-defined constraints.
diff --git a/src/Kconfig b/src/Kconfig
index b019e9d..6b60767 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -122,6 +122,7 @@
choice
prompt "Option backend to use"
+ default USE_MAINBOARD_SPECIFIC_OPTION_BACKEND if HAVE_MAINBOARD_SPECIFIC_OPTION_BACKEND
default USE_OPTION_TABLE if NVRAMCUI_SECONDARY_PAYLOAD
config OPTION_BACKEND_NONE
@@ -134,6 +135,13 @@
Enable this option if coreboot shall read options from the "CMOS"
NVRAM instead of using hard-coded values.
+config USE_MAINBOARD_SPECIFIC_OPTION_BACKEND
+ bool "Use mainboard-specific option backend"
+ depends on HAVE_MAINBOARD_SPECIFIC_OPTION_BACKEND
+ help
+ Use a mainboard-specific mechanism to access runtime-configurable
+ options.
+
endchoice
config STATIC_OPTION_TABLE
@@ -683,6 +691,13 @@
help
How many execution threads to cooperatively multitask with.
+config HAVE_MAINBOARD_SPECIFIC_OPTION_BACKEND
+ bool
+ help
+ Selected by mainboards which implement a mainboard-specific mechanism
+ to access the values for runtime-configurable options. For example, a
+ custom BMC interface or an EEPROM with an externally-imposed layout.
+
config HAVE_OPTION_TABLE
bool
default n
--
To view, visit https://review.coreboot.org/c/coreboot/+/54729
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Idccdb9a008b1ebb89821961659f27b1c0b17d29c
Gerrit-Change-Number: 54729
Gerrit-PatchSet: 2
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-MessageType: merged
Angel Pons has submitted this change. ( https://review.coreboot.org/c/coreboot/+/54728 )
Change subject: option: Turn CMOS option backend into choice
......................................................................
option: Turn CMOS option backend into choice
In order to add more option backends, transform the current CMOS option
backend into a Kconfig choice. Replace the `select` directives, as they
cannot be used with choice options.
Change-Id: Id3180e9991f0e763b4bae93a92d40668e7fc99bc
Signed-off-by: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Signed-off-by: Angel Pons <th3fanbus(a)gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/54728
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
Reviewed-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M payloads/Kconfig
M src/Kconfig
M src/include/option.h
3 files changed, 12 insertions(+), 4 deletions(-)
Approvals:
build bot (Jenkins): Verified
Arthur Heymans: Looks good to me, approved
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 6d0ba0f..b019e9d 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -120,6 +120,13 @@
Otherwise, say N to use the provided pregenerated scanner/parser.
+choice
+ prompt "Option backend to use"
+ default USE_OPTION_TABLE if NVRAMCUI_SECONDARY_PAYLOAD
+
+config OPTION_BACKEND_NONE
+ bool "None"
+
config USE_OPTION_TABLE
bool "Use CMOS for configuration values"
depends on HAVE_OPTION_TABLE
@@ -127,6 +134,8 @@
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/include/option.h b/src/include/option.h
index 4089378..3a00570 100644
--- a/src/include/option.h
+++ b/src/include/option.h
@@ -7,7 +7,7 @@
void sanitize_cmos(void);
-#if !CONFIG(USE_OPTION_TABLE)
+#if CONFIG(OPTION_BACKEND_NONE)
static inline unsigned int get_uint_option(const char *name, const unsigned int fallback)
{
@@ -19,11 +19,11 @@
return CB_CMOS_OTABLE_DISABLED;
}
-#else /* USE_OPTION_TABLE */
+#else /* !OPTION_BACKEND_NONE */
unsigned int get_uint_option(const char *name, const unsigned int fallback);
enum cb_err set_uint_option(const char *name, unsigned int value);
-#endif /* USE_OPTION_TABLE? */
+#endif /* OPTION_BACKEND_NONE? */
#endif /* _OPTION_H_ */
--
To view, visit https://review.coreboot.org/c/coreboot/+/54728
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Id3180e9991f0e763b4bae93a92d40668e7fc99bc
Gerrit-Change-Number: 54728
Gerrit-PatchSet: 2
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Patrick Rudolph <patrick.rudolph(a)9elements.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-MessageType: merged
Attention is currently required from: Anjaneya "Reddy" Chagam, Jonathan Zhang, Johnny Lin, Morgan Jang.
Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/55046 )
Change subject: arch/x86/bootblock.ld: Align the bottom of the bootblock to 64 bytes
......................................................................
Patch Set 1: Code-Review-1
(1 comment)
Patchset:
PS1:
Not tested with CBnT yet.
--
To view, visit https://review.coreboot.org/c/coreboot/+/55046
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I69cdacdd15bfca1b91b6f271f2ff76889969fd91
Gerrit-Change-Number: 55046
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Anjaneya "Reddy" Chagam <anjaneya.chagam(a)intel.com>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Johnny Lin <Johnny_Lin(a)wiwynn.com>
Gerrit-Reviewer: Jonathan Zhang <jonzhang(a)fb.com>
Gerrit-Reviewer: Morgan Jang <Morgan_Jang(a)wiwynn.com>
Gerrit-Attention: Anjaneya "Reddy" Chagam <anjaneya.chagam(a)intel.com>
Gerrit-Attention: Jonathan Zhang <jonzhang(a)fb.com>
Gerrit-Attention: Johnny Lin <Johnny_Lin(a)wiwynn.com>
Gerrit-Attention: Morgan Jang <Morgan_Jang(a)wiwynn.com>
Gerrit-Comment-Date: Fri, 28 May 2021 11:31:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/55046 )
Change subject: arch/x86/bootblock.ld: Align the bottom of the bootblock to 64 bytes
......................................................................
arch/x86/bootblock.ld: Align the bottom of the bootblock to 64 bytes
Align the bootblock size to 64 bytes because:
- cachelines are often 64 bytes large
- Bootguard/CBnT requires a 64 byte alignment
- It can reduce the bootblock footprint as the size is aligned upwards
Change-Id: I69cdacdd15bfca1b91b6f271f2ff76889969fd91
Signed-off-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M src/arch/x86/bootblock.ld
M src/mainboard/ocp/deltalake/Kconfig
M src/security/intel/cbnt/Kconfig
3 files changed, 1 insertion(+), 9 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/46/55046/1
diff --git a/src/arch/x86/bootblock.ld b/src/arch/x86/bootblock.ld
index 3cd0900..4ab2275 100644
--- a/src/arch/x86/bootblock.ld
+++ b/src/arch/x86/bootblock.ld
@@ -17,7 +17,7 @@
. = _ebootblock - CONFIG_C_ENV_BOOTBLOCK_SIZE;
#else
. = BOOTBLOCK_TOP - PROGRAM_SZ;
- . = ALIGN(16);
+ . = ALIGN(64);
#endif
_bootblock = .;
diff --git a/src/mainboard/ocp/deltalake/Kconfig b/src/mainboard/ocp/deltalake/Kconfig
index b92bd96..3161495 100644
--- a/src/mainboard/ocp/deltalake/Kconfig
+++ b/src/mainboard/ocp/deltalake/Kconfig
@@ -58,11 +58,4 @@
bool
default y
-config C_ENV_BOOTBLOCK_SIZE
- hex
- default 0xc000 if FIXED_BOOTBLOCK_SIZE
- help
- This matches the IBB size used for CBnT. Adjust this to the
- used CBnT settings.
-
endif # BOARD_OCP_DELTALAKE
diff --git a/src/security/intel/cbnt/Kconfig b/src/security/intel/cbnt/Kconfig
index 9d48490..5bc82fb 100644
--- a/src/security/intel/cbnt/Kconfig
+++ b/src/security/intel/cbnt/Kconfig
@@ -7,7 +7,6 @@
#depends on PLATFORM_HAS_DRAM_CLEAR
select INTEL_TXT
# With CBnT the bootblock is set up as a CBnT IBB and needs a fixed size
- select FIXED_BOOTBLOCK_SIZE
select TPM_MEASURED_BOOT_INIT_BOOTBLOCK if TPM_MEASURED_BOOT
help
Enables Intel Converged Bootguard and Trusted Execution Technology
--
To view, visit https://review.coreboot.org/c/coreboot/+/55046
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I69cdacdd15bfca1b91b6f271f2ff76889969fd91
Gerrit-Change-Number: 55046
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-MessageType: newchange