coreboot/src/lib
Angel Pons 91fe658714 drivers/option: Add forms in cbtables
Introduce a mechanism so that coreboot can provide a list of options to
post-coreboot code. The options are grouped together into forms and
have a meaning name and optional help text. This can be used to let
payloads know which options should be displayed in a setup menu,
for instance. Although this system was written to be used with edk2,
it has been designed with flexibility in mind so that other payloads
can also make use of this mechanism. The system currently lacks a way
to describe where to find option values.

This information is stored in a set of data structures specifically
created for this purpose. This format is known as CFR, which means
"coreboot forms representation" or "cursed forms representation".
Although the "forms representation" is borrowed from UEFI, CFR can
be used in non-UEFI scenarios as well.

The data structures are implemented as an extension of cbtables records
to support nesting. It should not break backwards compatibility because
the CFR root record (LB_TAG_CFR_ROOT) size includes all of its children
records. The concept of record nesting is borrowed from the records for
CMOS options. It is not possible to reuse the CMOS records because they
are too closely coupled with CMOS options; using these structures would
needlessly restrict more capable backends to what can be done with CMOS
options, which is undesired.

Because CFR supports variable-length components, directly transforming
options into CFR structures is not a trivial process. Furthermore, CFR
structures need to be written in one go. Because of this, abstractions
exist to generate CFR structures from a set of "setup menu" structures
that are coreboot-specific and could be integrated with the devicetree
at some point. Note that `struct sm_object` is a tagged union. This is
used to have lists of options in an array, as building linked lists of
options at runtime is extremely impractical because options would have
to be added at the end of the linked list to maintain option order. To
avoid mistakes defining `struct sm_object` values, helper macros exist
for supported option types. The macros also provide some type checking
as they initialise specific union members.

It should be possible to extend CFR support for more sophisticated
options like fan curve points. Feedback about this is highly
appreciated.

