Filip Brozovic has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/86039?usp=email )
Change subject: CFR: Add min/max/step values and hex display flag for number options ......................................................................
CFR: Add min/max/step values and hex display flag for number options
This commit adds support for minimum/maximum limit values as well as step sizes for CFR number options. Additionally, add a new flag that specifies the option should be displayed in hexadecimal notation instead of decimal.
Change-Id: I2e70f1430fb1911f1ad974832f8abfe76f928ac3 Signed-off-by: Filip Brozovic fbrozovic@gmail.com --- M src/commonlib/include/commonlib/cfr.h M src/drivers/option/cfr.c M src/drivers/option/cfr_frontend.h 3 files changed, 20 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/39/86039/1
diff --git a/src/commonlib/include/commonlib/cfr.h b/src/commonlib/include/commonlib/cfr.h index 564c8a1..7ce1cbd 100644 --- a/src/commonlib/include/commonlib/cfr.h +++ b/src/commonlib/include/commonlib/cfr.h @@ -91,6 +91,9 @@ * this sets the EFI_VARIABLE_RUNTIME_ACCESS attribute. * It is out of scope of this specification how non runtime variables * are protected after the payload has hand over control. + * CFR_OPTFLAG_NUMBER_HEX: + * Displays a numeric option in hexadecimal instead of decimal notation. + * This flag is only valid for numeric options. */ enum cfr_option_flags { CFR_OPTFLAG_READONLY = 1 << 0, @@ -98,6 +101,7 @@ CFR_OPTFLAG_SUPPRESS = 1 << 2, CFR_OPTFLAG_VOLATILE = 1 << 3, CFR_OPTFLAG_RUNTIME = 1 << 4, + CFR_OPTFLAG_NUMBER_HEX = 1 << 5, };
struct __packed lb_cfr_varbinary { @@ -132,6 +136,9 @@ */ uint32_t flags; /* enum cfr_option_flags */ uint32_t default_value; + uint32_t min; + uint32_t max; + uint32_t step; /* * struct lb_cfr_varbinary opt_name * struct lb_cfr_varbinary ui_name diff --git a/src/drivers/option/cfr.c b/src/drivers/option/cfr.c index 6d59ca9..09a32bf 100644 --- a/src/drivers/option/cfr.c +++ b/src/drivers/option/cfr.c @@ -104,8 +104,9 @@
static uint32_t write_numeric_option(char *current, uint32_t tag, const uint64_t object_id, const char *opt_name, const char *ui_name, const char *ui_helptext, - uint32_t flags, uint32_t default_value, const struct sm_enum_value *values, - const uint64_t dep_id, const uint32_t *dep_values, const uint32_t num_dep_values) + uint32_t flags, uint32_t default_value, uint32_t min, uint32_t max, uint32_t step, + const struct sm_enum_value *values, const uint64_t dep_id, + const uint32_t *dep_values, const uint32_t num_dep_values) { struct lb_cfr_numeric_option *option = (struct lb_cfr_numeric_option *)current; size_t len; @@ -117,6 +118,9 @@ if (option->flags & (CFR_OPTFLAG_INACTIVE | CFR_OPTFLAG_VOLATILE)) option->flags |= CFR_OPTFLAG_READONLY; option->default_value = default_value; + option->min = min; + option->max = (min == 0 && max == 0) ? 0xffffffff : max; + option->step = step; option->size = sizeof(*option);
current += option->size; @@ -148,7 +152,7 @@ { return write_numeric_option(current, CFR_TAG_OPTION_ENUM, object_id, sm_enum->opt_name, sm_enum->ui_name, sm_enum->ui_helptext, - sm_enum->flags, sm_enum->default_value, sm_enum->values, + sm_enum->flags, sm_enum->default_value, 0, 0, 0, sm_enum->values, dep_id, dep_values, num_dep_values); }
@@ -159,8 +163,8 @@ { return write_numeric_option(current, CFR_TAG_OPTION_NUMBER, object_id, sm_number->opt_name, sm_number->ui_name, sm_number->ui_helptext, - sm_number->flags, sm_number->default_value, NULL, dep_id, - dep_values, num_dep_values); + sm_number->flags, sm_number->default_value, sm_number->min, sm_number->max, + sm_number->step, NULL, dep_id, dep_values, num_dep_values); }
static uint32_t sm_write_opt_bool(char *current, const struct sm_obj_bool *sm_bool, @@ -170,7 +174,7 @@ { return write_numeric_option(current, CFR_TAG_OPTION_BOOL, object_id, sm_bool->opt_name, sm_bool->ui_name, sm_bool->ui_helptext, - sm_bool->flags, sm_bool->default_value, NULL, dep_id, + sm_bool->flags, sm_bool->default_value, 0, 0, 0, NULL, dep_id, dep_values, num_dep_values); }
diff --git a/src/drivers/option/cfr_frontend.h b/src/drivers/option/cfr_frontend.h index 21c18e7..d83f18b 100644 --- a/src/drivers/option/cfr_frontend.h +++ b/src/drivers/option/cfr_frontend.h @@ -30,6 +30,9 @@ const char *ui_name; const char *ui_helptext; uint32_t default_value; + uint32_t min; + uint32_t max; + uint32_t step; };
struct sm_obj_bool {