Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Documentation/drivers/cfr.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ visible name, a help text, a default value and status flags.
All strings are in ASCII.

The boot options are grouped into forms, where each form hold
one ore more options. Boot options that are not used in the current
one or more options. Boot options that are not used in the current
boot flow, and are never reachable should be marked as hidden.
Dependecies between options can be defined in the code and should
be evaluated by the CFR parser/UI.
Expand Down Expand Up @@ -66,7 +66,7 @@ The public API can be found in
## Implementation design
### Tags
Tags identify the structure defined in `src/commonlib/include/commonlib/cfr.h`.
Every struct might be immideatly followed by additional structs (so called
Every struct might be immediately followed by additional structs (so called
sub nodes), having their own tag and size field. The sum of all sub nodes size
fields plus the size of the struct itself equals the size field.

Expand Down Expand Up @@ -208,7 +208,7 @@ effect on the non-volatile variable.

Prevents writes to the variable.

* `CFR_OPTFLAG_GRAYOUT`
* `CFR_OPTFLAG_INACTIVE`

Implies `READONLY`. The option is visible, but cannot be modified
because one of the dependencies are not given. However there's a
Expand Down
36 changes: 34 additions & 2 deletions Documentation/drivers/cfr_internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ static const struct sm_object serial_number = SM_DECLARE_VARCHAR({

The CFR options can have a dependency that must be evaluated at runtime by
the OS/payload that parses the CFR record and displays the UI.
By using the `WITH_DEP()` macro you can specify another numberic option that
is checked to hide the current option.
By using the `WITH_DEP()` macro you can specify another numeric option that
is checked to hide the current option. The `WITH_DEP_VALUES()` macro allows
specifying one or more values that cause the dependent option to be displayed.

**Example:** Declares a dependency from `sata_disable_port0` to `sata_enable`.
The option `sata_disable_port0` will be hidden as long as "sata_enable" is 0.
Expand All @@ -76,6 +77,37 @@ static struct sm_object sata_disable_port0 = SM_DECLARE_BOOL({
}, WITH_DEP(&sata_enable));
```

**Example:** Declares a dependency from `com1_termination` to `com1_mode`.
The option `com1_termination` will only be shown if `com1_mode` is set to RS-485.

```
#define COM_MODE_DISABLED 3
#define COM_MODE_RS232 0
#define COM_MODE_RS485 1

static struct sm_object com1_mode = SM_DECLARE_ENUM({
.flags = CFR_OPTFLAG_RUNTIME,
.opt_name = "com1_mode",
.ui_name = "COM1 Mode",
.ui_helptext = NULL,
.default_value = 1,
.values = (const struct sm_enum_value[]) {
{ "Disabled", COM_MODE_DISABLED },
{ "RS-232", COM_MODE_RS232 },
{ "RS-485", COM_MODE_RS485 },
SM_ENUM_VALUE_END },
});

static struct sm_object com1_termination = SM_DECLARE_BOOL({
.flags = CFR_OPTFLAG_RUNTIME,
.opt_name = "com1_termination",
.ui_name = "Enable COM1 termination resistors",
.ui_helptext = NULL,
.default_value = false,
}, WITH_DEP_VALUES(&com1_mode, COM_MODE_RS485));

```

### Providing mainboard custom options

A mainboard that uses CFR can provide a list of custom options
Expand Down
49 changes: 49 additions & 0 deletions configs/config.lenovo_m900_tiny
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
CONFIG_CCACHE=y
CONFIG_VENDOR_LENOVO=y
CONFIG_VBOOT=y
CONFIG_VBOOT_SLOTS_RW_A=y
CONFIG_VBOOT_NO_BOARD_SUPPORT=y
CONFIG_BOARD_LENOVO_THINKCENTRE_M900_TINY=y
CONFIG_TPM_MEASURED_BOOT=y
CONFIG_INTEL_ME_DISABLED_HECI=y
CONFIG_DRIVERS_EFI_VARIABLE_STORE=y
CONFIG_DRIVERS_OPTION_CFR=y
CONFIG_CBFS_VERIFICATION=y
CONFIG_VBOOT_CBFS_INTEGRATION=y
CONFIG_VBOOT_MOCK_SECDATA=y
CONFIG_VBOOT_CLEAR_RECOVERY_IN_RAMSTAGE=y
CONFIG_TPM2=y
CONFIG_TPM_HASH_SHA256=y
CONFIG_BOOTMEDIA_LOCK_CONTROLLER=y
CONFIG_BOOTMEDIA_LOCK_WPRO_VBOOT_RO=y
CONFIG_BOOTMEDIA_LOCK_IN_VERSTAGE=y
CONFIG_BOOTMEDIA_SMM_BWP=y
CONFIG_DEFAULT_CONSOLE_LOGLEVEL_0=y
CONFIG_PAYLOAD_EDK2=y
CONFIG_EDK2_REPOSITORY="https://github.com/Dasharo/edk2.git"
CONFIG_EDK2_TAG_OR_REV="origin/cfr_ng"
CONFIG_EDK2_USE_EDK2_PLATFORMS=y
CONFIG_EDK2_PLATFORMS_REPOSITORY="https://github.com/Dasharo/edk2-platforms"
CONFIG_EDK2_PLATFORMS_TAG_OR_REV="3323ed481d35096fb6a7eae7b49f35eff00f86cf"
CONFIG_EDK2_CBMEM_LOGGING=y
CONFIG_EDK2_FOLLOW_BGRT_SPEC=y
CONFIG_EDK2_SERIAL_SUPPORT=y
CONFIG_EDK2_CUSTOM_BUILD_PARAMS="--pcd gDasharoSystemFeaturesTokenSpaceGuid.PcdShowMenu=FALSE"
CONFIG_BUILD_IPXE=y
CONFIG_EDK2_ENABLE_IPXE=y
# CONFIG_EDK2_SECURE_BOOT_DEFAULT_ENABLE is not set
CONFIG_EDK2_PERFORMANCE_MEASUREMENT_ENABLE=y
CONFIG_EDK2_DASHARO_SYSTEM_FEATURES=y
CONFIG_EDK2_DASHARO_SECURITY_OPTIONS=y
CONFIG_EDK2_DASHARO_INTEL_ME_OPTIONS=y
CONFIG_EDK2_DASHARO_USB_CONFIG=y
CONFIG_EDK2_DASHARO_NETWORK_CONFIG=y
CONFIG_EDK2_DASHARO_NETWORK_BOOT_DEFAULT_ENABLE=y
CONFIG_EDK2_DASHARO_SERIAL_REDIRECTION_DEFAULT_ENABLE=y
CONFIG_EDK2_DASHARO_CPU_CONFIG=y
CONFIG_EDK2_HYPERTHREADING_OPTION=y
CONFIG_EDK2_DISABLE_OPTION_ROMS=y
CONFIG_EDK2_CREATE_PREINSTALLED_BOOT_OPTIONS=y
CONFIG_EDK2_USE_UEFIVAR_BACKED_TPM_PPI=y
CONFIG_EDK2_ENABLE_FAST_BOOT_FEATURE=y
CONFIG_EDK2_ENABLE_QUIET_BOOT_FEATURE=y
28 changes: 25 additions & 3 deletions src/commonlib/include/commonlib/cfr.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
*
*/

#define CFR_VERSION 0x00000000

enum cfr_tags {
CFR_TAG_OPTION_FORM = 1,
CFR_TAG_ENUM_VALUE = 2,
Expand All @@ -61,14 +63,15 @@ enum cfr_tags {
CFR_TAG_VARCHAR_UI_HELPTEXT = 9,
CFR_TAG_VARCHAR_DEF_VALUE = 10,
CFR_TAG_OPTION_COMMENT = 11,
CFR_TAG_DEP_VALUES = 12,
};

/*
* The optional flags describe the visibilty of the option and the
* effect on the non-volatile variable.
* CFR_OPTFLAG_READONLY:
* Prevents writes to the variable.
* CFR_OPTFLAG_GRAYOUT:
* CFR_OPTFLAG_INACTIVE:
* Implies READONLY. The option is visible, but cannot be modified
* because one of the dependencies are not given. However there's a
* possibility to enable the option by changing runtime configuration.
Expand All @@ -93,7 +96,7 @@ enum cfr_tags {
*/
enum cfr_option_flags {
CFR_OPTFLAG_READONLY = 1 << 0,
CFR_OPTFLAG_GRAYOUT = 1 << 1,
CFR_OPTFLAG_INACTIVE = 1 << 1,
CFR_OPTFLAG_SUPPRESS = 1 << 2,
CFR_OPTFLAG_VOLATILE = 1 << 3,
CFR_OPTFLAG_RUNTIME = 1 << 4,
Expand All @@ -102,7 +105,8 @@ enum cfr_option_flags {
struct __packed lb_cfr_varbinary {
uint32_t tag; /*
* CFR_TAG_VARCHAR_OPT_NAME, CFR_TAG_VARCHAR_UI_NAME,
* CFR_TAG_VARCHAR_UI_HELPTEXT or CFR_TAG_VARCHAR_DEF_VALUE
* CFR_TAG_VARCHAR_UI_HELPTEXT, CFR_TAG_VARCHAR_DEF_VALUE
* or CFR_TAG_DEP_VALUES
*/
uint32_t size; /* Length of the entire structure */
uint32_t data_length; /* Length of data, including NULL terminator for strings */
Expand All @@ -117,6 +121,15 @@ struct __packed lb_cfr_enum_value {
*/
};

/*
* The optional flags describe how a numeric option is to be displayed.
* CFR_NUM_OPT_DISPFLAG_HEX:
* Displays a NUMBER option in hexadecimal instead of decimal notation.
*/
enum cfr_numeric_option_display_flags {
CFR_NUM_OPT_DISPFLAG_HEX = 1 << 0,
};

/* Supports multiple option types: ENUM, NUMBER, BOOL */
struct __packed lb_cfr_numeric_option {
uint32_t tag; /*
Expand All @@ -130,10 +143,16 @@ struct __packed lb_cfr_numeric_option {
*/
uint32_t flags; /* enum cfr_option_flags */
uint32_t default_value;
uint32_t min;
uint32_t max;
uint32_t step;
uint32_t display_flags; /* enum cfr_numeric_option_display_flags */

/*
* struct lb_cfr_varbinary opt_name
* struct lb_cfr_varbinary ui_name
* struct lb_cfr_varbinary ui_helptext (Optional)
* struct lb_cfr_varbinary dependency_values (Optional)
* struct lb_cfr_enum_value enum_values[]
*/
};
Expand All @@ -151,6 +170,7 @@ struct __packed lb_cfr_varchar_option {
* struct lb_cfr_varbinary opt_name
* struct lb_cfr_varbinary ui_name
* struct lb_cfr_varbinary ui_helptext (Optional)
* struct lb_cfr_varbinary dependency_values (Optional)
*/
};

Expand All @@ -170,6 +190,7 @@ struct __packed lb_cfr_option_comment {
/*
* struct lb_cfr_varbinary ui_name
* struct lb_cfr_varbinary ui_helptext (Optional)
* struct lb_cfr_varbinary dependency_values (Optional)
*/
};

Expand All @@ -184,6 +205,7 @@ struct __packed lb_cfr_option_form {
uint32_t flags; /* enum cfr_option_flags */
/*
* struct lb_cfr_varbinary ui_name
* struct lb_cfr_varbinary dependency_values (Optional)
* struct lb_cfr_varchar_option options[]
*/
};
Expand Down
1 change: 1 addition & 0 deletions src/commonlib/include/commonlib/coreboot_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ struct lb_efi_fw_info {
struct lb_cfr {
uint32_t tag;
uint32_t size;
uint32_t version;
uint32_t checksum; /* Checksum of the variable payload. */
/* struct lb_cfr_option_form forms[] */
};
Expand Down
Loading