Change-Id: I304de7d26d79245a2e31a6d01f6c5643b31cb772
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/74121
Reviewed-by: Christian Walter <christian.walter@9elements.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-12-18 18:16:51 +00:00
..
gnat lib,console,sbom: Rename Makefiles from .inc to .mk 2024-01-24 10:12:57 +00:00
asan.c Allow to build romstage sources inside the bootblock 2023-11-09 13:20:18 +00:00
b64_decode.c treewide: replace GPLv2 long form headers with SPDX header 2020-05-06 22:20:57 +00:00
bmp_logo.c lib: Refactor bmp_load_logo() implementation 2024-04-06 04:31:50 +00:00
boot_device.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
bootblock.c timestamps: Rename timestamps to make names more consistent 2022-03-08 16:06:33 +00:00
bootmem.c drivers/efi/uefi_capsules.c: coalesce and store UEFI capsules 2024-08-30 15:48:25 +00:00
bootmode.c security/vboot: Set VBOOT_ALWAYS_ENABLE_DISPLAY if BMP_LOGO 2024-07-03 08:43:01 +00:00
bootsplash.c lib/jpeg: return string (not int) error messages 2024-09-18 21:51:40 +00:00
cb.ads lib: Add SPDX identifiers to files missing them 2022-08-11 17:53:29 +00:00
cbfs.c treewide: Move list.h to commonlib 2024-02-24 11:49:46 +00:00
cbfs_master_header.c Makefile.inc: Generate master header and pointer as C structs 2022-05-12 11:11:53 +00:00
cbmem_common.c src: Remove unused 'include <bootstate.h>' 2020-06-02 07:40:35 +00:00
cbmem_console.c lib/cbmem_console.c: Use C99 flexible arrays 2023-07-30 09:59:46 +00:00
cbmem_stage_cache.c src/lib: Add memory/time saving special case for ramstage caching 2023-12-18 08:13:12 +00:00
coreboot_table.c drivers/option: Add forms in cbtables 2024-12-18 18:16:51 +00:00
crc_byte.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
decompressor.c timestamps: Rename timestamps to make names more consistent 2022-03-08 16:06:33 +00:00
delay.c lib: Add SPDX identifiers to files missing them 2022-08-11 17:53:29 +00:00
dimm_info_util.c lib/dimm_info_util.c: Add newlines to log messages 2023-06-03 16:12:54 +00:00
dp_aux.c Use the fallthrough statement in switch loops 2022-02-16 21:29:53 +00:00
edid.c tree: Remove blank lines before '}' and after '{' 2024-04-11 19:19:08 +00:00
edid_fill_fb.c drivers/intel/gma: Fix mismatching types for fb_add_framebuffer_info 2024-09-02 09:33:59 +00:00
espi_debug.c lib/espi_debug: Add espi_show_slave_peripheral_channel_configuration 2021-04-23 21:20:26 +00:00
ext_stage_cache.c ext_stage_cache: Make sure variables are initialized 2024-08-30 07:35:10 +00:00
fallback_boot.c lib: Add SPDX identifiers to files missing them 2022-08-11 17:53:29 +00:00
fit.c include/device_tree.h: Fix function name fdt_node_name 2024-06-28 12:29:13 +00:00
fit_payload.c cbmem.h: Change return type of cbmem_get_region 2024-08-29 13:58:21 +00:00
fmap.c region: Introduce region_create() functions 2024-08-11 17:07:32 +00:00
fw_config.c util/sconfig: Probe device when fw_config is unprovisioned 2024-08-22 13:53:18 +00:00
gcc.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
gcov-glue.c tree: Use __func__ instead of hard-coded names 2023-02-17 16:08:04 +00:00
gcov-io.c lib: Add SPDX identifiers to files missing them 2022-08-11 17:53:29 +00:00
gcov-io.h lib/gcov-io.h: Use C99 flexible arrays 2023-08-01 13:34:27 +00:00
gcov-iov.h lib: Add SPDX identifiers to files missing them 2022-08-11 17:53:29 +00:00
gpio.c gpio: Pull down HiZ pins after reading tristate GPIO strapping 2020-08-06 23:54:41 +00:00
halt.c treewide: Move stdlib.h to commonlib 2024-03-15 10:09:43 +00:00
hardwaremain.c tree: Remove blank lines before '}' and after '{' 2024-04-11 19:19:08 +00:00
hexdump.c lib/hexdump: remove hexdump32 and use hexdump instead 2021-05-27 15:41:15 +00:00
hexstrtobin.c treewide: Convert more license headers to SPDX style 2020-05-11 19:37:19 +00:00
hw-time-timer.adb treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
identity.c lib/version: Move board identification strings 2023-04-22 16:20:49 +00:00
imd.c lib: Remove unused <stdlib.h> and use <types.h> when appropriate 2022-04-24 17:43:57 +00:00
imd_cbmem.c cbmem.h: Change return type of cbmem_get_region 2024-08-29 13:58:21 +00:00
jpeg.c lib/jpeg: return string (not int) error messages 2024-09-18 21:51:40 +00:00
jpeg.h lib/jpeg: return string (not int) error messages 2024-09-18 21:51:40 +00:00
Kconfig lib/smbios: Create SMBIOS type 4 entry 2024-07-22 22:30:47 +00:00
Kconfig.cbfs_verification Kconfig.cbfs_verification: Update TOCTOU_SAFETY combination with VBOOT 2023-11-07 22:30:20 +00:00
libgcc.c treewide: Replace CONFIG(ARCH_xx) tests 2020-06-17 21:13:09 +00:00
libgcov.c treewide: Move stdlib.h to commonlib 2024-03-15 10:09:43 +00:00
lzma.c lib: Add SPDX identifiers to files missing them 2022-08-11 17:53:29 +00:00
lzmadecode.c lib/lzmadecode: Allow for 8 byte reads on 64bit 2024-02-21 16:19:05 +00:00
lzmadecode.h lib/lzmadecode: Allow for 8 byte reads on 64bit 2024-02-21 16:19:05 +00:00
Makefile.mk lib/rmodules: Add support for LTO 2024-08-29 13:56:39 +00:00
malloc.c malloc/memalign: Return NULL if the request is too large 2024-01-29 19:12:43 +00:00
master_header_pointer.c Kconfig: Add an option to skip adding a cbfs bootblock on x86 2022-05-12 11:12:21 +00:00
memchr.c lib: Add SPDX identifiers to files missing them 2022-08-11 17:53:29 +00:00
memcmp.c lib: Add SPDX identifiers to files missing them 2022-08-11 17:53:29 +00:00
memcpy.c lib: Add SPDX identifiers to files missing them 2022-08-11 17:53:29 +00:00
memmove.c lib: Add SPDX identifiers to files missing them 2022-08-11 17:53:29 +00:00
memrange.c tree: Remove blank lines before '}' and after '{' 2024-04-11 19:19:08 +00:00
memset.c lib: Add SPDX identifiers to files missing them 2022-08-11 17:53:29 +00:00
metadata_hash.c cbfs/vboot: Adapt to new vb2_digest API 2022-09-02 23:51:29 +00:00
nhlt.c lib/nhlt, soc/intel/skl: Update NHLT to program feedback config 2022-12-21 13:57:48 +00:00
primitive_memtest.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
prog_loaders.c cbmem_top: Change the return value to uintptr_t 2024-07-10 12:55:46 +00:00
prog_ops.c lib/prog_ops.c: Add <types.h> 2022-10-06 18:13:19 +00:00
program.ld drivers/option: Add forms in cbtables 2024-12-18 18:16:51 +00:00
ramdetect.c riscv/mb/qemu: fix DRAM probing 2024-03-04 23:43:46 +00:00
ramtest.c commonlib/console/post_code.h: Change post code prefix to POSTCODE 2023-06-23 15:06:04 +00:00
reg_script.c tree: Drop duplicated <device/{path,resource}.h> 2024-04-12 04:24:20 +00:00
region_file.c tree: Remove blank lines before '}' and after '{' 2024-04-11 19:19:08 +00:00
reset.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
rmodule.c payloads,src: Replace ALIGN(x, a) by ALIGN_UP(x, a) for clarity 2022-10-13 19:14:57 +00:00
rmodule.ld lib: Add SPDX identifiers to files missing them 2022-08-11 17:53:29 +00:00
romstage_handoff.c ACPI S3: Replace stashed acpi_slp_typ value 2021-01-23 20:19:47 +00:00
rtc.c lib/rtc: Fix off-by-one error in February day count in leap year 2024-02-29 13:07:02 +00:00
selfboot.c /: Remove extra space after comma 2022-11-30 03:07:23 +00:00
smbios.c lib/smbios: Improve Type9 2024-10-28 22:06:01 +00:00
smbios_defaults.c tree: Remove unused <string.h> 2024-05-29 10:34:08 +00:00
spd_bin.c lib/spd_bin: Add LPDDR5X dram_type in use_ddr4_params 2024-03-28 07:26:45 +00:00
spd_cache.c lib: Check for non-existent DIMMs in check_if_dimm_changed 2022-04-20 06:57:21 +00:00
stack.c tree: Remove blank lines before '}' and after '{' 2024-04-11 19:19:08 +00:00
string.c commonlib/bsd: Add strlen() and strnlen() functions 2024-08-14 03:09:03 +00:00
thread.c tree: Fix cast an object of type 'nullptr_t' to 'uintptr_t' error 2024-10-29 01:41:41 +00:00
timer.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
timer_queue.c lib/timer_queue.c: Fix function signature 2022-09-23 17:34:30 +00:00
timestamp.c CBMEM: Change declarations for initialization hooks 2022-05-20 07:15:39 +00:00
ubsan.c lib/ubsan.c: Restore Jonas' copyright 2023-05-22 12:33:32 +00:00
uuid.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
ux_locales.c tree: Use <stdio.h> for snprintf 2024-05-29 10:33:54 +00:00
version.c lib/version: Move board identification strings 2023-04-22 16:20:49 +00:00
wrdd.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
xxhash.c lib/xxhash.c: Add new hash functions 2022-09-07 22:24:51 +00:00