1 # CFR - coreboot form representation
3 This documents the API exposed by coreboot to be consumed by
4 loaded OS image or payload.
8 As per coreboot design there's no UI present to change firmware
9 related options like "Hyper-Theading Enable". There's no way of
10 knowing what options are supported, if they are supported in the
11 current configuration and what they do.
13 The `USE_OPTION_TABLE` Kconfig allows to integrate a list of
14 mainboard specific options into coreboot tables when the option
15 API is using the *CMOS NVRAM*. It has no meaning if another option
20 Propose a new coreboot table that is independent from the option
21 backend. The coreboot table is generated from coreboot ramstage
24 Every possible boot option is described by its name, the user
25 visible name, a help text, a default value and status flags.
26 All strings are in ASCII.
28 The boot options are grouped into forms, where each form hold
29 one or more options. Boot options that are not used in the current
30 boot flow, and are never reachable should be marked as hidden.
31 Dependecies between options can be defined in the code and should
32 be evaluated by the CFR parser/UI.
34 A boot option can be one of the following types:
40 All of the information is *Position Independent Data*. That is, it is
41 safe to relocate any of the information without its meaning/correctness
44 CFR records form a tree structure. Every record starts with a `tag`
45 and a `size` field as generic header:
48 struct __packed lb_cfr_header {
54 The size of a record includes the size of its own fields plus the size of all
55 child records. A record can have none or multiple child records.
56 The record `tag` must be known by the parser to parse the record and its
57 sub records. If it is not known to the parser it can simply skip it by
58 jumping `size` bytes forward.
60 The coreboot table containing the CFR tree has the tag `LB_TAG_CFR`.
62 The public API can be found in
63 `src/commonlib/include/commonlib/cfr.h` and
64 `src/commonlib/include/commonlib/coreboot_tables.h`.
66 ## Implementation design
68 Tags identify the structure defined in `src/commonlib/include/commonlib/cfr.h`.
69 Every struct might be immediately followed by additional structs (so called
70 sub nodes), having their own tag and size field. The sum of all sub nodes size
71 fields plus the size of the struct itself equals the size field.
75 Used in `struct lb_cfr_option_form` to describe a group of options. Every
76 sub node is one option that should be displayed in the order found in
80 - `CFR_TAG_OPTION_ENUM`
81 - `CFR_TAG_OPTION_NUMBER`
82 - `CFR_TAG_OPTION_BOOL`
83 - `CFR_TAG_OPTION_VARCHAR`
84 - `CFR_TAG_OPTION_FORM`
85 - `CFR_TAG_OPTION_COMMENT`
86 - `CFR_TAG_VARCHAR_UI_NAME`
89 - `CFR_TAG_VARCHAR_UI_NAME`
93 Used in `struct lb_cfr_enum_value` to describe a numeric value to be
94 used in a parent `CFR_TAG_OPTION_ENUM`.
97 - `CFR_TAG_VARCHAR_UI_NAME`
100 - `CFR_TAG_VARCHAR_UI_NAME`
102 * CFR_TAG_OPTION_ENUM
104 Used in `struct lb_cfr_numeric_option` to describe a numeric variable with
105 a predefined selection of possible values in the referenced variable.
108 - `CFR_TAG_VARCHAR_OPT_NAME`
109 - `CFR_TAG_VARCHAR_UI_NAME`
110 - `CFR_TAG_ENUM_VALUE`
111 - `CFR_TAG_VARCHAR_UI_HELPTEXT`
114 - `CFR_TAG_VARCHAR_OPT_NAME`
115 - `CFR_TAG_VARCHAR_UI_NAME`
116 - `CFR_TAG_ENUM_VALUE`
118 * CFR_TAG_OPTION_NUMBER
120 Used in `struct lb_cfr_numeric_option` to describe a numeric variable with
121 any possible value in the referenced variable.
124 - `CFR_TAG_VARCHAR_OPT_NAME`
125 - `CFR_TAG_VARCHAR_UI_NAME`
126 - `CFR_TAG_VARCHAR_UI_HELPTEXT`
129 - `CFR_TAG_VARCHAR_OPT_NAME`
130 - `CFR_TAG_VARCHAR_UI_NAME`
132 * CFR_TAG_OPTION_BOOL
134 Used in `struct lb_cfr_numeric_option` to describe a numeric variable with
135 the possible values [0, 1] in the referenced variable.
138 - `CFR_TAG_VARCHAR_OPT_NAME`
139 - `CFR_TAG_VARCHAR_UI_NAME`
140 - `CFR_TAG_VARCHAR_UI_HELPTEXT`
143 - `CFR_TAG_VARCHAR_OPT_NAME`
144 - `CFR_TAG_VARCHAR_UI_NAME`
146 * CFR_TAG_OPTION_VARCHAR
148 Used in `struct lb_cfr_varchar_option` to describe an ASCII string
149 stored in the referenced variable.
151 *Example:* Linux kernel cmdline.
154 - `CFR_TAG_VARCHAR_DEF_VALUE`
155 - `CFR_TAG_VARCHAR_OPT_NAME`
156 - `CFR_TAG_VARCHAR_UI_NAME`
157 - `CFR_TAG_VARCHAR_UI_HELPTEXT`
160 - `CFR_TAG_VARCHAR_DEF_VALUE`
161 - `CFR_TAG_VARCHAR_OPT_NAME`
162 - `CFR_TAG_VARCHAR_UI_NAME`
164 * CFR_TAG_OPTION_COMMENT
166 Used in `struct lb_cfr_option_comment` to describe an ASCII string visible
167 to the user, but doesn't reference a variable. Informal use only.
170 - `CFR_TAG_VARCHAR_UI_NAME`
171 - `CFR_TAG_VARCHAR_UI_HELPTEXT`
174 - `CFR_TAG_VARCHAR_UI_NAME`
176 * CFR_TAG_VARCHAR_OPT_NAME
178 Used in `struct lb_cfr_varbinary` to describe the option name used by
179 coreboot's code. It thus must match what is used in code by
184 * CFR_TAG_VARCHAR_UI_NAME
186 Used in `struct lb_cfr_varbinary`
188 User visible name of the option.
190 * CFR_TAG_VARCHAR_UI_HELPTEXT
192 Used in `struct lb_cfr_varbinary`
194 Optional user visible description what is changed by this option.
196 * CFR_TAG_VARCHAR_DEF_VALUE
198 Used in `struct lb_cfr_varbinary`
200 Default value in case the variable is not present.
204 The optional flags describe the visibilty of the option and the
205 effect on the non-volatile variable.
207 * `CFR_OPTFLAG_READONLY`
209 Prevents writes to the variable.
211 * `CFR_OPTFLAG_INACTIVE`
213 Implies `READONLY`. The option is visible, but cannot be modified
214 because one of the dependencies are not given. However there's a
215 possibility to enable the option by changing runtime configuration.
217 *For example:* Setting SATA mode, but SATA is globally disabled.
219 * `CFR_OPTFLAG_SUPPRESS`
221 Runtime code sets this flag to indicate that the option has no effect
222 and is never reachable, not even by changing runtime configuration.
223 This option is never shown in the UI.
225 * `CFR_OPTFLAG_VOLATILE`
228 The option is not backed by a non-volatile variable. This is useful
229 to display the current state of a specific component, a dependency or
230 a serial number. This information could be passed in a new coreboot
231 table, but it not useful other than to be shown at this spot in the
234 * `CFR_OPTFLAG_RUNTIME`
236 The option is allowed to be changed by a post payload entity. On UEFI
237 this sets the `EFI_VARIABLE_RUNTIME_ACCESS` attribute.
238 It is out of scope of this specification how non runtime variables
239 are protected after the payload has hand over control.
243 To display a boolean option with the label `Boolean`, that default value
244 is `true`, on a form called `test`, that modifies the variable `First`
245 the following structure will be generated:
248 struct lb_cfr_option_form {
249 uint32_t tag; = CFR_TAG_OPTION_FORM
250 uint32_t size; = sizeof(struct lb_cfr_option_form) +
251 sizeof(struct lb_cfr_varbinary) +
252 strlen(name) + 1 + 3 +
253 sizeof(struct lb_cfr_numeric_option) +
254 sizeof(struct lb_cfr_varbinary) +
255 strlen(optname) + 1 + 2 +
256 sizeof(struct lb_cfr_varbinary) +
257 strlen(uiname) + 1 = 120
258 uint64_t object_id; = 1
259 uint64_t dependency_id; = 0
262 struct lb_cfr_varbinary {
263 uint32_t tag; = CFR_TAG_VARCHAR_UI_NAME
264 uint32_t size; = sizeof(struct lb_cfr_varbinary) +
265 strlen(name) + 1 + 3 = 20
266 uint32_t data_length; = strlen(name) + 1
268 char name[5]; = "test"
270 struct lb_cfr_numeric_option {
271 uint32_t tag; = CFR_TAG_OPTION_BOOL
272 uint32_t size; = sizeof(struct lb_cfr_numeric_option) +
273 sizeof(struct lb_cfr_varbinary) +
274 strlen(optname) + 1 + 2 +
275 sizeof(struct lb_cfr_varbinary) +
276 strlen(uiname) + 1 = 72
277 uint64_t object_id; = 2
278 uint64_t dependency_id; = 0
280 uint32_t default_value; = true
282 struct lb_cfr_varbinary {
283 uint32_t tag; = CFR_TAG_VARCHAR_OPT_NAME
284 uint32_t size; = sizeof(struct lb_cfr_varbinary) +
285 strlen(optname) + 1 + 2 = 20
286 uint32_t data_length; = strlen(optname) + 1 = 6
288 char optname[6]; = "First"
290 struct lb_cfr_varbinary {
291 uint32_t tag; = CFR_TAG_VARCHAR_UI_NAME
292 uint32_t size; = sizeof(struct lb_cfr_varbinary) +
293 strlen(uiname) + 1 = 20
294 uint32_t data_length; = strlen(uiname) + 1 = 8
296 char uiname[8]; = "Boolean"